mirror of
https://github.com/affaan-m/ECC.git
synced 2026-12-06 07:03:57 +09:00
fix(ecc2): resolve native assignment directory from parent lead
This commit is contained in:
1 parent
25278e7d7b
commit
098c2350ba
1 file changed
+54
-2
@@ -883,8 +883,9 @@ pub async fn assign_session_with_profile_and_grouping(
|
||||
profile_name: Option<&str>,
|
||||
grouping: SessionGrouping,
|
||||
) -> Result<AssignmentOutcome> {
|
||||
let repo_root =
|
||||
std::env::current_dir().context("Failed to resolve current working directory")?;
|
||||
// Native assignment belongs to the recorded Lead, not the operator's
|
||||
// shell (which may be outside the project and lack its model settings).
|
||||
let repo_root = resolve_session(db, lead_id)?.working_dir;
|
||||
assign_session_in_dir_with_runner_program(
|
||||
db,
|
||||
cfg,
|
||||
@@ -6855,6 +6856,57 @@ mod tests {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[tokio::test(flavor = "current_thread")]
|
||||
async fn native_assign_uses_lead_working_dir_not_operator_cwd() -> Result<()> {
|
||||
let tempdir = TestDir::new("manager-assign-lead-cwd")?;
|
||||
let repo_root = tempdir.path().join("original-lead-repo");
|
||||
init_git_repo(&repo_root)?;
|
||||
let foreign_dir = tempdir.path().join("operator-outside-repo");
|
||||
fs::create_dir_all(&foreign_dir)?;
|
||||
let mut cfg = build_config(tempdir.path());
|
||||
cfg.max_parallel_sessions = 3;
|
||||
cfg.max_parallel_worktrees = 0; // queue without launching a test process
|
||||
let db = StateStore::open(&cfg.db_path)?;
|
||||
let now = Utc::now();
|
||||
db.insert_session(&Session {
|
||||
id: "lead".to_string(),
|
||||
task: "original lead task".to_string(),
|
||||
project: "original-project".to_string(),
|
||||
task_group: "general".to_string(),
|
||||
agent_type: "claude".to_string(),
|
||||
working_dir: repo_root.clone(),
|
||||
state: SessionState::Running,
|
||||
pid: Some(42),
|
||||
worktree: None,
|
||||
created_at: now,
|
||||
updated_at: now,
|
||||
last_heartbeat_at: now,
|
||||
metrics: SessionMetrics::default(),
|
||||
})?;
|
||||
let _cwd_guard = crate::test_support::CurrentDirGuard::enter(&foreign_dir)?;
|
||||
let outcome = assign_session_with_profile_and_grouping(
|
||||
&db,
|
||||
&cfg,
|
||||
"lead",
|
||||
"One independent change",
|
||||
"claude",
|
||||
true,
|
||||
None,
|
||||
SessionGrouping::default(),
|
||||
)
|
||||
.await?;
|
||||
assert_eq!(outcome.action, AssignmentAction::Spawned);
|
||||
let delegate = db
|
||||
.get_session(&outcome.session_id)?
|
||||
.context("missing queued delegate")?;
|
||||
assert_eq!(
|
||||
delegate.working_dir, repo_root,
|
||||
"never inherit caller working directory"
|
||||
);
|
||||
assert_eq!(delegate.state, SessionState::Pending);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[tokio::test(flavor = "current_thread")]
|
||||
async fn assign_session_reuses_idle_delegate_when_available() -> Result<()> {
|
||||
let tempdir = TestDir::new("manager-assign-reuse-idle")?;
|
||||
|
||||
Reference in new issue
Block a user