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.
Think9m
Plan6m
Build17m
Verify7m
Assertion ledger
21 claims, each independently verified. Showing 8 — show all →
| ID | Says | Matcher | |
|---|---|---|---|
| A001 | Pipeline state computation lives in its own module | verified | fail |
| A002 | All five pipeline type definitions are exported from the state module | verified | ok |
| A003 | The concurrency timeout constant is exported from the state module | verified | ok |
| A004 | Proof chain writing lives in its own module | verified | ok |
| A005 | Surface derivation is re-exported from work.ts for backward compatibility | verified | ok |
| A006 | The main work module is significantly smaller after decomposition | verified | ok |
| A007 | The main work module is significantly smaller after decomposition | verified | ok |
| A008 | Work module imports state functions from the new state module | verified | ok |
Findings 5 total
debtpackages/cli/src/commands/work.ts→ scope
getNextAction not moved to work-state.ts — 9 functions instead of contract's 10
obspackages/cli/src/commands/work.ts→ closed
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
obs→ closed
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.ts→ monitor
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.ts→ closed
_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
Adjacent proofs:← extract-artifact-validators