Decompose work.ts

`work.ts` is the largest source file (2545 lines) and the highest-churn file in the codebase (104 commits all-time — 50% more than the next highest). It contains 22 functions spanning 3 unrelated responsibilities: pipeline state computation, proof chain writing, and command orchestration + display. A developer adding a new pipeline stage has to navigate 2545 lines to find `determineStage`. A developer debugging proof chain entries has to find `writeProofChain` buried between `guardFailResult` and `completeWork`.

verdict PASSscore 20 / 21findings 5 (0 risk · 2 debt · 3 obs)duration 18h 55mrejection cycles 0shipped May 26, 2026surface cli

Pipeline timeline

Intent to proven code in 18h 55m across Think, Plan, Build, and Verify.

Think
9m
Plan
6m
Build
17m
Verify
7m

Assertion ledger

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

IDSaysMatcher
A001Pipeline state computation lives in its own moduleverifiedfail
A002All five pipeline type definitions are exported from the state moduleverifiedok
A003The concurrency timeout constant is exported from the state moduleverifiedok
A004Proof chain writing lives in its own moduleverifiedok
A005Surface derivation is re-exported from work.ts for backward compatibilityverifiedok
A006The main work module is significantly smaller after decompositionverifiedok
A007The main work module is significantly smaller after decompositionverifiedok
A008Work module imports state functions from the new state moduleverifiedok

Findings 5 total

debtpackages/cli/src/commands/work.tsscope
getNextAction not moved to work-state.ts — 9 functions instead of contract's 10
obspackages/cli/src/commands/work.tsclosed
computeChainHealth imported in both work.ts and work-proof.ts — spec said it should only be in work-proof.ts but recovery path needs it
obsclosed
Contract A001 value may be miscounted — getNextAction is a display concern (maps stages to commands) and arguably belongs with display functions in work.ts, not state computation in work-state.ts
debtpackages/cli/src/commands/work-state.tsmonitor
work-state.ts determineStage function is 148 lines with deeply nested conditionals — largest function in the new module, could benefit from phase-specific helpers
obspackages/cli/src/commands/work.tsclosed
_branchPrefix parameter in getNextAction still unused after refactor — pre-existing issue now more visible

Integrity seal

scopesha256:7b77d3edc21ed...
contractsha256:a96e45c6c00e3...
plansha256:0d433c5fec050...
specsha256:4e704ae7cff04...
build-reportsha256:000b001c8a8dc...
build-datasha256:1f6a902c1b5e9...
verify-reportsha256:03e1dc96ac909...
verify-datasha256:39946996949d9...
audit cmd$ ana proof audit decompose-work-ts   → all hashes match