Skip to content

fix(#879): fail exec on uncommitted-only work and make PR-creation failure fatal - #889

Merged
admarble merged 6 commits into
mainfrom
feature/879-fix-run-exec-that-leaves-work-uncommitted-reports-
Aug 4, 2026
Merged

admarble merged 6 commits into
mainfrom
feature/879-fix-run-exec-that-leaves-work-uncommitted-reports-

Conversation

@admarble

Copy link
Copy Markdown
Contributor

Summary

Closes #534's empty-branch escape, reopened via a new route (exec finishing with work uncommitted). Two independent gaps, both fixed:

  1. hasExecChanges treated a dirty tree as exec success. But uncommitted work cannot rebase, push, or become a PR — so a run "passed" with no commits and no PR. New classifyExecChanges() returns a three-state discriminated result (commits / uncommitted / none / unknown); exec now fails on both none and uncommitted, naming the dirty paths so the work is discoverable from the run log. The guard is read-only (git rev-list + git status), so a failed phase leaves the worktree and its dirty files byte-identical. hasExecChanges is kept as a thin boolean wrapper. The ready gate uses the same classifier (new UNCOMMITTED_ONLY reason, exit code 2, distinct from NO_IMPLEMENTATION).

  2. A failed createPR was a non-fatal warning while the issue reported success. executeIssue now records prCreationError and returns success: false; the batch loop flips the run-log status to failure via new LogWriter.markIssueFailed, and the summary names the PR error as the failure reason. --no-pr is unaffected (shouldCreatePR already gates it).

Design note honored: exec fails rather than auto-commits — an auto-commit would sweep up scratch files and author a PR nobody wrote. .sequant/state.json is deliberately untouched (chain-resume keys off it).

Pre-PR AC Verification

AC Description Status Evidence
AC-1 hasExecChanges distinguishes "no work" from "uncommitted only"; exec fails on both ✅ phase-executor.ts classifyExecChanges + exec guard; phase-executor.test.ts
AC-2 Exec failure message names the uncommitted paths (capped at 20) ✅ formatUncommittedExecError; unit + integration tests
AC-3 Failed exec leaves the worktree + dirty files untouched ✅ read-only classifier; phase-executor.integration.test.ts byte-identical assertion
AC-4 Ready gate reports uncommitted-only as UNCOMMITTED_ONLY, distinct from NO_IMPLEMENTATION ✅ ready-gate.ts; exit code 2 in ready.ts; ready-gate.test.ts + ready.test.ts
AC-5 Failed createPR sets issue run status failed; summary counts it under failed ✅ batch-executor.ts overallSuccess; run-display.ts; batch-executor.test.ts + run-display.test.ts
AC-6 Regression: uncommitted worktree, no commits → exec fails ✅ phase-executor.integration.test.ts (real git)
AC-7 Regression: createPR failure → non-success issue status in run log ✅ log-writer.test.ts markIssueFailed

Mutation verification (gate tests)

Per CLAUDE.md, each new gate test was mutation-verified — the asserted behavior was broken, exactly the intended test failed, then restored:

AC Mutation Result
AC-1 uncommitted branch returns success: true ✅ only "names the paths…" failed
AC-2 drop paths from the failure message ✅ only that test failed
AC-4 finish("UNCOMMITTED_ONLY") → NO_IMPLEMENTATION ✅ only the ready-gate test failed
AC-5 overallSuccess = success (ignore prCreationError) ✅ only the PR-failure test failed
AC-7 markIssueFailed sets success ✅ only the two status-asserting tests failed
AC-7 drop prCreationError from summary fallback ✅ only the run-display test failed

Test plan

  • npm run build — clean
  • npm run lint — clean
  • npm test (touched files): 491 passed across 9 files incl. real-git integration

Closes #879

…ilure fatal

Closes #534's empty-branch escape via a new route. Two independent gaps:

1. hasExecChanges treated a dirty tree as exec success — but uncommitted
   work cannot rebase, push, or become a PR. Add classifyExecChanges (a
   three-state discriminated result: commits/uncommitted/none/unknown);
   exec now FAILS on both 'none' and 'uncommitted', naming the dirty paths
   so the work is discoverable from the run log. The guard is read-only, so
   a failed phase leaves the worktree and its dirty files untouched. Extend
   the same classifier to the ready gate (new UNCOMMITTED_ONLY reason, exit
   code 2, distinct from NO_IMPLEMENTATION).

2. A failed createPR printed a warning while the issue still reported
   success — a run could 'pass' with no PR. executeIssue now records
   prCreationError and returns success:false; the batch loop flips the run
   log status to failure via LogWriter.markIssueFailed, and the summary
   names the PR error as the failure reason.

Entire-Checkpoint: 337b1a32e7c0
admarble added 5 commits July 31, 2026 04:13
QA (AC_NOT_MET) found the run-log-status half of the fix was attached to a
dead code path: markIssueFailed was called only in executeBatch, which has
zero live callers. The real `sequant run` path is
RunOrchestrator.executeOneIssue, which finalized issues via setPRInfo +
completeIssue but never markIssueFailed — so on a real run a post-QA
createPR failure left the persisted run-log status at `success` (AC-5/AC-7
unmet on the live path).

Extract a single recordIssueCompletion(logWriter, result, issueNumber) helper
that does setPRInfo → markIssueFailed (on prCreationError) → completeIssue, and
route BOTH executeBatch and the live executeOneIssue through it so the two batch
loops cannot drift again. Add spy-based regression tests asserting the helper
marks the issue failed (before completing) on a PR-creation failure and records
PR info without flipping status on success.

Entire-Checkpoint: b8d48afcacc7
…ation

Merging main brought in #856, which reworked completeIssue to re-derive an
issue's status from its phase list at completion time (forcing failure only
for aborts). That silently defeated #879's markIssueFailed, which seeded the
slot status to failure: completeIssue overwrote it back to success from the
all-green phase prefix, so a PR-creation failure no longer counted under
failed (AC-5/AC-7) -- reproduced by the two markIssueFailed tests failing
only in the merged suite.

Track forced failures in a WeakSet keyed on the issue slot and honor it in
completeIssue alongside abort, so markIssueFailed's override wins over the
phase-derived status. Covers both the numbered and legacy currentIssue paths.

Entire-Checkpoint: a43e194f6eeb
…ion, live-path completion test

Three gaps from the /qa review:

- CHANGELOG: add the [Unreleased] > Fixed entry for the two user-facing
  behavior changes (exec fails on uncommitted-only work naming the preserved
  paths; a failed createPR fails the run and is counted under failed).
- Deprecate executeBatch (@deprecated): no live caller remains — it survives
  only as a commands/run-compat re-export. The doc names the constraint that
  any future completion path must go through recordIssueCompletion, so the
  #879 status-drift class cannot silently return via a third loop.
- Test the LIVE completion path: recordIssueCompletion had unit coverage, but
  the #879 defect was executeOneIssue (what `sequant run` actually executes)
  not calling the flip at all. New tests drive executeOneIssue itself with
  only runIssueWithLogging mocked and the real helper in between.

Mutation-verified: reverting executeOneIssue's completion block to the
pre-#879 bare setPRInfo+completeIssue form fails exactly the new test
"flips the run-log status when the result carries a prCreationError"
(1 failed, 4 passed); restored, all 5 pass.

Claude-Session: https://claude.ai/code/session_018ZNB3A5b3f12RwwfmYncvc
…xec-that-leaves-work-uncommitted-reports-

# Conflicts:
#	CHANGELOG.md
@admarble
admarble merged commit 1ef378b into main Aug 4, 2026
5 checks passed
@admarble
admarble deleted the feature/879-fix-run-exec-that-leaves-work-uncommitted-reports- branch August 4, 2026 04:05
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