Skip to content

fix(run): abort-path paper cuts — "work is preserved in <worktree>" is false under SIGTERM, and abort's doc comment cites the wrong issue #935

Closed

Description

@admarble

Epic: M1 Blocked by: #933 Tier: mechanical Doc: docs/internal/graph-2026-09/PLAN.md §7 D13, §8, §9 OQ-2/OQ-3 Graph node: 09

Two small, related shutdown-path defects surfaced by the 2026-08-07 ad-motion
incident (context: ad-motion experiments/overnight-autonomy/review-log.md).

1. The #879 failure message promises a worktree that shutdown then deletes

formatUncommittedExecError (#879) tells the user "The work is preserved in
: ". But run-orchestrator.ts:1123-1137 registers a
git worktree remove --force cleanup for every worktree the run created, and
ShutdownManager fires cleanups on SIGINT/SIGTERM (shutdown.ts:231-237). An
externally-terminated headless run therefore destroys the exact directory its
own failure message points at — observed: the #177 worktree named in the
02:20:53 failure no longer existed by morning.

Options (pick one):

  • Don't force-remove DIRTY worktrees during signal-driven shutdown (keep the
    force-remove for clean ones; print "preserved at " only when true), or
  • Keep removal but stop promising preservation: name the branch (which
    survives) instead of the worktree path.

2. sequant abort's source comment cites #645, which is the relay bug

bin/cli.ts:487-489: "Out-of-band abort: signal a running sequant session
directly (#645)" — but #645 is "bug(#383): relay messages silently lost".
Whatever issue actually specified abort, the citation should point there;
as-is it sends incident investigators to an unrelated bug (it did, on 08-07).

Scope (graph plan 2026-09)

Acceptance criteria (graph plan 2026-09)

  • AC-1: on a signal-driven shutdown a worktree with uncommitted changes is not removed; a clean one still is — Verify: npx vitest run src/lib/workflow/run-orchestrator.shutdown.test.ts -t "935" → passes; the test creates two real worktrees in a temp repo, dirties one, invokes the registered cleanups with reason SIGTERM, and asserts on git worktree list afterwards.
  • AC-2: the failure text matches the post-shutdown filesystem — Verify: same test: the message emitted for the dirty case contains a path that exists; for the path-removed case (non-signal completion) the message names the branch instead of a path.
  • AC-3: abort cites its origin — Verify: grep -n '#645' bin/cli.ts src/commands/abort.ts | wc -l → 0, and the replacement citation equals the PR of git log --format=%s -S'Out-of-band abort' -- bin/cli.ts | tail -1.

Done when (graph plan 2026-09)

An externally terminated run never deletes a worktree its own failure text points at, and the abort command's comment sends a reader to the issue that specified it.

Original acceptance criteria (superseded by the graph-plan ACs above; kept for history)
  • A SIGTERM'd run either preserves dirty worktrees or its failure text
    stops naming a path that won't exist (test: assert message matches
    post-shutdown filesystem state)
  • abort doc comment cites the correct issue

Activity

  1. added
    graph-2026-09
    on Sep 7, 2026
  2. admarble commented on Sep 8, 2026

    @admarble
    ContributorAuthor

    Runner context — wave 2 launch (2026-09-08, main at ecea618). All wave-1 PRs are merged (#999 #1000 #1001 #1002 #1003 #1004 #1005) plus the plan PR #998 and #1006, so read the plan and your node file from main: docs/internal/graph-2026-09/PLAN.md (§5 invariants, §7 decisions D16–D22, §8 conventions) and docs/internal/graph-2026-09/issues/<NN>-*.md. Launch discipline learned in wave 1: the launcher kills any phase that is silent for 30 minutes and the shutdown cleanup deletes an uncommitted worktree — commit a WIP every ~10 minutes and before any long test run; run tests in the foreground only (never background npm test); prefer the node file's targeted -t commands over the full suite (the full suite takes ~6 min). A phase that reports "Out of credits" at ~30 min was a timeout, not a wallet problem. Consent mode is stop-at-PR: open the PR, do not merge.

    Node file: issues/09-935-signal-shutdown-worktrees.md. #933 (PR #1001) changed the region you own: the skills preflight now runs after provisioning and, on failure, removes the worktrees the run just created (or names the git worktree remove step for a reused one); read run-orchestrator.ts's current cleanup registration block on main before editing — line numbers in the node file are from 2026-09-06. D13 stands: dirty worktrees survive signal-driven shutdown, clean ones are still removed. Keep the preflight call itself out of scope (node 05 owns it; OQ-22 is a separate follow-up).

  3. admarble commented on Sep 8, 2026

    @admarble
    ContributorAuthor

    QA Verdict: AC_MET_BUT_NOT_A_PLUS

    AC coverage: 0/1 met

    Gaps:

    Suggestions:

    • cleanupWorktreeOnShutdown invokes git worktree remove with no cwd/-C, resolving against process.cwd(), while isWorktreeDirty two functions above correctly uses -C worktreePath. This is faithfully preserved pre-existing behavior (the original inline block did the same) and is safe in production, but the inconsistency is what forced the test to process.chdir. Passing -C would remove both the asymmetry and the need for the chdir.
    • The test mutates process-global cwd in beforeAll/afterAll in a unit-project file that shares a worker with other files. It is correctly restored, and afterAll runs even if beforeAll throws, so risk is low — but this repo has a documented history of cwd manipulation causing cross-fork fallout (worktree-manager's bare || "npm" fallback disagrees with the PM-aware shell path on manifest-less projects #870). Worth avoiding if the -C change above is made.
  4. admarble commented on Sep 8, 2026

    @admarble
    ContributorAuthor

    Runner verification — node 09 (PR #1007, QA verdict AC_MET_BUT_NOT_A_PLUS, iteration 1)

    Verify commands from issues/09-935-signal-shutdown-worktrees.md, run verbatim in the worktree at 963cc786:

    AC Command Result
    AC-1 npx vitest run src/lib/workflow/run-orchestrator.shutdown.test.ts -t "935" passed (2 tests): dirty worktree survives a SIGTERM-reason cleanup, clean one is removed
    AC-2 same run passed: dirty-case message names an existing path; non-signal path-removed case names the branch
    AC-3 grep -n '#645' bin/cli.ts src/commands/abort.ts | wc -l 1, not 0 — the survivor is bin/cli.ts:470, the --wait option's own citation (#645, Gap 4, the relay reply loop), which is unrelated to abort and correct. Both abort citations (bin/cli.ts:507, src/commands/abort.ts:3) now read #858, which equals git log --format=%s -S'Out-of-band abort' -- bin/cli.ts | tail -1 → fix(#853): … (#858). Literal AC text says 0; the intent (abort cites its origin) is met. Owner's call whether the AC's grep should have been scoped to the abort lines.
    gate PR body mutation record 1 marker present, parses

    Field note: this fix is the one that would have saved the two judgment worktrees killed at 05:02Z today (#986, #862 — MCP launcher's 30-minute no-progress ceiling, then git worktree remove --force on shutdown). Their committed work survives on the local branches; their uncommitted tails did not.

    Stop-at-PR: not merged.

  5. added a commit that references this issue on Sep 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    graph-2026-09

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions