Skip to content

fix(pr): sequant run PRs double the conventional prefix in the title and ship a placeholder body #1223

Closed

Description

@admarble

Tier: mechanical Graph: tracker #1236 (wave 3) Found: 2026-09-29, field graph wave 3 (tracker #1203)

Problem. A PR that sequant run opens has two defects that a human has to fix by hand before merging:

  1. Doubled title prefix. createPR builds ${prefix}(#${issueNumber}): ${issueTitle} (src/lib/workflow/worktree-manager.ts:1866) and never strips a conventional-commit prefix that the issue title already has. An issue titled feat(adopt): … gets feat(#1209): feat(adopt): …. Seen on feat(#1198): run log records each phase's model and the sequant version #1220 and feat(#1209): init --manifest-only and sync --only skills — cheap, documented adoption #1221 (2026-09-29), and long-standing: feat(#740): feat(assess): emit sequant run when a global install is present, not always npx sequant run #743 feat(#740): feat(assess): …, feat(#932): fix(run): manifest fallback ?? "npm" bypasses resolvePackageManager — pnpm worktrees get npm ci (surviving #870 site) #1000 feat(#932): fix(run): …. The second example also shows the label-derived prefix (feat) contradicting the title's own type (fix).
  2. Placeholder body. buildAutomatedPRBody (worktree-manager.ts:1740) emits only Automated PR for issue #N. plus the closing line and the QA note. There is no summary of the change, even though exec's own summary is available. Squash-merging such a PR puts the placeholder into the commit message on main.

Not previously filed (searched "Automated PR", "doubled title", "PR title prefix").

AC

  • AC-1: When the issue title starts with a conventional-commit prefix (type: or type(scope):), the PR title uses that type, puts #N where the scope was (this repo's type(#N): convention), and does not repeat the prefix. For example feat(adopt): x becomes feat(#1209): x, and fix(run): y on an issue labelled enhancement becomes fix(#932): y. Titles without a prefix keep today's label-derived behaviour. Evidence: npx vitest run src/lib/workflow/worktree-manager.test.ts
  • AC-2: The automated PR body includes a summary of the change taken from the exec phase's output (its ## Summary section, when present), and still has the closing line and QA note. It falls back to today's text only when no summary is available. Evidence: npx vitest run src/lib/workflow/worktree-manager.build-pr-body.test.ts
  • AC-3: Closing keywords inside the imported exec summary (close[sd]?, fix(e[sd])?, resolve[sd]? followed by #N) are rewritten to Refs #N, so only the body's own trailer (Fixes #N, or Refs #N under feat(pr): opt out of closing keywords — Refs #N for issues a PR should not close #1197's prIssueLink: "refs") can close an issue. Evidence: npx vitest run src/lib/workflow/worktree-manager.build-pr-body.test.ts, including a summary that contains Closes #279

Graph metadata

  • Blocked by: (none)

May touch

  • src/lib/workflow/worktree-manager.ts
  • src/lib/workflow/worktree-manager.test.ts, src/lib/workflow/worktree-manager.build-pr-body.test.ts
  • src/lib/workflow/batch-executor.ts (to pass the exec summary into createPR)

Activity

  1. added
    bug
    graph-2026-09-prerelease
    on Sep 30, 2026
  2. admarble commented on Sep 30, 2026

    @admarble
    ContributorAuthor

    Context for the run (graph tracker #1236, wave 3; re-checked after #1233 lands)

    Body changes:

    • AC-1's text now matches its own examples. The PR title takes the issue title's type and replaces the scope with #N: feat(adopt): x → feat(#1209): x. Keeping the scope as well would break this repo's type(#N): convention.
    • AC-3 is new, and it guards AC-2. See below.

    Current code:

    • src/lib/workflow/worktree-manager.ts:1953-1954: const prefix = isBug ? "fix" : "feat"; const prTitle = \${prefix}(#${issueNumber}): ${issueTitle}`;`
    • worktree-manager.ts:1813: buildAutomatedPRBody(issueNumber, opts) emits the placeholder Automated PR for issue #N., then the closing line (Fixes #N, or Refs #N under feat(pr): opt out of closing keywords — Refs #N for issues a PR should not close #1197's linkMode: "refs"), then the QA note.
    • src/lib/workflow/batch-executor.ts (the createPR( call, about :2343 on main) passes positional args. The exec phase's text is on PhaseResult.output (phaseResults.find(p => p.phase === "exec")?.output).

    AC-1, the title: match a leading type(scope)!?: or type: using the conventional-commit types. Take the type from the title, even when the labels disagree (fix(run): y on an enhancement → fix(#932): y). Titles without a prefix keep today's label-derived feat/fix. Don't match mid-title colons (Docs: foo isn't a type; keep the list to real types: feat, fix, docs, chore, refactor, test, perf, build, ci, style, revert).

    AC-2, the body: take the last ## Summary section from exec's output (up to the next ## heading or the end), trimmed. Cap its length (for example 4 KB) so a runaway section can't bloat the body. When there's no summary, keep today's placeholder. Keep the closing line and the QA note exactly as they are now. Thread the summary through createPR as an options field, not another positional arg. The signature already has 11 positional parameters.

    AC-3, why it's needed: GitHub reads a closing keyword anywhere in a PR body. Agent-written summaries do contain lines like "Close #279 with the AC mapping comment after this merges", and that one auto-closed an issue in a downstream repo (the case behind #1197). Imported summary text must never close anything. Rewrite \b(close[sd]?|fix(e[sd])?|resolve[sd]?)\s*:?\s+#(\d+) (case-insensitive) to Refs #$N in the imported text only, never in the trailer. Test it with a summary containing Closes #279 and one containing fixes #1223 (the issue itself: the trailer still closes it, and the summary line must not).

    Standard block:

    • No full npm test in exec or in qa. This applies to the qa phase as well as exec. Run targeted suites in the foreground with a timeout: timeout 600 npx vitest run src/lib/workflow/worktree-manager.test.ts src/lib/workflow/worktree-manager.build-pr-body.test.ts src/lib/workflow/batch-executor.test.ts. Global setup runs npm run build first.
    • Commit WIP early, and always before any mutation.
    • A mutation marker's failedTest starts with the test file path.
    • Before moving or reshaping a code block, grep the tests for a literal from it: some tests regex-scan source files.
    • PR body: Closes #1223. Use Refs only for the tracker, tracker(graph): pre-release fixes before the next release after 2.18.0 (4 nodes) #1236.
    • Add a CHANGELOG ### Fixed entry under [Unreleased].
  3. admarble commented on Sep 30, 2026

    @admarble
    ContributorAuthor

    Complexity: Standard (3 ACs, 1 directory)

    AC Quality Check

    All three AC are single-line, each carries a concrete Evidence: command, and AC-1/AC-3 include literal before/after examples. No vague/unmeasurable/open-ended language detected. Evidence: commands point at whole test files (worktree-manager.test.ts, worktree-manager.build-pr-body.test.ts) that currently pass — they only gate the fix once exec adds the new assertions those ACs describe; running the unchanged file today proves nothing. Flagging so exec doesn't mistake "file exists and passes" for AC coverage.

    Scope Assessment

    Non-Goals: Not present in the issue body. Scope is implicitly bounded by the graph tracker (#1236 wave 3) and the "May touch" file list, so this isn't blocking, but consider adding one if a follow-up broadens it.

    Metric Value Status
    Feature count 1 ✅
    AC items 3 ✅
    Directory spread 1 (src/lib/workflow/) ✅

    Verdict: ✅ SCOPE_OK

    Conflict Risk Analysis

    A worktree for #1223 already exists (feature/1223-fix-pr-...) at the same commit as main — no work started yet, safe to reuse. Two in-flight worktrees touch worktree-manager.ts but in disjoint regions: #1199 edits resolveWorktreeRoot/ensureWorktree(s) (~lines 722–1150) and #1222 edits shouldPreserveWorktree/shutdown logic (~lines 396–480); this issue's target (createPR/buildAutomatedPRBody, ~1737–1970) doesn't overlap either. #1233 edits batch-executor.ts around the qaVerdict/finalStatus block (~2233–2290), adjacent to but not overlapping this issue's createPR( call site (~2360–2380). Low conflict risk; no action needed beyond normal merge order.

    Acceptance Criteria

    AC-1: PR title takes the issue title's conventional-commit type, #N replaces the scope, never doubled

    Verification: Unit Test
    Scenario: Given issue title feat(adopt): x → When createPR builds the title → Then feat(#1209): x (type from the title wins over the label-derived prefix; titles without a recognized type(scope)!?:/type: prefix keep today's isBug ? "fix" : "feat" behavior).
    Assumptions: Type list is limited to real conventional-commit types (feat, fix, docs, chore, refactor, test, perf, build, ci, style, revert) so Docs: foo (capitalized, not a real prefix) isn't mistaken for one. createPR itself isn't unit-testable today (shells out to gh/git) — extract the title-building logic into a new pure, exported function (parallel to buildAutomatedPRBody) so AC-1 is testable without mocking process calls.

    AC-2: PR body carries exec's own ## Summary, falling back to today's placeholder

    Verification: Unit Test
    Scenario: Given exec's captured PhaseResult.output contains a ## Summary section → When buildAutomatedPRBody runs → Then the body's ## Summary uses that text (trimmed, capped ~4KB) instead of Automated PR for issue #N.; closing line and QA note are unchanged. Given no ## Summary in the output → Then today's placeholder text is kept.
    Assumptions: "Last" ## Summary section wins if exec's output contains more than one (e.g. a template example earlier in the transcript). Runs up to the next ## heading or end of string.

    AC-3: Closing keywords inside the imported summary never auto-close an issue

    Verification: Unit Test
    Scenario: Given an imported summary containing Closes #279 → When the body is built (regardless of linkMode) → Then it reads Refs #279. Given a summary containing fixes #1223 (the PR's own issue) → Then that line also becomes Refs #1223, while the body's own trailer (Fixes #1223 / Refs #1223 under #1197) still carries the real close.
    Assumptions: This is a new, unconditional sanitizer scoped to any issue number (#(\d+)), applied only to the imported summary text — distinct from the existing rewriteClosingKeywordsToRefs(body, issueNumber), which stays scoped to the current issueNumber and gated on linkMode === "refs" (#1197, unchanged). Reusing the existing function here would miss Closes #279 since it only ever rewrites references to the PR's own issue.

    Implementation Plan

    Phase 1: Title construction (AC-1)

    1. In worktree-manager.ts, add a CONVENTIONAL_COMMIT_TYPES list and an exported pure function (e.g. buildPRTitle(issueTitle, issueNumber, labels)) that matches a leading ^(type)(\([^)]*\))?!?:\s* against the real types, strips it, and emits type(#N): <rest>; falls back to isBug ? "fix" : "feat" when no match.
    2. Swap createPR's inline prefix/prTitle lines for a call to the new function.

    Phase 2: Body summary + sanitizer (AC-2, AC-3)

    1. In worktree-manager.ts, add extractExecSummary(execOutput: string): string | undefined (last ## Summary → next ## /EOF, trimmed, capped) and a separate unconditional sanitizer (e.g. sanitizeImportedClosingKeywords) implementing \b(close[sd]?|fix(e[sd])?|resolve[sd]?)\s*:?\s+#(\d+) → Refs #$2, applied to the extracted summary only.
    2. Extend buildAutomatedPRBody's opts with execOutput?: string; when extractExecSummary returns text, sanitize it and use it in place of the placeholder line.

    Phase 3: Wiring (AC-2)

    1. In batch-executor.ts (~line 2364), read phaseResults.find(p => p.phase === "exec")?.output and pass it through createPR as a trailing options object (e.g. opts?: { execOutput?: string }), not another positional argument — createPR already has 11.

    Phase 4: Tests, CHANGELOG

    1. Add AC-1 cases to worktree-manager.test.ts; AC-2/AC-3 cases (including Closes #279 and fixes #1223) to worktree-manager.build-pr-body.test.ts. Run timeout 600 npx vitest run src/lib/workflow/worktree-manager.test.ts src/lib/workflow/worktree-manager.build-pr-body.test.ts src/lib/workflow/batch-executor.test.ts — no full npm test.
    2. Add a CHANGELOG ### Fixed entry under [Unreleased].

    Design Review

    1. Where does this logic belong? worktree-manager.ts, alongside buildAutomatedPRBody/resolvePrLinkMode — same module already owns PR title/body construction and is already structured for pure, testable helpers.
    2. What's the simplest correct approach? For AC-2's wiring, add one trailing opts object to createPR for the new field rather than refactoring all 11 existing positional params into an options object. Rejected the full refactor: it's a single call site, and reshaping every existing param is unrelated churn for a mechanical-tier fix — not an architectural decision, so no ADR.
    3. What existing pattern does this follow? Mirrors buildAutomatedPRBody's existing shape: pure, @internal Exported for testing helpers that createPR composes, keeping the gh/git-shelling code thin.
    4. What would a senior reviewer challenge? "Why a second closing-keyword sanitizer instead of reusing rewriteClosingKeywordsToRefs?" — because that one is scoped to the current issue number and gated on linkMode; reusing it would silently fail the Closes #279 case AC-3 exists to cover.

    Feature Quality Planning

    All standard checks pass. Notable items:

    • Regex robustness: confirm the type-prefix match rejects mid-title colons (Docs: foo) and multi-word titles with colons elsewhere in them.
    • Cap length choice (~4KB) for the imported summary is a judgment call, not specified by the issue — fine as an implementation detail, not an AC gap.

    Open Questions

    1. Does the title regex also need to accept a scope-less breaking marker (feat!: with no scope)? — Recommendation: yes, treat ! as optional independent of scope, matching conventional-commits generally. Impact if wrong: a rare type!: title keeps the label-derived prefix instead of using its own type — low severity, easy follow-up.

    Recommended Workflow

    Phases: exec → qa
    Quality Loop: disabled
    Reasoning: Mechanical-tier, fully-specified fix (owner's comment already pins exact line numbers, regexes, and test files) with SCOPE_OK and no design ambiguity worth a quality-loop retry. testgen skipped — bug-only label, and the owner's comment already names the exact test files and cases; stub generation would just be redone by exec.

    Label Review

    Current: bug, graph-2026-09-prerelease
    Recommended: bug, graph-2026-09-prerelease, planned
    Reason: Standard post-spec marker; no other label change warranted — not ui/frontend (no browser test), not complex/refactor (mechanical fix).
    Quality Loop: Won't auto-enable — SCOPE_OK, no complexity trigger.

    → gh issue edit 1223 --add-label planned


    --- DRAFT GITHUB ISSUE COMMENT (PLAN) ---

    Plan for #1223

    AC checklist

    • AC-1 (Unit Test): title uses the issue title's own conventional-commit type with #N replacing the scope, never doubled — extract a pure buildPRTitle helper so it's testable without mocking gh/git.
    • AC-2 (Unit Test): body's ## Summary pulls from exec's PhaseResult.output (last ## Summary section, capped ~4KB), falling back to today's placeholder.
    • AC-3 (Unit Test): a new, unconditional sanitizer rewrites any closing-verb + #N inside the imported summary to Refs #N — distinct from the existing issue-scoped, linkMode-gated rewriteClosingKeywordsToRefs. Covers both an unrelated issue (Closes #279) and the PR's own issue (fixes #1223) appearing inside the summary text.

    Implementation plan: title-building in worktree-manager.ts (new buildPRTitle + type list) → summary extraction + sanitizer (new extractExecSummary / sanitizeImportedClosingKeywords, wired into buildAutomatedPRBody) → thread exec output through createPR via a trailing options object in batch-executor.ts (not another positional arg) → tests in worktree-manager.test.ts / worktree-manager.build-pr-body.test.ts → CHANGELOG ### Fixed entry.

    Key decision: new options object on createPR for the exec-summary field, instead of refactoring its existing 11 positional params — scoped to this fix, not a broader signature cleanup.

    Open question: should the title regex also accept a scope-less breaking marker (feat!:)? Recommend yes; low-severity if deferred.

    Testing: timeout 600 npx vitest run src/lib/workflow/worktree-manager.test.ts src/lib/workflow/worktree-manager.build-pr-body.test.ts src/lib/workflow/batch-executor.test.ts (no full npm test, per graph tracker #1236 standard block).

    Workflow: exec → qa, quality loop disabled.

  4. added
    planned
    on Sep 30, 2026
  5. admarble commented on Sep 30, 2026

    @admarble
    ContributorAuthor

    QA Verdict: AC_MET_BUT_NOT_A_PLUS

  6. added 3 commits that reference this issue on Sep 30, 2026
  7. admarble commented on Sep 30, 2026

    @admarble
    ContributorAuthor

    QA Verdict: AC_MET_BUT_NOT_A_PLUS

    AC coverage: 3/3 met

    Gaps:

    • PR body imports the first exec pass's summary, which is out of date after a quality-loop iteration
    • Cross-repo closing references in the imported exec summary are not rewritten to Refs
    • Breaking-change ! marker is dropped from the PR title
    • The exec-output hand-off in batch-executor is not covered by a test
  8. added 2 commits that reference this issue on Sep 30, 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

    buggraph-2026-09-prereleaseplanned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions