Repository navigation
Description
Blocked by: — Tier: mechanical Doc: W2 field finding 2026-09-10 (graph-run wave 1)
Why
A recurring exec-phase failure class across three projects: the phase agent starts the full test suite as a background job (Monitor, or Bash with run_in_background: true plus a polling loop), then ends its turn with "I'll wait for the notification". Under sequant run the driver treats the end of the turn as the end of the phase (claude-code.ts returns on the first result message), and in every stranded transcript zero task notifications were ever delivered. The #879 guard then fires — exec left N file(s) uncommitted and made no commits — and the work sits in the worktree until a human rescues it.
Instances found in the retained run logs and their exec transcripts (last assistant text quoted):
| Date | Project | Issue | Outcome | Agent's last words |
|---|---|---|---|---|
| 2026-08-24 | ad-motion | #226 | exec 574s, 21 files stranded | "While the suite runs, let me re-read…" (Monitor on the suite) |
| 2026-08-30 | vid-gen bench | #5, #6 | phase ended, re-dispatched | "The Monitor task is still running and will notify me… I'll wait for that." |
| 2026-09-07 | sequant | #933 ×2 | exec 557s/680s, 5 files stranded | (backgrounded npm test) |
| 2026-09-10 | ad-motion | #233 | exec 474s, 18 files stranded | "I'll stop issuing commands now and wait for the Monitor/background task notification to arrive." |
| 2026-09-10 | sequant | #990 | exec 708s, 12 files stranded | "I'll now wait for the original npm test background task to notify me when it completes." |
A second sub-pattern: when the agent keeps polling instead of ending its turn (#980, 2026-09-10), the phase idles until the MCP server's 30-minute no-progress kill, which landed mid-suite and left 35 tracked root files deleted in the worktree (a test moves them aside and never got to restore them).
Nothing prevents it today: the /exec skill has no foreground rule for test runs (it models backgrounding for worktree creation and parallel implementers), and pre-tool.sh has no guard for Monitor or run_in_background inside a phase.
Proposed change (three parts)
- Deterministic guard (hook). When
SEQUANT_ORCHESTRATORis set,pre-tool.shblocks aMonitortool call and aBashcall withrun_in_background: truewithHOOK_BLOCKED: background tasks never notify a phase agent — run it in the foreground with \timeout``. Interactive sessions are untouched. - Skill rule.
/exec§3 Checks-first: run the suite once, in the foreground, with atimeout, after a WIP commit; never wait on a background task or Monitor for it. - WIP-commit on the guard. When
mapAgentSuccessToPhaseResultclassifies the exec tree asuncommitted, commit the dirty paths aschore(#N): wip checkpoint — exec ended with uncommitted work (auto-committed by sequant)(a conventional type: the pre-tool hook rejectswipas a type) before failing the phase, and name the commit in the error. The phase still fails; the work now survivesgit checkout, stale-worktree cleanup and a re-dispatch's rebase.
Scope
- may touch:
templates/hooks/pre-tool.sh(+ synced copies vianpm run sync:hooks),templates/skills/exec/SKILL.md(+ synced copies vianpm run sync:skills),src/lib/workflow/phase-executor.ts(mapAgentSuccessToPhaseResult, one helper),CHANGELOG.md(one bullet); tests: newsrc/lib/__tests__/pre-tool-background-guard.integration.test.ts, newsrc\/lib\/workflow\/phase-executor.wip-commit.test.ts(real temp git repo; the existing phase-executor.test.ts mocks child_process), newsrc\/lib\/__tests__\/exec-skill-foreground-rule.test.ts. - not in scope: the MCP 30-minute
PHASE_TIMEOUT; the driver's phase-end semantics; the root-file-moving test (separate finding).
Acceptance criteria
- AC-1: with
SEQUANT_ORCHESTRATORset,pre-tool.shexits 2 with aHOOK_BLOCKED:line for aMonitortool call and for aBashcall whosetool_input.run_in_backgroundistrue; a foregroundBashcall with the same command is allowed — Verify:npx vitest run src/lib/__tests__/pre-tool-background-guard.integration.test.ts -t "AC-1"→ three cases. Mutation: delete the guard block → the two blocked cases fail; restore. - AC-2: without
SEQUANT_ORCHESTRATOR, the sameMonitorand backgroundBashcalls exit 0 — Verify:npx vitest run src/lib/__tests__/pre-tool-background-guard.integration.test.ts -t "AC-2"→ both allowed. - AC-3:
/exec§3 (Checks-first Mindset) states the foreground rule and namestimeout, and the three skill copies are identical — Verify:npx vitest run src/lib/__tests__/exec-skill-foreground-rule.test.ts→ the §3 region (between the### 3. Checks-first Mindsetheading and the next###) matches/foreground/and/timeout/;npm run lint:skill-sync→ clean. Mutation: delete the rule line → fails; restore. - AC-4: an exec phase whose worktree has uncommitted changes and no commits ends with the files committed as a
chore(#N): wip checkpoint …commit on the branch, the phase still reportssuccess: false, and the error names the commit SHA — Verify:npx vitest run src\/lib\/workflow\/phase-executor.wip-commit.test.ts -t "AC-4"→ real temp git repo,git rev-list --count base..HEAD→1,git status --porcelainempty, error matches/auto-committed as [0-9a-f]{7}/. Mutation: drop the commit call → fails; restore. - AC-5: the WIP commit never runs when the tree has commits or is clean — Verify:
npx vitest run src\/lib\/workflow\/phase-executor.wip-commit.test.ts -t "AC-5"→commitsandnonecases leave the log untouched. - AC-6:
CHANGELOG.md[Unreleased]names the guard and the WIP commit — Verify:grep -c "run_in_background" CHANGELOG.md≥ 1. - AC-7: suite green — Verify:
npm run build && npm test→ pass.
Done when
A phase agent cannot park itself on a background task, and when an exec phase still ends with uncommitted work, that work is on the branch before the failure is reported.
Activity
docs(graph): wave-1 execution record — D15–D17, post-wave ledger, han…
docs(graph): wave-2 plan — node 09 (#1030), D14–D17, and the wave-1 e…
fix(exec): block background tasks under the orchestrator; WIP-commit …
docs(#980): guard count is 17 after the #1032 background-task guard l…
docs(#980): public threat model with OWASP agentic mapping and SECURI…
fix(sync): never rewrite a user-owned AGENTS.md or write a machine-sp…
docs(exec): run the full suite exactly once per phase — gate-tested (#…
docs: What's new in 2.15, sync/dry-run coverage, orchestrator-only gu…
docs(skills): name the macOS coreutils install and the portable perl …