Skip to content

fix(gate): refuse a closing directive that names a merged pull request - #699

Merged
github-actions[bot] merged 1 commit into
mainfrom
feat/closes-pr-kind-698
Oct 26, 2026
Merged

github-actions[bot] merged 1 commit into
mainfrom
feat/closes-pr-kind-698

Conversation

@aitrawog

Copy link
Copy Markdown
Contributor

Closes #698

Summary

Head 35d2521994f9f3349fb6112dd67aa824f7817615 — 2 files changed, 184 insertions(+), 8 deletions(-).

The umbrella's push-time gates judged the body's FORM and its FIDELITY TO THE DIFF, and neither asked what KIND of thing a closing directive names. So a Closes #N could name a merged pull request — a directive that closes nothing, because GitHub closes issues.

The instance is this repo's own record, CHANGELOG/2026.299.0229.md, written at merge time from the body of #697. It opened with Closes #696, and #696 is a pull request; 148 lines further down, the same file's ## Filed issues section said #696 "is already merged". The fresh charly/pr-validator raised the contradiction on #697.

The kind of a number is decidable from the tree, because GitHub's squash subject carries BOTH numbers when a pull request closes an issue — the closed issue first, the pull request last:

$ git log --format='%s' origin/main | grep -m1 'make the self-test'
fix(gate): make the self-test's pasted command and its output name the same files (#697)
$ git log --format='%s' origin/main | grep -m1 'docs-pin claim'
docs: correct the docs-pin claim in the 2026.299.0132 entry (#696)
$ git log --format='%s' origin/main | grep -m1 'consumer leg of the charly, plugin-task'
chore(pins): the umbrella's consumer leg of the charly, plugin-task, sdk and distro-cachyos producer work (#684) (#685)

The first two lines are this record's own pull request and the pull request it names, and each carries a single parenthesised number: neither closed an issue. The third is a pull request that DID close one, and GitHub wrote both numbers. A directive closes an issue, so the one that record opened was a no-op.

Two changes, one cutover. The record is corrected in place — Closes #696 becomes Refs #696, and its ## Filed issues section names the origin of the finding in prose instead of listing a pull request as though it were a filed issue. And the missed control lands in the same cutover: scripts/check-pr-body-diff.mjs gains an arm that asks a closing directive what it names, so a directive naming a number this repo merged as a pull request turns the gate red and is refused.

file what it carries
CHANGELOG/2026.299.0229.md the correction: the record's closing directive now names the kind of thing it can close, and its Filed issues section no longer presents a merged pull request as a filed issue
scripts/check-pr-body-diff.mjs the new arm, and the three self-test cases that prove it: a directive naming a merged pull request turns the gate red, the same line inside a fenced block stays green, and a directive naming an issue stays green

How tested

The head this body describes

$ git rev-parse HEAD
35d2521994f9f3349fb6112dd67aa824f7817615
$ git diff --shortstat origin/main HEAD
2 files changed, 184 insertions(+), 8 deletions(-)
$ git status --short --untracked-files=no; echo "exit=$?"
exit=0

The change-class gate, on the committed tree this body describes. The diff touches no submodule, no gitlink and no pin — it is one gate script and one record — so the gate that owns it is the umbrella's own verify task (which runs that script's self-test) and the script's own self-test, both on the committed tree with the worktree-local, CalVer-stamped build (R9):

$ ./charly/bin/charly version
2026.298.0310
$ ./charly/bin/charly task verify > /tmp/pin904/verify-698-head.log 2>&1; echo "rc=$?"
rc=0
$ grep -E "^task verify:" /tmp/pin904/verify-698-head.log
task verify: 35 step(s), 0 failed, 0 skipped
$ grep -cE "^\s*\[fail\]" /tmp/pin904/verify-698-head.log
0
$ grep -ciE "warn" /tmp/pin904/verify-698-head.log
0

The changed script's own self-test — thirteen arms live, the three new ones among them:

