Skip to content

Commit 30a0fba

Browse files
committed
fix(pm): the record writer refuses a Head-sha key followed by a hex span anywhere on a line; a backtick fence's info string holds no backtick
Three should-fixes from the #28103 contract review (record 6523547564), filed as #28111. 1. `post-stamped.mjs`: a second presence limb, `HEAD_SHA_KEY_SPAN` — the key directly followed by a 7-to-40 hex code span anywhere on a line — restores the write-time refusal of the 16 reader-null shapes the key-line limb alone let through (a word before the key, a second key on the line, a table row, underscore emphasis, a task-list item, a heading-styled key, a unicode bullet or an emoji, a bullet then a blockquote marker, strikethrough, parentheses, a no-break-space indent, an HTML comment). The prose mentions #28103 freed stay free; the one prose shape the limb refuses (the key immediately followed by a hex span inside a sentence) is the bound the card accepted, and it matches 0 of 11764 live comments updated since 2026-10-23. Six pins. 2. `RECORD_KEY_SPELLINGS['Head-sha']`, the refusal's `why` and the function docblock grant the heading the three spaces of indent the reader admits, instead of saying "unindented". Pinned. 3. `check-half-states.mjs`: `FENCE_LINE` opens a backtick fence only when its info string carries no backtick (CommonMark §4.5); a tilde fence's info string may hold one. Pinned in the H51 block. Self-tests: half-states 5131, post-stamped 753, exit 0. Corpus: 0 records read differently, 0 refused differently, on 11764 comments / 750 records. Co-authored-by: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016WV4cwv77cYicgaKyj39Y2
1 parent 27e0bd5 commit 30a0fba

2 files changed

Lines changed: 45 additions & 13 deletions

File tree

‎scripts/pm/check-half-states.mjs‎

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12710,8 +12710,16 @@ export const CONTRACT_REVIEW_HEAD_SHA_LINE = new RegExp(
1271012710
* Measured in the delta review of the fence-tracking reader (2026-10-30): a
1271112711
* ``` followed by prose closed the fence here while the renderer kept it open,
1271212712
* so a `Head-sha:` line after it was read; 0 of 713 live records carry one.
12713+
*
12714+
* A BACKTICK fence's info string may not contain a backtick (CommonMark §4.5):
12715+
* a line opening on three backticks whose rest carries one more is a paragraph
12716+
* holding code spans, not a fence, so it opens nothing and the lines below it
12717+
* are read. A tilde fence's info string may hold anything, backticks included.
12718+
* Measured in the #28103 review (F16, 2026-10-30): the opener read such a line
12719+
* as a fence and skipped the record's own line below it, in the fail-closed
12720+
* direction; 0 of 713 live records carry one.
1271312721
*/
12714-
const FENCE_LINE = /^[ ]{0,3}(`{3,}|~{3,})/;
12722+
const FENCE_LINE = /^[ ]{0,3}(`{3,}(?!.*`)|~{3,})/;
1271512723
const FENCE_CLOSE_LINE = /^[ ]{0,3}(`{3,}|~{3,})[ \t]*$/;
1271612724

1271712725
/**
@@ -33618,6 +33626,7 @@ Doubles as the fire's **write self-check** (step 0). \`201\` is not the reading.
3361833626
t('⛔ record reader: a `Head-sha:` line before the heading, blockquoted, bulleted or fenced — naming another head ABOVE the record\'s own — is NO review of that head', Object.values(CITED51).map((body) => latestContractReviewOnHead([cm51(1, body, T51)], HEAD51)).join('|'), '|||');
3361933627
t('⭐ record reader: …and each IS the review of the head its own line names — the cited line is prose to the reader', Object.values(CITED51).map((body) => latestContractReviewOnHead([cm51(1, body, T51)], OLDHEAD51)?.sha).join(), [OLDHEAD51, OLDHEAD51, OLDHEAD51, OLDHEAD51].join());
3362033628
t('⛔ record reader: a quoted, bulleted or fenced line ALONE names no head, nor does a line with NO heading above it, nor one inside an unclosed fence', [contractReviewHeadSha(UNDER51(`> Head-sha: \`${HEAD51}\``)), contractReviewHeadSha(UNDER51(`- **Head-sha:** \`${HEAD51}\``)), contractReviewHeadSha(UNDER51('```md', `Head-sha: \`${HEAD51}\``, '```')), contractReviewHeadSha(`Head-sha: \`${HEAD51}\``), contractReviewHeadSha(UNDER51('```', `Head-sha: \`${HEAD51}\``))].join('|'), '||||');
33629+
t('⛔ #28111 · record reader: a backtick run whose info string carries a BACKTICK opens no fence (CommonMark) — the line below it reads; a backtick-free info string opens one, and so does a tilde run with a backtick in its info string', [contractReviewHeadSha(UNDER51('``` a`b', `Head-sha: \`${HEAD51}\``)), contractReviewHeadSha(UNDER51('```md `x`', `Head-sha: \`${HEAD51}\``, '```', `Head-sha: \`${OLDHEAD51}\``)), contractReviewHeadSha(UNDER51('```md', `Head-sha: \`${HEAD51}\``)), contractReviewHeadSha(UNDER51('~~~ a`b', `Head-sha: \`${HEAD51}\``)), contractReviewHeadSha(UNDER51('````', '``` a`b', `Head-sha: \`${HEAD51}\``, '````', `Head-sha: \`${OLDHEAD51}\``))].join('|'), [HEAD51, HEAD51, '', '', OLDHEAD51].join('|'));
3362133630
t('record reader: a tilde fence is a fence too, and CRLF line endings read', [contractReviewHeadSha(UNDER51('~~~', `Head-sha: \`${HEAD51}\``, '~~~', `Head-sha: \`${OLDHEAD51}\``)), contractReviewHeadSha(`## Contract review\r\nHead-sha: \`${HEAD51}\`\r\n`)].join(), [OLDHEAD51, HEAD51].join());
3362233631
t('⛔ record reader: the RETIRED dialects — head in the heading (two spellings), on the first body line, in an adoption sentence — name no head', [DIALECT_A, DIALECT_B, DIALECT_C, DIALECT_D].map((d) => latestContractReviewOnHead([cm51(1, d(HEAD51), T51)], HEAD51)).join('|'), '|||');
3362333632

