Skip to content

fix(pre-push): the body is reconciled against the head the push PUBLISHES (#744) - #746

Merged
github-actions[bot] merged 1 commit into
mainfrom
feat/pr-body-published-head
Oct 27, 2026
Merged

github-actions[bot] merged 1 commit into
mainfrom
feat/pr-body-published-head

Conversation

@aitrawog

Copy link
Copy Markdown
Contributor

fix(pre-push): the body is reconciled against the head the push PUBLISHES

Summary

Head 3f84384fa114a9cafa97e9f13da14fe868e03197 — 4 files changed, 297 insertions(+), 61 deletions(-).

The pre-push gate reconciled the PR body against the diff of the CHECKOUT's HEAD, and the org's body linter judged the body's own head claim against that same checkout. A push of a branch other than the checked-out one publishes THAT branch's commit — git push origin other publishes other's sha while the checkout still sits on main — so both readers judged the body against a tree the push does not publish: a body that described the pushed branch was BLOCKED, and a body that described the checkout was let through. That is the defect #744 filed; it was separable from the hook's argument contract, so it lands in its own PR, and this is it.

The fix resolves the published refs ONCE — the branch AND the commit the push publishes — and names that commit to BOTH readers of the body's head claim. The checked-out tree stays the fallback for a push that publishes no single branch (a tag, a deletion, several branches at once, or a hand-run hook): the tree it always read.

file what it carries
scripts/check-pr-body-diff.mjs --head <rev> (default HEAD), and every arm that reads the tree — the diff, the file table, the pasted evidence, the rewritten record's claims, the reader-independent count — reads that ONE head.
hooks/pre-push the published refs resolved once from the refs git writes to the hook's stdin; the published commit named to the reconciliation and to the org linter alike; the checked-out tree kept as the fallback.
scripts/check-pr-body-gate.mjs the fixture's second branch moved onto a DIFFERENT tree, so the two branches can be told apart; two new FIRED arms that discriminate them; three new static assertions; three new mutations, plus the two the moved invocations needed.
CHANGELOG/2026.300.1647.md the merged record's claim that the reconciler compares the body against origin/main...HEAD — corrected in the same cutover, because a record that states the old thing is a claim the tree does not support.

Closes #744

How tested

The gate that owns this change is the umbrella's own: bash scripts/self-test.sh and ./charly/bin/charly task verify, plus the hook's own gate node scripts/check-pr-body-gate.mjs in its green mode and in its --self-test mode, the reconciler's own --self-test, and the body's cap check. Every command below was run on the committed tree this PR publishes; the RED proofs were run against the MERGED tree under this change's own gate, so the coverage fails without the change.

$ git rev-parse HEAD
3f84384fa114a9cafa97e9f13da14fe868e03197
$ git diff --shortstat origin/main HEAD
 4 files changed, 297 insertions(+), 61 deletions(-)
$ git status --short --untracked-files=no
# empty — the worktree carries nothing beyond the commit

The change-class gate, on that same tree:

$ ./charly/bin/charly version
2026.300.1028
$ bash scripts/self-test.sh > /tmp/gate744/self-test.log 2>&1; echo "SELFTEST_EXIT=$?"
SELFTEST_EXIT=0
$ ./charly/bin/charly task verify > /tmp/gate744/verify.log 2>&1; echo "VERIFY_EXIT=$?"
VERIFY_EXIT=0
$ grep -E "^task verify:" /tmp/gate744/verify.log
task verify: 42 step(s), 0 failed, 0 skipped
$ grep -cE "^\s*\[fail\]" /tmp/gate744/verify.log
0
$ grep -cE "^\s*\[warn\]" /tmp/gate744/verify.log
0
$ grep -cE "^\s*\[pass\]" /tmp/gate744/verify.log
42

The hook's own gate, in its green mode — the two arms this change adds are the last two:

$ node scripts/check-pr-body-gate.mjs
  PASS  hooks/pre-push: executable, git-dir body path with an override, both skips visible and never fail-closed, and it runs the marketplace body linter; its skip counts (hook=8 live-body=6) match the code
  PASS  hooks/pre-push FIRED: a defective body is BLOCKED at the push (exit 1) by the linter's own FAIL finding, found at the git-dir default
  PASS  hooks/pre-push FIRED: a well-formed body passes (exit 0)
  PASS  hooks/pre-push FIRED: no body SKIPS visibly (exit 0) and names the path to create
  PASS  hooks/pre-push FIRED: a missing linter SKIPS visibly (exit 0) and names the fix; PR_BODY_FILE is honoured
  PASS  hooks/pre-push FIRED: a linter that cannot run SKIPS visibly (exit 0) instead of blocking a legitimate push
  PASS  hooks/pre-push FIRED: a body whose file table matches the diff passes (exit 0)
  PASS  hooks/pre-push FIRED: a body whose file table lists a file the diff does not change is BLOCKED at the push
  PASS  hooks/pre-push FIRED: a body whose pasted `git rev-parse HEAD` is not the head being pushed is BLOCKED at the push
  PASS  hooks/pre-push FIRED: a body whose fences do not pair is BLOCKED at the push, and the finding names the fences
  PASS  hooks/pre-push FIRED: a body over the size cap is BLOCKED at the push, and the finding names the cap
  PASS  hooks/pre-push FIRED: a PR whose LIVE body matches the validated body passes (exit 0), and the match is named
  PASS  hooks/pre-push FIRED: a PR whose LIVE body does NOT match the validated body is BLOCKED at the push, and the finding names the PR and the fix
  PASS  hooks/pre-push FIRED: a branch with no open PR SKIPS the LIVE-body check visibly (exit 0)
  PASS  hooks/pre-push FIRED: gh failing SKIPS the LIVE-body check visibly (exit 0) instead of blocking a legitimate push
  PASS  the no-gh farm is built from the RESOLVED PATH, so it holds a tool that lives outside the three directories the merged gate hard-coded
  PASS  hooks/pre-push FIRED: without gh the LIVE-body check SKIPS visibly (exit 0) instead of blocking a legitimate push
  PASS  hooks/pre-push FIRED: a push that publishes a branch OTHER than the checked-out one is checked against THAT branch's PR, not the checkout's
  PASS  hooks/pre-push FIRED: a push that publishes a branch other than the checked-out one passes when THAT branch's PR holds the same body
  PASS  hooks/pre-push FIRED: a push that publishes a TAG skips the LIVE-body check visibly (exit 0) instead of comparing against the checkout's PR
  PASS  hooks/pre-push FIRED: a push to a remote other than origin is checked against THAT remote's PR, not against origin's
  PASS  hooks/pre-push FIRED: a push whose PUBLISHED branch has no open PR skips the LIVE-body check visibly, naming the published branch
  PASS  hooks/pre-push FIRED: a body that describes the CHECKOUT's diff is BLOCKED when the push publishes ANOTHER branch's diff
  PASS  hooks/pre-push FIRED: a body that describes the PUBLISHED branch's diff passes when the push publishes that branch
check-pr-body-gate: OK

The same gate in the mode that MUTATES the hook to prove each arm can fail — the three new mutations are the ones this change adds, and the two moved invocations are re-keyed so they can still fail:

$ node scripts/check-pr-body-gate.mjs --self-test
  PASS  mutation 'missing body fails closed' is caught (gate red)
  PASS  mutation 'missing linter fails closed' is caught (gate red)
  PASS  mutation 'a lint finding does not block the push' is caught (gate red)
  PASS  mutation 'a linter that cannot run blocks the push' is caught (gate red)
  PASS  mutation 'the body path defaults into the tracked tree' is caught (gate red)
  PASS  mutation 'the body/diff reconciliation does not run' is caught (gate red)
  PASS  mutation 'the reconciliation reads the checkout's tree instead of the published one' is caught (gate red)
  PASS  mutation 'the linter reads the checkout's head instead of the published one' is caught (gate red)
  PASS  mutation 'the published commit is not read from the ref git publishes' is caught (gate red)
  PASS  mutation 'the live-body check does not run' is caught (gate red)
  PASS  mutation 'a stale live body does not block the push' is caught (gate red)
  PASS  mutation 'the live-body check fails closed when gh is absent' is caught (gate red)
  PASS  mutation 'the published branch is not read from the refs git publishes' is caught (gate red)
  PASS  mutation 'the pushed remote is not the one the push names' is caught (gate red)
  PASS  the unmutated copy is GREEN
check-pr-body-gate --self-test: OK (14/14 arms live)

The reconciler's own self-test — the last case is the one this change adds, and the fourth mutation is the one that names the defect:

$ node scripts/check-pr-body-diff.mjs --self-test
  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 'a body that describes another branch's diff is red when the head is the checkout's' 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  mutation 'the body closes a merged pull request with the keyword 'close'' is caught (gate red)
  PASS  mutation 'the body closes a merged pull request with the keyword 'closes'' is caught (gate red)
  PASS  mutation 'the body closes a merged pull request with the keyword 'closed'' is caught (gate red)
  PASS  mutation 'the body closes a merged pull request with the keyword 'fix'' is caught (gate red)
  PASS  mutation 'the body closes a merged pull request with the keyword 'fixes'' is caught (gate red)
  PASS  mutation 'the body closes a merged pull request with the keyword 'fixed'' is caught (gate red)
  PASS  mutation 'the body closes a merged pull request with the keyword 'resolve'' is caught (gate red)
  PASS  mutation 'the body closes a merged pull request with the keyword 'resolves'' is caught (gate red)
  PASS  mutation 'the body closes a merged pull request with the keyword 'resolved'' is caught (gate red)
  PASS  mutation 'the body closes a merged pull request in UPPERCASE' is caught (gate red)
  PASS  mutation 'the body closes a merged pull request with a COLON' is caught (gate red)
  PASS  mutation 'the body closes a merged pull request AFTER a nested fence' is caught (gate red)
  PASS  mutation 'the body pastes a stale evidence line inside a TILDE fence in the prose' is caught (gate red)
  PASS  mutation 'the body pastes evidence in a TILDE fence the tree does not hold' is caught (gate red)
  PASS  mutation 'the body leaves a fence open' is caught (gate red)
  PASS  mutation 'the body hides a required section inside a fenced block' is caught (gate red)
  PASS  mutation 'the body is over GitHub's cap' 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 inside a TILDE fence is evidence, not a directive' stays green
  PASS  case 'a closing directive naming an issue is left alone' stays green
  PASS  case 'a closing directive naming an issue is left alone in a form the arm newly reads' stays green
  PASS  case 'a closing directive inside a NESTED fence is evidence, not a directive' stays green
  PASS  case 'a closing directive in the MIDDLE of a line is not a directive' stays green
  PASS  case 'a fence whose closing line carries text does not close the fence' stays green
  PASS  case 'a body that quotes a section heading inside a fence is not hiding a section' stays green
  PASS  case 'a body just under GitHub's cap stays green' stays green
  PASS  case 'a body that describes another branch's diff is green when the head names that branch' stays green
  PASS  a diff two algorithms count differently turns the reader-independence arm RED (myers 29/10, histogram 32/13)
  PASS  the unmutated fixture body is GREEN
check-pr-body-diff --self-test: OK (40 arms live)

The body's cap check — the two readers read the SAME number from the one shipped cap:

$ node scripts/check-pr-body-cap.mjs
  PASS  the two readers read the SAME number from the shipped cap (65536 bytes)
  PASS  a cap file with TWO content lines: BOTH readers refuse it, and each names the cap
  PASS  a cap file whose content line carries a trailing note: BOTH readers refuse it, and each names the cap
  PASS  a cap file with NO content line: BOTH readers refuse it, and each names the cap
  PASS  the reconciler's self-test is GREEN under an ambient GITHUB_BODY_MAX (the ambient does not size the fixture)
  PASS  the cap file's header states the ONE-content-line rule
  PASS  the RETIRED rule's wording is gone from every tracked file EXCEPT this gate — which names it in order to forbid it — and except CHANGELOG/, which is the record of what happened (252 tracked file(s) scanned)
check-pr-body-cap: OK

The RED proof — the MERGED tree under this change's gate. The merged hook and the merged reconciler are put in place and the same gate is run against them, so every arm this change adds fails without the change:

$ git show origin/main:hooks/pre-push > /tmp/pp744-old/hooks/pre-push
$ git show origin/main:scripts/check-pr-body-diff.mjs > /tmp/pp744-old/scripts/check-pr-body-diff.mjs
$ git show origin/main:scripts/lib/pr-body-cap > /tmp/pp744-old/scripts/lib/pr-body-cap
$ node scripts/check-pr-body-gate.mjs --root /tmp/pp744-old; echo "PROOF1_RC=$?"
  FAIL  takes the commit the push PUBLISHES from the published ref's local sha
  FAIL  reconciles the body against the head the push PUBLISHES, not the checkout's
  FAIL  lints the body against the head the push PUBLISHES, not the checkout's
  PASS  hooks/pre-push FIRED: a defective body is BLOCKED at the push (exit 1) by the linter's own FAIL finding, found at the git-dir default
  PASS  hooks/pre-push FIRED: a well-formed body passes (exit 0)
  PASS  hooks/pre-push FIRED: no body SKIPS visibly (exit 0) and names the path to create
  PASS  hooks/pre-push FIRED: a missing linter SKIPS visibly (exit 0) and names the fix; PR_BODY_FILE is honoured
  PASS  hooks/pre-push FIRED: a linter that cannot run SKIPS visibly (exit 0) instead of blocking a legitimate push
  PASS  hooks/pre-push FIRED: a body whose file table matches the diff passes (exit 0)
  PASS  hooks/pre-push FIRED: a body whose file table lists a file the diff does not change is BLOCKED at the push
  PASS  hooks/pre-push FIRED: a body whose pasted `git rev-parse HEAD` is not the head being pushed is BLOCKED at the push
  PASS  hooks/pre-push FIRED: a body whose fences do not pair is BLOCKED at the push, and the finding names the fences
  PASS  hooks/pre-push FIRED: a body over the size cap is BLOCKED at the push, and the finding names the cap
  PASS  hooks/pre-push FIRED: a PR whose LIVE body matches the validated body passes (exit 0), and the match is named
  PASS  hooks/pre-push FIRED: a PR whose LIVE body does NOT match the validated body is BLOCKED at the push, and the finding names the PR and the fix
  PASS  hooks/pre-push FIRED: a branch with no open PR SKIPS the LIVE-body check visibly (exit 0)
  PASS  hooks/pre-push FIRED: gh failing SKIPS the LIVE-body check visibly (exit 0) instead of blocking a legitimate push
  PASS  the no-gh farm is built from the RESOLVED PATH, so it holds a tool that lives outside the three directories the merged gate hard-coded
  PASS  hooks/pre-push FIRED: without gh the LIVE-body check SKIPS visibly (exit 0) instead of blocking a legitimate push
  PASS  hooks/pre-push FIRED: a push that publishes a branch OTHER than the checked-out one is checked against THAT branch's PR, not the checkout's
  PASS  hooks/pre-push FIRED: a push that publishes a branch other than the checked-out one passes when THAT branch's PR holds the same body
  PASS  hooks/pre-push FIRED: a push that publishes a TAG skips the LIVE-body check visibly (exit 0) instead of comparing against the checkout's PR
  PASS  hooks/pre-push FIRED: a push to a remote other than origin is checked against THAT remote's PR, not against origin's
  PASS  hooks/pre-push FIRED: a push whose PUBLISHED branch has no open PR skips the LIVE-body check visibly, naming the published branch
  FAIL  hooks/pre-push FIRED: a body that describes the CHECKOUT's diff is BLOCKED when the push publishes ANOTHER branch's diff
  FAIL  hooks/pre-push FIRED: a body that describes the PUBLISHED branch's diff passes when the push publishes that branch
check-pr-body-gate: 5 finding(s)
PROOF1_RC=1

The RED proof — the NEW hook with the OLD reconciler. The reconciler is the half that READS the tree, and the old one IGNORES an unknown flag: its argument parser looks up only --repo, --body and --base, so passing --head to it is not a fix but a silent no-op. This is the arm that proves both halves are needed:

$ git show origin/main:scripts/check-pr-body-diff.mjs > /tmp/pp744-oldrecon/scripts/check-pr-body-diff.mjs
$ node scripts/check-pr-body-gate.mjs --root /tmp/pp744-oldrecon; echo "PROOF2_RC=$?"
  PASS  hooks/pre-push: executable, git-dir body path with an override, both skips visible and never fail-closed, and it runs the marketplace body linter; its skip counts (hook=8 live-body=6) match the code
  PASS  hooks/pre-push FIRED: a defective body is BLOCKED at the push (exit 1) by the linter's own FAIL finding, found at the git-dir default
  PASS  hooks/pre-push FIRED: a well-formed body passes (exit 0)
  PASS  hooks/pre-push FIRED: no body SKIPS visibly (exit 0) and names the path to create
  PASS  hooks/pre-push FIRED: a missing linter SKIPS visibly (exit 0) and names the fix; PR_BODY_FILE is honoured
  PASS  hooks/pre-push FIRED: a linter that cannot run SKIPS visibly (exit 0) instead of blocking a legitimate push
  PASS  hooks/pre-push FIRED: a body whose file table matches the diff passes (exit 0)
  PASS  hooks/pre-push FIRED: a body whose file table lists a file the diff does not change is BLOCKED at the push
  PASS  hooks/pre-push FIRED: a body whose pasted `git rev-parse HEAD` is not the head being pushed is BLOCKED at the push
  PASS  hooks/pre-push FIRED: a body whose fences do not pair is BLOCKED at the push, and the finding names the fences
  PASS  hooks/pre-push FIRED: a body over the size cap is BLOCKED at the push, and the finding names the cap
  PASS  hooks/pre-push FIRED: a PR whose LIVE body matches the validated body passes (exit 0), and the match is named
  PASS  hooks/pre-push FIRED: a PR whose LIVE body does NOT match the validated body is BLOCKED at the push, and the finding names the PR and the fix
  PASS  hooks/pre-push FIRED: a branch with no open PR SKIPS the LIVE-body check visibly (exit 0)
  PASS  hooks/pre-push FIRED: gh failing SKIPS the LIVE-body check visibly (exit 0) instead of blocking a legitimate push
  PASS  the no-gh farm is built from the RESOLVED PATH, so it holds a tool that lives outside the three directories the merged gate hard-coded
  PASS  hooks/pre-push FIRED: without gh the LIVE-body check SKIPS visibly (exit 0) instead of blocking a legitimate push
  PASS  hooks/pre-push FIRED: a push that publishes a branch OTHER than the checked-out one is checked against THAT branch's PR, not the checkout's
  PASS  hooks/pre-push FIRED: a push that publishes a branch other than the checked-out one passes when THAT branch's PR holds the same body
  PASS  hooks/pre-push FIRED: a push that publishes a TAG skips the LIVE-body check visibly (exit 0) instead of comparing against the checkout's PR
  PASS  hooks/pre-push FIRED: a push to a remote other than origin is checked against THAT remote's PR, not against origin's
  PASS  hooks/pre-push FIRED: a push whose PUBLISHED branch has no open PR skips the LIVE-body check visibly, naming the published branch
  FAIL  hooks/pre-push FIRED: a body that describes the CHECKOUT's diff is BLOCKED when the push publishes ANOTHER branch's diff
  FAIL  hooks/pre-push FIRED: a body that describes the PUBLISHED branch's diff passes when the push publishes that branch
check-pr-body-gate: 2 finding(s)
PROOF2_RC=1

The two halves, in the tree being pushed. The hook resolves the published refs once and names that one commit to both readers; the reconciler reads the tree through that one head:

$ sed -n "185,186p" hooks/pre-push
resolve_published_refs
RECONCILE_HEAD="${PUBLISHED_HEAD:-HEAD}"
$ sed -n "201p" hooks/pre-push
  if node "$RECONCILE" --body "$BODY" --repo "$ROOT" --head "$RECONCILE_HEAD"; then
$ sed -n "332p" hooks/pre-push
if python3 "$LINT" "$BODY" --repo "$ROOT" --head "$RECONCILE_HEAD"; then
$ sed -n "153p" scripts/check-pr-body-diff.mjs
const headRef = argOf("--head") ?? "HEAD";

Rulebook compliance

  • R0: the dispatcher's rows for this work — the git/PR workflow and the engineering-discipline triggers — were loaded before the first tool action; the umbrella's own AGENTS.md was read before the change.
  • R1: the change's own gate caught the defect twice, and each finding was RCA'd before any remediation. The missed control, the first time: the fixture's two branches shared a commit, so a body about one branch was indistinguishable from a body about the other — the gate could not see the wrong tree because it could not tell the two trees apart. The root fix went into the control: the fixture's second branch moved onto a different tree, and two arms were added that discriminate them. The missed control, the second time: the first run of the new arm that publishes another branch was RED for a reason this change had not seen — the org linter ALSO judges the body's head claim, and the hook was still handing it the checkout's head, so the body that described the PUBLISHED branch was blocked by the LINTER rather than by the reconciliation. The root fix went into the control as well as into the code: the hook now names the published head to the linter as well, a static assertion pins that invocation, and a mutation proves the arm can fail without it. Both findings were introduced by this change's own first cut, so neither was filed away; the one finding that is genuinely separable — the reconciler's own diff base — was filed as the body/diff reconciliation resolves the diff it compares the body against from HEAD, so a push of a branch other than the checked-out one is reconciled against the wrong tree #744 and is what this PR closes.
  • R2: one implementation — the published refs are parsed once, in the hook, and both consumers read that one resolution; the reconciler reads the tree through one headRef, and the gate ASSERTS the contract instead of re-deriving it.
  • R3: no sleep, no retry, no suppression, no fallback branch and no manual workaround: the hook reads what git publishes, and the arms exercise exactly that.
  • R4: the product is fixed first — the reconciler and the hook are the product — and the merged record's claim about the reconciler's diff base is corrected in the same cutover.
  • R5: the retracted claim is gone from the tree; the claim-keyed sweep is pasted below.
  • R6: git status was clean before the commit and the tree carries nothing beyond it; the push is a branch push — no force-push, no amend after the push, no hook bypass, no direct push to main.
  • R7: the coverage fails without the change: the MERGED tree under this change's gate is RED with five findings, and the NEW hook with the OLD reconciler is RED with two, both pasted above; the gate's own --self-test mode mutates the hook fourteen ways and each mutation is caught.
  • R8: N/A — this change crosses no live service: the hook's boundary is git's own stdin and the local filesystem, and both are exercised live above.
  • R9: the worktree-local binary the gate ran is ./charly/bin/charly version → 2026.300.1028; this change touches no Go source and adds no runtime dependency, so no rebuild is owed.
  • R10: the change class is the umbrella's own gate — bash scripts/self-test.sh and ./charly/bin/charly task verify — run on the committed tree this PR publishes: 42 steps, 0 failed, 0 skipped, 0 warnings.

Change classification

  • Change class: the umbrella's own gate — no runtime, no submodule, no gitlink, no pin, no schema.
  • The diff: four files — the reconciler, the hook, the hook's gate, and the record that states the reconciler's diff base.
  • The gate: bash scripts/self-test.sh and ./charly/bin/charly task verify, plus node scripts/check-pr-body-gate.mjs and node scripts/check-pr-body-gate.mjs --self-test, node scripts/check-pr-body-diff.mjs --self-test and node scripts/check-pr-body-cap.mjs — all on the committed tree, all green, zero warnings.
  • The attribution tier: fully tested and validated — the change-class gate passed on the final tree, and the changed paths were executed live.
  • The R5 sweep, claim-keyed. The retracted claim — that the reconciler compares the body against the checkout's HEAD — survives nowhere in the code, and the record that stated it now says it in the past tense and names the fix. The positive sweep: every tree read in the reconciler goes through the one head.
$ git grep -n "compares the body against" -- . ; echo "grep exit=$?"
grep exit=1
$ git grep -n "origin/main\.\.\.HEAD" -- hooks/ scripts/ ; echo "grep exit=$?"
grep exit=1
$ git grep -cn "headRef" -- scripts/check-pr-body-diff.mjs
scripts/check-pr-body-diff.mjs:17
$ git grep -n "headRef" -- scripts/check-pr-body-diff.mjs | head -4
scripts/check-pr-body-diff.mjs:153:const headRef = argOf("--head") ?? "HEAD";
scripts/check-pr-body-diff.mjs:273:function diffTotals(algorithm, baseRef, headRef) {
scripts/check-pr-body-diff.mjs:274:  const out = git("diff", "--numstat", `--diff-algorithm=${algorithm}`, `${baseRef}...${headRef}`);
scripts/check-pr-body-diff.mjs:309:function checkDiffCountIsReaderIndependent(baseRef, headRef) {

Filed issues

None. Both findings this change's own gate raised were introduced by this change's own first cut, so both are fixed here rather than filed: the first because the fixture could not tell the two branches apart, the second because the linter was still reading the checkout's head. The one finding that was genuinely separable — the reconciler's own diff base — was filed as #744 and is what this PR closes.

Agent: pin666-removed-row · session ses_8efb271d-f2c0-47d3-85e3-2a1e00b11ae0
Assisted-by: Claude Code minimax/minimax-m3.1-flash:cloud (fully tested and validated)

…SHES (#744)

The body/diff reconciliation and the org linter both judged the body's head
claim against the CHECKOUT's HEAD — while a push of a branch other than the
checked-out one publishes THAT branch's commit. The body was therefore checked
against a tree the push does not publish: a body that described the pushed
branch was BLOCKED, and a body that described the checkout was let through.

- scripts/check-pr-body-diff.mjs: gains `--head <rev>` (default `HEAD`), and
  every arm that reads the tree — the diff, the file table, the evidence, the
  record claims, the reader-independence count — reads that ONE head.
- hooks/pre-push: resolves the published refs ONCE — the branch AND the commit
  the push publishes — and names that commit to the reconciliation and to the
  org linter alike. The checked-out tree stays the fallback for a push that
  publishes no single branch (a tag, a deletion, several branches, a hand-run
  hook), which is the tree it always read.
- scripts/check-pr-body-gate.mjs: the fixture's second branch moves onto a
  DIFFERENT tree, so the two branches can be told apart, and two new FIRED arms
  discriminate — a body about the checkout is BLOCKED when the push publishes
  another branch, and a body about the published branch passes. Three new
  mutations, and the two the old invocations moved to, keep every arm able to
  fail.
- CHANGELOG/2026.300.1647.md: the merged record's claim that the reconciler
  compares the body against `origin/main...HEAD` is corrected — it no longer
  does.

Closes #744

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

Copy link
Copy Markdown
Contributor

Review — PASS

What the PR does

The change resolves the refs a push publishes ONCE (in hooks/pre-push) and names the published commit to both readers of the body's head claim: the umbrella reconciler (scripts/check-pr-body-diff.mjs, new --head <rev>) and the org linter (also invoked with --head). The checked-out tree (HEAD) is kept as the documented fallback for tag/deletion/multi-branch/hand-run pushes. A CHANGELOG record is corrected to past tense.

Verified against the diff

  • Counts. 4 files; insertions 1+89+108+99 = 297; deletions 1+31+23+6 = 61. Matches the body and git diff --shortstat claim.
  • Reconciler. headRef = argOf("--head") ?? "HEAD" is threaded through every tree-reading arm that the diff touches: diffTotals, checkDiffCountIsReaderIndependent, checkEvidence (cat-file/show), recordAdditions, checkRecordClaims, and check()'s rev-parse/diff --name-only/--name-status. Default HEAD preserves the umbrella gate's existing behavior (the pre-existing arms run without --head).
  • Hook. resolve_published_refs parses the four-field stdin lines, skips (delete), takes remote_ref#refs/heads/, and sets PUBLISHED_HEAD only for a single published branch; RECONCILE_HEAD="${PUBLISHED_HEAD:-HEAD}" is then passed to both the reconciler and the linter. The LIVE-body branch/why logic was de-duplicated to read the same resolution (R2 honored). It is called before the reconciliation so the LIVE-body check never loses its branch.
  • Static assertions. All three new regexes (published_head="$local_sha", --head "$RECONCILE_HEAD" on the node call, the full linter line) match the hook text exactly.
  • Mutations. The two re-keyed mutations and the three new ones target distinct lines and each should make the F21 arm go red (reconciliation-on-HEAD, linter-on-HEAD, and published_head="" all collapse RECONCILE_HEAD to the checkout).
  • Fixture discrimination. The gate's other branch is moved onto a different tree (f.txt/i.txt) with its own SHA, and the reconciler self-test's other adds b.txt/d.txt with no record row, so the two branches are genuinely distinguishable — this is what lets F20/F21 and the new self-test cases fail without the fix.
  • RED proofs are internally consistent. PROOF1 (old hook + old reconciler) = 3 static + 2 fired = 5 findings; PROOF2 (new hook + old reconciler that ignores --head) = 2 fired findings. Both match the described mechanism.
  • Record correction. The CHANGELOG bullet is reworded to past tense and names the fix; the whole-tree grep for the retracted phrase exits 1, and the origin/main...HEAD literal is correctly left only in the historical record.

Comments

No comments were provided (0 comments), so there is nothing to disposition. No maintainer sign-off is available; the change is evaluated on its own evidence, which is strong (static assertions + FIRED arms + mutations + RED proofs).

Non-blocking observations

  • The hook now always passes --head to the marketplace linter. Its --head support is asserted by the author and exercised only through the gate's stub, not demonstrated against the real linter in this diff. If the real linter rejected the flag it would fail closed. Given the author's account that the linter already judges the head claim and the stub encodes that contract, this is treated as an accepted external contract rather than a defect.
  • The HEAD fallback for tag/deletion/multi-branch pushes is unchanged behavior (pre-existing) and is clearly documented as a fallback, not a skip.

No correctness, security, scope, or cleanliness defects were found in the diff; the change is coherent, tested, and internally consistent with the body.

Verdict: PASS


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

View action run

@github-actions
github-actions Bot enabled auto-merge (squash) October 27, 2026 17:24
@github-actions
github-actions Bot merged commit fb48c90 into main Oct 27, 2026
3 checks passed
charly-auto-merge Bot added a commit that referenced this pull request Oct 27, 2026
@aitrawog
aitrawog deleted the feat/pr-body-published-head branch November 1, 2026 19:10
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