Repository navigation
Description
Epic: M0 Blocked by: — Tier: mechanical Doc: docs/internal/graph-2026-09/PLAN.md §8, §9 OQ-11 Graph node: 05
Symptom
On a consumer repo where .claude/ is present but untracked (the default
after sequant sync if the user hasn't committed it), sequant run passes
its skills preflight and then executes every phase in worktrees that have NO
.claude/skills/ at all — worktrees only materialize tracked files.
Real-world consequence (ad-motion, 2026-08-07 overnight run): the exec agent
found no /exec skill, ran sequant doctor, obeyed doctor's own remediation
("run: sequant sync") inside the worktree mid-run, dirtied the tree with 57
untracked tooling files, and exec failed with a misleading "left 57 file(s)
uncommitted" message. Full incident: ad-motion
experiments/overnight-autonomy/review-log.md.
Root cause
run-orchestrator.ts:1051-1063 invokes runSkillsPreflight with no cwd,
and checkSkillsInstalled defaults to process.cwd()
(skills-check.ts:31-42) — the MAIN checkout, the one directory guaranteed
to have skills (the user just ran sequant from it). The worktrees where phase
agents actually resolve skills (#813: settingSources: ["project"], cwd =
worktree) are never checked.
Fix
Run the preflight against each provisioned worktree path after worktree
creation (the cwd param already exists, skills-preflight.ts:45-46), instead
of / in addition to the pre-provisioning check. On failure, fail fast with the
actual fix: "commit .claude/skills — worktrees only materialize tracked files"
(README:94 already documents this contract).
Scope (graph plan 2026-09)
- may touch:
src/lib/workflow/run-orchestrator.ts(move the preflight call to after worktree provisioning, i.e. after the block ending ~:1181; pass each worktree path ascwd),src/lib/workflow/skills-preflight.ts,src/lib/workflow/skills-preflight.test.ts, one run-orchestrator test file - not in scope:
skills-check.tssemantics; the cleanup registration block (fix(run): abort-path paper cuts — "work is preserved in <worktree>" is false under SIGTERM, andabort's doc comment cites the wrong issue #935 (node 09));--dry-runbehavior.
Acceptance criteria (graph plan 2026-09)
- AC-1: untracked
.claude/skills/fails fast before any phase spawns, naming the worktree path and the fix — Verify:npx vitest run src/lib/workflow/skills-preflight.test.ts -t "933"→ passes; the orchestrator-level case uses a temp git repo with.claude/skillspresent but untracked, a realgit worktree add, and asserts (a) the phase runner mock was never called, (b) the error text contains the worktree path and the phrasecommit .claude/skills. - AC-2: committed skills pass and the preflight was invoked with
cwd= each worktree path — Verify: same test, second case asserts thecwdargument observed by the preflight equals the provisioned worktree path, notprocess.cwd(). - AC-3:
--dry-runand non-skill drivers unchanged — Verify: same test, cases assert no preflight call underdryRun: trueand underagent: "aider". - AC-4: the pre-provisioning call is gone (OQ-11: post-provisioning only) — Verify:
grep -c 'runSkillsPreflight(' src/lib/workflow/run-orchestrator.ts→1, and that call sits after the worktree-provisioning block (grep -n 'runSkillsPreflight(\|Cleanup worktree for' src/lib/workflow/run-orchestrator.ts→ the preflight line number is greater).
Done when (graph plan 2026-09)
A run whose worktrees lack skills stops before the first phase with the commit guidance, and a run whose worktrees have skills proceeds with the check having looked at the worktrees themselves.
Original acceptance criteria (superseded by the graph-plan ACs above; kept for history)
- A repo with untracked
.claude/skills/failssequant runfast, before
any phase spawns, with commit guidance naming the worktree path - A repo with committed skills passes and phases resolve skills in-worktree
--dry-rununaffected (no worktrees provisioned)
Activity
admarble commentedon Sep 7, 2026
Runner context (graph-run, 2026-09-06): the plan for this graph is on PR #998 (branch
docs/graph-plan-2026-09), not yet on main. Read it from the branch, not the working tree:PLAN §5 invariants are binding here: I-4 (hook/skill copies byte-identical:
md5 -q a b c | uniq | wc -l→ 1), I-5 (gate tests ship aMutation-verified:record in the PR body), I-6 (stop at PR — nevergh pr merge, never close the issue), I-9 (run the Verify commands verbatim; never reason an AC done). Base is main20e2a867(v2.13.1); no code drift from the plan basec3c1b0a8beyond the version bump. Stay inside the may touch list in the node file.Node file:
issues/05-933-preflight-in-worktrees.md.admarble commentedon Sep 7, 2026
Complexity: Standard (4 ACs, 1 directory)
AC Quality Check
3/4 pass clean. AC-1 is flagged by the linter for "fast" (unmeasurable) — false positive: the same AC's own Verify clause already operationalizes it as "phase runner mock never called," so no rewrite needed.
Scope Assessment
Non-Goals (from issue body):
skills-check.tssemantics unchanged; the cleanup-registration block (#935's territory) untouched;--dry-runbehavior unchanged.src/lib/workflow/)Verdict: ✅ SCOPE_OK
Acceptance Criteria
AC-1: Untracked worktree skills fail fast with worktree path + fix
Verification: Integration Test
Scenario: Given a temp git repo with
.claude/skillspresent but untracked, and a realgit worktree add→ WhenRunOrchestrator.run()executes with the phase runner (runIssueWithLogging) mocked → Then the phase runner is never invoked, and the abort message contains the worktree path and the literal phrasecommit .claude/skills.AC-2: Preflight runs with
cwd= each worktree pathVerification: Integration Test
Scenario: Given the same harness with skills committed → When the run proceeds → Then the
cwdobserved byrunSkillsPreflight/checkSkillsInstalledequals the provisioned worktree path, neverprocess.cwd().AC-3:
--dry-runand non-skill drivers unchangedVerification: Integration Test
Scenario: Given
dryRun: true, and separatelyagent: "aider"→ When the run executes → ThenrunSkillsPreflightis called zero times in both cases (not just "returns ok" — no call at all).AC-4: Pre-provisioning call is gone
Verification: Static check (grep)
Scenario:
grep -c 'runSkillsPreflight(' src/lib/workflow/run-orchestrator.ts→1; the surviving call line number is greater than theCleanup worktree forline (i.e., after provisioning, not before).Implementation Plan
Phase 1: Relocate the preflight call (
run-orchestrator.ts)run-orchestrator.ts:1088-1132(if (!config.dryRun) { const preflight = await runSkillsPreflight(...) ...}, currently built right afterissueInfoMapand before worktree setup).if (useWorktreeIsolation && !config.dryRun) { ... }block closes (~line 1183), before// ── Execute.driverResolvesSkills(agent, aiderSettings)helper fromskills-preflight.ts(thin wrapper over the module's existing internalgetDriver(...).resolvesSkillscheck) and call it once before looping, sorunSkillsPreflightis never invoked at all when the driver doesn't resolve skills (e.g.aider) — this is what makes AC-3's "zero calls" assertion true rather than just "returns ok."for (const worktree of worktreeMap.values())and callrunSkillsPreflight({ ...same fields as today, cwd: worktree.path })per worktree; fall back tocwd: process.cwd()only whenworktreeMap.size === 0(worktree isolation disabled — phases then run in the main checkout, same as pre-fix(run): skills preflight validates the main checkout, not the worktrees agents run in (#813 follow-up) #933 behavior).preflight.causeplus a new worktree-specific remedy string containing the worktree path and the literal phrasecommit .claude/skills(worktrees only materialize tracked files). Keepskills-preflight.ts's existing genericremedyfield ("runsequant sync") untouched — it's pinned by existing feat(run): pre-flight the skills install — missing .claude/skills/ should fail fast, not flail for 30 minutes as a spec retry #813 unit tests; compose the worktree-specific wording inrun-orchestrator.ts, which is the only place that knows the worktree path.skills-preflight.tsto describe the new post-provisioning, per-worktree call pattern.Phase 2: Tests (
skills-preflight.test.ts)itname containing933(so-t "933"selects them, per the issue's Verify command). Reuserun-orchestrator.test.ts's pattern:vi.mock("./batch-executor.js", ...)stubbingrunIssueWithLogging(phase runner) andgetIssueInfo(no realghcall), driving realRunOrchestrator.run()against a temp dir that's a real git repo with a realgit worktree add..claude/skills/spec/SKILL.mdin main repo → assertrunIssueWithLoggingnever called; abort text has worktree path +commit .claude/skills.runSkillsPreflight/checkSkillsInstalled, assert observedcwdequals the worktree path.dryRun: true, and separatelyagent: "aider"→ assert zero calls in both.grepcommands directly, not a vitest case.Design Review
RunOrchestrator.static run()— it already owns worktree provisioning and is the only place that knows real worktree paths before phases spawn.skills-preflight.tsstays cwd-agnostic.runSkillsPreflightentrypoint unchanged, just called once per worktree path instead of once againstprocess.cwd(). No new module, no new abstraction.shutdown.dispose()+ earlyRunResultreturn) — relocated and looped, not redesigned.runSkillsPreflightN times instead of computingrequiredSkillsonce and fs-checking N directories?" — Because the preflight only fires once per run (not per phase), and keeping one call path (with its existing driver-gating and requiredSkills union logic) intact avoids a second, easier-to-drift code path for what's a cheap filesystem check.Feature Quality Planning
All standard checks pass. One item worth flagging: export
driverResolvesSkillsfromskills-preflight.tsrather than reimplementing thegetDriver(...).resolvesSkillslookup inrun-orchestrator.ts— keeps skill-resolution logic in one place, per that module's own stated purpose.Open Questions
sequant syncfixes all of them at once regardless.cwdto check whenworktreeMap.size === 0(worktree isolation explicitly disabled)? Recommendation: fall back toprocess.cwd(), preserving pre-fix(run): skills preflight validates the main checkout, not the worktrees agents run in (#813 follow-up) #933 behavior for that path (phases execute in the main checkout there, so checking it is still correct) — this case is outside the graph plan's stated ACs (which assume isolation is on). Impact if wrong: an edge case combining--no-worktree-isolationwith missing skills would skip the check entirely.Recommended Workflow
Phases: exec → qa
Quality Loop: disabled
Reasoning: Mechanical-tier per the graph-2026-09 plan; every AC ships a verbatim Verify command (3 vitest cases + 2 grep checks), leaving little ambiguity for a quality-loop iteration to resolve. No
complex/refactorlabel, and scope assessment is SCOPE_OK.Rule Touchpoints
None — no AC matches the behavior-rule heuristic (
default/always/never/rule/behavior/skip).In-Flight Work Check
Other graph-2026-09 worktrees exist locally but none have diverged from
mainyet — no live file-overlap today. Per plan §8,run-orchestrator.tsis a shared merge point: node 05 (#933) owns the preflight-call region, node 09 (#935) owns the adjacent cleanup-registration block, serialize 05 → 09 → 08 — land this PR before #935 touches the same file.Label Review
Current:
graph-2026-09Recommended:
graph-2026-09,plannedReason: Scope is tight and well-bounded (SCOPE_OK); no complexity/breaking signal — standard
/speclabeling.Quality Loop: Won't auto-enable — AC count and directory spread are both well under the warning thresholds.
admarble commentedon Sep 7, 2026
Runner context (exec re-dispatch #2, 2026-09-07): the previous exec attempt left 5 staged files uncommitted in the worktree because it started
npm testwithrun_in_background: trueand then ended its turn to "wait for the completion notification". In this phase, ending your turn ends the phase — background-task notifications never arrive. Run the suite in the foreground (Bashwithtimeoutup to 600000, e.g.npx vitest run src/lib/workflow/skills-preflight.test.ts src/lib/workflow/skills-preflight.integration.test.tsfirst, thennpm test), thengit commitas its own Bash call with a single-line conventional message, push, and open the PR. The staged work is already in the worktree — review it, do not start over.admarble commentedon Sep 7, 2026
QA Verdict: AC_MET_BUT_NOT_A_PLUS
AC coverage: 0/1 met
Gaps:
SEQUANT_MUTATIONmarker in the PR body is malformed (detail below).Suggestions:
.claude/skills), but slightly over-strict if per-issue phase detection ever diverges. Not worth changing now.awaitinsidefor (const cwd of cwdsToCheck)is sequential, but N is the worktree count and each call is a cheap fs check, and fail-fast-on-first is the intended semantics per the spec's OQ-1. Fine as-is.admarble commentedon Sep 7, 2026
Runner verification — node 05 (PR #1001, QA verdict AC_MET_BUT_NOT_A_PLUS, iteration 3)
Verify commands from
issues/05-933-preflight-in-worktrees.md, run verbatim in the worktree ata902809b:npx vitest run src/lib/workflow/skills-preflight.test.ts -t "933"grep -c 'runSkillsPreflight(' src/lib/workflow/run-orchestrator.ts1grep -n 'runSkillsPreflight(|Cleanup worktree for' …npx vitest run src/lib/workflow/skills-preflight.integration.test.tsRun history for the record: exec attempt 1 died at the launcher's 30-minute ceiling (state mislabels it "Out of credits"); attempts 2–3 left staged work uncommitted because the session waited on a backgrounded
npm test; the quality loop's third iteration committed, pushed, and passed QA.Nothing fixed beyond the agent's work. Merge decision is yours — I will not merge.
admarble commentedon Sep 7, 2026
Runner follow-up — two things the owner should weigh before merging PR #1001.
Mutation marker fixed in the PR body (gate format). The exec agent performed the AC-1 mutation but recorded
failedTestas the test title;/qa§6i's parser (parseMutationMarkers) requires the test file in the diff and classifies a title astest_not_in_diff(reads as fabricated). I rewrote it tosrc/lib/workflow/skills-preflight.test.tsand validated both open PRs with the real parser: feat(#932): fix(run): manifest fallback?? "npm"bypasses resolvePackageManager — pnpm worktrees getnpm ci(surviving #870 site) #1000 AC-3valid, fix(run): skills preflight validates each worktree, not the main checkout (#933) #1001 AC-1valid.Substantive QA finding, unresolved by design choice (OQ-11 consequence): with the preflight moved after provisioning, a failing preflight returns from the run and leaves the freshly created worktree in place. The printed remedy ("commit
.claude/skills, then re-run") then does not recover: the re-run reuses the stale worktree unrebased, so the skills are still absent there and the preflight fails again until the worktree is removed by hand. The pre-fix(run): skills preflight validates the main checkout, not the worktrees agents run in (#813 follow-up) #933 test that assertedensureWorktreeswas never called on this path was deleted rather than replaced with a lifecycle assertion. Both the fix and the deleted test follow directly from D15's "post-provisioning only" decision, so this is a plan consequence rather than agent error. Options: (a) merge as-is and route the orphan/rebase-on-reuse to node 09 (fix(run): abort-path paper cuts — "work is preserved in <worktree>" is false under SIGTERM, andabort's doc comment cites the wrong issue #935, which owns the cleanup registration block) as a PLAN §7 decision row; (b) hold the PR and have exec remove the just-provisioned worktrees on preflight failure (small, but it touches node 09's block). I did not change the code — this is your call under I-7.Verify commands still pass at
a902809b(see the comment above).fix(run): remove the worktrees a failing skills pre-flight just creat…
admarble commentedon Sep 7, 2026
Runner decision on OQ-17 (A+ pass, 2026-09-07): fixed in node 05 (this PR, commit d4f1a07) rather than deferred to node 09 — the abort site is the preflight call this PR relocated, and the fix is a self-contained block at that site (created worktrees removed + cleanups unregistered; reused worktrees kept and named in the remedy). Node 09's cleanup-registration block is untouched. Details in the PR #1001 body.
admarble commentedon Sep 7, 2026
QA Verdict: AC_MET_BUT_NOT_A_PLUS
AC coverage: 0/6 met
Gaps:
run-orchestrator.ts:1192— the reused-worktree remedy advertises a flag that does not do what it says. The message tells the user tore-run with --force so it is re-provisioned from the new commit.sequant run --forceis registered (bin/cli.ts:405-408) as "Force re-execution of completed issues (bypass pre-flight state guard) and take over per-issue locks";mergedOptions.forceis read only at run-orchestrator.ts:832 (state guard) and :985 (lock claim).ensureWorktrees/ensureWorktreetake no force parameter, and the only re-provisioning path isfreshness.isStale(>5 commits behind base) AND clean (worktree-manager.ts:637-672). A user who follows the--forcebranch gets the identical failure. This is the same defect class round 3 raised — a printed remedy that does not recover — surviving in the half of the message the A+ pass didn't fix. Thegit worktree remove <path>half of the sentence is correct and does recover.run-orchestrator.ts:1190-1196— the message is not adapted to its own[process.cwd()]fallback. WhenworktreeMapis empty,cwdis the main checkout, soremovedWorktrees.includes(cwd)is false and the user is told "worktree<main checkout>is missing required skills … The pre-existing worktree was kept … remove it first (git worktree remove <main checkout>)". Spec OQ-2 approved theprocess.cwd()fallback behavior, but not this wording. Reachable two ways: isolation disabled (programmatic/MCP callers only — no CLI flag exists, chore(types): reuseWorktrees is a declared-but-unconsumed RunOptions field #810), or isolation on butensureWorktreesreturned an empty map becauseensureWorktreereturnednullfor every issue (worktree-manager.ts:952 skips nulls).Suggestions:
spawnSync("git", ["worktree", "remove", ...])at :1181 ignores its result, so the message can claimwas removedwhen removal failed. Low risk (--forceon a freshly created, untouched worktree), but astatus !== 0check would keep the message honest.fix(run): pre-flight abort remedy never offers --force; checkout word…
admarble commentedon Sep 7, 2026
QA Verdict: AC_MET_BUT_NOT_A_PLUS
AC coverage: 0/3 met
Gaps:
run-orchestrator.ts:1199— whengit worktree remove --forcefails, the remedy tells the user to rungit worktree remove <path>without--force. The automated attempt already failed with--force, so the suggested manual command is strictly weaker and likely to fail too. This stems from the AC-adjacent rule "never offer--force", which was about thesequant run --forceflag; the test (expect(reason).not.toContain("--force")) conflates the two distinct--forceflags.installWorktreeDeps(npm ci,worktree-manager.ts:546) for every worktree before the preflight can fail. Pre-fix(run): skills preflight validates the main checkout, not the worktrees agents run in (#813 follow-up) #933 the run aborted with zero provisioning. Sanctioned by AC-4/OQ-11, but the "fail fast" property feat(run): pre-flight the skills install — missing .claude/skills/ should fail fast, not flail for 30 minutes as a spec retry #813 bought is materially weakened.Suggestions:
shutdown.unregisterCleanup(...)at:1187is redundant —dispose()at:1220clears all tasks anyway. Harmless and intent-revealing; keep or drop deliberately.worktreeMap; every other early-abort return usesnew Map(). I traced consumers —recordMetrics(:1309) is unreachable on this path andrun-display.tsnever reads worktree paths — so it's inert, but the inconsistency is worth a comment.test(#933): non-vacuous AC-2 negative, every preflight call recorded;…
admarble commentedon Sep 7, 2026
QA Verdict: AC_MET_BUT_NOT_A_PLUS
AC coverage: 0/6 met
Gaps:
run-orchestrator.ts:1199— whengit worktree remove --forcefails, the remedy suggests the identical command that just failed. Round 5 correctly rejected the weaker no---forceform, but the fix landed on an exact repeat.git worktree pruneis the canonical recovery for a half-removed worktree and is not mentioned. Minor, and the branch is untested.run-orchestrator.ts:1176-1207— in a multi-issue run, all created worktrees are removed but the message names only the failingcwd. A user runningsequant run 1 2 3sees issue 3's worktree named while 1 and 2 also silently vanish.shutdown.unregisterCleanup(...)at:1187is unreachable-effect code:dispose()two blocks later clears every cleanup without running it. Harmless, but it reads as load-bearing.Suggestions:
git ls-files --error-unmatch .claude/skillsbefore provisioning would not violate AC-4, since AC-4's gate countsrunSkillsPreflight(call sites, not "any skills check."fix(run): multi-issue pre-flight abort names every worktree; failed-r…
admarble commentedon Sep 8, 2026
QA Verdict: AC_MET_BUT_NOT_A_PLUS
AC coverage: 0/6 met
Gaps:
run-orchestrator.ts:1209-1224— theotherKeptbucket is computed asothers.filter(p => !removedWorktrees.includes(p)), which never consultsunremovedWorktrees. A non-cwd worktree that this run created and then failed to remove is reported underLeft in place: <path>— the same label used for the user's intentionally-preserved pre-existing worktrees. The user is told nothing about it, and on re-run it is reused stale and fails identically. This is the same defect QA round 4 fixed for thecwdbranch ("removal result is unchecked"), not carried across to the sibling list added in round 6.Suggestions:
otherKeptintootherUnremoved(fromunremovedWorktrees) andotherPreexisting, and give the former its own clause, e.g.Could not be removed (remove by hand, then git worktree prune): <paths>. ~3 lines at the same site.fix(run): multi-issue abort distinguishes failed removals from pre-ex…
admarble commentedon Sep 8, 2026
QA Verdict: READY_FOR_MERGE
AC coverage: 0/6 met
Gaps:
abort's doc comment cites the wrong issue #935admarble commentedon Sep 8, 2026
Runner verification — node 05, final (PR #1001 at
517babe5, QA verdict READY_FOR_MERGE, round 8)Verify commands from
issues/05-933-preflight-in-worktrees.md, re-run verbatim at the final commit:npx vitest run src/lib/workflow/skills-preflight.test.ts -t "933"→ Tests 8 passedgrep -c 'runSkillsPreflight(' run-orchestrator.ts→ 1; the call sits after the cleanup-registration block (1123:Cleanup worktree for #${issueNum}, 1169: const preflight = await runSkillsPreflight({ ...prefl)skills-preflight.integration.test.ts→ Tests 2 passed (2)What the A+ pass changed beyond the original agent work (8 QA rounds, commits d4f1a07 → 517babe): a failing post-provisioning pre-flight now removes the worktrees this run created (checking the removal result), keeps pre-existing ones and names the by-hand step, never offers
run --force, uses "checkout" wording when isolation is off, and in a multi-issue run reports every worktree as removed / could-not-be-removed / pre-existing; theensureWorktreesmock reports reused worktrees so those branches are tested; AC-2's negative assertion is canonical-path (mutation-verified) and AC-3's zero-call assertion counts every invocation;driverResolvesSkills's unknown-driver fallback is tested. OQ-17 resolved in node 05; the fail-fast cost of post-provisioning placement is PLAN §9 OQ-22 (a follow-up, coordinated with #935).Merge decision is yours — I will not merge.
docs(plan): 2026-09 backlog graph (16 nodes, /graph-run ready) (#998)
fix(run): skills preflight validates each worktree, not the main chec…
fix(exec): block background tasks under the orchestrator; WIP-commit …