Skip to content

test(#1232): exec-path tests run in a temp git repo, never the developer's checkout - #1241

Merged
admarble merged 3 commits into
mainfrom
fix/1232-test-exec-cwd
Sep 30, 2026
Merged

admarble merged 3 commits into
mainfrom
fix/1232-test-exec-cwd

Conversation

@admarble

@admarble admarble commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

Closes #1232

What

Three test files drove the real exec phase with no worktreePath, so executePhase ran the exec change guard against process.cwd(). On a dirty checkout, the #1032 rescue committed the developer's work as chore(#N): wip checkpoint ….

  • src/lib/workflow/__fixtures__/exec-temp-repo.fixture.ts (new) creates a throwaway git repo. Its HEAD is one commit ahead of refs/remotes/origin/main, so the guard classifies it as commits. That is the same success outcome CI saw before, where origin/main is absent and the guard failed open. The identity is set before the first commit, for CI runners.
  • In phase-executor.model-ladder, .model-roles and .phase-agent, every call goes through a runInExecRepo wrapper that passes the temp repo as worktreePath. Each file also gains a gate test asserting that the dispatched cwd is the temp repo.
  • In phase-agent, the AC-7 resume handle's originCwd is now the temp repo, because handle eligibility is keyed on cwd.

Acceptance criteria

  • AC-1: met. With an uncommitted edit in the tree, running the three files leaves git rev-parse HEAD and git status --short unchanged. Before this change, each of the three created a wip-checkpoint commit.
  • AC-2: met. git grep -l 'executePhaseWithRetry(\|executePhase(' -- '*.test.ts' returns 27 files. For each one I left an uncommitted sentinel file in the tree, ran the test file alone, and compared HEAD before and after. QA re-ran the non-live files independently and got the same result. One line per file:
    • __tests__/integration/multi-issue-reliability.integration.test.ts: HEAD unchanged
    • __tests__/integration/run-pipeline.integration.test.ts: HEAD unchanged
    • src/commands/run.test.ts: HEAD unchanged
    • src/lib/workflow/auto-wait.test.ts: HEAD unchanged
    • src/lib/workflow/drivers/__tests__/driver-conformance.test.ts: HEAD unchanged; calls the driver method, not the phase-executor guard
    • src/lib/workflow/drivers/aider-integration.test.ts: HEAD unchanged; calls the driver method, not the phase-executor guard
    • src/lib/workflow/drivers/aider.phase-policy.test.ts: HEAD unchanged; calls the driver method, not the phase-executor guard
    • src/lib/workflow/drivers/aider.test.ts: HEAD unchanged; calls the driver method, not the phase-executor guard
    • src/lib/workflow/drivers/claude-code.phase-policy.test.ts: HEAD unchanged; calls the driver method, not the phase-executor guard
    • src/lib/workflow/drivers/claude-code.test.ts: HEAD unchanged; calls the driver method, not the phase-executor guard
    • src/lib/workflow/drivers/codex.live.integration.test.ts: not run: needs a live backend; calls the driver method, not the phase-executor guard
    • src/lib/workflow/drivers/codex.test.ts: HEAD unchanged; calls the driver method, not the phase-executor guard
    • src/lib/workflow/drivers/opencode.live.integration.test.ts: not run: needs a live backend; calls the driver method, not the phase-executor guard
    • src/lib/workflow/drivers/opencode.test.ts: HEAD unchanged; calls the driver method, not the phase-executor guard
    • src/lib/workflow/drivers/resume-semantics.test.ts: HEAD unchanged; calls the driver method, not the phase-executor guard
    • src/lib/workflow/full-qa.test.ts: HEAD unchanged
    • src/lib/workflow/phase-executor.codex.test.ts: HEAD unchanged
    • src/lib/workflow/phase-executor.effort-escalation.test.ts: HEAD unchanged
    • src/lib/workflow/phase-executor.model-ladder.test.ts: moved HEAD (wip checkpoint #971), fixed here
    • src/lib/workflow/phase-executor.model-roles.test.ts: moved HEAD (wip checkpoint #975), fixed here
    • src/lib/workflow/phase-executor.opencode.test.ts: HEAD unchanged
    • src/lib/workflow/phase-executor.phase-agent.test.ts: moved HEAD (wip checkpoint #1150), fixed here
    • src/lib/workflow/phase-executor.phase-policy.test.ts: HEAD unchanged
    • src/lib/workflow/phase-executor.test.ts: HEAD unchanged; mocks child_process
    • src/lib/workflow/phase-pause-handle.test.ts: HEAD unchanged
    • src/lib/workflow/ready-gate.test.ts: HEAD unchanged
    • src/lib/workflow/spec-retry.test.ts: HEAD unchanged

Verification

  • QA follow-up (e7be1ee): the fixture removes its temp dir if repo setup throws, and afterAll guards against execRepo being undefined so it can't mask the setup error.

  • phase-executor*, run-orchestrator* and batch-executor* test files: 17 files, 413 tests passed.

  • Mutation-verified: AC-1 — runInExecRepo passes undefined instead of execRepo.path (model-ladder); 1232 dispatches exec with the temp repo as cwd failed; restored.

  • Mutation-verified: AC-1 — the same mutation in model-roles; 1232 dispatches exec with the temp repo as cwd failed; restored.

  • Mutation-verified: AC-1 — the same mutation in phase-agent; 1232 dispatches exec with the temp repo as cwd failed (AC-7 also failed, as expected); restored.

🤖 Generated with Claude Code

…per's checkout

phase-executor.model-ladder/model-roles/phase-agent tests called executePhaseWithRetry with no worktreePath, so the exec change guard ran against process.cwd() and the #1032 rescue auto-committed a dirty checkout as a wip checkpoint. They now pass a throwaway repo (HEAD one commit ahead of origin/main) and assert the dispatched cwd.

Entire-Checkpoint: 8c34f86c09f8
QA follow-up: a git error after mkdtempSync leaked the dir, and afterAll's cleanup on an undefined repo masked the real error.

Entire-Checkpoint: 1e9886dc23d5
@admarble
admarble merged commit 484b29c into main Sep 30, 2026
7 checks passed
@admarble
admarble deleted the fix/1232-test-exec-cwd branch September 30, 2026 19:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

test: phase-executor.model-roles.test.ts runs the exec guard against the developer's checkout and auto-commits uncommitted work

1 participant