Worktree Guard Integration Tests

Three CLI commands hard-block execution when run from inside a worktree: `init`, `setup complete`, and `work complete`. A fourth (`scan --save`) warns but continues. These guards prevent repo corruption — running `init` from a worktree creates a nested `.ana/`, running `work complete` corrupts the proof chain. All four guards are verified only by source inspection (A028, A030, A031, A032 in the worktree-isolation verify report). No integration test verifies that the guard actually fires when a command runs from inside a worktree. This scope adds those tests.

verdict PASSscore 10 / 10findings 3 (1 risk · 2 debt · 0 obs)duration 28mrejection cycles 0shipped May 15, 2026surface cli

Pipeline timeline

Intent to proven code in 28m across Think, Plan, Build, and Verify.

Think
4m
Plan
3m
Build
3m
Verify
4m

Assertion ledger

10 claims, each independently verified. Showing 8 — show all →

IDSaysMatcher
A001Running init from a worktree exits with an errorverifiedok
A002The init worktree error tells the user to use the main directoryverifiedok
A003Running setup complete from a worktree exits with an errorverifiedok
A004The setup complete worktree error tells the user to use the main directoryverifiedok
A005Running work complete from a worktree exits with an errorverifiedok
A006The work complete worktree error tells the user to use the main directoryverifiedok
A007Running scan --save from a worktree warns but does not exitverifiedok
A008The scan --save worktree warning mentions being in a worktreeverifiedok

Findings 3 total

debtpackages/cli/tests/commands/worktree-guards.test.tsclosed
A009 test only verifies cwd restoration, not process.exit or console spy cleanup
riskpackages/cli/tests/commands/worktree-guards.test.tsclosed
Console and process.exit spies restored inline after assertions — leak on assertion failure
debtpackages/cli/tests/commands/worktree-guards.test.tsclosed
A009 test is order-dependent — relies on running after the other describe blocks

Integrity seal

scopesha256:0bc4ee861115a...
contractsha256:47f9e1c0190bb...
plansha256:11b5256d1fda6...
specsha256:2ea64253795c4...
build-reportsha256:4c066b693da37...
build-datasha256:9f1424bb781bd...
verify-reportsha256:ebd5549fcfd5f...
verify-datasha256:b517e916d6e6b...
audit cmd$ ana proof audit worktree-guard-tests   → all hashes match