Repository navigation
refactor(#1508): split run, ensureWorktree, executePhaseWithRetry and executePhase to ≤ 200 counted lines; max-lines-per-function ratchet for src/lib/workflow - #1585
Merged
admarble merged 9 commits intoOct 24, 2026
Conversation
…and env helpers Entire-Checkpoint: 522a98fcdcc8
…ult and throw stages Entire-Checkpoint: c6fb99acef12
…and finish become module functions Entire-Checkpoint: 82bde66ef1be
…R-0020 note, CHANGELOG Entire-Checkpoint: c497442f5c88
…ounted lines Entire-Checkpoint: 1f3cc1d6bde9
…nctions of ≤ 200 counted lines Entire-Checkpoint: 75c1ecaf73d5
…0 counted lines Entire-Checkpoint: 531c978b2e9c
Entire-Checkpoint: 88e602f32dcd
…tor at their host functions resolvePhaseFiles and buildPhaseEnv now host the catches that used to be in executePhase, so the file:function labels follow them; the #3 suffix on the one left in executePhase has nothing to be numbered against any more. Entire-Checkpoint: 16ff31ee3dd6
admarble
deleted the
feature/1508-refactor-workflow-split-run-ensureworktree-execute
branch
October 24, 2026 12:27
2 tasks done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
All six functions in
src/lib/workflowthat were over 200 counted lines are now split. A newmax-lines-per-functionrule keeps the whole directory at 200 or under. I followed ADR-0020 Option A: private stage functions in the same file, early exits returned as values that the caller checks, and no new exports or modules. No test file changed. The branchfeature/1508-refactor-workflow-split-run-ensureworktree-executeis pushed, and the orchestrator opens the PR.RunOrchestrator.runensureWorktreeexecutePhaseWithRetryrunReadyGateexecutePhase(phase-executor)ClaudeCodeDriver.executePhaseStreamState)Pre-PR AC Verification
0(it was 6 on main)found. The newsrc/lib/workflow/**/*.tsblock ineslint.config.jscomes after thesrc/commands/**block.npm run lint→green0npx vitest run src/lib/workflow/(2 shards): 2,406 passed, 1 failed. The one failure is the known codex gpg conformance test, tracked in #1480. It also fails at base (block below).identical; see "Golden run" belowfunctions.over200→0.over400is also0. The longest function is nowcollectInstallChecks, 197 lines.Ratchet check: the same rule found 6 functions over the limit on main (the AC-1 baseline) and finds 0 now, with lint green.
Golden run (AC-6, runner)
The testbed is ad-motion #285, a fixture issue with one fixed change (
docs/golden-run.md). Both runs usedsequant run 285 --phases spec,exec,qa --force --full-qathrough the npm-linked devdist/, launched detached from ad-motion. Before each run I removed the fixture's branch, worktree, comments andplannedlabel, restored ad-motion's.sequant/from one snapshot, and bumped the title suffix so the branch slug could not find the previous closed PR.039d2021frun-2026-10-23T04-45-40-3ad400d4-d599-4ab0-affb-9566bf46a76b.jsonf851332c9run-2026-10-23T05-15-29-1751db83-1835-4c98-901b-dcfd54f72949.jsonAC-6 projection (
diff <(jq -S '[.issues[] | {issue: .issueNumber, status: .status, phases: [.phases[] | {phase: .phase, status: .status}]}]' "$BEFORE") <(jq -S … "$AFTER") && echo identical) →identical. Both sides:Also checked on both runs:
suppressedis{"total":12,"byScope":{"other":12}}; a "PR #N created" line is in both logs;plannedwas added both times. Both PRs are closed unmerged and the testbed is reset.Caveats. The durations differ because the agents' work is not deterministic; the AC compares statuses only. The previous session's
.sequantsnapshot was lost with the scratchpad, so both runs restored a fresh snapshot taken before run 3 (itsstate.jsonhas no #285 entry). That snapshot and the two run logs are kept outside both repos under~/Projects/ad-motion-sequant-snap/and~/Projects/ad-motion-golden-logs/.Runner re-verification on head
2dda4b1af(2026-10-24)After the golden run, the owner asked for the three
noteSuppressedlabels inphase-executor.tsto follow their host functions (2dda4b1af:resolvePhaseFiles,buildPhaseEnv, andexecutePhasewithout the orphaned#3). That commit changes three string literals in diagnostic labels, so the AC-6 result onf851332c9stands by the owner's decision; AC-1 to AC-5 and AC-7 were re-run on2dda4b1afwith the results below.npm run lint:healthreports no metric above the baseline.0(6 on main)foundnpm run lint→green0npx vitest run src/lib/workflow/→ 2406 passed, 1 failed, the known gpg codexdriver-conformancetest; identical counts on main039d2021fidentical(above)functions.over200→0,over400→0Freeze grep (
plugin/,.claude/skills/,templates/skills/) and session-link grep over the diff and the commit messages: empty. Branch 0 behind main.Settled against base
feature/1508-…@f851332c9origin/main@039d2021fTest:
src/lib/workflow/drivers/__tests__/driver-conformance.test.ts-t "commit: git add and git commit succeed". It also fails at base; the issue is #1480.Checks
npm run build✅,npm run lint✅,health-report --check✅ (no metric went up;unusedExportsis unchanged)Tests:
vitest list --changed origin/mainselects outside the workflow directory, plusscripts/qa/tautology-detector-cli.test.ts1,973 passed, and the only failure is the test(drivers): codex conformance commit item fails locally on macOS — git add exits 128 inside the sandbox #1480 test.
Test coverage: every changed source file already has tests; none were added, because AC-4 forbids it.
Files changed
eslint.config.js,scripts/qa/health-baseline.json,CHANGELOG.md.Pre-PR Confidence Check
run-orchestrator.tsandphase-executor.tsdiffs. The retry loop's oldattempt--; continueafter an auto-wait is now a returnedrewaitvalue, and every early exit fromrunnow goes through a returnedRunResult | null. The unchanged suites pass, but the golden run (AC-6) is the last check of behaviour.CLI wiring: N/A, no option interfaces changed. Quality Plan Alignment: there were no new tests or error paths to add. Log strings and call order are kept, and AC-6 is left to the runner. Docs: nothing user-facing beyond the CHANGELOG entry.
PR status: left to the orchestrator; the branch is pushed. Next step: the runner does the golden run (AC-6), then QA.
Fixes #1508
🤖 Generated by
sequant run