‎scripts/pm/post-stamped.mjs‎

Lines changed: 35 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2060,20 +2060,35 @@ export function keyedLineRefusalText(rows) {
20602060

20612061
/** What the record's owner accepts, printed BY the refusal so the fix is one line away. */
20622062
export const RECORD_KEY_SPELLINGS = Object.freeze({
2063-
'Head-sha': '`Head-sha: ` then the reviewed head as 7 to 40 hex in a code span of its OWN, at the START of a line (up to three spaces of indent) BELOW an unquoted, unindented `## Contract review` heading — not blockquoted, not bulleted, not inside a fence, not indented as code (four spaces or a tab), not before the heading, not under a quoted or code-indented heading; the first such line is the head the record names, and a record written before the line existed may omit it',
2063+
'Head-sha': '`Head-sha: ` then the reviewed head as 7 to 40 hex in a code span of its OWN, at the START of a line (up to three spaces of indent) BELOW an unquoted `## Contract review` heading itself indented at most three spaces — not blockquoted, not bulleted, not inside a fence, not indented as code (four spaces or a tab), not before the heading, not under a quoted or code-indented heading; the first such line is the head the record names, and a record written before the line existed may omit it',
20642064
'Local-runs': '`Local-runs: none` at the START of a line, or `Local-runs: probe — REASON` naming the ONE local run the read-only rule was broken for and why; a record written before the line existed may omit it',
20652065
});
20662066

2067-
/** PRESENCE only, case-blind: a `Head-sha` key opening a LINE, however decorated or placed — any indent, blockquote
2068-
* markers, a bullet or a list number, bold or backticks around the key — so a decorated, fenced, code-indented or
2069-
* pre-heading key line still counts as written. Consulted solely to tell "the author wrote the key and the reader
2070-
* cannot read it" (refused) from "no key at all" (not re-judged). ⛔ Not mid-sentence: a comment that quotes a record's
2071-
* heading and then names the key in prose wrote no key line, and was refused for it until 2026-10-30 (loudness only). */
2067+
/** PRESENCE only, case-blind, TWO limbs — either says "the author wrote the key":
2068+
* 1. `HEAD_SHA_KEY_LINE` — a `Head-sha` key opening a LINE, however decorated or placed: any indent, blockquote
2069+
* markers, a bullet or a list number, bold or backticks around the key — so a decorated, fenced, code-indented or
2070+
* pre-heading key line still counts as written. The convention `keyLineRegex` imposes on every other key.
2071+
* 2. `HEAD_SHA_KEY_SPAN` — the key DIRECTLY followed by a 7-to-40 hex code span, anywhere on a line, through the
2072+
* decoration a key or a value may wear (bold, backticks, underscores, strikethrough, a table cell bar). Restores the
2073+
* refusal of 16 reader-null shapes the line limb alone let through (the #28103 review, ①.4): a word before the
2074+
* key (`Current Head-sha:`), a second key on the line, a table row, underscore emphasis, a task-list item, a
2075+
* heading-styled key, a unicode bullet or an emoji, a bullet then a blockquote marker, strikethrough, parentheses,
2076+
* a no-break-space indent, an HTML comment. Each reads null to every reader, so each is a record that would be
2077+
* filed as a review of NO head; this limb says so before the write.
2078+
* Consulted solely to tell "the author wrote the key and the reader cannot read it" (refused) from "no key at all"
2079+
* (not re-judged). ⛔ Not a mid-sentence mention: a comment that quotes a record's heading and then names the key in
2080+
* prose — `Head-sha:` with no span, or a span further along the sentence — wrote no key, and was refused for it until
2081+
* 2026-10-30 (loudness only). The one prose shape the span limb DOES refuse is the key immediately followed by a hex
2082+
* span inside a sentence, which the #28103 review measured as its only false positive and this card accepted:
2083+
* measured on the 11764 issue comments updated since 2026-10-23 (750 carrying the record's heading, 2026-10-30),
2084+
* 0 comments write that shape on a line that is not also a key line, so the limb refuses no live body. */
20722085
const HEAD_SHA_KEY_LINE = /^[ \t]*(?:>[ \t]*)*(?:(?:[-*+]|\d+[.)])[ \t]+)?[`*]*head-sha[ \t`*]*:/im;
2086+
const HEAD_SHA_KEY_SPAN = /head-sha[`*_~]*[ \t]*:[ \t*_~|]*`[0-9a-f]{7,40}`/i;
2087+
const headShaKeyPresent = (line) => HEAD_SHA_KEY_LINE.test(line) || HEAD_SHA_KEY_SPAN.test(line);
20732088

20742089
/** The first line carrying a `Head-sha` key, however spelled — a LOCATOR for the writer's eye, ⛔ never the judgement. */
20752090
function headShaKeyLine(text) {
2076-
const hit = text.split(/\r?\n/).find((line) => HEAD_SHA_KEY_LINE.test(line));
2091+
const hit = text.split(/\r?\n/).find(headShaKeyPresent);
20772092
return hit === undefined ? '(no single line carries the key)' : offendingSpan(hit.trim(), 160);
20782093
}
20792094

@@ -2084,8 +2099,8 @@ function headShaKeyLine(text) {
20842099
* verdict over a line nobody had been asked to write. Scoped by the record's own heading marker, on `--comment`
20852100
* alone — a record IS a comment.
20862101
* Head-sha `contractReviewHeadSha` (`check-half-states.mjs`) is the ONE reader every guard reaches the record's head
2087-
* through: the first plain `Head-sha:` line below an unquoted, unindented heading, outside any blockquote,
2088-
* bullet, fence or indented code. A
2102+
* through: the first plain `Head-sha:` line below an unquoted heading indented at most three spaces (as the
2103+
* line itself may be), outside any blockquote, bullet, fence or indented code. A
20892104
* body that carries the key somewhere and reads `null` there would be filed by every reader as a review of
20902105
* NO head — absent on the owed list, refused at the queue — so it is refused here, before the write. The
20912106
* template's null-oid placeholder reads as a head (it is 40 hex) and is not this row's: C6 refuses it.
@@ -2097,8 +2112,8 @@ export function recordKeyedLineRefusals(body) {
20972112
const text = String(body ?? '');
20982113
if (!CONTRACT_REVIEW_HEADING_MARKER.test(text)) return [];
20992114
const rows = [];
2100-
if (HEAD_SHA_KEY_LINE.test(text) && contractReviewHeadSha(text) === null)
2101-
rows.push({ key: 'Head-sha', line: headShaKeyLine(text), why: '`contractReviewHeadSha` reads NO head here — a `Head-sha` key opens a line, but no line below an unquoted, unindented `## Contract review` heading carries it plainly with a hex span of its own (a blockquoted, bulleted, fenced or pre-heading line, a code-indented line — four spaces or a tab — a line under a quoted or code-indented heading, the key folded into the span, a bare hex value, a lowercase key and a sub-floor span all read as nothing). Every reader would file this record as a review of NO head.' });
2115+
if (headShaKeyPresent(text) && contractReviewHeadSha(text) === null)
2116+
rows.push({ key: 'Head-sha', line: headShaKeyLine(text), why: '`contractReviewHeadSha` reads NO head here — a `Head-sha` key opens a line or is followed by a hex span, but no line below an unquoted `## Contract review` heading indented at most three spaces carries it plainly with a hex span of its own (a blockquoted, bulleted, fenced or pre-heading line, a code-indented line — four spaces or a tab — a line under a quoted or code-indented heading, the key folded into the span, a bare hex value, a lowercase key and a sub-floor span all read as nothing). Every reader would file this record as a review of NO head.' });
21022117
const runs = readLocalRuns(text);
21032118
if (!localRunsStand(runs))
21042119
rows.push({ key: 'Local-runs', line: runs.line, why: '`readLocalRuns` reads the line and cannot grade its value — `none` and `probe — REASON` are the closed set, and a probe with no reason names no deviation.' });
@@ -5328,7 +5343,15 @@ export function selfTest() {
53285343
// or `+`-bulleted line, is a written line the reader refuses, and is refused here.
53295344
t('⭐ NOT a key line: a record-shaped comment that names `Head-sha:` mid-sentence, with no line opening on the key, is untouched — presence is a key LINE', rkeys('## Contract review\n\nThe seat\'s own record carries its Head-sha: line plainly, below the heading; see `Head-sha:` in the template.') === '' && rkeys(`> ## Contract review\n\nquoted above; the record\'s Head-sha: line is \`${SHA_HEAD}\` there`) === '');
53305345
t('⛔ …while a decorated key LINE still counts as written and is refused when the reader names no head: numbered, doubly quoted, `+`-bulleted, and one under a CODE-INDENTED heading', rkeys(SHA_WITH([`1. Head-sha: \`${SHA_HEAD}\``])) === 'Head-sha' && rkeys(SHA_WITH([`> > **Head-sha:** \`${SHA_HEAD}\``])) === 'Head-sha' && rkeys(SHA_WITH([`+ Head-sha: \`${SHA_HEAD}\``])) === 'Head-sha' && rkeys(` ## Contract review\nHead-sha: \`${SHA_HEAD}\``) === 'Head-sha');
5331-
t('the `Head-sha` refusal and the printed spelling NAME the two causes the reader added — a code-indented line and a line under a quoted or code-indented heading', (() => { const text = recordLineRefusalText(recordKeyedLineRefusals(SHA_WITH([`\tHead-sha: \`${SHA_HEAD}\``]))); const rule = RECORD_KEY_SPELLINGS['Head-sha']; return text.includes('a code-indented line — four spaces or a tab') && text.includes('a line under a quoted or code-indented heading') && rule.includes('not indented as code (four spaces or a tab)') && rule.includes('not under a quoted or code-indented heading') && rule.includes('BELOW an unquoted, unindented'); })());
5346+
// ⛔ #28111: the SECOND presence limb — the key directly followed by a hex span, anywhere on a line — restores the
5347+
// refusal of the 16 reader-null shapes the line limb let through (the #28103 review, ①.4); each reads null and is refused.
5348+
t('⛔ #28111 · the key behind a WORD, a second key on the line, a table row and a task-list item are written keys the reader cannot read — refused', [`Current Head-sha: \`${SHA_HEAD}\``, `Reviewed Head-sha: \`${SHA_HEAD}\``, `head: Head-sha: \`${SHA_HEAD}\``, `Served-tier: \`${CONTRACT_REVIEW_TIER_NAME}\` · Head-sha: \`${SHA_HEAD}\``, `| Head-sha: | \`${SHA_HEAD}\` |`, `| Head-sha: \`${SHA_HEAD}\` |`, `- [ ] Head-sha: \`${SHA_HEAD}\``].every((line) => rkeys(SHA_WITH([line])) === 'Head-sha' && contractReviewHeadSha(SHA_WITH([line])) === null));
5349+
t('⛔ #28111 · underscore emphasis, a heading-styled key, a unicode bullet or an emoji, a bullet then a blockquote marker, strikethrough, parentheses, a no-break-space indent and an HTML comment — each refused', [`_Head-sha:_ \`${SHA_HEAD}\``, `__Head-sha__: \`${SHA_HEAD}\``, `### Head-sha: \`${SHA_HEAD}\``, `• Head-sha: \`${SHA_HEAD}\``, `✅ Head-sha: \`${SHA_HEAD}\``, `- > Head-sha: \`${SHA_HEAD}\``, `~~Head-sha:~~ \`${SHA_HEAD}\``, `(Head-sha: \`${SHA_HEAD}\`)`, `\u00a0Head-sha: \`${SHA_HEAD}\``, `<!-- Head-sha: \`${SHA_HEAD}\` -->`].every((line) => rkeys(SHA_WITH([line])) === 'Head-sha' && contractReviewHeadSha(SHA_WITH([line])) === null));
5350+
t('⭐ #28111 · the prose cases #28103 freed STAY free under the span limb: the key with no span, the key with its span further along the sentence, a sub-floor span, and the key with a span that is no sha', rkeys('## Contract review\n\nThe seat\'s own record carries its Head-sha: line plainly, below the heading; see `Head-sha:` in the template.') === '' && rkeys(`> ## Contract review\n\nquoted above; the record\'s Head-sha: line is \`${SHA_HEAD}\` there`) === '' && rkeys('## Contract review\n\nits Head-sha: `ba3d95` prefix is the one I cite') === '' && rkeys('## Contract review\n\nits Head-sha: `origin/main` is what I cite') === '');
5351+
t('⛔ #28111 · the one prose shape the span limb refuses, by the card\'s accepted bound: the key IMMEDIATELY followed by a hex span inside a sentence, in a body whose reader names no head; a record carrying its own plain line above it passes', rkeys(`## Contract review\n\nI re-read the record above (its Head-sha: \`${SHA_HEAD}\` is the one I judged) and agree.`) === 'Head-sha' && rkeys(SHA_WITH([`Head-sha: \`${SHA_HEAD}\``], `(the earlier record\'s Head-sha: \`${'a'.repeat(40)}\` is superseded)`)) === '');
5352+
t('#28111 · the locator quotes the span-limb line the refusal is about, and the `why` names BOTH limbs', (() => { const rows = recordKeyedLineRefusals(SHA_WITH([`Current Head-sha: \`${SHA_HEAD}\``])); return rows.length === 1 && rows[0].line.startsWith('Current Head-sha') && rows[0].why.includes('opens a line or is followed by a hex span'); })());
5353+
t('#28111 · `RECORD_KEY_SPELLINGS[\'Head-sha\']` grants the heading the three spaces the reader admits — "indented at most three spaces", never "unindented"', RECORD_KEY_SPELLINGS['Head-sha'].includes('heading itself indented at most three spaces') && !/unindented/.test(RECORD_KEY_SPELLINGS['Head-sha']) && !/unindented/.test(recordKeyedLineRefusals(SHA_WITH([`> Head-sha: \`${SHA_HEAD}\``]))[0].why));
5354+
t('the `Head-sha` refusal and the printed spelling NAME the two causes the reader added — a code-indented line and a line under a quoted or code-indented heading', (() => { const text = recordLineRefusalText(recordKeyedLineRefusals(SHA_WITH([`\tHead-sha: \`${SHA_HEAD}\``]))); const rule = RECORD_KEY_SPELLINGS['Head-sha']; return text.includes('a code-indented line — four spaces or a tab') && text.includes('a line under a quoted or code-indented heading') && rule.includes('not indented as code (four spaces or a tab)') && rule.includes('not under a quoted or code-indented heading') && rule.includes('BELOW an unquoted'); })());
53325355
t('both lines unreadable ⇒ both rows, `Head-sha` first', rkeys(SHA_WITH([`> Head-sha: \`${SHA_HEAD}\``], 'Local-runs: probe')) === 'Head-sha,Local-runs');
53335356
t('the `Head-sha` refusal prints the spelling that reads, names the owner, and quotes the offending line', (() => { const rows = recordKeyedLineRefusals(SHA_WITH([`> Head-sha: \`${SHA_HEAD}\``])); const text = recordLineRefusalText(rows); return text.includes(RECORD_KEY_SPELLINGS['Head-sha']) && text.includes('contractReviewHeadSha') && rows[0].line.includes('> Head-sha'); })());
53345357
t('⛔ NOT a record: a claim or a report carrying a quoted `Head-sha:` line is untouched — the reader runs on the record\'s heading only', rkeys(`Claim: x\n> Head-sha: \`${SHA_HEAD}\``) === '' && rkeys(`os-dev-report\n\n> Head-sha: \`${SHA_HEAD}\``) === '');

0 commit comments

Comments
 (0)