Skip to content

ci(pr-lint): a fenced Ran: or Not run: line is not evidence (#1294) - #1299

Merged
HugoXK merged 2 commits into
mainfrom
dev4/1294-fenced-evidence
Nov 24, 2026
Merged

HugoXK merged 2 commits into
mainfrom
dev4/1294-fenced-evidence

Conversation

@HugoXK

@HugoXK HugoXK commented Nov 24, 2026 •

Copy link
Copy Markdown
Owner

Written-by: Fledge Platform Dev-4

Fixes #1294

Baseline and tip

  • Baseline: 6ebb0902c488267237b61a3e400cdb921d2d17d9 — GET /commits/main read through the API in the claim turn; FETCH_HEAD matched it, and the branch was cut from that sha. (The dispatch said 87cda2fc; the API said 6ebb0902, and the API is what the branch is built on.)
  • Commit 1: 4cf976fab9d4f6e72ed6174da26d03881029b6cd — tests only, so the red output below is from a tree that is this branch.
  • Tip: 8d8f11a2444c810b0f46ebadb307c9bfe043c990 — two commits, author and committer Fledge Platform Dev-4 <dev4@fledge.invalid>; its tree d323e1a0e679e65e4dbde47f49f223609658a655 is byte-identical to the local tree every gate below ran on.
  • Push path: the tip was written through the GitHub git-data API (blobs → tree → commit → ref) because the ghfast.top mirror refuses to update an existing ref (cannot lock ref 'refs/heads/dev4/1294-fenced-evidence': reference already exists) and github.com is not reachable from this host. The tree identity above is the check that the API commit is the same content.

What is wrong

hasRanSection and hasNotRunSection in scripts/lib/pr-body.mjs:20-31 were plain regexes over the whole body, with no fence awareness. A body could therefore satisfy the Ran: evidence rule with a line that is only an example inside a code fence — the rule read as "a command was run" and the fence said the opposite. Same for Not run:.

At the baseline tree this body passed checkBody with no errors:

Written-by: HugoXK

Fixes #96

Nothing was run for this change.

Ran: nothing


Not run: Docker image, real SMTP
hasRanSection -> true
checkBody     -> []

and the mirror case, where the only Not run: line is fenced and the Ran: line is real:

hasNotRunSection -> true
checkBody2       -> []

Red first, at the baseline tree with only the test hunk applied

npx tsx --test test/prLint.test.ts:

not ok 15 - a Ran: line that exists only inside a code fence is reported as missing
  error: |-
    Expected values to be strictly equal:

    true !== false
  expected: false
  actual: true
  operator: 'strictEqual'
  location: 'test/prLint.test.ts:330:1'

not ok 16 - a Not run: line that exists only inside a code fence is reported as missing
  error: |-
    Expected values to be strictly equal:

    true !== false
  expected: false
  actual: true
  operator: 'strictEqual'

not ok 20 - a ~~~ fence hides an evidence line exactly like a backtick fence
  error: |-
    Expected values to be strictly equal:

    true !== false

not ok 21 - an unterminated fence at the end of the body is treated as a fence
  error: |-
    Expected values to be strictly equal:

    true !== false

1..40
# tests 40
# pass 36
# fail 4

The failure is the rule, not a message: hasRanSection answered true for a line that only exists inside a fence, which is a pass a body should not get.

What changed

  • scripts/lib/pr-body.mjs: one unfenced(body) helper removes fenced blocks before the Ran: / Not run: rules read the text, and the same text feeds the heading lookups that explain a missing section. A fence opens with three or more backticks or tildes at up to three spaces of indent, closes on the same character with at least the same run length and nothing else on its line, and an unterminated fence runs to the end of the body (fail closed). Nothing else moved: Written-by: on line 1, isDependabotBump, attribution, the size rule and the issue-reference rules are untouched, and their existing tests are unchanged. The heading lookups that explain a missing section go through the same filter, so a ## Ran: that exists only inside a fence is reported as a missing section rather than as a heading — both are errors and no gate outcome changes.
  • test/prLint.test.ts: the seven tests quoted and listed in the acceptance below.
  • docs/autonomous-dev.md: one sentence on the pr-lint paragraph, so the rule the doc summarises still describes the code.

Acceptance

  1. A body whose only Ran: line is inside a fence is reported as missing its Ran: section — not ok 15 before, green after.
  2. The same for Not run:, and a real line outside a fence still satisfies it — not ok 16, plus the passing case.
  3. A real Ran: outside every fence still satisfies the rule, and a ### Ran: heading is still rejected as a heading rather than accepted — the existing plain-line test and the new heading test both green.
  4. Fence tracking: a line after a closing fence is real text again; a ~~~ fence hides evidence like a backtick fence; an unterminated fence at the end is treated as a fence — not ok 20 and not ok 21 before, green after.
  5. isDependabotBump and every existing pr-lint rule behave exactly as before — the whole existing suite runs unchanged and green.

Verification at this tree

Ran:

  • npx tsx --test test/prLint.test.ts — 36/40 at the baseline tree with only the test hunk (the four failures above), 40/40 at the tip
  • npm run check — exit 0: lint, typecheck, 3428/3428 tests, build
  • node scripts/risk-gate.mjs --base origin/main — risk-tier: T3; basis: docs/autonomous-dev.md (the diff also carries scripts/lib/pr-body.mjs, which is T3 on its own)
  • node scripts/changelog.mjs check — pass, no fragment expected: pr-lint is maintainer tooling, not a product surface a user can see

Not run: a live pr-lint run against a real pull request — the suite's fake server is its harness, and no workflow file changed; no Docker image.

Uncertainty and residual risk

  • The rule is stricter now, so a body that relied on a fenced Ran: example goes red with "the PR body needs a "Ran:" section". That is the card, and the message names the missing section, so the repair is one real line.
  • A fence the scanner does not recognise (four spaces of indent, which CommonMark reads as an indented code block rather than a fence) still counts its lines as text. Only the four-space form is outside this rule; the acceptance names the fenced forms, and treating indented blocks the same would need its own card.
  • The console read model src/lib/changeStory.ts still reads a fenced Ran: for display. It is a read model, not a gate, and this card does not change it.

Fledge Platform Dev-4 added 2 commits November 24, 2026 11:19
…nce (#1294)

Each new test builds the body the hole is about: the only `Ran:` (or `Not run:`)
line sits inside a code fence. At this commit both helpers still read the fenced
text, so both bodies pass `checkBody` with no error and the suite is 36/40.

Docs-not-needed: this commit adds tests only; the doc sentence lands with the fix.
`hasRanSection` and `hasNotRunSection` read the whole body, so a line that only
existed as an example inside a code fence satisfied the evidence rule. Both now
read the body with its fenced blocks removed: a fence opens on three or more
backticks or tildes at up to three spaces of indent, closes on the same character
with at least the same run length and nothing else on its line, and an
unterminated fence runs to the end of the body. `isDependabotBump`, attribution,
the size rule and the issue-reference rules are untouched.

The pr-lint paragraph in docs/autonomous-dev.md states the fence rule.

@HugoXK-bot HugoXK-bot left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verdict: PASS at 8d8f11a
Written-by: HugoXK-bot
Author: Fledge Platform Verdict

Grounds:

  1. The hole is real and closed: scripts/lib/pr-body.mjs:34-54 strips fenced blocks before the evidence rules read the body (:56-62); my probe of the exact body gives base hasRanSection=true, tip false, and a fenced Not run:, a ~~~ fence and an unterminated fence are hidden the same way.
  2. Red first is behavioural, not a missing helper: at 4cf976fab9d4f6e72ed6174da26d03881029b6cd (base 6ebb0902 + the test hunk only) the suite is 36/40 with tests 15/16/20/21 failing true !== false at test/prLint.test.ts:332; at the tip it is 40/40.
  3. No regression: a real unfenced Ran:/Not run: still passes (test/prLint.test.ts:342-345), ### Ran: is still rejected as a heading (:347-353, error unchanged), and a line after a closing fence counts again (:355-371).
  4. No collateral relaxation: the test diff is +100/−0, so no existing assertion was edited; my base-vs-tip matrix returns identical results for line-1 Written-by: (scripts/lib/pr-body.mjs:122-124), attribution (:83-89), the dependabot pair (:103-106) and a 4-space indented block (the body records that residual, and it is not a fence in the acceptance).
  5. Docs match the code (docs/autonomous-dev.md:865-867); at this sha ci-ok, pr-lint, test (24) and risk are success, and review-gate is red only for the missing verdict. No UI face.

Ran:

  • node tmp/pr1299/probe.mjs — differential base 6ebb0902 vs tip over 16 bodies: the fenced Ran: body flips true→false, fenced Not run:/~~~/unterminated flip true→false, all legacy cases identical.
  • npx tsx --test test/prLint.test.ts in the tip tree — 40/40 pass, exit 0.
  • npx tsx --test test/prLint.test.ts at 4cf976fa — 36/40, tests 15/16/20/21 fail with actual: true, expected: false, exit 1.
  • curl https://api.github.com/repos/HugoXK/fledge/pulls/1299/reviews — 0 reviews at this head; curl .../commits/8d8f11a2.../check-runs?filter=latest — 33 runs, 0 pending.

Not run: npm run check and Docker locally — ci-ok and test (24) are success at this sha, and there is no UI face to screenshot.

@HugoXK-bot HugoXK-bot added the review:approved Issue reviewed and approved by the Fledge Platform Reviewer label Nov 24, 2026
@HugoXK
HugoXK merged commit b706578 into main Nov 24, 2026
38 of 39 checks passed
@HugoXK
HugoXK deleted the dev4/1294-fenced-evidence branch November 24, 2026 11:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

review:approved Issue reviewed and approved by the Fledge Platform Reviewer

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ci(pr-lint): a Ran: or Not run: line inside a code fence must not count as evidence

2 participants