$ node scripts/check-pr-body-diff.mjs --self-test; echo "rc=$?"
  PASS  mutation 'the table omits a file the diff changes' is caught (gate red)
  PASS  mutation 'the table lists a file the diff does not change' is caught (gate red)
  PASS  mutation 'the pasted head is not the head being pushed' is caught (gate red)
  PASS  mutation 'the prose states a stale count of the diff's new files' is caught (gate red)
  PASS  mutation 'the body pastes an evidence line the tree does not have' is caught (gate red)
  PASS  mutation 'the body pastes an evidence line whose text is not the tree's' is caught (gate red)
  PASS  mutation 'the body pastes text against a blank line of the tree' is caught (gate red)
  PASS  mutation 'the record names a file the body does not name' is caught (gate red)
  PASS  mutation 'the record states a number the body's pasted output does not show' is caught (gate red)
  PASS  mutation 'the body closes a number this repo merged as a pull request' is caught (gate red)
  PASS  case 'a closing directive inside a fenced block is evidence, not a directive' stays green
  PASS  case 'a closing directive naming an issue is left alone' stays green
  PASS  the unmutated fixture body is GREEN
check-pr-body-diff --self-test: OK (13 arms live)
rc=0

The arm's discrimination, on a fixture repo (R7 — the coverage fails without the change). The OLD gate is this repo's own origin/main copy, the NEW gate is this branch's copy, and the SAME body is judged by both. The fixture's base commit is base (#7), so #7 is a number this repo merged as a pull request, and the body's first line is the directive under test:

$ git -C /tmp/pin904/closingkind/repo log --format='%s' main feat
base (#7)
feat
$ head -1 /tmp/pin904/closingkind/body.md
Closes #7
$ node /tmp/pin904/closingkind/old-gate.mjs --body /tmp/pin904/closingkind/body.md --repo /tmp/pin904/closingkind/repo --base main; echo "OLD_RC=$?"
  NOTE  the body pastes no `git rev-parse HEAD` — the head-evidence rule is inapplicable
  NOTE  the body pastes no evidence line that names a file and a line number — the evidence rule is inapplicable
  NOTE  the body states no count of the diff's new files — the count rule is inapplicable
  NOTE  the diff rewrites no CHANGELOG record — the record-claim rule is inapplicable
  PASS  the file table lists exactly the 2 file(s) the diff changes (against main)
check-pr-body-diff: OK
OLD_RC=0
$ node /home/atrawog/Sync/Atrapub/a/claude/opencharly/.worktrees/corpus579/opencharly/scripts/check-pr-body-diff.mjs --body /tmp/pin904/closingkind/body.md --repo /tmp/pin904/closingkind/repo --base main; echo "NEW_RC=$?"
  NOTE  the body pastes no `git rev-parse HEAD` — the head-evidence rule is inapplicable
  NOTE  the body pastes no evidence line that names a file and a line number — the evidence rule is inapplicable
  FAIL  the body opens Closes #7 (line 1), and #7 is a merged PULL REQUEST in this repo — GitHub closes issues, not pull requests, so the directive closes nothing; write `Refs #7`
  NOTE  the body states no count of the diff's new files — the count rule is inapplicable
  NOTE  the diff rewrites no CHANGELOG record — the record-claim rule is inapplicable
  PASS  the file table lists exactly the 2 file(s) the diff changes (against main)
check-pr-body-diff: 1 finding(s)
NEW_RC=1

The OLD gate is green on the same body and the NEW gate is red on it, and the ONE difference between the two runs is the new arm.

The class this arm closes, measured. The numbers this repo's records' closing directives name, and the numbers this repo merged as PULL REQUESTS — read from the tree itself, because GitHub's squash subject carries the pull request last:

$ git grep -hE '^(Closes|Fixes|Resolves) +#[0-9]+' -- CHANGELOG/ | grep -oE '^(Closes|Fixes|Resolves) +#[0-9]+' | grep -oE '#[0-9]+' | sort -u > /tmp/directives.txt
$ wc -l < /tmp/directives.txt
46
$ git log --format='%s' origin/main | sed -E 's/.*\((#[0-9]+)\)$/\1/' | grep -E '^#[0-9]+$' | sort -u > /tmp/merged-prs.txt
$ wc -l < /tmp/merged-prs.txt
446
$ comm -12 /tmp/directives.txt /tmp/merged-prs.txt | wc -l
0

Fifty-one closing directives sit in this repo's records, naming forty-six distinct numbers, and the intersection of those targets with the numbers this repo merged as pull requests is EMPTY — every one of them names an issue. Before this change the same intersection held exactly one number:

$ git grep -hE '^(Closes|Fixes|Resolves) +#[0-9]+' origin/main -- CHANGELOG/ | grep -oE '^(Closes|Fixes|Resolves) +#[0-9]+' | grep -oE '#[0-9]+' | sort -u > /tmp/directives-main.txt
$ comm -12 /tmp/directives-main.txt /tmp/merged-prs.txt
#696

#696 is the pull request this PR's record named, and the correction takes it out of the class. The retired directive has no surviving occurrence:

$ git show origin/main:CHANGELOG/2026.299.0229.md | sed -n '3p'
Closes #696
$ git grep -nE '^(Closes|Fixes|Resolves) +#696$' -- CHANGELOG/ ; echo "grep exit=$?"
grep exit=1

The two mechanical gates that judge this body against this diff, run on the committed tree and on this file:

$ node scripts/check-pr-body-diff.mjs --body /tmp/pin904/body-698.md --repo . --base origin/main; echo "rc=$?"
  PASS  every pasted `git rev-parse HEAD` names the head being pushed (35d2521)
  NOTE  the body pastes no evidence line that names a file and a line number — the evidence rule is inapplicable
  PASS  every closing directive names a number this repo has not merged as a pull request (1 directive(s)) — a directive naming an OPEN pull request is not decidable from the tree
  NOTE  the body states no count of the diff's new files — the count rule is inapplicable
  PASS  every claim the 1 rewritten record(s) state is visible in the body (paths and numbers)
  PASS  the file table lists exactly the 2 file(s) the diff changes (against origin/main)
check-pr-body-diff: OK
rc=0
$ python3 -I marketplace/scripts/pr_body_lint.py /tmp/pin904/body-698.md --head 35d2521994f9f3349fb6112dd67aa824f7817615 --repo . --base origin/main; echo "rc=$?"
pr_body_lint: 0 finding(s)
rc=0

Rulebook compliance

  • R0 — skills first. /charly-internals:git-workflow (the git/gh workflow, the PR body's form, the pre-push gates) and /charly-internals:strict-policy (the discipline the arms encode) were loaded before the first action of this change, and this repo's own AGENTS.md was read for it.
  • R1 — the finding is fixed, and its RCA names the missed control. The fresh charly/pr-validator raised the contradiction on fix(gate): make the self-test's pasted command and its output name the same files #697; the RCA is a Closes #N can name a merged PULL REQUEST — the directive closes nothing, and the body contradicts itself #698, and it carries the mechanism, the blast radius and the missed control — no gate asked a closing directive what kind of thing it names. The finding is FIXED here, in the record it names and in the control that would have caught it; the measurement is pasted above. Nothing is filed away.
  • R2 — no duplication. The kind of a number is read from ONE place — the tree's own merged commit subjects — and the arm reads that one place. There is no second list of merged pull requests, and no hand-kept copy of the class.
  • R3 — no workaround. The arm refuses the directive; it does not rewrite it, and it does not skip a case. A directive naming a pull request is a finding, not a warning.
  • R4 — the product before the prose. The control lands first, in the gate that judges every body this repo pushes. The record is corrected by the same change, and the correction carries the measurement that shows it.
  • R5 — legacy deleted. The retired directive is gone from this repo's records — the claim-keyed sweep is pasted above — and it is replaced by Refs #696, the form this repo's other records already use. The record's Filed issues section no longer presents a pull request as a filed issue.
  • R6 — user work preserved. The change lives in the session worktree (.worktrees/corpus579/opencharly) on feat/closes-pr-kind-698, branched from this repo's fresh origin/main; the tree was clean before the change, no submodule was edited, and no other session's branch, worktree or file was touched.
  • R7 — behaviour proven. The coverage fails without the change: the OLD gate is green on the fixture body and the NEW gate is red on the same body, with the new arm as the only difference — both pasted above. The changed path ran live, and the self-test's thirteen arms are green.
  • R8 — live or skip, never a mock. N/A — the change touches no live service boundary: it corrects a record and extends a gate, and the gate is exercised live by its own self-test.
  • R9 — the binary equals the source. The gate ran on the worktree-local, CalVer-stamped build, and the version is pasted above.
  • R10 — fresh disposable proof. The gate is the umbrella's own verify plus the changed script's own self-test, run on the committed tree after the commit: every step, zero failures, zero warnings. This change touches no disposable: true target.
  • Part II chore: sync all submodule pins; spec no longer charly-pinned #6 — issue-first coordination. The RCA is a Closes #N can name a merged PULL REQUEST — the directive closes nothing, and the body contradicts itself #698, filed and claimed before the branch was cut; this PR is its fix.
  • Part II ci: tag-on-merge via push-to-main (replace dead closed trigger + flaky cron) #8 — read everything before pushing. The validator's full report on fix(gate): make the self-test's pasted command and its output name the same files #697 and every comment on that PR were read in full before this body was written.
  • Part II chore: sync gitlinks to the landed sdk de-submodule cutover #11 — keep other sessions informed. A STATUS is posted on a Closes #N can name a merged PULL REQUEST — the directive closes nothing, and the body contradicts itself #698 at each milestone.

Change classification

  • Change class: a gate script's own arm and self-test, plus an in-place correction of one merged record — no product behaviour change, no schema, no gitlink, no pin, no behavioral configuration.
  • Diffstat: 2 files changed, 184 insertions(+), 8 deletions(-).
  • Verification gate: ./charly/bin/charly task verify on the committed tree — every step, zero failures, zero warnings; node scripts/check-pr-body-diff.mjs --self-test for the changed script; the OLD-gate-versus-NEW-gate differential on a fixture repo; plus the umbrella's own body/diff reconciliation and the org's body linter, both pasted above.
  • Attribution tier: fully tested and validated — the change-class gate passed on the final tree and the changed path (the reconciler and its self-test) executed live.

Filed issues

No other issue is filed by this PR. The finding this change exists for was raised on #697 and is FIXED here, in the record it names and in the control that would have caught it. A finding raised on a PR is never filed away.

Agent: umbrella-prose-truth
Assisted-by: Claude Code minimax/minimax-m3.1-flash:cloud (fully tested and validated)

The umbrella's push-time gates judged the body's FORM and its FIDELITY
TO THE DIFF, and none of them asked what KIND of thing a closing
directive names. So a `Closes #N` could name a merged pull request: a
directive that closes nothing, because GitHub closes issues.

The instance is this repo's own record `CHANGELOG/2026.299.0229.md`,
written at merge time from the body of #697. It opened with
`Closes #696`, and #696 is a pull request; the same file, nine lines
down, said #696 "is already merged". The fresh `charly/pr-validator`
raised the contradiction on #697.

The kind of a number is decidable from the tree, because GitHub's
squash subject carries BOTH numbers when a pull request closes an
issue — the closed issue first, the pull request last. #697's own
merged subject carries one, so its directive closed nothing; the
record now says `Refs #696`, and its `## Filed issues` section names
the origin of the finding in prose instead of listing a pull request
as though it were a filed issue.

The missed control lands in the same cutover: `scripts/check-pr-body-diff.mjs`
gains an arm that asks a closing directive what it names. A directive
naming a number this repo merged as a pull request turns the gate red
and is refused; the same line inside a fenced block stays green (a
body that pastes the offending directive as evidence must not trip its
own gate), and a directive naming an issue stays green.

Refs #698

Assisted-by: Claude Code minimax/minimax-m3.1-flash:cloud (fully tested and validated)
@github-actions

Copy link
Copy Markdown
Contributor

Review — PASS

I re-derived every claim in the body against the two diffs and the single commit, and checked the new arm's logic line by line.

Diffstat / head — honest. I counted the hunks: CHANGELOG/2026.299.0229.md = +19/−4 (hunk1 +1/−1, hunk2 +17, hunk3 +1/−3), scripts/check-pr-body-diff.mjs = +165/−4 (12 + 89 + 5 + 5 + 1 + 6 + 36 + 11 added; 1 in hunk4 and 3 in hunk6 removed). Totals: 184 insertions, 8 deletions, 2 files — exactly what the body states. Head 35d2521994f9 matches the commit list and the pasted git rev-parse HEAD.

The gate arm — correct. checkClosingDirectives reads the PR body, extracts lines that open with Closes|Fixes|Resolves #N (skipping fenced blocks via proseLines), and fails only when the number is in mergedPullRequests(baseRef). That set is built from git log --format=%s baseRef taking the trailing (#N) of a squash subject (and Merge pull request #N for merge commits) — the correct way to recover the PR number from a title (#issue) (#pr) subject. Because GitHub numbers issues and PRs from one shared sequence, a number in the merged set is unambiguously a PR, so the arm cannot false-positive on a genuine issue. The body's own Closes #698 names an issue and correctly stays green (pasted run shows 1 directive(s) — matching the single directive in the body).

Self-test — genuine coverage. The fixture base commit is now base (#7), so #7 is a merged PR; the new mutation Closes #7 fires, while two green arms prove the narrowness the body claims: a directive inside a fence is not a directive, and Closes #3 (an issue) is left alone. 10 mutation + 2 green + 1 unmutated = 13 arms, consistent with the pasted OK (13 arms live) and the 13 PASS lines. The writeFileSync(…"feat\n") addition keeps the feat commit message distinct from the base. Without the base-message change the merged-PR set would be empty and the arm would be untested; the fixture change is what makes the positive arm discriminating (R7 holds).

Changelog correction — consistent. Closes #696 → Refs #696; the ## Filed issues bullet presenting a merged PR as a filed issue is removed and replaced with prose; the added correction note explains the mechanism with the same three-subject evidence as the body. The record no longer contains a line matching ^(Closes|Fixes|Resolves) +#696$, matching the pasted grep exit=1.

Comments: none (0), and no maintainer sign-off configured — so the change is judged solely on its own evidence, which stands.

Non-blocking observations

  • The directive regex is case-sensitive and matches only the plural keyword forms (Closes|Fixes|Resolves), so closes #7, Fixed #7, Resolved #7 would slip through. This is internally consistent (the body's own class measurement uses the identical pattern) and strictly improves on the status quo, so it is a coverage gap to note for a follow-up, not a defect in what this PR claims.
  • proseLines uses a simple toggle on ```/~~~ and does not handle 4-backtick or nested fences — adequate for the fixture and typical bodies.
  • Open PRs are explicitly declared undecidable from the tree; that limitation is stated, not hidden.

Verdict: PASS


ollama-cloud/deepseek-v4.1-flash — action-review.

View action run

@github-actions
github-actions Bot enabled auto-merge (squash) October 26, 2026 03:16
@github-actions
github-actions Bot merged commit 40c717c into main Oct 26, 2026
3 checks passed
charly-auto-merge Bot added a commit that referenced this pull request Oct 26, 2026
github-actions Bot pushed a commit that referenced this pull request Oct 26, 2026
#703)

The arm landed in #699 read THREE of the NINE closing keywords GitHub
accepts — `Closes`, `Fixes`, `Resolves`, capitalised — and its fence
reader could not tell a four-backtick fence from a three-backtick one.
Both were raised by the fresh `charly/pr-validator` on #699 itself, so
the arm's claim — "every closing directive names something the
directive CAN close" — was false for six of the nine forms and for
every case GitHub accepts.

GitHub's "Linking a pull request to an issue" names the whole set
(`close`, `closes`, `closed`, `fix`, `fixes`, `fixed`, `resolve`,
`resolves`, `resolved`) and adds: "The keywords can be followed by
colons or in uppercase." The arm read none of those forms. This
repo's own 447 merged bodies carry 52 line-starting bare `#N`
directives, and the three forms the arm read were exactly the three it
read.

The fence reader was TWO readers of one thing: `proseLines` toggled on
a backtick or a tilde fence, `fencedBlocks` toggled on a backtick fence
only, and both ignored CommonMark's fence rules. So a body could paste
evidence in a tilde block and the evidence arm never saw it; a
four-backtick fence closed early at the three-backtick line inside it;
a directive after a nested fence escaped the arm entirely; and a run
followed by text closed a fence that CommonMark says is still open.

ONE scanner now serves both readers, and it implements CommonMark's
fence rules: the length rule, and the closing fence's rule that only
whitespace may follow the run (an info string belongs to the OPENING
fence alone). The keyword grammar reads all nine forms,
case-insensitively, with the optional colon, and the finding quotes the
directive as it was written. The boundary the widening does NOT cross
is the arm's POSITION — a directive is read only when the body OPENS a
line with it — and that boundary is measured and filed rather than
asserted: 8 mid-line directives in this repo's 447 merged bodies, 3 of
them naming a pull request and 2 of them legitimate prose ("the
auto-closed #348", "the channel bootstrap fix #43's gitlink") that a
full-parity grammar would block.

The self-test's fixture table was spelled out in twelve arms and is
now one constant, so no arm can spell the table differently from
another.

R7: the self-test grows to 30 live arms — one per keyword form, the
uppercase form, the colon form, a directive after a nested fence, a
tilde-fenced evidence block, a directive inside a nested fence, a
mid-line directive, and a fence whose closing line carries text. On
four bodies the OLD gate is green and the NEW gate is red, and on two
the OLD gate is red and the NEW gate is green; the ONE difference
between the two runs is this change.

Closes #702
Refs #700
Refs #701

Assisted-by: Claude Code minimax/minimax-m3.1-flash:cloud (fully tested and validated)
@aitrawog
aitrawog deleted the feat/closes-pr-kind-698 branch November 1, 2026 19:07
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.

a Closes #N can name a merged PULL REQUEST — the directive closes nothing, and the body contradicts itself

1 participant