Skip to content

feat(#1197): opt out of closing keywords — Refs #N for issues a PR should not close - #1215

Merged
admarble merged 5 commits into
mainfrom
feature/1197-feat-pr-opt-out-of-closing-keywords-refs-n-for-iss
Sep 29, 2026
Merged

admarble merged 5 commits into
mainfrom
feature/1197-feat-pr-opt-out-of-closing-keywords-refs-n-for-iss

Conversation

@admarble

@admarble admarble commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • run.prIssueLink ("closes" default, "refs") and run.prNoCloseLabel (default no-autoclose) control whether the automated PR path (buildAutomatedPRBody/createPR in worktree-manager.ts) emits Fixes #N or Refs #N. The label always wins over the setting (resolvePrLinkMode).
  • In refs mode, the assembled PR body is scrubbed for any other closing-verb + issue-number combination (close/fix/resolve, any tense, table cells included) via rewriteClosingKeywordsToRefs, so an AC-table row that happens to start with a closing verb can't slip an auto-close past the setting.
  • /exec's manual PR-creation template (all three mirrored copies) now resolves the same keyword before running gh pr create.
  • /merger and /fullsolve query closingIssuesReferences (via GraphQL — see note below) before merging and stop, naming the issue, if it lists anything the PR is not allowed to close. In refs mode, or for a no-autoclose-labelled issue, that is every number, the PR's own issue included.

Resolved the issue's open question: isIssueMergedIntoMain (pr-status.ts) detects a merge via branch-tip ancestry and Merge #N commit-message grep — neither depends on GitHub's closing-issue link. State reconciliation (#1044) does not need a refs-mode-specific merge detector.

Field finding: gh pr view --json closingIssuesReferences errors Unknown JSON field on gh CLI 2.66.1 (the version in this environment) — that field isn't exposed through gh pr view --json, only through the GraphQL API directly. AC-5's skill text uses gh api graphql with the {owner}/{repo} magic placeholders instead; verified live against this PR (#1215) — the query correctly returns only 1197, not 1203 (the Refs #1203 tracker mention in this body does not count as closing, confirming AC-4's scrub also behaves as intended).

AC Verification

AC Description Status Evidence
AC-1 run.prIssueLink setting controls the keyword ✅ Implemented src/lib/settings.ts (schema+defaults), src/lib/workflow/worktree-manager.ts buildAutomatedPRBody/resolvePrLinkMode, src/lib/workflow/worktree-manager.build-pr-body.test.ts, src/lib/workflow/config-resolver.pr-issue-link.test.ts
AC-2 no-autoclose-labelled issue always gets Refs #N ✅ Implemented resolvePrLinkMode in worktree-manager.ts; worktree-manager.build-pr-body.test.ts
AC-3 exec skill PR template follows the same rule, all 3 copies ✅ Implemented .claude/skills/exec/SKILL.md, skills/exec/SKILL.md, templates/skills/exec/SKILL.md (identical)
AC-4 refs mode rewrites every closing verb for the issue anywhere in the body, tables included ✅ Implemented rewriteClosingKeywordsToRefs in worktree-manager.ts; worktree-manager.build-pr-body.test.ts; live-verified on this PR (see Field finding above)
AC-5 /merger//fullsolve check closingIssuesReferences, halt naming the issue ✅ Implemented skills/merger/SKILL.md Step 1a, skills/fullsolve/SKILL.md §5.3 (all 3 copies each); command fixed to GraphQL after live verification failed on gh pr view --json

Runner follow-up (graph-run #1203, commit 3b30dbaa)

QA returned AC_NOT_MET on AC-5. Fixed here:

  • AC-5: the guard never flagged the PR's own issue. Both skills compared against {<issue-number>} unconditionally, so a refs-mode or no-autoclose issue whose body still carried Fixes #N (the field incident) would pass and close. /merger Step 1a and /fullsolve §5.3 (3 copies each) now read run.prIssueLink / run.prNoCloseLabel from .sequant/settings.json and the issue's labels (gh api …/issues/N). In either mode the allowed set is empty. Ran the snippet against this repo for issue 1197: no settings gave expected=[1197]; {"run":{"prIssueLink":"refs"}} gave expected=[]; {"run":{"prNoCloseLabel":"enhancement"}} (a label feat(pr): opt out of closing keywords — Refs #N for issues a PR should not close #1197 carries) gave expected=[].
  • Repo-prefixed form. rewriteClosingKeywordsToRefs now also rewrites Fixes owner/repo#N, keeping the prefix, since GitHub documents that form as closing. Fixes: #N and **Fixes** #N are still not rewritten (the function comment says so); the merge guard catches them.
  • Evidence file. The issue's Evidence command (worktree-manager.test.ts) passed on base, so it tested nothing. It now holds a #1197 describe block (AC-1, AC-2, AC-4) that cannot pass on base.

Mutation-verified: AC-4 — reverted the repo-prefix group in the scrub regex; src/lib/workflow/worktree-manager.test.ts > #1197 PR issue link: closes vs refs > AC-4: refs mode rewrites closing verbs in tables and the owner/repo#N form failed (1/10); restored.
Mutation-verified: AC-4 — scrub replacement made a no-op; same test failed (1/10); restored.

Evidence-command note (superseded by the follow-up above): the issue's AC-1/AC-2/AC-4 evidence names src/lib/workflow/worktree-manager.test.ts, but buildAutomatedPRBody/resolvePrLinkMode are actually tested in the sibling file worktree-manager.build-pr-body.test.ts (where the pre-existing #749/#817 tests for the same function already lived) plus the new config-resolver.pr-issue-link.test.ts for the settings→ExecutionConfig wiring. Ran both; worktree-manager.test.ts itself passes unaffected (unrelated tests).

Runner follow-up, round 2 (commit 030afbe6)

The second QA pass found that the AC-5 guard read .sequant/settings.json with raw jq. sequant init writes that file as JSONC, so jq failed and the || echo closes fallback silently ran refs mode as closes. The six guard blocks now strip whole-line // comments before jq (only whole-line, since devUrl contains //). On a parse error the guard fails closed: it prints a warning and treats every closing reference as unexpected. I ran the snippet for issue 1197 against a generateSettingsJsonc file:

Settings file Result
none expected=[1197]
JSONC, prIssueLink: "refs" expected=[]
JSONC, prNoCloseLabel: "enhancement" expected=[]
JSONC, closes expected=[1197]
{ nope warning, expected=[]
this repo's real settings expected=[1197]

Still no automated test of the skill's bash. It's prose in SKILL.md, so the table above is the evidence.

Test plan

  • npx vitest run src/lib/workflow/worktree-manager.build-pr-body.test.ts — 18 passed
  • npx vitest run src/lib/workflow/config-resolver.pr-issue-link.test.ts — 5 passed
  • npx vitest run src/lib/workflow/worktree-manager.test.ts — runner re-run at 3b30dbaa: 10 passed, including the 3 new #1197 cases
  • npx vitest run src/lib/workflow/execution-config-parity.test.ts — passed (new ExecutionConfig fields inherited, not a second producer)
  • npx vitest run src/lib/workflow/batch-executor.test.ts src/lib/workflow/batch-executor.model-ladder.test.ts src/lib/workflow/model-ladder.test.ts src/lib/workflow/ready-gate-run.test.ts — 183 passed (createPR call-site change)
  • npx vitest run src/commands/init.test.ts — 54 passed (settings docs generators)
  • npm run build — passed
  • npm run lint — passed
  • npx tsx scripts/lint-skill-calls.ts — no violations
  • Live-verified the AC-5 gh api graphql command against this PR: returns 1197 only
  • Runner re-run at 3b30dbaa: npx vitest run src/lib/workflow/worktree-manager.test.ts src/lib/workflow/worktree-manager.build-pr-body.test.ts src/lib/workflow/config-resolver.pr-issue-link.test.ts — 3 files, 33/33 passed; npx tsc --noEmit clean; npm run lint:skill-calls no violations
  • AC-3 grep -n "Refs #" across the 3 exec copies and AC-5 grep -n "closingIssuesReferences" in merger/fullsolve — all match

Full npm test intentionally not run in this phase per the issue's launch constraints (30-min MCP phase wall); CI runs it.

Pre-PR Confidence Check

  • Weakest part: rewriteClosingKeywordsToRefs is a regex over the assembled body text, not an AST/markdown-aware pass — it will catch verb+#N combinations correctly for the documented cases (including table cells) but a sufficiently adversarial body (e.g. verb and number split across a line-wrap inside a code fence) could evade it. Scoped tightly to the linked issue number only, by design.
  • Coverage gaps: createPR and GitHubProvider.createPRCliSync themselves aren't unit-tested (pre-existing — no test invokes the real gh CLI path); the pure logic they call (buildAutomatedPRBody, resolvePrLinkMode) is fully covered.

Quality Plan Alignment: N/A — no quality plan in issue comments (mechanical-tier graph issue).

Refs #1203 (graph tracker)

Closes #1197

🤖 Generated with Claude Code

admarble and others added 3 commits September 28, 2026 22:37
Co-Authored-By: Claude Sonnet 5 <[email protected]>
Entire-Checkpoint: 26a2e88a8078
…n rejects the field

Verified live against this branch's own PR #1215: gh CLI 2.66.1 errors 'Unknown JSON field' on gh pr view --json closingIssuesReferences, but the GraphQL query resolves correctly and confirmed the PR closes only #1197 (not the Refs #1203 tracker mention).

Co-Authored-By: Claude Sonnet 5 <[email protected]>
Entire-Checkpoint: 94c9d209e6ff
…ode; scrub owner/repo#N; tests in the Evidence file

Entire-Checkpoint: c0a7d8be823b
…sed on a parse error

Entire-Checkpoint: e366a37c6c02
@admarble
admarble merged commit 1b0fa9a into main Sep 29, 2026
10 checks passed
@admarble
admarble deleted the feature/1197-feat-pr-opt-out-of-closing-keywords-refs-n-for-iss branch September 29, 2026 15:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(pr): opt out of closing keywords — Refs #N for issues a PR should not close

1 participant