Skip to content

fix(#1247): sequant run has one PR producer; createPR updates an existing PR - #1252

Merged
admarble merged 7 commits into
mainfrom
feature/1247-fix-run-sequant-run-has-two-pr-producers-exec-open
Oct 1, 2026
Merged

admarble merged 7 commits into
mainfrom
feature/1247-fix-run-sequant-run-has-two-pr-producers-exec-open

Conversation

@admarble

@admarble admarble commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Under sequant run, createPR is now the only PR producer, and it updates a PR that already exists for the branch instead of returning it untouched.

  • AC-1: all three exec/SKILL.md copies skip "PR Creation and Verification" when SEQUANT_ORCHESTRATOR is set: exec commits, runs git push -u origin <branch>, and opens no PR (no gh pr create, and no MCP pull-request tool in in-place mode). The in-place feat(exec/qa): explicit in-place checkout mode — run a phase on a branch in the current clone without creating or resolving a worktree #1136 block and the orchestrated-mode list now say the same thing. Exec is told to put its AC table and SEQUANT_MUTATION markers inside its final ## Summary, because that section is what the orchestrator copies into the PR body. Standalone /exec still creates the PR.
  • AC-2: createPR builds the title and body before Step 1. Both early returns (the Step 1 check and the "already exists" race) now push the branch and call the new GitHubProvider.updatePRSync, which runs gh api -X PATCH repos/{owner}/{repo}/pulls/N --input - with a JSON body on stdin, not gh pr edit. The overwrite policy from the spec is now written into the AC-2 line: title and body are overwritten only when the existing body is empty or carries the 🤖 Generated by \sequant run`trailer. Otherwise sequant logsPR #N body was edited by hand; not overwritten, and baseis still set under--stacked`. A failed PATCH prints a warning and the run keeps its PR. A failed push fails the run, the same as on the create path.
  • AC-3: state now has a new optional field, IssueState.execSummary, written by StateManager.updateExecSummary after each successful exec pass (an exec pass with no summary clears it). A run with no exec pass of its own (a qa-only re-run) passes the stored summary to createPR as opts.execSummary. buildAutomatedPRBody uses that summary when execOutput yields none.
  • AC-4: with exec no longer opening PRs under the orchestrator, --no-pr now stops both producers. No new env var.
  • AC-5 (owner decision, option B; added to the issue after QA's first pass): QA reads the PR body in four places: §6i mutation records, the precheck AC literal-diff, §2a settle evidence and the test-plan boxes. A PR opened only after QA left all four with nothing to read. runIssueWithLogging now has one openOrUpdatePR closure, called after each successful exec pass that left commits and declared no SPEC_DIVERGENCE, and again after QA. The second call takes the AC-2 update path and adds the QA note and ready-gate report. A failed after-exec call only warns, and the post-QA call stays fatal (fix(run): exec that leaves work uncommitted reports success and the run passes with no PR — #534's empty-branch escape, reopened via a new route #879). The after-exec PR opens non-draft, the same as exec-opened PRs today; draft policy belongs to decision(run): a sequant run where no qa ran still ends with a PR — draft+note, require qa, or unchanged (blocked by #1247) #1246. ADR-0004 point 5, the skill text, the docs and the CHANGELOG all describe this timing now.
  • ADR-0004, a CHANGELOG entry, and a "Who opens the PR" note in docs/reference/run-command.md.

Pre-PR AC Verification

AC Status Evidence
AC-1 ✅ src/lib/__tests__/exec-orchestrated-no-pr-skill.test.ts (9 cases, 3 copies × section skip / in-place block / marker channel)
AC-2 ✅ src/lib/workflow/worktree-manager.test.ts › #1247 AC-2 (real git and a bare remote; GitHubProvider spied): Step 1 path, empty body, hand-edited body with --stacked base, race path, failed PATCH, failed push. github.test.ts › updatePRSync (#1247)
AC-3 ✅ src/lib/workflow/batch-executor.test.ts › #1247 › run 1 exec → qa AC_NOT_MET, then run 2 qa-only gets the stored summary; a fresh exec pass wins over the stored one
AC-4 ✅ batch-executor.test.ts › AC-4: under --no-pr … plus the AC-1 gate
AC-5 ✅ batch-executor.test.ts › #1247 … › AC-5: the PR opens right after exec, before qa reads it (5 cases: call order against qa's start, a failed after-exec call, no commits, SPEC_DIVERGENCE, --no-pr). The call-count tests in ready-gate-run.test.ts and in batch-executor's #749/#879/#1223 tests now assert the two-call shape

Mutation-verified: AC-1: deleted the orchestrator skip paragraph from skills/exec/SKILL.md; the skills/exec cases of the gate test failed; restored.

Other probes, all restored afterwards:

  • I reverted the in-place reword in templates/skills/exec/SKILL.md. Only the templates/skills/exec in-place case failed.
  • I dropped execSummary from the batch-executor createPR call. Only the AC-3 qa-only case failed.

Test plan

Runner verification (head 8707d6a)

QA returned NEEDS_VERIFICATION. I did the following myself:

  • AC test files: ran all 7 at 0121cd2, 467 passed. Checked the three exec/SKILL.md copies are byte-identical. The AC-1 gate test reads only the PR-creation section and the in-place block, and makes real buildAutomatedPRBody and parseMutationMarkers calls.
  • AC-5: implemented it (above). While wiring it I found a regression and fixed it: an exec that returns success while declaring SPEC_DIVERGENCE would have opened a PR before the halt. model-ladder.test.ts caught it.
  • CI's red test at 0121cd2: reported by a peer session. in-place-checkout-skill.integration.test.ts flagged an "in-place" mention outside the delimited region at exec/SKILL.md:985. I reworded it in all three copies.
  • Wider test run: merged origin/main (with fix(#1248): Codex usage-limit tests no longer read the real clock #1251) and ran every test file naming in-place, SEQUANT_ORCHESTRATOR, gh pr create, createPR, buildAutomatedPRBody, viewPRByBranchSync, updatePRSync, execSummary, PR Creation and Verification or runIssueWithLogging: 46 files, 1,826 passed. npm run build, lint, tsc --noEmit, lint:skill-calls and skill-sync (47/47) are all clean.
  • Not exercised end-to-end: this run's PR was opened by exec under the old skill, so the AC-2 update path has only run in tests (real git with a bare remote, GitHubProvider spied). Pre-release sequant run uses the released 2.18.0 orchestrator. With this branch's skill, exec opens no PR, and 2.18.0's createPR opens it after QA. So until a release ships, QA in this repo's own runs still has no PR body. Land this with the release.

Mutation-verified: AC-5 — replaced the after-exec openOrUpdatePR call with a no-op result; src/lib/workflow/batch-executor.test.ts > #1247: exec summary persists for a later qa-only run (AC-3) and --no-pr has no producer (AC-4) > AC-5: the PR opens right after exec, before qa reads it > createPR runs after exec and before qa starts, then updates after qa with the verdict failed; restored.

Second mutation: I removed the !result.specDivergence gate. Only … > AC-5: … > an exec that declares SPEC_DIVERGENCE opens no PR, even on success failed. Restored.

ADR number: #1253 also adds docs/adr/0004-*. Whichever merges second gets renumbered to 0005.

Closes #1247

🤖 Generated with Claude Code

@admarble
admarble merged commit 7b6efb9 into main Oct 1, 2026
10 checks passed
@admarble
admarble deleted the feature/1247-fix-run-sequant-run-has-two-pr-producers-exec-open branch October 1, 2026 04:16
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