Skip to content

Commit fd3f1f3

Browse files
committed
fix(pm): read a record's Head-sha line only below its heading, refuse an unreadable one at write time, and name the line in the rules
`contractReviewHeadSha` (check-half-states.mjs) now takes the first `Head-sha:` line BELOW the record's own `## Contract review` heading, outside any fenced code block, and `CONTRACT_REVIEW_HEAD_SHA_LINE` no longer admits a blockquoted or bulleted key: a `Head-sha:` line naming another head that sits above the record's own — before the heading, quoted, bulleted or fenced — was read as the record's head, so the record was found at the cited head and absent at its own. Every reader (H43, the locator, the owed list, the queue guard) reaches the head through this one function, so they move together; pins cover each shape in the H51 battery and the locator battery. `post-stamped.mjs` `recordKeyedLineRefusals` refuses a record that carries a `Head-sha` key which `contractReviewHeadSha` (imported, never re-spelled) reads as null, before the write; a record with no key is not re-judged. `contract-review.md` names the line the readers read: 「`Head-sha:` 行独占码段」, line-count neutral, 117 bytes. Measured on the 709 line-initial records posted 2026-10-23..30: 707 carry the line plain below the heading, 2 carry no key (the retired dialects), 0 read differently under the new rules. Co-authored-by: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016WV4czYNVYrGQqbs51hpvv
1 parent e1dde1a commit fd3f1f3

4 files changed

Lines changed: 141 additions & 32 deletions

File tree

‎.claude/skills/pm-dispatch/references/contract-review.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
- 新 head 即清;点名现 head 时 (b) 不起;条件满足由持有车道挂等复核标记或落交接行。
3131
- 逾 24 小时条件未满的 hold 列入分诊轮次记录(`check-owed-reviews.mjs` 标出)。
3232
- 复核记录 = 一条评论落 PR 或卡,席内与子代理同形;散文、dev 自评、`os-dev-report` 恒不算。
33-
- 同形 = `## Contract review` 题头、head sha 独占码段、①②③ 逐项、独立性对、PASS/FAIL。
33+
- 同形 = `## Contract review` 题头、`Head-sha:` 行独占码段、①②③ 逐项、独立性对、PASS/FAIL。
3434
- 同形含首行 `Served-tier:`:值写该面所定档的常量名 `CONTRACT_REVIEW_TIER` 或 `TIER_DEFAULT`;
3535
无此行不成裁决;模板 `node scripts/pm/record-recognisers.mjs --template`,申报面加 `--face declaration`。
3636
- 同形带 `Local-runs:` 行:`none` 或 `probe — REASON` 具名唯一探针;有行必校,缺行旧记录不改判。

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

Lines changed: 80 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -12641,9 +12641,18 @@ export const H51_SHA_SPAN = /`([0-9a-fA-F]{7,40})`/g;
1264112641
* The `Head-sha:` key line — the ONE place a contract-review record names the
1264212642
* head it reviewed.
1264312643
*
12644-
* The key half is `record-recognisers.mjs`'s `keyLineRegex` convention, spelled
12645-
* here because that file imports this one: optional blockquote, bullet, bold
12646-
* and backticks around the key, then the colon. The VALUE is a hex code span of
12644+
* The key half is `record-recognisers.mjs`'s `keyLineRegex` convention WITHOUT
12645+
* its two positional tolerances, spelled here because that file imports this
12646+
* one: bold and backticks around the key are tolerated, then the colon. ⛔ A
12647+
* leading blockquote or list bullet is NOT — `keyLineRegex` admits both for
12648+
* `Served-tier:`, `Reviewed-by:` and `Local-runs:`, whose values describe the
12649+
* record itself, but this line decides WHICH HEAD a PASS clears, and a quoted
12650+
* or bulleted `Head-sha:` line is one the author CITED rather than wrote (a
12651+
* review quoting the seat's hand-off, a record quoting an earlier record), so
12652+
* a reader that took it read a quoted sha as reviewed. `contractReviewHeadSha`
12653+
* adds the two positional rules a single-line regex cannot carry: the line
12654+
* sits BELOW the record's own `## Contract review` heading and outside any
12655+
* fenced code block. The VALUE is a hex code span of
1264712656
* its OWN — the shape `--template` prints — and it is the FIRST thing after the
1264812657
* colon (spaces and bold may precede it, ⛔ nothing else); what follows the span
1264912658
* on that line is prose and decides nothing. A key folded into the span with
@@ -12652,24 +12661,66 @@ export const H51_SHA_SPAN = /`([0-9a-fA-F]{7,40})`/g;
1265212661
* decoration and the value then opens with hex rather than a backtick, so the
1265312662
* record names no head — the accept set stays exactly one spelling. A bare hex
1265412663
* value with no span, a lowercase key and a span below the floor name no head
12655-
* either; the repair for every one of them is on the WRITE side.
12664+
* either; the repair for every one of them is on the WRITE side, where
12665+
* `post-stamped.mjs` refuses a record carrying a `Head-sha` key this reader
12666+
* cannot read BEFORE the write.
1265612667
*/
1265712668
export const CONTRACT_REVIEW_HEAD_SHA_LINE = new RegExp(
12658-
`^[ \\t]*(?:>[ \\t]*)?(?:[-*][ \\t]+)?(?:\\*\\*)?\`?Head-sha\`?(?:\\*\\*)?[ \\t]*:(?:[ \\t]|\\*\\*)*${H51_SHA_SPAN.source}`,
12669+
`^[ \\t]*(?:\\*\\*)?\`?Head-sha\`?(?:\\*\\*)?[ \\t]*:(?:[ \\t]|\\*\\*)*${H51_SHA_SPAN.source}`,
1265912670
);
1266012671

1266112672
/**
12662-
* The head a contract-review record names — the span on its first `Head-sha:`
12663-
* line, as written (case kept), or `null` when no line reads.
12664-
*
12665-
* First line wins, as `readServedTier` reads its key: a record is one comment
12666-
* and names one head, and a later `Head-sha:` line (a quoted record, say) is
12667-
* prose to this reader. Not judged against any head here — that is
12668-
* `contractReviewHeadMatch`'s half — so a caller can also ask which head a
12669-
* record is ABOUT, which the sentence a patrol prints needs.
12673+
* A fenced-code boundary, as CommonMark opens and closes one: three or more
12674+
* backticks or tildes at the line start (up to three spaces of indent).
12675+
* One toggle for both fence characters — the reader needs "inside a fence or
12676+
* not", never which fence; an unclosed fence runs to the end of the body, as
12677+
* it renders.
12678+
*/
12679+
const FENCE_LINE = /^[ ]{0,3}(?:`{3,}|~{3,})/;
12680+
12681+
/**
12682+
* The head a contract-review record names — the span on the first `Head-sha:`
12683+
* line BELOW its `## Contract review` heading, as written (case kept), or
12684+
* `null` when no such line reads.
12685+
*
12686+
* Three positional rules, each measured in the review of the line-form reader
12687+
* (2026-10-30) as a way a sha the author never reviewed became the record's
12688+
* head: a `Head-sha:` line placed BEFORE the heading, a blockquoted or
12689+
* bulleted one, and one inside a fenced code block — each naming another head
12690+
* ABOVE the record's own line — read as the head, so the record was found at
12691+
* the cited head and absent at the real one. None is prose to a first-line
12692+
* reader, and all four shapes are what a quotation looks like. So: lines
12693+
* before the first heading-marker line are skipped (the heading is read with
12694+
* `CONTRACT_REVIEW_HEADING_MARKER`, blockquoted heading included, exactly as
12695+
* the locator finds the record); a fenced line is skipped, fence boundaries
12696+
* included; and `CONTRACT_REVIEW_HEAD_SHA_LINE` itself refuses the blockquote
12697+
* and the bullet. Among the lines that remain, the FIRST wins, as
12698+
* `readServedTier` reads its key: a record is one comment and names one head,
12699+
* and a later `Head-sha:` line (a quoted record, say) is prose to this reader.
12700+
* Measured on the 709 records with a line-initial heading posted to this
12701+
* repository in the week to 2026-10-30: 707 carry the line plain and below
12702+
* the heading, 2 carry no `Head-sha` key at all (the two retired-dialect
12703+
* records), and 0 read differently under these rules than under the
12704+
* first-line-anywhere reader they replace.
12705+
*
12706+
* Not judged against any head here — that is `contractReviewHeadMatch`'s half
12707+
* — so a caller can also ask which head a record is ABOUT, which the sentence
12708+
* a patrol prints needs, and which `post-stamped.mjs` asks before it writes a
12709+
* record: a body carrying a `Head-sha` key that reads `null` here is refused.
1267012710
*/
1267112711
export function contractReviewHeadSha(body) {
12712+
let fenced = false;
12713+
let belowHeading = false;
1267212714
for (const line of String(body ?? '').split(/\r?\n/)) {
12715+
if (FENCE_LINE.test(line)) {
12716+
fenced = !fenced;
12717+
continue;
12718+
}
12719+
if (fenced) continue;
12720+
if (!belowHeading) {
12721+
belowHeading = CONTRACT_REVIEW_HEADING_MARKER.test(line);
12722+
continue;
12723+
}
1267312724
const m = CONTRACT_REVIEW_HEAD_SHA_LINE.exec(line);
1267412725
if (m) return m[1];
1267512726
}
@@ -33452,8 +33503,22 @@ Doubles as the fire's **write self-check** (step 0). \`201\` is not the reading.
3345233503
const DELTA51 = RECORD51(OLDHEAD51, `\nThe PR has since moved to \`${HEAD51.slice(0, 8)}\` (seat comment 6515952505); this record judges \`${OLDHEAD51.slice(0, 8)}\` alone. Runs cancelled by the push of \`${HEAD51.slice(0, 8)}\`; landing waits on \`${HEAD51}\`.\n`);
3345333504
t('⛔ record reader: a delta record on head A whose PROSE names head B is NO review of B', latestContractReviewOnHead([cm51(1, DELTA51, T51)], HEAD51), null);
3345433505
t('⭐ record reader: …and IS the review of A — the `Head-sha:` line alone decides', latestContractReviewOnHead([cm51(1, DELTA51, T51)], OLDHEAD51)?.sha, OLDHEAD51);
33455-
t('record reader: `contractReviewHeadSha` reads the line\'s span — the first line wins, decoration and a trailing span tolerated', [contractReviewHeadSha(DELTA51), contractReviewHeadSha(`- **Head-sha:** \`${HEAD51}\` (moved to \`${OLDHEAD51}\`)\nHead-sha: \`${OLDHEAD51}\``), contractReviewHeadSha(`> Head-sha: \`${HEAD51}\``)].join(), [OLDHEAD51, HEAD51, HEAD51].join());
33456-
t('⛔ record reader: the key folded INTO the span, a bare hex value, a lowercase key and a sub-floor span name no head', [contractReviewHeadSha(`\`Head-sha: ${HEAD51}\``), contractReviewHeadSha(`Head-sha: ${HEAD51}`), contractReviewHeadSha(`head-sha: \`${HEAD51}\``), contractReviewHeadSha('Head-sha: `ba3d95`')].join('|'), '|||');
33506+
const UNDER51 = (...lines) => ['## Contract review', ...lines].join('\n');
33507+
t('record reader: `contractReviewHeadSha` reads the line\'s span — the first line BELOW the heading wins; bold or backticks on the key, a trailing span and a blockquoted heading are tolerated', [contractReviewHeadSha(DELTA51), contractReviewHeadSha(UNDER51(`**Head-sha:** \`${HEAD51}\` (moved to \`${OLDHEAD51}\`)`, `Head-sha: \`${OLDHEAD51}\``)), contractReviewHeadSha(UNDER51(`\`Head-sha\`: \`${HEAD51}\``)), contractReviewHeadSha(`> ## Contract review\nHead-sha: \`${HEAD51}\``)].join(), [OLDHEAD51, HEAD51, HEAD51, HEAD51].join());
33508+
t('⛔ record reader: the key folded INTO the span, a bare hex value, a lowercase key and a sub-floor span name no head', [contractReviewHeadSha(UNDER51(`\`Head-sha: ${HEAD51}\``)), contractReviewHeadSha(UNDER51(`Head-sha: ${HEAD51}`)), contractReviewHeadSha(UNDER51(`head-sha: \`${HEAD51}\``)), contractReviewHeadSha(UNDER51('Head-sha: `ba3d95`'))].join('|'), '|||');
33509+
// ⛔ The shapes the review of the line-form reader probed (2026-10-30): a `Head-sha:` line naming ANOTHER head above the
33510+
// record's own — placed before the heading, blockquoted, bulleted or fenced. Each is a citation, not the record's line,
33511+
// so the record reads ABSENT at the cited head and FOUND at its own; the first-line-anywhere reader read all four as cited.
33512+
const CITED51 = {
33513+
preHeading: `Head-sha: \`${HEAD51}\`\n\n${RECORD51(OLDHEAD51)}`,
33514+
quoted: UNDER51('', `> Head-sha: \`${HEAD51}\``, `Head-sha: \`${OLDHEAD51}\``, '**VERDICT: PASS**'),
33515+
bulleted: UNDER51('', `- Head-sha: \`${HEAD51}\``, `Head-sha: \`${OLDHEAD51}\``, '**VERDICT: PASS**'),
33516+
fenced: UNDER51('', '```', `Head-sha: \`${HEAD51}\``, '```', `Head-sha: \`${OLDHEAD51}\``, '**VERDICT: PASS**'),
33517+
};
33518+
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('|'), '|||');
33519+
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());
33520+
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('|'), '||||');
33521+
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());
3345733522
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('|'), '|||');
3345833523

3345933524
// -- H54 — a `[Decision]`-titled card sitting in the DISPATCH pool (#16688) -

0 commit comments

Comments
 (0)