Skip to content

fix(exec): block background tasks under the orchestrator; WIP-commit stranded exec work (#1032) - #1034

Merged
admarble merged 2 commits into
mainfrom
feature/1032-fix-exec-phase-agent-that-backgrounds-the-tes
Sep 10, 2026
Merged

admarble merged 2 commits into
mainfrom
feature/1032-fix-exec-phase-agent-that-backgrounds-the-tes

Conversation

@admarble

@admarble admarble commented Sep 10, 2026 •

Copy link
Copy Markdown
Contributor

Closes #1032.

Why

Every stranded-exec transcript in the retained logs — ad-motion #226 (08-24) and #233 (09-10), sequant #933 ×2 (09-07) and #990 (09-10), the vid-gen bench #5/#6 (08-30) — ends the same way: the agent starts the full test suite as a Monitor or a backgrounded Bash command, then "waits for the notification". Under sequant run the end of the turn is the end of the phase (claude-code.ts returns on the first result), no task notification was delivered in any of those transcripts, and the #879 guard fails the phase with the work uncommitted. An agent that polls instead idles until the MCP 30-minute kill (#980 today).

What

  1. Hook guard (deterministic). pre-tool.sh blocks a Monitor tool call and a Bash call with run_in_background: true whenever SEQUANT_ORCHESTRATOR is set, with a message that shows the foreground form. Interactive sessions are untouched. Synced to .claude/hooks/ and the plugin hooks/ copy.
  2. Skill rule. /exec §3 Checks-first: run the suite once, foreground, with timeout, after a WIP commit; never wait on a background task. Synced to all three skill copies.
  3. WIP commit on the guard. When mapAgentSuccessToPhaseResult finds an uncommitted exec tree it commits exactly the dirty paths as chore(#N): wip checkpoint — exec ended with uncommitted work (auto-committed by sequant) (a conventional type — the pre-tool hook rejects wip) (--no-verify: a checkpoint, not a reviewed commit), then still fails the phase, naming the commit. Git errors fall back to the pre-fix(exec): phase agent that backgrounds the test suite and waits for a notification strands uncommitted work — block Monitor/run_in_background under the orchestrator, WIP-commit on the no-commit guard #1032 message and leave the work in place.

Known gap, not addressed: Agent(run_in_background=true) for parallel implementers is still allowed — the /exec skill prescribes it and no stranded transcript involved it.

AC verification

AC Command Result
AC-1 npx vitest run src/lib/__tests__/pre-tool-background-guard.integration.test.ts -t "AC-1" 3 passed
AC-2 … -t "AC-2" 2 passed
AC-3 npx vitest run src/lib/__tests__/exec-skill-foreground-rule.test.ts → 6 passed; npm run lint:skill-sync → 44 synced, 0 diverged ✅
AC-4 npx vitest run src/lib/workflow/phase-executor.wip-commit.test.ts -t "AC-4" 2 passed (real temp git repo)
AC-5 … -t "AC-5" 2 passed
AC-6 grep -c "run_in_background" CHANGELOG.md → 1 ✅
AC-7 npm run build && npm test run alone at 5bb2b5d: 306/307 files, 6215 passed, 1 failed — the #879 AC-3 integration case that asserted the guard mutates nothing, i.e. the contract this PR replaces; rewritten in 736b03c to assert byte-identical files and the checkpoint commit (4 affected files re-run: 194 passed). Duration 824s.

Also updated: phase-executor.integration.test.ts #879 AC-3 case (see AC-7 row).

Mutation verification

Mutation-verified: AC-1 — deleted the orchestrator guard block from .claude/hooks/pre-tool.sh; pre-tool-background-guard.integration.test.ts > AC-1 > blocks a Monitor tool call and > blocks a Bash call with run_in_background: true failed (2); restored.

Mutation-verified: AC-3 — deleted the "Foreground only (#1032)" paragraph from .claude/skills/exec/SKILL.md; both exec-skill-foreground-rule.test.ts cases for that copy failed; restored.

Mutation-verified: AC-4 — dropped the git commit call in autoCommitUncommittedWork; phase-executor.wip-commit.test.ts > AC-4 > commits the dirty paths, still fails, and names the commit failed; restored.

🤖 Generated with Claude Code

admarble and others added 2 commits September 10, 2026 09:53
…stranded exec work (#1032)

Every stranded-exec transcript found (ad-motion #226/#233, sequant #933/#990,
the vid-gen bench) ended with the agent starting the test suite as a Monitor or
a backgrounded Bash command and then "waiting for the notification". Under
sequant run the phase ends when the turn ends, no notification is ever
delivered, and the #879 guard fails the phase with the work uncommitted.

- pre-tool.sh: with SEQUANT_ORCHESTRATOR set, HOOK_BLOCK a Monitor tool call
  and a Bash call with run_in_background: true, pointing at the foreground
  form (`timeout 600 npm test ...`). Interactive sessions untouched.
- /exec §3: foreground-only rule for the suite, after a WIP commit.
- phase-executor: when the exec tree is `uncommitted`, commit the dirty paths
  as `wip(#N): exec ended with uncommitted work (auto-committed by sequant)`
  before failing the phase; the error names the commit. Git errors fall back
  to the pre-#1032 message and leave the work in place.
- Tests: hook integration (AC-1/AC-2), skill gate (AC-3), real-git WIP commit
  (AC-4/AC-5).

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_0147heJNRw8wBBujPGMqxDpR
…AC-3 test to the #1032 contract

The pre-tool hook (and commitlint setups downstream) reject `wip` as a commit
type, so the auto-commit and the /exec skill example now use
`chore(#N): wip checkpoint — …`. The #879 AC-3 integration case asserted the
guard mutates nothing; it now asserts the dirty file is byte-identical AND
checkpointed on the branch, which is the new contract.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_0147heJNRw8wBBujPGMqxDpR
admarble added a commit that referenced this pull request Sep 10, 2026
…doff constraints

Adds what running wave 1 on 2026-09-10 decided and found: D15 (#982 AC-3
verify command amended), D16 (#990 AC-6 `update --dry-run` clause moved to
#1030), D17 (background-task stranding → #1032 / PR #1034); the execution
table on issue-graph.md; HANDOFF.md's ledger rewritten for the next runner
(three PRs awaiting the owner, owner actions, MCP 30-minute wall guidance).

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_0147heJNRw8wBBujPGMqxDpR
admarble added a commit that referenced this pull request Sep 10, 2026
…xecution ledger (#1031)

* docs(graph): add node 09 (#1030 dry-run/apply drift) and decision D14 to the wave-2 plan

Claude-Session: https://claude.ai/code/session_01Y4tK7EXMEUze1VkjkKAMU4
Entire-Checkpoint: b5dab9dfebb7

* docs(graph): wave-1 execution record — D15–D17, post-wave ledger, handoff constraints

Adds what running wave 1 on 2026-09-10 decided and found: D15 (#982 AC-3
verify command amended), D16 (#990 AC-6 `update --dry-run` clause moved to
#1030), D17 (background-task stranding → #1032 / PR #1034); the execution
table on issue-graph.md; HANDOFF.md's ledger rewritten for the next runner
(three PRs awaiting the owner, owner actions, MCP 30-minute wall guidance).

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_0147heJNRw8wBBujPGMqxDpR

---------

Co-authored-by: Claude Fable 5.1 <[email protected]>
@admarble
admarble merged commit ebcdeff into main Sep 10, 2026
9 checks passed
admarble pushed a commit that referenced this pull request Sep 10, 2026
…anded on main

AC-4's gate caught exactly the drift it exists for: merging main brought
the seventeenth distinct HOOK_BLOCKED refusal (#1032, PR #1034) and the
computed count no longer matched the typed slot.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_0147heJNRw8wBBujPGMqxDpR
Entire-Checkpoint: 5070c7c3df27
admarble added a commit that referenced this pull request Sep 10, 2026
…TY.md (#1035)

* test(#980): gate test for SECURITY.md and THREAT-MODEL.md (WIP)

Entire-Checkpoint: a7d871dfe538

* docs(security): public threat model, SECURITY.md, and CI-gated claims (#980)

Entire-Checkpoint: b88d4b15dee0

* test(#980): report a missing enforcer path cleanly instead of throwing ENOENT

Entire-Checkpoint: 3a13e689f28f

* test(#980): mark the security-docs gate @tautology-skip with mutation evidence

The file asserts on the text of SECURITY.md, THREAT-MODEL.md and README.md;
there is no production function to call, by design. Without the pragma the
advisory detector reads the whole file as 100% tautological and
scripts/qa/tautology-detector-cli.test.ts (which runs the CLI against the
branch's own changed test files) exits 1, failing npm test.

Entire-Checkpoint: 204e10f911e3

* docs(#980): the merge gate is a human control, not a deterministic one; the injection eval is evidence, not containment

Second-pass QA (AC_MET_BUT_NOT_A_PLUS) notes: the ASI01 row listed the
human merge gate inside the deterministic bound, contradicting the
Residual risks section; the manually dispatched eval was classed
deterministic alongside runtime hook refusals. Both cells corrected;
the citation gate still passes (35/35).

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_0147heJNRw8wBBujPGMqxDpR
Entire-Checkpoint: a606392f4b70

* docs(#980): guard count is 17 after the #1032 background-task guard landed on main

AC-4's gate caught exactly the drift it exists for: merging main brought
the seventeenth distinct HOOK_BLOCKED refusal (#1032, PR #1034) and the
computed count no longer matched the typed slot.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_0147heJNRw8wBBujPGMqxDpR
Entire-Checkpoint: 5070c7c3df27

---------

Co-authored-by: Claude Fable 5.1 <[email protected]>
Co-authored-by: t <[email protected]>
@admarble
admarble deleted the feature/1032-fix-exec-phase-agent-that-backgrounds-the-tes branch September 10, 2026 22:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant