From e1eaf7d211a62368a5c83dc1dc6ddbcd3aca4e20 Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 1 Dec 2026 06:46:11 +0000 Subject: [PATCH 01/10] feat(pm): record-recognisers reads a decision analysis's Served-tier / Analysed-by pair Claude-Session: https://claude.ai/code/session_01WGufzfWWgrLkABDvbRjhAk Co-authored-by: Claude --- scripts/pm/record-recognisers.mjs | 109 +++++++++++++++++++++++++++++- 1 file changed, 108 insertions(+), 1 deletion(-) diff --git a/scripts/pm/record-recognisers.mjs b/scripts/pm/record-recognisers.mjs index 4b24c739588..972c3fe7621 100644 --- a/scripts/pm/record-recognisers.mjs +++ b/scripts/pm/record-recognisers.mjs @@ -22,6 +22,7 @@ * locateReviewOfRecord the record on this head, on the PR thread or its card * deliveredCardNumber which card thread a pull request's record may sit on — and `deliveredCardsAtStrongest` every card a tie holds, for a reader that reads them all * readServedTier the `Served-tier:` line, and `servedTierStands` on it — at the tier its face maps to + * readDecisionAnalysisTier the same line on a DECISION ANALYSIS, beside its `Analysed-by:` line (`readAnalysedBy`) — at tier, below it, unreadable or missing * reviewFace / REVIEW_FACES which face made the review owed, and the ONE tier NAME it stands at * reviewScopeHits the at-tier review's scope floor — `reviewFace`'s `hits`, the record's `Scope:` line * recordCarriesDesignJudgment whether a face's record carries item ④, the full review's design judgment @@ -95,6 +96,8 @@ import { contractReviewHeadMatch, contractReviewRecordReading, contractReviewVerdictLines, + DECISION_FACET_MARKER, + hasDecisionFacetMarker, deliveryEvidence, deliveryEvidenceNote, latestMarkedComment, @@ -110,6 +113,7 @@ import { releaseAnswersClaim, SEAT_SIGNATURE_SESSION_SOURCE, seatOnDuty, + stripMarkdownCode, stripSignatureLine, yieldedClaimIndexes, } from './check-half-states.mjs'; @@ -807,6 +811,69 @@ export function readServedTier(text) { return { state: 'missing', stamps: null }; } +/** + * The `Analysed-by:` key line -- the decision analysis's twin of `Reviewed-by:`: WHO wrote the analysis, the second + * of the two lines `references/decision-analysis.md` 〈落卡分析模板〉 opens the English analysis with, under its + * `Served-tier:` line. Read in this file's one key convention (`keyLineRegex`), never a second. + */ +export const ANALYSED_BY_LINE = keyLineRegex('Analysed-by'); + +/** The value token of an `Analysed-by:` line: a session id or another opaque name, closed on an alphanumeric. */ +const ANALYSED_BY_TOKEN = /^([A-Za-z0-9](?:[A-Za-z0-9_.:@#/-]*[A-Za-z0-9])?)/; + +/** + * What one text declares about who analysed it. ⛔ A model identifier is the one value the template forbids (「⛔ 不写模型 + * id」): it reads `unreadable` with NO line quoted, because quoting it back would land the identifier in whatever + * prints the reading (`isModelIdentifierToken`). Its value is not otherwise judged: who that is stays human. + * + * @returns {{ state: 'missing' } | { state: 'unreadable', line: string|null } | { state: 'read', value: string }} + */ +export function readAnalysedBy(text) { + for (const line of String(text ?? '').split(/\r?\n/)) { + const m = ANALYSED_BY_LINE.exec(line); + if (!m) continue; + const token = ANALYSED_BY_TOKEN.exec(stripValueDecoration(m[1])); + if (token && isModelIdentifierToken(token[1])) return { state: 'unreadable', line: null }; + return token ? { state: 'read', value: token[1] } : { state: 'unreadable', line: quoteLine(line) }; + } + return { state: 'missing' }; +} + +/** + * The tier a DECISION ANALYSIS was written at, read off one text (a card body or one comment): the pair + * `references/decision-analysis.md` 〈落卡分析模板〉 asks the English analysis to open with. + * + * ⭐ ONE parser: the `Served-tier:` line is `readServedTier`'s and its verdict `servedTierStands`', at + * `CONTRACT_REVIEW_TIER_NAME` -- an analysis has no face, and the template names that one tier as the one an analysis + * may be presented at without a re-run. So `at-tier` is exactly what stands a contract review record's line, the + * `N/M` stamp control included; `below-tier` is every other readable value (`TIER_DEFAULT` and a broken stamp control + * among them); `unreadable` a line no token can be read off; `missing` no line. + * + * ⭐ What makes a text an ANALYSIS (`analysis`): the four-facet block's marker outside code (the reading the handover + * check and `post-stamped.mjs` give it) or an `Analysed-by:` line -- the line no other record carries. A `## Contract + * review` record is never one: its `Served-tier:` line is the record's, read by the readers above. `carriesLine` is an + * analysis that carries either line of the pair: the text a card-level reader takes the line from. + * + * ⛔ Fenced code is blanked before either line is read (`stripMarkdownCode`, inline spans KEPT, since the template's + * own spelling backticks the value): a fence quoting another analysis is citing it, not carrying it. + * + * @returns {{ state: 'at-tier'|'below-tier'|'unreadable'|'missing', served: object, analysedBy: object, + * analysis: boolean, carriesLine: boolean }} + */ +export function readDecisionAnalysisTier(text) { + const raw = String(text ?? ''); + const prose = stripMarkdownCode(raw, { inline: false }); + const served = readServedTier(prose); + const analysedBy = readAnalysedBy(prose); + const record = CONTRACT_REVIEW_HEADING_MARKER.test(raw); + const analysis = !record && (hasDecisionFacetMarker(stripMarkdownCode(raw)) || analysedBy.state !== 'missing'); + const state = + served.state === 'missing' ? 'missing' + : served.state === 'unreadable' ? 'unreadable' + : servedTierStands(served, CONTRACT_REVIEW_TIER_NAME) ? 'at-tier' : 'below-tier'; + return { state, served, analysedBy, analysis, carriesLine: analysis && (served.state !== 'missing' || analysedBy.state !== 'missing') }; +} + /** * The `Local-runs:` key line -- the FOURTH provenance fact a verdict declares * about itself: whether the round that rendered it ran anything locally. @@ -2901,6 +2968,8 @@ const SELF_TEST_BATTERIES = Object.freeze({ // Raised 22 → 23 with the unedited-paste pin: the shipped `Rule-change-verified: yes` lands nothing. '#18701: ONE thread set -- what the template STATES is what the queue guard READS': 23, 'the `Local-runs:` reading — `none` or ONE named probe, judged when present; an absent line is not re-judged': 12, + // The decision analysis's pair: at tier, below it, unreadable, missing (the card's Done-when: present, missing and below-tier). + '⭐ a decision analysis\'s `Served-tier:` / `Analysed-by:` pair — at tier, below it, unreadable or missing, read with the record\'s own parser; never off a contract review record or out of a fence': 18, // Raised 23 → 24 with ③'s SQL push-down check on every face's brief: one pin. 'the reviewer BRIEF template — the read-only shape a hand-written brief dropped, built in and printed': 24, '⭐ B′ with C: the review tier FOLLOWS THE FACE that made it owed — exact, never a floor': 23, @@ -3406,6 +3475,43 @@ export async function selfTest() { t('the key is ONE regex, built by the one key-line convention — never a second spelling', LOCAL_RUNS_LINE.source === keyLineRegex('Local-runs').source); t('prose naming the key mid-sentence is not the line — the declaration is line-initial', readLocalRuns('the Local-runs: line goes here').state === 'missing'); + // -- a decision analysis's tier pair ------------------------------------------- + // + // `references/decision-analysis.md` 〈落卡分析模板〉: the English analysis opens with `Served-tier:` and + // `Analysed-by:`. The presenting seat reads the pair before presenting; this is the reading it gets. + battery('⭐ a decision analysis\'s `Served-tier:` / `Analysed-by:` pair — at tier, below it, unreadable or missing, read with the record\'s own parser; never off a contract review record or out of a fence'); + const DA_SESSION = 'session_01AnalysisFixture9Qx'; + const DA = (served, by = `\`${DA_SESSION}\``, marker = DECISION_FACET_MARKER) => [ + 'repo:objectstack@os-example · os-example · session_01AnalysisFixture9Qx', + '## 维护者速读', + '- 问题:一句话。', + '', + ...(served === null ? [] : [`Served-tier: ${served}`]), + ...(by === null ? [] : [`Analysed-by: ${by}`]), + '', + 'Background prose.', + ...(marker === null ? [] : ['', marker, '- ① 项目长远合理性:不扩大特例。']), + ].join('\n'); + const da = (text) => readDecisionAnalysisTier(text); + t('⭐ PRESENT at tier — the pair reads, the line stands, and the text is an analysis that carries it', (() => { const r = da(DA(`\`${CONTRACT_REVIEW_TIER_NAME}\``)); return r.state === 'at-tier' && r.analysedBy.state === 'read' && r.analysedBy.value === DA_SESSION && r.analysis && r.carriesLine; })()); + t('…with the stamp control the records carry, read and judged the same way', da(DA(`12/12 \`${CONTRACT_REVIEW_TIER_NAME}\``)).state === 'at-tier'); + t('⭐ BELOW TIER — `TIER_DEFAULT` reads, and is not at tier', (() => { const r = da(DA(`\`${TIER_DEFAULT_NAME}\``)); return r.state === 'below-tier' && r.served.value === TIER_DEFAULT_NAME && r.carriesLine; })()); + t('⛔ BELOW TIER — the tier name over a control that is not total is 回退证据, not at tier', da(DA(`3/9 \`${CONTRACT_REVIEW_TIER_NAME}\``)).state === 'below-tier'); + t('⛔ BELOW TIER — a prefix of the name, or the name with a suffix, is not the name: EXACT, as on a record', da(DA(CONTRACT_REVIEW_TIER_NAME.split('_')[0])).state === 'below-tier' && da(DA(`${CONTRACT_REVIEW_TIER_NAME}_X`)).state === 'below-tier'); + t('⭐ MISSING — an analysis (the facet marker) with no `Served-tier:` line reads `missing`, and carries no line', (() => { const r = da(DA(null, null)); return r.state === 'missing' && r.analysis && !r.carriesLine; })()); + t('…while one with its `Analysed-by:` line alone carries half the pair: `missing`, but the line is THERE to name', (() => { const r = da(DA(null)); return r.state === 'missing' && r.carriesLine && r.analysedBy.state === 'read'; })()); + t('⛔ UNREADABLE — a count with no tier after it declares no tier, never a reading', da(DA('75/75')).state === 'unreadable' && da(DA('')).state === 'unreadable'); + t('⭐ ONE parser: the `Served-tier:` reading IS `readServedTier`\'s on the same text, and its verdict `servedTierStands`\'', (() => { const text = DA(`7/7 \`${CONTRACT_REVIEW_TIER_NAME}\``); return JSON.stringify(da(text).served) === JSON.stringify(readServedTier(text)) && servedTierStands(readServedTier(text)); })()); + t('…and the `Analysed-by:` key is built by the one key-line convention, never a second spelling', ANALYSED_BY_LINE.source === keyLineRegex('Analysed-by').source); + t('⛔ NOT AN ANALYSIS — a `Served-tier:` line with neither the facet marker nor an `Analysed-by:` line carries nothing', (() => { const r = da(DA(`\`${CONTRACT_REVIEW_TIER_NAME}\``, null, null)); return r.state === 'at-tier' && !r.analysis && !r.carriesLine; })()); + t('⛔ a `## Contract review` record is never an analysis, whatever it carries — its line is the record\'s', (() => { const r = da(`## Contract review\n\nServed-tier: \`${CONTRACT_REVIEW_TIER_NAME}\`\nAnalysed-by: x\n${DECISION_FACET_MARKER}\n\n**VERDICT: PASS**`); return !r.analysis && !r.carriesLine; })()); + t('⛔ a FENCE quoting another analysis\'s pair and block is a citation: nothing read, no analysis', (() => { const r = da(`A note.\n\n\`\`\`\n${DA(`\`${CONTRACT_REVIEW_TIER_NAME}\``)}\n\`\`\`\n`); return r.state === 'missing' && r.analysedBy.state === 'missing' && !r.analysis; })()); + t('⛔ …and the marker inside an inline span is a quotation too, the reading the handover check gives it', da(`See the \`${DECISION_FACET_MARKER}\` block.\nServed-tier: \`${CONTRACT_REVIEW_TIER_NAME}\``).analysis === false); + t('decoration reads on `Analysed-by:` as on `Reviewed-by:` — a bulleted, bolded key and a backticked value', readAnalysedBy(`- **Analysed-by:** \`${DA_SESSION}\`, the decision thread`).value === DA_SESSION && readAnalysedBy(`> Analysed-by: ${DA_SESSION}.`).value === DA_SESSION); + t('⛔ a model identifier on `Analysed-by:` reads `unreadable` and is NEVER quoted back — the template forbids it', (() => { const r = readAnalysedBy(`Analysed-by: \`${CONTRACT_REVIEW_TIER}\``); return r.state === 'unreadable' && r.line === null && !JSON.stringify(r).includes(CONTRACT_REVIEW_TIER) && readAnalysedBy('Analysed-by: claude-example-9-9').state === 'unreadable'; })()); + t('an empty `Analysed-by:` is started-and-unreadable and quoted through the shared helper; no line is `missing`', readAnalysedBy('Analysed-by:').state === 'unreadable' && readAnalysedBy('Analysed-by:').line.includes('Analysed-by') && readAnalysedBy('no line').state === 'missing'); + t('the line is read anywhere in the text, as on a record — the template asks the AUTHOR for the top', da(`${DA(null, null)}\n\nServed-tier: \`${CONTRACT_REVIEW_TIER_NAME}\``).state === 'at-tier'); + // -- the `Contract-review-handoff:` line -------------------------------------- // // The maintainer's rule: a seat with a working contract-review tier reviews @@ -4198,7 +4304,8 @@ export async function selfTest() { + 'floor read off `hits` onto the `Scope:` line and into the brief, `--paths` included; the pure-regeneration carry and the prose-only carry decided on committed trees in ' + 'every direction; the copyable template, per face, driven back through the ' + 'locator and printed by `--template`; the `Local-runs:` reading — none, one named probe, absent not re-judged, ' - + 'unreadable refused; the reviewer brief printed by `--brief-template` with its read-only shape; the mailbox ' + + 'unreadable refused; a decision analysis\'s `Served-tier:` / `Analysed-by:` pair — at tier, below it, unreadable, missing, ' + + 'with the record\'s own parser, never off a contract review record or out of a fence; the reviewer brief printed by `--brief-template` with its read-only shape; the mailbox ' + 'doorbell — `To: ` then each of the table\'s keys read, the table named both ways in the protocol text and printed by `--mailbox-keys`, and a key with no `To:`, a `To:` naming a login, free text, an acknowledgement, ' + 'a key outside the table, a second line and an over-long line refused; the knock signature listing — `listed` only for a session the seat it names lists on its held post (`Successor-of:` included), its open mailbox opening or its open newest claim\'s `Thread session:` line (one spelling; released, superseded and closed claims drop), a copied signature line `listed` too (consistency, never proof), a maintainer\'s knock exempt, everything else `unverified seat signature` and failing closed; the review claim line — read signed and unsigned, ' + 'spelled verbatim in the rule text, lapsing on a moved head or after two hours, the earliest live claim holding; the review hold ' From 7e107537a4463a6f95dc7424fadabf7da527f664 Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 1 Dec 2026 06:47:29 +0000 Subject: [PATCH 02/10] feat(pm): post-stamped judges --tier-evidence on a decision analysis declaring CONTRACT_REVIEW_TIER Claude-Session: https://claude.ai/code/session_01WGufzfWWgrLkABDvbRjhAk Co-authored-by: Claude --- scripts/pm/post-stamped.mjs | 97 ++++++++++++++++++++++++++++--------- 1 file changed, 75 insertions(+), 22 deletions(-) diff --git a/scripts/pm/post-stamped.mjs b/scripts/pm/post-stamped.mjs index 89d89f12c9d..d26b2e29740 100644 --- a/scripts/pm/post-stamped.mjs +++ b/scripts/pm/post-stamped.mjs @@ -996,7 +996,7 @@ import { CONTRACT_REVIEW_TIER, CONTRACT_REVIEW_TIER_NAME, TIER_DEFAULT, TIER_FLO // The record's `Local-runs:` line is read by the file that owns the record's // every other line — judged when present, an absent line not re-judged. // The mailbox doorbell is read by the same file: a knock's `To:` seat and its key come from `readMailboxLine`. -import { localRunsStand, readLocalRuns, readMailboxLine, readServedTier } from './record-recognisers.mjs'; +import { localRunsStand, readDecisionAnalysisTier, readLocalRuns, readMailboxLine, readServedTier } from './record-recognisers.mjs'; // A record that names `CONTRACT_REVIEW_TIER` is written only on the reviewer's transcript showing every turn served // there: the judge lives in the file that owns it, ⛔ never a copy here. import { verdictText as tierVerdictText, verifyReviewTranscriptFile } from './verify-review-tier.mjs'; @@ -2335,38 +2335,52 @@ export function recordLineRefusalText(rows) { } // --------------------------------------------------------------------------- -// The record's tier — a record naming `CONTRACT_REVIEW_TIER` is written only on evidence that the tier served it +// The record's tier — a record or a decision analysis naming `CONTRACT_REVIEW_TIER` is written only on evidence that the tier served it // --------------------------------------------------------------------------- /** - * Why a `## Contract review` record that names `CONTRACT_REVIEW_TIER` on its `Served-tier:` line cannot be written, - * or `null` when it can. The name is the seat's own declaration and AGENTS.md keeps the model identifier out of the - * comment, so the evidence stays local: `--tier-evidence=PATH` names the reviewing run's transcript (a sub-agent's output file, or a session's own) and - * `verify-review-tier.mjs` must pass on it (every turn served at the tier, no fallback). ⛔ The path and every model - * identifier stay out of the comment, and out of this refusal too. A record naming another tier and every comment - * that is not a record are untouched. Reads the evidence file and nothing else. + * Why a `## Contract review` record — or a DECISION ANALYSIS — that names `CONTRACT_REVIEW_TIER` on its `Served-tier:` + * line cannot be written, or `null` when it can. The name is the seat's own declaration and AGENTS.md keeps the model + * identifier out of the comment, so the evidence stays local: `--tier-evidence=PATH` names the transcript of the run + * that reviewed or analysed (a sub-agent's output file, or a session's own) and `verify-review-tier.mjs` must pass on + * it (every turn served at the tier, no fallback). ⛔ The path and every model identifier stay out of the comment, and + * out of this refusal too. A text naming another tier, and every text that is neither a record nor an analysis, are + * untouched. Reads the evidence file and nothing else. + * + * An analysis is what `readDecisionAnalysisTier` (`record-recognisers.mjs`) calls one — the four-facet marker outside + * code, or an `Analysed-by:` line — and its `Served-tier:` line is that reader's, read with fences blanked: the reading + * the presenting seat's listing gives the same text later (`check-owed-reviews.mjs --decisions`), ⛔ never a second + * parser. `kind` names which of the two the refusal is about. */ export function recordTierEvidenceRefusal(body, tierEvidence) { const text = String(body ?? ''); - if (!CONTRACT_REVIEW_HEADING_MARKER.test(text)) return null; - const served = readServedTier(text); + const record = CONTRACT_REVIEW_HEADING_MARKER.test(text); + const analysis = record ? null : readDecisionAnalysisTier(text); + if (!record && !analysis.analysis) return null; + const served = record ? readServedTier(text) : analysis.served; if (served.state !== 'read' || served.value !== CONTRACT_REVIEW_TIER_NAME) return null; - if (tierEvidence === null || tierEvidence === undefined) return { why: `no --tier-evidence was given — nothing shows this review was served at ${CONTRACT_REVIEW_TIER_NAME}` }; + const kind = record ? 'record' : 'analysis'; + if (tierEvidence === null || tierEvidence === undefined) return { kind, why: `no --tier-evidence was given — nothing shows this ${record ? 'review' : 'analysis'} was served at ${CONTRACT_REVIEW_TIER_NAME}` }; const verdict = verifyReviewTranscriptFile(tierEvidence); - return verdict.ok ? null : { why: tierVerdictText(verdict) }; + return verdict.ok ? null : { kind, why: tierVerdictText(verdict) }; } /** The refusal a caller reads, from `recordTierEvidenceRefusal`; `tool` names the sender, as the signature refusal does. */ export function recordTierEvidenceRefusalText(refusal, { tool = 'post-stamped' } = {}) { + const analysis = refusal?.kind === 'analysis'; + const subject = analysis ? 'decision analysis' : '`## Contract review` record'; + const run = analysis ? 'ANALYSED' : 'REVIEWED'; + const agent = analysis ? 'an analysis' : 'a review'; + const own = analysis ? 'an analysis this session wrote itself (a decision thread, or in-seat)' : 'a review this session ran itself (a card\n thread, or in-seat)'; return ( - `${tool}: REFUSED — this \`## Contract review\` record declares \`Served-tier: ${CONTRACT_REVIEW_TIER_NAME}\` without evidence that passes. Nothing was written.\n` + + `${tool}: REFUSED — this ${subject} declares \`Served-tier: ${CONTRACT_REVIEW_TIER_NAME}\` without evidence that passes. Nothing was written.\n` + ` ${refusal.why}\n\n` + - ` Pass the transcript of the run that REVIEWED, as --tier-evidence=PATH on this ${tool} call: a review sub-agent's\n` + - ' output file (the Agent tool names it when the agent starts), or, for a review this session ran itself (a card\n' + - ' thread, or in-seat), this session\'s own transcript under ~/.claude/projects/ (SESSION.jsonl, every turn of it).\n' + + ` Pass the transcript of the run that ${run}, as --tier-evidence=PATH on this ${tool} call: ${agent} sub-agent's\n` + + ` output file (the Agent tool names it when the agent starts), or, for ${own},\n` + + ' this session\'s own transcript under ~/.claude/projects/ (SESSION.jsonl, every turn of it).\n' + ' The file stays local; neither it nor any model identifier enters the comment. `node scripts/pm/verify-review-tier.mjs\n' + - ' PATH` reads the same verdict. A transcript that refuses means the review did not run at the tier: rerun it with the\n' + - ' tier\'s model passed explicitly, ⛔ never post the record as at-tier and ⛔ never rename its tier to clear this.' + ` PATH\` reads the same verdict. A transcript that refuses means the ${analysis ? 'analysis' : 'review'} did not run at the tier: rerun it with the\n` + + ' tier\'s model passed explicitly, ⛔ never post it as at-tier and ⛔ never rename its tier to clear this.' ); } @@ -3754,7 +3768,7 @@ export function parseOptions(argv) { } const tierEvidence = readOption(args, 'tier-evidence'); if (tierEvidence !== null && comment === null) { - return { ok: false, error: '--tier-evidence belongs to a comment (--comment=N): it is the transcript behind a `## Contract review` record, and a record IS a comment.' }; + return { ok: false, error: '--tier-evidence belongs to a comment (--comment=N): it is the transcript behind a `## Contract review` record or a decision analysis comment. A NEW card whose body is an analysis takes it on issue-create.mjs.' }; } if (tierEvidence === '') { return { ok: false, error: '--tier-evidence= names no file. Pass the reviewing run\'s transcript (a sub-agent\'s output file, or this session\'s own): --tier-evidence=PATH.' }; @@ -4109,7 +4123,7 @@ function rearmThroughProxy(args) { * `main` does, never a copy. `options.mode` is `comment` or `body`; `nowMs` is the clock the stamp substitutes; * `tool` names the sender in the signature refusal. Answers `{ ok: true, rendered }`, or `{ ok: false, rendered, * text }` — `text` is what the caller prints before it exits refused with nothing written. Pure but for one read: the - * `options.tierEvidence` transcript, read only when the body is a record that names `CONTRACT_REVIEW_TIER`. + * `options.tierEvidence` transcript, read only when the body is a record or a decision analysis that names `CONTRACT_REVIEW_TIER`. */ export function judgeBody(input, options = {}, nowMs = Date.now(), tool = 'post-stamped') { const rendered = renderBody(input, nowMs); @@ -4125,7 +4139,7 @@ export function judgeBody(input, options = {}, nowMs = Date.now(), tool = 'post- // The record's line, on the same act and with the same scope: a record IS a comment. const record = options.mode === 'comment' ? recordKeyedLineRefusals(rendered.body) : []; if (record.length > 0) return { ok: false, rendered, text: recordLineRefusalText(record) }; - // The record's tier, on the same act: a record naming `CONTRACT_REVIEW_TIER` carries local evidence that passes. + // The record's tier, on the same act: a record or a decision analysis naming `CONTRACT_REVIEW_TIER` carries local evidence that passes. const tier = options.mode === 'comment' ? recordTierEvidenceRefusal(rendered.body, options.tierEvidence ?? null) : null; if (tier !== null) return { ok: false, rendered, text: recordTierEvidenceRefusalText(tier, { tool }) }; // ⛔ Comments only: a decision analysis is anchored on its card AS A COMMENT, and the handover check reads comments. @@ -4174,7 +4188,8 @@ const USAGE = [ ' A `## Contract review` comment\'s `Local-runs:` line is read the same way when it is present (`none`, or', ' `probe — REASON`); a record without the line is not re-judged. A record whose `Served-tier:` names', ' `CONTRACT_REVIEW_TIER` is REFUSED unless --tier-evidence=PATH names the reviewing run\'s transcript and', - ' `verify-review-tier.mjs` passes on it; the path and the model stay local, out of the comment.', + ' `verify-review-tier.mjs` passes on it; the path and the model stay local, out of the comment. A decision', + ' analysis (the four-facet marker outside code, or an `Analysed-by:` line) naming it is judged the same way.', ' A comment that is a decision analysis — a decision frame, an options table or lettered options, and a', ` recommendation naming one — is REFUSED when it carries no \`${DECISION_FACET_MARKER}\` marker outside code; the`, ' refusal prints the four-facet block it owes. Card bodies and every other route are untouched.', @@ -4440,6 +4455,7 @@ const SELF_TEST_BATTERIES = Object.freeze({ 'the one judge: every body refusal on ONE path — `main` and `label-write.mjs --comment-file` call `judgeBody`, never a copy': 14, 'the review route: a `Request: contract-review` knock addressed to triage is refused; to a review or sibling seat, and every other key to triage, it passes': 13, 'the record tier: a record naming `CONTRACT_REVIEW_TIER` is written only on a transcript `verify-review-tier.mjs` passes; another tier and a non-record comment are untouched': 16, + 'the analysis tier: a decision analysis naming `CONTRACT_REVIEW_TIER` is written only on a transcript `verify-review-tier.mjs` passes, read by the listing\'s own reader; another tier, no line, a quotation and a non-analysis are untouched': 12, 'the claim stroke: a comment opening `Claim:` is refused on every route but `direct`, pointing at the `label-write` fold; the same body through that fold passes': 21, }); const SELF_TEST_BATTERY_FLOOR = 30; @@ -6180,6 +6196,43 @@ export function selfTest() { } } + battery('the analysis tier: a decision analysis naming `CONTRACT_REVIEW_TIER` is written only on a transcript `verify-review-tier.mjs` passes, read by the listing\'s own reader; another tier, no line, a quotation and a non-analysis are untouched'); + { + const SIG = 'repo:objectstack@os-example · os-example · session_01AnalysisWriterFixture7Q'; + const OTHER = 'other-model-for-the-self-test'; + const ANALYSIS = (served, { by = '`session_01AnalysisWriterFixture7Q`', marker = true, fence = false } = {}) => { + const pair = [...(served === null ? [] : [`Served-tier: \`${served}\``]), ...(by === null ? [] : [`Analysed-by: ${by}`])]; + return [SIG, '## 决策:空闲清理放在哪一层', '', ...(fence ? ['```', ...pair, '```'] : pair), '', 'Background prose.', + ...(marker ? ['', DECISION_FACET_MARKER, '- ① 项目长远合理性:不扩大特例。', '- ② 实际业务拉动:今天谁撞上。', '- ③ 防 AI 犯错:响亮拒绝。', '- ④ 创业阶段不扩散:不新增面。', 'Prior rulings read: 清理 → 0 hits; ADR none; thread: none'] : [])].join('\n'); + }; + const turn = (model) => JSON.stringify({ type: 'assistant', requestedModel: model, message: { role: 'assistant', model, content: [] } }); + const dir = mkdtempSync(join(tmpdir(), 'post-stamped-analysis-tier-')); + try { + const atTier = join(dir, 'at-tier.output'); + const offTier = join(dir, 'off-tier.output'); + writeFileSync(atTier, [JSON.stringify({ type: 'user', message: { role: 'user', content: 'analyse' } }), turn(CONTRACT_REVIEW_TIER), turn(CONTRACT_REVIEW_TIER)].join('\n')); + writeFileSync(offTier, [turn(CONTRACT_REVIEW_TIER), turn(OTHER)].join('\n')); + const judged = (body, tierEvidence) => judgeBody(body, { mode: 'comment', tierEvidence }, NOW_MS); + const none = judged(ANALYSIS(CONTRACT_REVIEW_TIER_NAME), null); + t('⛔ an analysis declaring CONTRACT_REVIEW_TIER with no --tier-evidence is refused, and the refusal says it is an analysis', !none.ok && none.text.startsWith('post-stamped: REFUSED — this decision analysis') && none.text.includes('--tier-evidence') && none.text.includes('ANALYSED')); + t('⭐ …and the same analysis passes on a transcript served at the tier throughout', judged(ANALYSIS(CONTRACT_REVIEW_TIER_NAME), atTier).ok); + const off = judged(ANALYSIS(CONTRACT_REVIEW_TIER_NAME), offTier); + t('⛔ a transcript with one turn served off the tier is refused', !off.ok && off.text.includes('REFUSED')); + t('⛔ no refusal text carries a model identifier or the evidence path', [none, off].every((r) => !String(r.text).includes(CONTRACT_REVIEW_TIER) && !String(r.text).includes(OTHER) && !String(r.text).includes(dir))); + t('⛔ a delta re-analysis carrying the pair and no facet block is an analysis by its `Analysed-by:` line, and judged', !judged(ANALYSIS(CONTRACT_REVIEW_TIER_NAME, { marker: false }), null).ok && judged(ANALYSIS(CONTRACT_REVIEW_TIER_NAME, { marker: false }), atTier).ok); + t('⭐ an analysis declaring TIER_DEFAULT is untouched, with no evidence', judged(ANALYSIS('TIER_DEFAULT'), null).ok); + t('⭐ an analysis carrying no `Served-tier:` line is untouched here (the listing reads it `missing`)', judged(ANALYSIS(null), null).ok); + t('⭐ the pair quoted inside a FENCE is a citation, not a declaration: untouched', judged(ANALYSIS(CONTRACT_REVIEW_TIER_NAME, { fence: true }), null).ok); + t('⭐ a note carrying the line with neither the facet marker nor an `Analysed-by:` line is no analysis: untouched', judged(ANALYSIS(CONTRACT_REVIEW_TIER_NAME, { by: null, marker: false }), null).ok); + t('the refusal names the sender it was handed — the label-write fold judges an analysis on this same path', (() => { const lw = judgeBody(ANALYSIS(CONTRACT_REVIEW_TIER_NAME), { mode: 'comment' }, NOW_MS, 'label-write'); return !lw.ok && lw.text.startsWith('label-write: REFUSED — this decision analysis'); })()); + t('⛔ a card BODY refresh is not judged here — a new card\'s body is, by issue-create.mjs --tier-evidence (the stated bound)', judgeBody(ANALYSIS(CONTRACT_REVIEW_TIER_NAME), { mode: 'body' }, NOW_MS).ok); + const own = readFileSync(SELF_PATH, 'utf8'); + t('structural: the analysis reading is `readDecisionAnalysisTier`, imported from record-recognisers.mjs — ⛔ no second reader of the pair here', /import \{[^}]*\breadDecisionAnalysisTier\b[^}]*\} from '\.\/record-recognisers\.mjs';/u.test(own) && !/function\s+(readDecisionAnalysisTier|readAnalysedBy)\b/u.test(own)); + } finally { + rmSync(dir, { recursive: true, force: true }); + } + } + // The floor, evaluated last: a battery that stops running names itself here. const failed = cases.filter((c) => !c.ok); for (const c of cases) console.log(` ${c.ok ? '✓' : '✗'} ${c.name}`); From 0ca0f59ea0d9040781d157e53164d7361a27ccb3 Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 1 Dec 2026 06:48:29 +0000 Subject: [PATCH 03/10] feat(pm): issue-create judges --tier-evidence on a card body that is an at-tier decision analysis Claude-Session: https://claude.ai/code/session_01WGufzfWWgrLkABDvbRjhAk Co-authored-by: Claude --- scripts/pm/issue-create.mjs | 62 ++++++++++++++++++++++++++++++++++--- 1 file changed, 58 insertions(+), 4 deletions(-) diff --git a/scripts/pm/issue-create.mjs b/scripts/pm/issue-create.mjs index d51b2a50d38..08d4ae19f90 100644 --- a/scripts/pm/issue-create.mjs +++ b/scripts/pm/issue-create.mjs @@ -6,6 +6,7 @@ * * node scripts/pm/issue-create.mjs --repo owner/name --title-file title.txt --body-file body.md [--label L]… [--assignee A]… [--json] * node scripts/pm/issue-create.mjs --title 'A short title' --body-file body.md --dry-run + * node scripts/pm/issue-create.mjs --title-file t.txt --body-file analysis.md --tier-evidence=PATH # a card whose body is an at-tier decision analysis * node scripts/pm/issue-create.mjs --self-test # offline, a fake platform, no network at all * * ## Why this file exists @@ -40,7 +41,14 @@ * (`check-half-states.mjs`, whose banner carries the shape and the ruling), * listed beside the token refusal when both apply. Every card this door * creates is seat-authored: the workflow-generated cards are written by - * their workflows, never through here. + * their workflows, never through here; + * - a body that is a DECISION ANALYSIS declaring `Served-tier: + * CONTRACT_REVIEW_TIER` with no `--tier-evidence=PATH`, or with one + * `verify-review-tier.mjs` refuses — `recordTierEvidenceRefusal` + * (`post-stamped.mjs`), the judge a comment meets, imported and ⛔ never + * restated. The transcript stays local; neither it nor a model identifier + * enters the card. A body that is not an analysis, or names another tier, + * is untouched. * * ## The transport — `OS_FLEET_TRANSPORT` direct | dispatch | auto * @@ -107,7 +115,10 @@ import process from 'node:process'; import { fileURLToPath } from 'node:url'; import { isEntrypoint } from '../invoked-as.mjs'; -import { EXIT_PREREQUISITE_NOT_MET, PROXY_FLAG, SEAT_SIGNATURE_SHAPE, proxyRearmPlan, resolveSweepRepo, signatureRefusal } from './check-half-states.mjs'; +import { DECISION_FACET_MARKER, EXIT_PREREQUISITE_NOT_MET, PROXY_FLAG, SEAT_SIGNATURE_SHAPE, proxyRearmPlan, resolveSweepRepo, signatureRefusal } from './check-half-states.mjs'; +import { recordTierEvidenceRefusal, recordTierEvidenceRefusalText } from './post-stamped.mjs'; +// The self-test's transcript fixtures name the tier by the constants' own values, ⛔ never a spelled model id. +import { CONTRACT_REVIEW_TIER, CONTRACT_REVIEW_TIER_NAME } from './dispatch-gates.mjs'; import { EXIT_UNCONFIRMED, exitForResult, matchRunAnnotations, packRequest, parseRelayAnnotation, relayAnnotationMessage, resolveRoute, retiredLaneRewriteLine, rewriteRetiredLaneLabels, sendFleetWrite, unconfirmedText } from './fleet-write/dispatch.mjs'; import { refusalText as relayRefusalText } from './fleet-write/validate.mjs'; import { KIND_ISSUE, KIND_RULE_AWAITING_MERGE_PR_ONLY, classifyHttp, refuseKindLabels } from './label-write.mjs'; @@ -132,7 +143,7 @@ const STAMP_TOKEN = /\{\{(?:NOW|WAS:)/; // --------------------------------------------------------------------------- export function parseArgs(argv) { - const opts = { repo: null, title: null, titleFile: null, bodyFile: null, labels: [], assignees: [], json: false, dryRun: false, selfTest: false, help: false, unknown: [], errors: [] }; + const opts = { repo: null, title: null, titleFile: null, bodyFile: null, tierEvidence: null, labels: [], assignees: [], json: false, dryRun: false, selfTest: false, help: false, unknown: [], errors: [] }; const args = [...argv]; const value = (flag) => { const v = args.shift(); @@ -152,6 +163,7 @@ export function parseArgs(argv) { else if (a === '--title') opts.title = value(a); else if (a === '--title-file') opts.titleFile = value(a); else if (a === '--body-file') opts.bodyFile = value(a); + else if (a === '--tier-evidence') opts.tierEvidence = value(a); else if (a === '--label') { const v = value(a); if (v !== null) opts.labels.push(v); @@ -225,6 +237,12 @@ export function planFrom(opts, { read = (p) => readFileSync(p, 'utf8'), env = pr // The signature (#27113), judged beside the token rule so a body breaking both hears both. const unsigned = signatureRefusal(body); if (unsigned !== null) errors.push(`the body carries no signature line — ${unsigned.why}; its first line reads \`${unsigned.line}\`. Write ${SEAT_SIGNATURE_SHAPE} as the FIRST line; nothing inserts it for you`); + // A decision analysis at the contract-review tier carries local evidence that passes — post-stamped's own judge (header). + if (opts.tierEvidence === '') errors.push('--tier-evidence= names no file. Pass the analysing run\'s transcript (a sub-agent\'s output file, or this session\'s own): --tier-evidence=PATH'); + else { + const tier = recordTierEvidenceRefusal(body, opts.tierEvidence ?? null); + if (tier !== null) errors.push(recordTierEvidenceRefusalText(tier, { tool: 'issue-create' })); + } } } @@ -460,6 +478,7 @@ const SELF_TEST_BATTERIES = Object.freeze({ 'the relay transport: ONE dispatch carrying the create, the card found by title since the dispatch, and an accepted dispatch with no run UNCONFIRMED under auto too — never the direct POST': 9, 'the retired lane aliases: a domain:engine / services / cli / rest --label is sent as domain:server on either transport, the dry run and the read-back say so, a live domain:* label passes untouched, and nothing is refused': 8, "the relay annotation: the number the relay run's annotation carries is read first — the card read back at it with NO list; absent, the title finds it as before; the read-back still judges the annotated card": 5, + 'the analysis tier: a card body that is a decision analysis declaring CONTRACT_REVIEW_TIER is planned only on a transcript verify-review-tier.mjs passes — post-stamped\'s own judge; another tier and a body that is no analysis are untouched': 8, }); const SELF_TEST_BATTERY_FLOOR = 9; const UNATTRIBUTED_BATTERY = '(unattributed)'; @@ -534,6 +553,38 @@ export async function selfTest() { t('a body carrying a stamp token is refused — that is post-stamped\'s contract', planFrom(parseArgs(['--title', 'x', '--body-file', 'stamped.md']), { read, env }).errors.some((e) => e.includes('{{NOW}}'))); } + // ── the analysis tier ───────────────────────────────────────────────────── + battery('the analysis tier: a card body that is a decision analysis declaring CONTRACT_REVIEW_TIER is planned only on a transcript verify-review-tier.mjs passes — post-stamped\'s own judge; another tier and a body that is no analysis are untouched'); + { + const tierDir = mkdtempSync(join(tmpdir(), 'issue-create-tier-')); + try { + const turn = (model) => JSON.stringify({ type: 'assistant', requestedModel: model, message: { role: 'assistant', model, content: [] } }); + const atTier = join(tierDir, 'at-tier.output'); + const offTier = join(tierDir, 'off-tier.output'); + writeFileSync(atTier, [JSON.stringify({ type: 'user', message: { role: 'user', content: 'analyse' } }), turn(CONTRACT_REVIEW_TIER), turn(CONTRACT_REVIEW_TIER)].join('\n')); + writeFileSync(offTier, [turn(CONTRACT_REVIEW_TIER), turn('other-model-for-the-self-test')].join('\n')); + const analysis = (tier) => `${SIG}\n## 维护者速读\n- 问题:一句话。\n\nServed-tier: \`${tier}\`\nAnalysed-by: \`session_01AnalysisFixture9Qx\`\n\n${DECISION_FACET_MARKER}\n- ① 项目长远合理性:不扩大特例。\n`; + const tierFiles = { 't.txt': 'A decision card', 'at.md': analysis(CONTRACT_REVIEW_TIER_NAME), 'default.md': analysis('TIER_DEFAULT'), 'plain.md': `${SIG}\nA note: Served-tier: \`${CONTRACT_REVIEW_TIER_NAME}\` is what analyses carry.\n` }; + const tierRead = (p) => { + if (!(p in tierFiles)) throw new Error('ENOENT'); + return tierFiles[p]; + }; + const plan = (...extra) => planFrom(parseArgs(['--title-file', 't.txt', '--body-file', ...extra]), { read: tierRead, env }); + const none = plan('at.md'); + t('⛔ an at-tier analysis body with no --tier-evidence is refused before any request, naming the analysis and the option', !none.ok && none.errors.some((e) => e.startsWith('issue-create: REFUSED — this decision analysis') && e.includes('--tier-evidence'))); + t('⭐ …and the same body is planned on a transcript served at the tier throughout', plan('at.md', `--tier-evidence=${atTier}`).ok, true, plan('at.md', `--tier-evidence=${atTier}`).errors.join(' | ')); + t('⛔ a transcript with one turn off the tier is refused', plan('at.md', '--tier-evidence', offTier).ok, false); + t('⛔ no refusal carries a model identifier or the evidence path', [none, plan('at.md', '--tier-evidence', offTier)].every((p) => !p.errors.join(' ').includes(CONTRACT_REVIEW_TIER) && !p.errors.join(' ').includes(tierDir))); + t('⭐ an analysis body at TIER_DEFAULT is untouched, with no evidence', plan('default.md').ok); + t('⭐ a body that is no analysis is untouched, with no evidence', plan('plain.md').ok); + t('⛔ --tier-evidence= with no path is refused, never read as absent', plan('default.md', '--tier-evidence=').errors.some((e) => e.includes('names no file'))); + const own = readReal(SELF_PATH, 'utf8'); + t('structural: the judge is post-stamped.mjs\'s, imported — ⛔ never restated here', /import \{[^}]*\brecordTierEvidenceRefusal\b[^}]*\} from '\.\/post-stamped\.mjs';/u.test(own) && !/function\s+(recordTierEvidenceRefusal|readDecisionAnalysisTier)\b/u.test(own)); + } finally { + rmSync(tierDir, { recursive: true, force: true }); + } + } + // ── the signature ───────────────────────────────────────────────────────── battery('the signature: a card body opens with the seat\'s signature line, or the plan is refused before any request'); { @@ -800,7 +851,7 @@ export async function selfTest() { const USAGE = [ 'usage:', ' node scripts/pm/issue-create.mjs [--repo owner/name] (--title-file | --title ) --body-file ', - ' [--label ]… [--assignee ]… [--json] [--dry-run]', + ' [--label ]… [--assignee ]… [--tier-evidence=PATH] [--json] [--dry-run]', ' node scripts/pm/issue-create.mjs --self-test', '', ' The body comes from a file, always; the title from a file by preference. A batch of N ≥ 5 cards is', @@ -808,6 +859,9 @@ const USAGE = [ ' OS_FLEET_TRANSPORT=direct|dispatch|auto (default auto): dispatch sends the create through the fleet-write relay as', " objectstack-fleet[bot]; auto takes it in a cloud seat container (the seat's session is read from the container's", ' CLAUDE_CODE_REMOTE_SESSION_ID; OS_FLEET_SESSION overrides it — a local checkout, a test) and direct elsewhere.', + ' A body that is a decision analysis (the four-facet marker outside code, or an `Analysed-by:` line) declaring', + ' `Served-tier: CONTRACT_REVIEW_TIER` is REFUSED unless --tier-evidence=PATH names the analysing run\'s transcript and', + ' `verify-review-tier.mjs` passes on it — the judge post-stamped.mjs gives a comment; the path stays local.', ` Exits: 0 created and read back · ${EXIT_USAGE} usage · ${EXIT_PREREQUISITE} prerequisite · ${EXIT_READ_BACK_MISMATCH} read-back mismatch · ${EXIT_PLATFORM_REFUSAL} platform refused · ${EXIT_UNCONFIRMED} dispatched but UNCONFIRMED · ${EXIT_WRITE_PACE_REFUSED} throttle refused`, ].join('\n'); From b3a385a53eb728689ca9c8cfc9d4c0f38436df0f Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 1 Dec 2026 06:51:04 +0000 Subject: [PATCH 04/10] feat(pm): check-owed-reviews --decisions lists each decision card's analysis tier, carrier and currency Claude-Session: https://claude.ai/code/session_01WGufzfWWgrLkABDvbRjhAk Co-authored-by: Claude --- scripts/pm/check-owed-reviews.mjs | 211 +++++++++++++++++++++++++++++- 1 file changed, 208 insertions(+), 3 deletions(-) diff --git a/scripts/pm/check-owed-reviews.mjs b/scripts/pm/check-owed-reviews.mjs index a35ce8f7f3b..54916b021cd 100644 --- a/scripts/pm/check-owed-reviews.mjs +++ b/scripts/pm/check-owed-reviews.mjs @@ -6,6 +6,7 @@ * included, whose face owes a contract review, and whether anybody is doing it. * * node scripts/pm/check-owed-reviews.mjs [--repo OWNER/NAME] [--board OWNER/NAME] [--now ISO] [--json] + * node scripts/pm/check-owed-reviews.mjs --decisions [--repo OWNER/NAME] [--json] # the decision box: each analysis's tier * node scripts/pm/check-owed-reviews.mjs --self-test # offline, no network * node scripts/pm/check-owed-reviews.mjs --help * @@ -97,6 +98,31 @@ * barred): it reaches the L2 seat the one way this reader can read, * a hand-off line naming it. ⛔ Never triage. * + * ## `--decisions` — the other review a presenting seat owes: a decision analysis at the tier + * + * `references/decision-analysis.md` 〈落卡分析模板〉 asks every decision analysis to open its English part with + * `Served-tier:` and `Analysed-by:`, and the presenting seat to read that line before it presents: missing or + * below the tier ⇒ re-run at the tier; at the tier and still current ⇒ presented as it stands, its premise + * re-checked. `--decisions` is that reading for every open `needs-user-decision` card, one row each: + * + * tier `readDecisionAnalysisTier` (`record-recognisers.mjs`, the record's own `Served-tier:` parser) on + * the NEWEST text on the card that carries a line of the pair — the body, or a comment (a delta + * re-analysis is newer than the body it re-runs): `at-tier`, `below-tier`, `unreadable`, `missing` + * (no line anywhere; the row says whether the card carries an analysis at all), or `unjudged` (the + * thread could not be read). Read through the queue guard's author binding, as records are: a body + * or comment by any other author is never the carrier, and the drops are counted on the row. + * carrier the comment id that carries the line, or `body`. + * current whether the analysis is still the card's question: `stale` when a ruling comment + * (`classifyRulingComment`, the prior-rulings reader's three measured shapes) follows the carrier, + * when the body carries a `Ruled:` record (`ruledRecords`) at or after it, or, for a comment + * carrier, when the body's newest protocol stamp (`lastWriteStamp`) is at or after its minute — a + * body written since. ⚠️ A body edit that writes no stamp is NOT seen: the REST issue carries no + * body-edit time (`check-half-states.mjs` states the measurement), so `current` is the strongest + * reading REST allows, and the premise re-check the rule orders is what covers the rest. An + * unstamped `Ruled:` record counts as after (the safe direction). + * act `present as it stands, premise re-check` on an `at-tier` and `current` row; every other row + * `re-run at tier before presenting`. The verdict stays the seat's, under the rule text. + * * ## Report-only — the exit is 0 on every completed or incomplete read * * ⛔ Not a gate (the skill's 「新增门禁默认否」): it reads, prints and exits 0, @@ -110,7 +136,9 @@ import process from 'node:process'; import { isEntrypoint } from '../invoked-as.mjs'; -import { cardIntakeKeys, CONTRACT_REVIEW_HEADING_MARKER, contractReviewVerdictLines, latestMarkedComment, readSignatureLine, seatNameId, seatIntakeKeys, signedSeatId, withSeatNumbers } from './check-half-states.mjs'; +import { cardIntakeKeys, CONTRACT_REVIEW_HEADING_MARKER, contractReviewVerdictLines, DECISION_INBOX_LABEL, latestMarkedComment, readSignatureLine, ruledRecords, seatNameId, seatIntakeKeys, signedSeatId, withSeatNumbers } from './check-half-states.mjs'; +import { classifyRulingComment } from './check-prior-rulings.mjs'; +import { lastWriteStamp } from './post-stamped.mjs'; import { repoIdForSlug } from './check-governed-merges.mjs'; import { GOVERNED_APPROVERS, NARROWING_FACE_LINE, narrowingDeclarationsIn, recordAuthorTrusted, recordTrustedAuthors } from './check-governed-queue-guard.mjs'; import { FLEET_BOT_LOGIN } from './check-handover.mjs'; @@ -128,6 +156,7 @@ import { contractReviewHold, deliveredCardNumber, locateReviewOfRecord, + readDecisionAnalysisTier, reviewFace, } from './record-recognisers.mjs'; @@ -158,7 +187,7 @@ const labelNames = (x) => (Array.isArray(x?.labels) ? x.labels.map((l) => (typeo // --------------------------------------------------------------------------- export function parseArgs(argv) { - const opts = { repo: DEFAULT_REPO, board: null, now: null, json: false, selfTest: false, help: false, errors: [] }; + const opts = { repo: DEFAULT_REPO, board: null, now: null, json: false, decisions: false, selfTest: false, help: false, errors: [] }; const args = [...argv]; const value = (flag) => { const v = args.shift(); @@ -182,6 +211,7 @@ export function parseArgs(argv) { if (v !== null && !Number.isFinite(Date.parse(v))) opts.errors.push(`--now takes an ISO time, not ${v}`); else if (v !== null) opts.now = v; } else if (a === '--json') opts.json = true; + else if (a === '--decisions') opts.decisions = true; else if (a === '--self-test') opts.selfTest = true; else if (a === '--help' || a === '-h') opts.help = true; else opts.errors.push(`unknown argument ${a}`); @@ -525,6 +555,110 @@ export function renderReport(rows, { repo, now, read, gaps }) { return lines; } +// --------------------------------------------------------------------------- +// `--decisions` — the decision box, one row per card: the analysis's tier, its carrier, whether it is current +// --------------------------------------------------------------------------- + +/** The tier states, re-run owed first; `unjudged` last of the owed (the thread was not read, nothing is claimed). */ +export const DECISION_TIER_ORDER = Object.freeze(['missing', 'unreadable', 'below-tier', 'unjudged', 'at-tier']); +/** What the rule text has the presenting seat do with a row (`references/decision-analysis.md` 〈落卡分析模板〉). */ +export const DECISION_ACT_PRESENT = 'present as it stands, premise re-check'; +export const DECISION_ACT_RERUN = 're-run at tier before presenting'; + +const createdMs = (row) => { + const at = Date.parse(String(row?.created_at ?? '')); + return Number.isFinite(at) ? at : Number.POSITIVE_INFINITY; // unreadable ⇒ newest, never silently old +}; +const byThreadOrder = (a, b) => createdMs(a) - createdMs(b) || Number(a?.id) - Number(b?.id); +const minuteFloor = (ms) => Math.floor(ms / 60000) * 60000; + +/** + * Whether the analysis on `carrier` is still the card's question — the reasons it is not, empty when it is. Pure. + * The bound (an unstamped body edit is unseen) is the header's. + */ +export function decisionCurrency(card, comments, carrier) { + const reasons = []; + const at = carrier.where === 'body' ? Number.NEGATIVE_INFINITY : createdMs(carrier.row); + const after = carrier.where === 'body' ? comments : comments.filter((c) => byThreadOrder(c, carrier.row) > 0); + const ruling = after.find((c) => classifyRulingComment(c?.body) !== null); + if (ruling) reasons.push(`ruling comment ${ruling.id ?? '?'} after it`); + const ruled = ruledRecords(card?.body ?? '').find((r) => r.at === null || r.at >= minuteFloor(at)); + if (ruled) reasons.push(`body \`Ruled: ${ruled.id}\`${ruled.at === null ? ' (unstamped)' : ''} at or after it`); + if (carrier.where === 'comment') { + const stamp = lastWriteStamp(card?.body ?? ''); + if (stamp.from !== null && stamp.from >= minuteFloor(at)) reasons.push(`body stamp \`${stamp.stamp}\` at or after it`); + } + return { state: reasons.length === 0 ? 'current' : 'stale', reasons }; +} + +/** + * One row for one decision card. Pure. `comments` null means the thread could not be read: `unjudged`, ⛔ never + * `missing`. Body and comments are read only from `trusted` authors, as records are. + */ +export function decisionAnalysisRow(card, comments, trusted = RECORD_AUTHORS) { + const base = { card: card?.number ?? null, title: String(card?.title ?? '') }; + if (!Array.isArray(comments)) return { ...base, state: 'unjudged', analysis: null, carrier: null, analysedBy: null, current: null, act: DECISION_ACT_RERUN, ignored: 0, bodyRead: false }; + const kept = comments.filter((c) => recordAuthorTrusted(c, trusted)).sort(byThreadOrder); + const bodyRead = recordAuthorTrusted(card, trusted); + const texts = [ + ...(bodyRead ? [{ where: 'body', id: null, row: card, reading: readDecisionAnalysisTier(card.body) }] : []), + ...kept.map((c) => ({ where: 'comment', id: c.id ?? null, row: c, reading: readDecisionAnalysisTier(c.body) })), + ]; + const carrier = [...texts].reverse().find((x) => x.reading.carriesLine) ?? null; + const state = carrier === null ? 'missing' : carrier.reading.state; + const current = carrier === null ? null : decisionCurrency(card, kept, carrier); + const by = carrier?.reading.analysedBy; + return { + ...base, + state, + analysis: texts.some((x) => x.reading.analysis), + carrier: carrier === null ? null : { where: carrier.where, id: carrier.id, at: carrier.row?.created_at ?? null }, + analysedBy: by === undefined ? null : by.state === 'read' ? by.value : by.state, + current, + act: state === 'at-tier' && current?.state === 'current' ? DECISION_ACT_PRESENT : DECISION_ACT_RERUN, + ignored: comments.length - kept.length, + bodyRead, + }; +} + +/** Every decision row, re-run owed first, then at tier but stale, then present-as-it-stands; by card number. Pure. */ +export function decisionRows(snapshot) { + const rows = (snapshot?.cards ?? []).map((c) => decisionAnalysisRow(c, c.comments)); + const rank = (r) => DECISION_TIER_ORDER.indexOf(r.state) * 2 + (r.act === DECISION_ACT_PRESENT ? 1 : 0); + return rows.sort((a, b) => rank(a) - rank(b) || a.card - b.card); +} + +/** One printed line for one decision row. Pure. */ +export function renderDecisionRow(row) { + const where = row.carrier === null ? null : row.carrier.where === 'body' ? 'line in the body' : `line on comment ${row.carrier.id}`; + const parts = [`#${row.card} ${row.state}`]; + if (row.state === 'unjudged') parts.push('thread not read'); + else if (row.carrier === null) parts.push(row.analysis ? 'analysis carries no Served-tier / Analysed-by line' : 'no analysis found on the card'); + else parts.push(`${where} (Analysed-by ${row.analysedBy})`, row.current.state === 'current' ? 'current' : `stale: ${row.current.reasons.join('; ')}`); + const dropped = row.ignored > 0 || (row.bodyRead === false && row.state !== 'unjudged') ? ` (${row.bodyRead ? '' : 'body by an untrusted author not read; '}${row.ignored} comment(s) by an untrusted author not read)` : ''; + return `${parts.join(' · ')} → ${row.act}${dropped} · ${row.title}`; +} + +/** The printed decision report. Pure. */ +export function renderDecisionReport(rows, { repo, now, gaps }) { + const n = (pred) => rows.filter(pred).length; + const present = n((r) => r.act === DECISION_ACT_PRESENT); + const lines = [ + `check-owed-reviews --decisions — ${repo}, ${new Date(now).toISOString().replace(/:\d\d\.\d{3}Z$/, 'Z')}: ${rows.length} open \`${DECISION_INBOX_LABEL}\` card(s); ` + + `${present} at tier and current (${DECISION_ACT_PRESENT}), ${rows.length - present} to re-run at tier — ` + + `${n((r) => r.state === 'at-tier') - present} at tier but stale, ${n((r) => r.state === 'below-tier')} below tier, ${n((r) => r.state === 'missing')} missing, ${n((r) => r.state === 'unreadable')} unreadable, ${n((r) => r.state === 'unjudged')} unjudged.`, + '', + ...rows.map(renderDecisionRow), + ]; + if (gaps.length > 0) lines.push('', `⚠️ sweep INCOMPLETE — ${gaps.length} read(s) failed; the rows above are not the whole answer:`, ...gaps.map((g) => ` - ${g}`)); + lines.push( + '', + '`current` reads ruling comments, `Ruled:` records and the body\'s newest stamp; a body edit that writes no stamp is not seen (REST carries no body-edit time) — the premise re-check covers it.', + 'Report-only: exit 0, nothing written. The rule is `references/decision-analysis.md` 〈落卡分析模板〉.', + ); + return lines; +} + // --------------------------------------------------------------------------- // The live read — every read through one injected `get`, so the self-test drives it offline // --------------------------------------------------------------------------- @@ -583,8 +717,25 @@ export function readSnapshot({ repo, board, get = ghApi }) { return { repo, pulls, seats, gaps }; } +/** + * Read the decision box into the snapshot `decisionRows` takes: every open `needs-user-decision` issue and its + * thread. ⛔ A failed thread read is a GAP and its card reads `unjudged`; a failed listing is the whole sweep's gap. + */ +export function readDecisionSnapshot({ repo, get = ghApi }) { + const listed = readAllPages(`/repos/${repo}/issues?state=open&labels=${encodeURIComponent(DECISION_INBOX_LABEL)}`, { get }); + if (!listed.ok) return { repo, cards: [], gaps: [`the open \`${DECISION_INBOX_LABEL}\` list (${listed.error})`] }; + const gaps = []; + const cards = listed.value.filter((issue) => !issue.pull_request).map((issue) => { + const thread = readAllPages(`/repos/${repo}/issues/${issue.number}/comments`, { get }); + if (!thread.ok) gaps.push(`#${issue.number}: comments (${thread.error})`); + return { ...issue, comments: thread.ok ? thread.value : null }; + }); + return { repo, cards, gaps }; +} + const USAGE = [ 'usage: node scripts/pm/check-owed-reviews.mjs [--repo OWNER/NAME] [--board OWNER/NAME] [--now ISO] [--json]', + ' node scripts/pm/check-owed-reviews.mjs --decisions [--repo OWNER/NAME] [--now ISO] [--json]', ' node scripts/pm/check-owed-reviews.mjs --self-test | --help', '', ' Lists the open pull requests, drafts included, whose face owes a contract review, with the record,', @@ -593,6 +744,9 @@ const USAGE = [ ' the tier or by a hand-off line — the L2 seat is the fallback, never the default; never triage.', ` --repo the repository whose pulls are read (default ${DEFAULT_REPO}); --board, where the seat posts live`, ' --now the clock (default: now); --json prints the rows as JSON', + ' --decisions instead: each open needs-user-decision card\'s analysis tier (at-tier / below-tier / unreadable /', + ' missing), the comment that carries the line, and whether it is still current — at tier and current is', + ' presented as it stands with a premise re-check, every other row is re-run at the tier first', ' Report-only: reads through `gh api`, writes nothing, exits 0 on every read; 2 on a usage error.', ].join('\n'); @@ -608,6 +762,13 @@ export function main(argv, { get = ghApi, log = console.log, error = console.err return EXIT_OK; } const now = opts.now === null ? Date.now() : Date.parse(opts.now); + if (opts.decisions) { + const box = readDecisionSnapshot({ repo: opts.repo, get }); + const rows = decisionRows(box); + if (opts.json) log(JSON.stringify({ repo: opts.repo, now: new Date(now).toISOString(), gaps: box.gaps, rows }, null, 2)); + else for (const line of renderDecisionReport(rows, { repo: opts.repo, now, gaps: box.gaps })) log(line); + return EXIT_OK; + } const snapshot = readSnapshot({ repo: opts.repo, board: opts.board, get }); const rows = owedReviewRows(snapshot, { now }); const read = { pulls: snapshot.pulls.length, drafts: snapshot.pulls.filter((p) => p.draft === true).length }; @@ -645,6 +806,8 @@ const SELF_TEST_BATTERIES = Object.freeze({ 'the live read: every read through one reader; a failed read is INCOMPLETE, never clean': 6, 'the report: one line per owing PR, TAKE first, exit 0': 5, 'the hold: a live hold on this head holds (b) alone, (a) and (c) still fire; a new head clears it; at 24 hours it is listed, still WAIT': 14, + // The decision box (`--decisions`): the analysis tier read by the record's own parser, its carrier, its currency. + 'the decision box: each open needs-user-decision card\'s analysis tier on its newest carrier — at tier, below, missing, unjudged — whether it is still current, and what the seat does with it': 16, }); const SELF_TEST_BATTERY_FLOOR = 10; const UNATTRIBUTED_BATTERY = '(no battery open)'; @@ -887,6 +1050,47 @@ export function selfTest() { t('--json carries the hold on the row, live and listed, through the one live reader — the status still one of the four', (() => { const r = JSON.parse(holdJson.join('\n')).rows[0]; return r.pr === 27136 && r.status === 'WAIT' && r.hold.state === 'live' && r.hold.listed === true && r.hold.session === LANE && STATUS_ORDER.includes(r.status); })()); t('⛔ the status vocabulary stays exactly four, in order — a hold is the lane\'s own WAIT', STATUS_ORDER.join() === 'TAKE,WAIT,HELD,DONE'); + battery('the decision box: each open needs-user-decision card\'s analysis tier on its newest carrier — at tier, below, missing, unjudged — whether it is still current, and what the seat does with it'); + { + const BOT = FLEET_BOT_LOGIN; + const DSIG = 'repo:objectstack@os-example · os-example · session_01DecisionSeatFixture3Q'; + const analysisBody = (tier, extra = '') => `${DSIG}\n## 维护者速读\n- 问题:一句话。\n\n${tier === null ? '' : `Served-tier: \`${tier}\`\nAnalysed-by: \`session_01AnalysisFixture9Qx\`\n`}\nos-decision-facets\n- ① 项目长远合理性:不扩大特例。\n${extra}`; + const card = (o = {}) => ({ number: 38624, title: 'A decision', created_at: '2026-11-29T08:00:00Z', user: { login: BOT }, body: analysisBody(null), ...o }); + const cmt = (id, at, body, login = BOT) => ({ id, created_at: at, user: { login }, body }); + const AT = 'CONTRACT_REVIEW_TIER'; + const delta = (id, at, tier = AT) => cmt(id, at, `${DSIG}\n## Re-analysis for the decision: x\n\nServed-tier: \`${tier}\`\nAnalysed-by: \`session_01AnalysisFixture9Qx\`\n\nPer facet: same.`); + const ruling = (id, at) => cmt(id, at, `${DSIG}\nRuling: batch #9 item 2 · letter A · maintainer 「同意」 2026-11-30T10:00Z`); + const r1 = decisionAnalysisRow(card(), [delta(7301, '2026-11-30T09:00:00Z')]); + t('⭐ AT TIER and CURRENT — a delta re-analysis carrying the pair, nothing after it ⇒ present as it stands, premise re-check; the comment named', r1.state === 'at-tier' && r1.carrier.id === 7301 && r1.current.state === 'current' && r1.act === DECISION_ACT_PRESENT && r1.analysedBy === 'session_01AnalysisFixture9Qx', JSON.stringify(r1)); + const r2 = decisionAnalysisRow(card(), [delta(7301, '2026-11-30T09:00:00Z'), ruling(7302, '2026-11-30T10:05:00Z')]); + t('⛔ a RULING comment after the carrier makes it stale ⇒ re-run, and the row names the ruling', r2.state === 'at-tier' && r2.current.state === 'stale' && r2.current.reasons[0].includes('7302') && r2.act === DECISION_ACT_RERUN); + t('…while a ruling BEFORE it (a card back in the box, re-analysed since) leaves it current', decisionAnalysisRow(card(), [ruling(7300, '2026-11-30T08:00:00Z'), delta(7301, '2026-11-30T09:00:00Z')]).current.state === 'current'); + t('⛔ a body `Ruled:` record stamped after the carrier makes it stale; an unstamped one counts as after (the safe direction)', decisionAnalysisRow(card({ body: `Ruled: 7302999 · letter A · 2026-11-30T10:05Z\n${analysisBody(null)}` }), [delta(7301, '2026-11-30T09:00:00Z')]).current.state === 'stale' && decisionAnalysisRow(card({ body: `Ruled: 7302999 · letter A\n${analysisBody(null)}` }), [delta(7301, '2026-11-30T09:00:00Z')]).current.state === 'stale'); + t('⛔ the body\'s newest stamp at or after a comment carrier\'s minute is a body written since ⇒ stale; an older stamp is not', decisionAnalysisRow(card({ body: analysisBody(null, 'Refreshed 2026-11-30T09:00Z.') }), [delta(7301, '2026-11-30T09:00:30Z')]).current.state === 'stale' && decisionAnalysisRow(card({ body: analysisBody(null, 'Read at 2026-11-29T07:00Z.') }), [delta(7301, '2026-11-30T09:00:30Z')]).current.state === 'current'); + t('⭐ the line in the BODY is the carrier when no comment carries one — at tier and current with no ruling', (() => { const r = decisionAnalysisRow(card({ body: analysisBody(AT) }), []); return r.state === 'at-tier' && r.carrier.where === 'body' && r.act === DECISION_ACT_PRESENT; })()); + const r3 = decisionAnalysisRow(card({ body: analysisBody('TIER_DEFAULT') }), []); + t('⭐ BELOW TIER — `TIER_DEFAULT` ⇒ re-run at tier', r3.state === 'below-tier' && r3.act === DECISION_ACT_RERUN); + const r4 = decisionAnalysisRow(card(), []); + t('⭐ MISSING — an analysis with no line ⇒ re-run, and the row says the card does carry an analysis', r4.state === 'missing' && r4.carrier === null && r4.analysis === true && r4.act === DECISION_ACT_RERUN && renderDecisionRow(r4).includes('analysis carries no Served-tier')); + t('…and a card with no analysis at all says so', renderDecisionRow(decisionAnalysisRow(card({ body: `${DSIG}\nA plain question.` }), [])).includes('no analysis found on the card')); + t('⭐ the NEWEST carrier governs, both ways — an at-tier body under a TIER_DEFAULT delta is below tier, and the reverse is at tier', decisionAnalysisRow(card({ body: analysisBody(AT) }), [delta(7301, '2026-11-30T09:00:00Z', 'TIER_DEFAULT')]).state === 'below-tier' && decisionAnalysisRow(card({ body: analysisBody('TIER_DEFAULT') }), [delta(7301, '2026-11-30T09:00:00Z')]).state === 'at-tier'); + t('⛔ the author binding: an at-tier delta by an untrusted author is never the carrier, and the drop is counted and printed', (() => { const r = decisionAnalysisRow(card(), [delta(7301, '2026-11-30T09:00:00Z')].map((c) => ({ ...c, user: { login: 'drive-by' } }))); return r.state === 'missing' && r.ignored === 1 && renderDecisionRow(r).includes('1 comment(s) by an untrusted author not read'); })()); + t('⛔ …and a body by an untrusted author is not read either', (() => { const r = decisionAnalysisRow(card({ body: analysisBody(AT), user: { login: 'drive-by' } }), []); return r.state === 'missing' && r.bodyRead === false && renderDecisionRow(r).includes('body by an untrusted author not read'); })()); + t('⛔ a `## Contract review` record on the card is not an analysis\'s carrier', decisionAnalysisRow(card(), [recordRow(HEAD)]).state === 'missing'); + t('⛔ a thread that could not be read is UNJUDGED, never missing', decisionAnalysisRow(card(), null).state === 'unjudged'); + const boxPaths = []; + const boxGet = (path) => { + boxPaths.push(path); + if (path.startsWith('/repos/objectstack-ai/objectstack/issues?')) return { ok: true, value: [card({ body: analysisBody(AT) }), card({ number: 38700, title: 'Lost thread' }), { number: 1, pull_request: {} }] }; + if (path.startsWith('/repos/objectstack-ai/objectstack/issues/38624/comments')) return { ok: true, value: [] }; + return { ok: false, error: 'HTTP 502' }; + }; + const out = []; + const code = main(['--decisions', '--now', '2026-12-01T00:00:00Z'], { get: boxGet, log: (l) => out.push(l) }); + t('the live read: the label listing through the one reader, a PR dropped, a failed thread a GAP and its card unjudged, exit 0', code === EXIT_OK && boxPaths[0].includes(`labels=${encodeURIComponent(DECISION_INBOX_LABEL)}`) && boxPaths[0].includes('state=open') && out.some((l) => l.startsWith('#38700 unjudged')) && out.some((l) => l.includes('sweep INCOMPLETE')) && !out.some((l) => l.startsWith('#1 ')), out.join(' | ')); + t('the report: re-run rows first, the present row last, and the bound on body edits printed', (() => { const i = out.findIndex((l) => l.startsWith('#38700')); const j = out.findIndex((l) => l.startsWith('#38624')); return i > 0 && j > i && out[j].endsWith('A decision') && out[j].includes(DECISION_ACT_PRESENT) && out.some((l) => l.includes('a body edit that writes no stamp is not seen')); })(), out.join(' | ')); + } + // Floor: the opened set equals the declared set, each battery at or above its pin. const declared = Object.keys(SELF_TEST_BATTERIES); if (declared.length < SELF_TEST_BATTERY_FLOOR) cases.push({ name: `SELF_TEST_BATTERIES declares ${declared.length} batteries, below the pinned ${SELF_TEST_BATTERY_FLOOR}`, ok: false }); @@ -907,7 +1111,8 @@ export function selfTest() { + 'the Clause-② line and the label, drafts included; the record on this head, an earlier head, none, unjudged, read by the queue guard\'s author binding with its verdict lines counted; ' + 'the (a) / (b) / (c) triggers and the taker — the seat a hand-off names, an L2 seat on the delta of its own record, else the lane seat, never triage; claims holding and lapsing, the earliest live claim holding; the two live drafts as TAKE; ' + 'every read through one reader with failures as gaps; the report, exit 0; a lane\'s live hold holding (b) alone, ' - + 'cleared by a new head, an unreadable hold line voiding nothing and printed, listed at 24 hours and still WAIT).', + + 'cleared by a new head, an unreadable hold line voiding nothing and printed, listed at 24 hours and still WAIT; ' + + 'the decision box — each analysis\'s tier on its newest trusted carrier, at tier, below, missing or unjudged, stale after a ruling or a body written since, and present-as-it-stands only at tier and current).', ); selfTestReachedVerdict = true; return 0; From 2600515247a33191bb52367cd18e045db14e70ec Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 1 Dec 2026 06:51:47 +0000 Subject: [PATCH 05/10] docs(pm-dispatch): an at-tier, still-current decision analysis is presented as it stands, with a premise re-check Ruling record 7303021478. The decision-analysis.md ceiling rises by the landed 223 bytes, recorded under ruledRaises on that file's cross-file move declaration. Claude-Session: https://claude.ai/code/session_01WGufzfWWgrLkABDvbRjhAk Co-authored-by: Claude --- .claude/skills/pm-dispatch/references/decision-analysis.md | 7 ++++--- scripts/pm/check-skill-line-ratchet.mjs | 5 ++++- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/.claude/skills/pm-dispatch/references/decision-analysis.md b/.claude/skills/pm-dispatch/references/decision-analysis.md index b43eae04a99..83523d2a35c 100644 --- a/.claude/skills/pm-dispatch/references/decision-analysis.md +++ b/.claude/skills/pm-dispatch/references/decision-analysis.md @@ -19,8 +19,9 @@ - 问题写客户看到的症状、谁碰到、多频繁;选项句写选了客户看到什么、约几个 PR。 - ⛔ 速读不写代码名、文件路径、命令、裁决字母、裸卡号;点到的卡配一句中文说明。 - 四轴、四棱块、自检行、置信缺口、工作量先例归英文分析段,⛔ 不删。 -- 英文段首两行 `Served-tier: `、`Analysed-by: `(执笔会话或子代理),⛔ 不写模型 id;标 `CONTRACT_REVIEW_TIER` 须执笔转录过 `verify-review-tier.mjs`(`--tier-evidence=` 只判 L2 记录)。 -- 呈维护者前读该行:缺或未达档 ⇒ 达档重跑,贴带两行的 delta 评论(逐棱同异)再呈;⛔ 永不呈读不出档的分析。 +- 英文段首两行 `Served-tier: `、`Analysed-by: `(执笔会话或子代理),⛔ 不写模型 id;标 `CONTRACT_REVIEW_TIER` 须执笔转录过 `verify-review-tier.mjs`(`--tier-evidence=` 写入即判)。 +- 呈维护者前读该行(`check-owed-reviews.mjs --decisions` 逐卡列):缺或未达档 ⇒ 达档重跑,贴带两行的 delta 评论(逐棱同异)再呈;⛔ 永不呈读不出档的分析。 +- 达档且仍现行(载行后无裁决、正文未改)⇒ 照原样呈,只跑前提 re-check,⛔ 不重跑;前提已变 ⇒ 达档重跑。 分析段骨架:背景 / Governing text(引文 + grep,或 none found + 检索式)/ 协议声明、是否改协议 / 带 re-check 命令的前提 / 具体问题 / 选项 / 推荐 / 相关单与 PR。正文六项: @@ -31,7 +32,7 @@ - 业务含义直译:每选项配一句业务上等于什么,允许行业类比。 - 四轴从业务立场论证(含四棱行):论据是客户、产品或事故后果,机制名词只作括号补充。 - 防 AI 犯错轴写清出错时谁看到什么:响亮拒绝,还是静默泄露。 -- 推荐 + 置信缺口:只荐一,余各一句不取理由;盲区明说,⛔ 不因此另荐;⛔ 不沿用他席推荐。 +- 推荐 + 置信缺口:只荐一,余各一句不取理由;盲区明说,⛔ 不因此另荐;⛔ 不沿用他席推荐(照原样呈达档现行分析除外)。 - 推荐先只按①得出:终态句写两年后该能力的平台样子与主流平台建模,点名参照。 - ②③④与工作量只调时序分期 ⛔ 不翻字母;契约迁就实现、分期半量(缺陷除外)⛔ 不荐。 - ①读数相近而工作量差 ≥3× 推荐须点名;翻字母只凭维护者卡上另裁,唯④新增门禁例外。 diff --git a/scripts/pm/check-skill-line-ratchet.mjs b/scripts/pm/check-skill-line-ratchet.mjs index 4f4e4c81b66..f41500b4568 100644 --- a/scripts/pm/check-skill-line-ratchet.mjs +++ b/scripts/pm/check-skill-line-ratchet.mjs @@ -85,7 +85,7 @@ export const CEILINGS = new Map([ ['.claude/skills/pm-dispatch/references/dispatch-runbook.md', 20483], // raised 20070 → 20354 (+284) by ruling record 7075909669 (#36203 items 1-5: 「同意五条都改」): a card thread confirms Actions started after each push; the seat reads pr-state of every in-flight card PR; lowered 20354 → 20344 by the PR that moved the tier and effort values to the one home; raised 20344 → 20483 (+139) by ruling record 7076315104 (Q13, the decision card 「定一下:五条新增规则要不要写进技能」: 「五条都写」): the thread's first report carries the served tier and the seat writes it into the claim ['.claude/skills/pm-dispatch/references/state-machine.md', 4243], // raised 4189 → 4243 (+54, the landed bytes) by the maintainer's ruling quoted in the body of the rule card and recorded by triage record 7254553088 (「立卡改技能,现在就派发」): lane seats unlock their own blocked cards every round and first-touch the cards they file ['.claude/skills/pm-dispatch/references/contract-review.md', 6420], // raised 6419 → 6420 (+1) by ruling record 7249169754 (Q1 A: 「同意,立卡派发」): the hand-off line names its target seat `LANE@ACCOUNT`, the template `record-recognisers.mjs` holds verbatim - ['.claude/skills/pm-dispatch/references/decision-analysis.md', 5580], // lowered 5589 → 5580 by the decision-analysis tier-line PR (its worked 速读 example deleted to pay for the `Served-tier:` / `Analysed-by:` lines); before that: raised 5023 → 5589 (+566) by the declared cross-file move from SKILL.md (CROSS_FILE_MOVES below); before that: raised 4892 → 5023 (+131) by ruling record 7076338827, the addendum to 7076315104 (a simple question goes to the maintainer in chat after the at-tier analysis: 「不一定要写成文件吧?简单的问题是不是直接和我沟通就可以」) + ['.claude/skills/pm-dispatch/references/decision-analysis.md', 5803], // raised 5580 → 5803 (+223, the landed bytes) by ruling record 7303021478 (「升 p2,交 fleet 区现在做」, with the maintainer's 「之前已经用 fable 分析过的不用重复分析吧?」): an analysis at tier and still current is presented as it stands with a premise re-check, the per-card reading that says so is named, and the `--tier-evidence=` parenthetical now says the writer judges an analysis — recorded under `ruledRaises` on this file's move declaration below; before that: lowered 5589 → 5580 by the decision-analysis tier-line PR (its worked 速读 example deleted to pay for the `Served-tier:` / `Analysed-by:` lines); before that: raised 5023 → 5589 (+566) by the declared cross-file move from SKILL.md (CROSS_FILE_MOVES below); before that: raised 4892 → 5023 (+131) by ruling record 7076338827, the addendum to 7076315104 (a simple question goes to the maintainer in chat after the at-tier analysis: 「不一定要写成文件吧?简单的问题是不是直接和我沟通就可以」) ['.claude/skills/pm-dispatch/references/platform-readings.md', 1082], ['.claude/skills/pm-dispatch/references/readings-queue.md', 9074], ['.claude/skills/pm-dispatch/references/readings-channels.md', 7138], @@ -197,6 +197,9 @@ export const CROSS_FILE_MOVES = new Map([ ruling: `five recommendation-order lines of SKILL.md 〈升级与决策〉 moved here verbatim — ${RULING_CITATION}`, was: 5023, sources: [['.claude/skills/pm-dispatch/SKILL.md', 33919]], + ruledRaises: [ + { ruling: 'ruling record 7303021478 — 「升 p2,交 fleet 区现在做」: an at-tier, still-current analysis is presented as it stands, with a premise re-check', date: '2026-12-01', delta: 223 }, + ], }], ]); From d60c4a019b5bb1f975bfacca45335f1c049d88af Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 1 Dec 2026 07:43:33 +0000 Subject: [PATCH 06/10] fix(pm): keep record-recognisers' self-test-reads declaration on its censused line The header entry for readDecisionAnalysisTier is folded into the readServedTier line, so the dispatch-gates live-marker census reads the declaration at line 77 again. Claude-Session: https://claude.ai/code/session_01WGufzfWWgrLkABDvbRjhAk Co-authored-by: Claude --- scripts/pm/record-recognisers.mjs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/scripts/pm/record-recognisers.mjs b/scripts/pm/record-recognisers.mjs index 972c3fe7621..7132af0d4e8 100644 --- a/scripts/pm/record-recognisers.mjs +++ b/scripts/pm/record-recognisers.mjs @@ -21,8 +21,7 @@ * * locateReviewOfRecord the record on this head, on the PR thread or its card * deliveredCardNumber which card thread a pull request's record may sit on — and `deliveredCardsAtStrongest` every card a tie holds, for a reader that reads them all - * readServedTier the `Served-tier:` line, and `servedTierStands` on it — at the tier its face maps to - * readDecisionAnalysisTier the same line on a DECISION ANALYSIS, beside its `Analysed-by:` line (`readAnalysedBy`) — at tier, below it, unreadable or missing + * readServedTier the `Served-tier:` line, and `servedTierStands` on it — at the tier its face maps to; `readDecisionAnalysisTier` the same line on a DECISION ANALYSIS, beside its `Analysed-by:` line (`readAnalysedBy`) — at tier, below it, unreadable or missing * reviewFace / REVIEW_FACES which face made the review owed, and the ONE tier NAME it stands at * reviewScopeHits the at-tier review's scope floor — `reviewFace`'s `hits`, the record's `Scope:` line * recordCarriesDesignJudgment whether a face's record carries item ④, the full review's design judgment From 8d9ba5a2b79483162c574cc006ca0dec9a6b4926 Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 1 Dec 2026 08:19:00 +0000 Subject: [PATCH 07/10] fix(pm): judge a card-body refresh that introduces an at-tier analysis line; read the record heading outside fences post-stamped --body now carries --tier-evidence and refuses a refresh whose analysis introduces Served-tier: CONTRACT_REVIEW_TIER that the stored body lacks; a refresh keeping an existing line is untouched. readDecisionAnalysisTier reads the record heading on the fence-blanked text, so an analysis quoting a record in a fence stays an analysis. Claude-Session: https://claude.ai/code/session_01WGufzfWWgrLkABDvbRjhAk Co-authored-by: Claude --- scripts/pm/post-stamped.mjs | 69 ++++++++++++++++++++++++------- scripts/pm/record-recognisers.mjs | 9 ++-- 2 files changed, 59 insertions(+), 19 deletions(-) diff --git a/scripts/pm/post-stamped.mjs b/scripts/pm/post-stamped.mjs index d26b2e29740..b96a5fe188a 100644 --- a/scripts/pm/post-stamped.mjs +++ b/scripts/pm/post-stamped.mjs @@ -2354,13 +2354,40 @@ export function recordLineRefusalText(rows) { */ export function recordTierEvidenceRefusal(body, tierEvidence) { const text = String(body ?? ''); - const record = CONTRACT_REVIEW_HEADING_MARKER.test(text); - const analysis = record ? null : readDecisionAnalysisTier(text); - if (!record && !analysis.analysis) return null; - const served = record ? readServedTier(text) : analysis.served; + if (!CONTRACT_REVIEW_HEADING_MARKER.test(text)) return analysisTierEvidenceRefusal(text, tierEvidence); + const served = readServedTier(text); if (served.state !== 'read' || served.value !== CONTRACT_REVIEW_TIER_NAME) return null; - const kind = record ? 'record' : 'analysis'; - if (tierEvidence === null || tierEvidence === undefined) return { kind, why: `no --tier-evidence was given — nothing shows this ${record ? 'review' : 'analysis'} was served at ${CONTRACT_REVIEW_TIER_NAME}` }; + return tierEvidenceVerdict('record', tierEvidence); +} + +/** Does this text carry a decision analysis whose `Served-tier:` line names `CONTRACT_REVIEW_TIER` — the one reading, `readDecisionAnalysisTier`'s? */ +function declaresAtTierAnalysis(text) { + const analysis = readDecisionAnalysisTier(text); + return analysis.analysis && analysis.served.state === 'read' && analysis.served.value === CONTRACT_REVIEW_TIER_NAME; +} + +/** + * The ANALYSIS half of `recordTierEvidenceRefusal`, alone: what a CARD BODY is judged on. A record is a comment, never a + * card body, so a body that quotes a `## Contract review` record is not a record here, and `issue-create.mjs` and a + * body refresh call this half only. + */ +export function analysisTierEvidenceRefusal(body, tierEvidence) { + return declaresAtTierAnalysis(String(body ?? '')) ? tierEvidenceVerdict('analysis', tierEvidence) : null; +} + +/** + * A card BODY refresh (`--body=N`): judged only when it INTRODUCES an at-tier analysis line the stored body does not + * carry. A refresh that keeps a line already written (a director's `Ruled:` edit over an analysis filed at the tier) has + * no transcript to show and is untouched; one that adds the line is the act of the run that just analysed, whose + * transcript is what `--tier-evidence=PATH` names. Reads the stored body the refresh already fetched for its unread check. + */ +export function bodyTierEvidenceRefusal(body, storedBody, tierEvidence) { + return declaresAtTierAnalysis(String(storedBody ?? '')) ? null : analysisTierEvidenceRefusal(body, tierEvidence); +} + +/** The evidence verdict both halves share: no transcript, or one `verify-review-tier.mjs` refuses, is a refusal. */ +function tierEvidenceVerdict(kind, tierEvidence) { + if (tierEvidence === null || tierEvidence === undefined) return { kind, why: `no --tier-evidence was given — nothing shows this ${kind === 'record' ? 'review' : 'analysis'} was served at ${CONTRACT_REVIEW_TIER_NAME}` }; const verdict = verifyReviewTranscriptFile(tierEvidence); return verdict.ok ? null : { kind, why: tierVerdictText(verdict) }; } @@ -3767,9 +3794,6 @@ export function parseOptions(argv) { } } const tierEvidence = readOption(args, 'tier-evidence'); - if (tierEvidence !== null && comment === null) { - return { ok: false, error: '--tier-evidence belongs to a comment (--comment=N): it is the transcript behind a `## Contract review` record or a decision analysis comment. A NEW card whose body is an analysis takes it on issue-create.mjs.' }; - } if (tierEvidence === '') { return { ok: false, error: '--tier-evidence= names no file. Pass the reviewing run\'s transcript (a sub-agent\'s output file, or this session\'s own): --tier-evidence=PATH.' }; } @@ -4158,7 +4182,7 @@ const USAGE = [ 'post-stamped — write a seat artefact to GitHub with a stamp this act read, never one typed from memory.', '', ' node scripts/pm/post-stamped.mjs --comment=N [--file=PATH] [--repo=OWNER/NAME] [--tier-evidence=PATH] [--dry-run] [--json]', - ' node scripts/pm/post-stamped.mjs --body=N [--file=PATH] [--repo=OWNER/NAME] [--ack-through=ID] [--dry-run] [--json]', + ' node scripts/pm/post-stamped.mjs --body=N [--file=PATH] [--repo=OWNER/NAME] [--ack-through=ID] [--tier-evidence=PATH] [--dry-run] [--json]', ' node scripts/pm/post-stamped.mjs --self-test', '', ' With no --file the body is read from stdin.', @@ -4189,7 +4213,8 @@ const USAGE = [ ' `probe — REASON`); a record without the line is not re-judged. A record whose `Served-tier:` names', ' `CONTRACT_REVIEW_TIER` is REFUSED unless --tier-evidence=PATH names the reviewing run\'s transcript and', ' `verify-review-tier.mjs` passes on it; the path and the model stay local, out of the comment. A decision', - ' analysis (the four-facet marker outside code, or an `Analysed-by:` line) naming it is judged the same way.', + ' analysis (the four-facet marker outside code, or an `Analysed-by:` line) naming it is judged the same way, and so', + ' is a --body refresh whose analysis INTRODUCES that line (the stored body does not carry it); one keeping it is not.', ' A comment that is a decision analysis — a decision frame, an options table or lettered options, and a', ` recommendation naming one — is REFUSED when it carries no \`${DECISION_FACET_MARKER}\` marker outside code; the`, ' refusal prints the four-facet block it owes. Card bodies and every other route are untouched.', @@ -4278,7 +4303,7 @@ async function main(argv) { `${substitutionSummary(rendered)}. Stamp verdict: ${rendered.verdict} — ` + `${STAMP_VERDICTS[rendered.verdict]}. Target would be ` + `${repoRes.repo}#${options.number} (${options.mode}).` + - (options.mode === 'body' ? ' The unread-comment check reads the card and runs only on a live write.' : ''), + (options.mode === 'body' ? ' The unread-comment check and the introduced-tier check read the card and run only on a live write.' : ''), ); console.log(rendered.body); return EXIT_OK; @@ -4299,6 +4324,12 @@ async function main(argv) { console.error(unreadRefusalText(unread, options.number)); return EXIT_REFUSED; } + // A refresh that INTRODUCES an at-tier analysis line carries the evidence of the run that analysed (`bodyTierEvidenceRefusal`). + const introduced = bodyTierEvidenceRefusal(rendered.body, tail.card?.body, options.tierEvidence ?? null); + if (introduced !== null) { + console.error(recordTierEvidenceRefusalText(introduced)); + return EXIT_REFUSED; + } } let written; @@ -4455,7 +4486,7 @@ const SELF_TEST_BATTERIES = Object.freeze({ 'the one judge: every body refusal on ONE path — `main` and `label-write.mjs --comment-file` call `judgeBody`, never a copy': 14, 'the review route: a `Request: contract-review` knock addressed to triage is refused; to a review or sibling seat, and every other key to triage, it passes': 13, 'the record tier: a record naming `CONTRACT_REVIEW_TIER` is written only on a transcript `verify-review-tier.mjs` passes; another tier and a non-record comment are untouched': 16, - 'the analysis tier: a decision analysis naming `CONTRACT_REVIEW_TIER` is written only on a transcript `verify-review-tier.mjs` passes, read by the listing\'s own reader; another tier, no line, a quotation and a non-analysis are untouched': 12, + 'the analysis tier: a decision analysis naming `CONTRACT_REVIEW_TIER` is written only on a transcript `verify-review-tier.mjs` passes, read by the listing\'s own reader; another tier, no line, a quotation and a non-analysis are untouched': 17, 'the claim stroke: a comment opening `Claim:` is refused on every route but `direct`, pointing at the `label-write` fold; the same body through that fold passes': 21, }); const SELF_TEST_BATTERY_FLOOR = 30; @@ -6184,7 +6215,7 @@ export function selfTest() { t('⭐ a comment that is not a record is untouched, with no evidence', judged(`${SIG}\nThe seat's own note: Served-tier: \`${CONTRACT_REVIEW_TIER_NAME}\` is what records carry.`, null).ok); t('⭐ a card BODY is untouched — the check is a record\'s, and a record is a comment', judgeBody(REC(CONTRACT_REVIEW_TIER_NAME), { mode: 'body' }, NOW_MS).ok); t('the CLI carries --tier-evidence=PATH on a comment, and leaves it null when absent', parseOptions(['--comment=1', `--tier-evidence=${atTier}`]).options.tierEvidence === atTier && parseOptions(['--comment=1']).options.tierEvidence === null); - t('⛔ --tier-evidence with --body, or with no path, is refused', parseOptions(['--body=1', '--tier-evidence=x']).ok === false && parseOptions(['--comment=1', '--tier-evidence=']).ok === false); + t('--tier-evidence is carried on a --body refresh too (its introduced-tier check), and with no path it is refused on either mode', parseOptions(['--body=1', '--tier-evidence=x']).options?.tierEvidence === 'x' && parseOptions(['--comment=1', '--tier-evidence=']).ok === false && parseOptions(['--body=1', '--tier-evidence=']).ok === false); const verifier = spawnSync(process.execPath, [fileURLToPath(new URL('./verify-review-tier.mjs', import.meta.url)), '--self-test'], { encoding: 'utf8', timeout: CHILD_RUN_TIMEOUT_MS }); t('the verifier\'s own --self-test runs HERE, so CI runs it inside check:pm-post-stamped: exit 0 and its success line', verifier.status === 0 && /✓ verify-review-tier self-test: \d+ cases pass/u.test(verifier.stdout), childRunDetail(verifier)); t('a child self-test that hangs is cut at its timeout and named, and a failing one relays its own ✗ lines', /timed out after \d+ ms/u.test(childRunDetail({ status: null, signal: 'SIGTERM', error: { code: 'ETIMEDOUT' }, stdout: '', stderr: '' })) && @@ -6213,6 +6244,7 @@ export function selfTest() { writeFileSync(atTier, [JSON.stringify({ type: 'user', message: { role: 'user', content: 'analyse' } }), turn(CONTRACT_REVIEW_TIER), turn(CONTRACT_REVIEW_TIER)].join('\n')); writeFileSync(offTier, [turn(CONTRACT_REVIEW_TIER), turn(OTHER)].join('\n')); const judged = (body, tierEvidence) => judgeBody(body, { mode: 'comment', tierEvidence }, NOW_MS); + const own = readFileSync(SELF_PATH, 'utf8'); const none = judged(ANALYSIS(CONTRACT_REVIEW_TIER_NAME), null); t('⛔ an analysis declaring CONTRACT_REVIEW_TIER with no --tier-evidence is refused, and the refusal says it is an analysis', !none.ok && none.text.startsWith('post-stamped: REFUSED — this decision analysis') && none.text.includes('--tier-evidence') && none.text.includes('ANALYSED')); t('⭐ …and the same analysis passes on a transcript served at the tier throughout', judged(ANALYSIS(CONTRACT_REVIEW_TIER_NAME), atTier).ok); @@ -6225,8 +6257,13 @@ export function selfTest() { t('⭐ the pair quoted inside a FENCE is a citation, not a declaration: untouched', judged(ANALYSIS(CONTRACT_REVIEW_TIER_NAME, { fence: true }), null).ok); t('⭐ a note carrying the line with neither the facet marker nor an `Analysed-by:` line is no analysis: untouched', judged(ANALYSIS(CONTRACT_REVIEW_TIER_NAME, { by: null, marker: false }), null).ok); t('the refusal names the sender it was handed — the label-write fold judges an analysis on this same path', (() => { const lw = judgeBody(ANALYSIS(CONTRACT_REVIEW_TIER_NAME), { mode: 'comment' }, NOW_MS, 'label-write'); return !lw.ok && lw.text.startsWith('label-write: REFUSED — this decision analysis'); })()); - t('⛔ a card BODY refresh is not judged here — a new card\'s body is, by issue-create.mjs --tier-evidence (the stated bound)', judgeBody(ANALYSIS(CONTRACT_REVIEW_TIER_NAME), { mode: 'body' }, NOW_MS).ok); - const own = readFileSync(SELF_PATH, 'utf8'); + t('a card BODY is not judged inside judgeBody, which is stateless — the refresh is judged against the stored body below', judgeBody(ANALYSIS(CONTRACT_REVIEW_TIER_NAME), { mode: 'body' }, NOW_MS).ok); + const intro = bodyTierEvidenceRefusal(ANALYSIS(CONTRACT_REVIEW_TIER_NAME), ANALYSIS(null), null); + t('⛔ a body refresh that INTRODUCES an at-tier analysis line the stored body lacks is refused without evidence, as an analysis', intro !== null && intro.kind === 'analysis' && recordTierEvidenceRefusalText(intro).startsWith('post-stamped: REFUSED — this decision analysis')); + t('⛔ …and so is one replacing a TIER_DEFAULT line with the contract tier, while at-tier evidence passes it and off-tier evidence does not', bodyTierEvidenceRefusal(ANALYSIS(CONTRACT_REVIEW_TIER_NAME), ANALYSIS('TIER_DEFAULT'), null) !== null && bodyTierEvidenceRefusal(ANALYSIS(CONTRACT_REVIEW_TIER_NAME), ANALYSIS(null), atTier) === null && bodyTierEvidenceRefusal(ANALYSIS(CONTRACT_REVIEW_TIER_NAME), ANALYSIS(null), offTier) !== null); + t('⭐ a refresh KEEPING an at-tier line already on the stored body is untouched — it has no transcript to show', bodyTierEvidenceRefusal(`${ANALYSIS(CONTRACT_REVIEW_TIER_NAME)}\n\nRuled: 7302999 · letter A · 2026-11-30T10:05Z`, ANALYSIS(CONTRACT_REVIEW_TIER_NAME), null) === null); + t('⭐ a refresh that is no analysis, or names another tier, is untouched; a card body quoting a record is no record', bodyTierEvidenceRefusal(ANALYSIS(CONTRACT_REVIEW_TIER_NAME, { by: null, marker: false }), '', null) === null && bodyTierEvidenceRefusal(ANALYSIS('TIER_DEFAULT'), '', null) === null && analysisTierEvidenceRefusal(`${SIG}\nA tooling card quoting a record:\n\n## Contract review\nServed-tier: \`${CONTRACT_REVIEW_TIER_NAME}\`\n\n**VERDICT: PASS**`, null) === null); + t('structural: main judges a --body refresh with bodyTierEvidenceRefusal on the stored body it read, right after the unread check', /unreadComments\(\{ storedBody: tail\.card\?\.body[^]*?const introduced = bodyTierEvidenceRefusal\(rendered\.body, tail\.card\?\.body, options\.tierEvidence \?\? null\);/u.test(own)); t('structural: the analysis reading is `readDecisionAnalysisTier`, imported from record-recognisers.mjs — ⛔ no second reader of the pair here', /import \{[^}]*\breadDecisionAnalysisTier\b[^}]*\} from '\.\/record-recognisers\.mjs';/u.test(own) && !/function\s+(readDecisionAnalysisTier|readAnalysedBy)\b/u.test(own)); } finally { rmSync(dir, { recursive: true, force: true }); diff --git a/scripts/pm/record-recognisers.mjs b/scripts/pm/record-recognisers.mjs index 7132af0d4e8..dea1ee281c5 100644 --- a/scripts/pm/record-recognisers.mjs +++ b/scripts/pm/record-recognisers.mjs @@ -850,7 +850,8 @@ export function readAnalysedBy(text) { * * ⭐ What makes a text an ANALYSIS (`analysis`): the four-facet block's marker outside code (the reading the handover * check and `post-stamped.mjs` give it) or an `Analysed-by:` line -- the line no other record carries. A `## Contract - * review` record is never one: its `Served-tier:` line is the record's, read by the readers above. `carriesLine` is an + * review` record is never one: its `Served-tier:` line is the record's, read by the readers above. The heading is read + * outside fences, so an analysis that QUOTES a record in a fence is still an analysis. `carriesLine` is an * analysis that carries either line of the pair: the text a card-level reader takes the line from. * * ⛔ Fenced code is blanked before either line is read (`stripMarkdownCode`, inline spans KEPT, since the template's @@ -864,7 +865,7 @@ export function readDecisionAnalysisTier(text) { const prose = stripMarkdownCode(raw, { inline: false }); const served = readServedTier(prose); const analysedBy = readAnalysedBy(prose); - const record = CONTRACT_REVIEW_HEADING_MARKER.test(raw); + const record = CONTRACT_REVIEW_HEADING_MARKER.test(prose); const analysis = !record && (hasDecisionFacetMarker(stripMarkdownCode(raw)) || analysedBy.state !== 'missing'); const state = served.state === 'missing' ? 'missing' @@ -2968,7 +2969,8 @@ const SELF_TEST_BATTERIES = Object.freeze({ '#18701: ONE thread set -- what the template STATES is what the queue guard READS': 23, 'the `Local-runs:` reading — `none` or ONE named probe, judged when present; an absent line is not re-judged': 12, // The decision analysis's pair: at tier, below it, unreadable, missing (the card's Done-when: present, missing and below-tier). - '⭐ a decision analysis\'s `Served-tier:` / `Analysed-by:` pair — at tier, below it, unreadable or missing, read with the record\'s own parser; never off a contract review record or out of a fence': 18, + // 18 → 19: an analysis quoting a record in a fence stays an analysis (the record heading read outside fences). + '⭐ a decision analysis\'s `Served-tier:` / `Analysed-by:` pair — at tier, below it, unreadable or missing, read with the record\'s own parser; never off a contract review record or out of a fence': 19, // Raised 23 → 24 with ③'s SQL push-down check on every face's brief: one pin. 'the reviewer BRIEF template — the read-only shape a hand-written brief dropped, built in and printed': 24, '⭐ B′ with C: the review tier FOLLOWS THE FACE that made it owed — exact, never a floor': 23, @@ -3504,6 +3506,7 @@ export async function selfTest() { t('…and the `Analysed-by:` key is built by the one key-line convention, never a second spelling', ANALYSED_BY_LINE.source === keyLineRegex('Analysed-by').source); t('⛔ NOT AN ANALYSIS — a `Served-tier:` line with neither the facet marker nor an `Analysed-by:` line carries nothing', (() => { const r = da(DA(`\`${CONTRACT_REVIEW_TIER_NAME}\``, null, null)); return r.state === 'at-tier' && !r.analysis && !r.carriesLine; })()); t('⛔ a `## Contract review` record is never an analysis, whatever it carries — its line is the record\'s', (() => { const r = da(`## Contract review\n\nServed-tier: \`${CONTRACT_REVIEW_TIER_NAME}\`\nAnalysed-by: x\n${DECISION_FACET_MARKER}\n\n**VERDICT: PASS**`); return !r.analysis && !r.carriesLine; })()); + t('⭐ …while an analysis QUOTING a record in a fence stays an analysis, its own line read — the heading is read outside fences', (() => { const r = da(`${DA(`\`${CONTRACT_REVIEW_TIER_NAME}\``)}\n\n\`\`\`\n## Contract review\nServed-tier: \`${TIER_DEFAULT_NAME}\`\n\`\`\``); return r.analysis && r.state === 'at-tier'; })()); t('⛔ a FENCE quoting another analysis\'s pair and block is a citation: nothing read, no analysis', (() => { const r = da(`A note.\n\n\`\`\`\n${DA(`\`${CONTRACT_REVIEW_TIER_NAME}\``)}\n\`\`\`\n`); return r.state === 'missing' && r.analysedBy.state === 'missing' && !r.analysis; })()); t('⛔ …and the marker inside an inline span is a quotation too, the reading the handover check gives it', da(`See the \`${DECISION_FACET_MARKER}\` block.\nServed-tier: \`${CONTRACT_REVIEW_TIER_NAME}\``).analysis === false); t('decoration reads on `Analysed-by:` as on `Reviewed-by:` — a bulleted, bolded key and a backticked value', readAnalysedBy(`- **Analysed-by:** \`${DA_SESSION}\`, the decision thread`).value === DA_SESSION && readAnalysedBy(`> Analysed-by: ${DA_SESSION}.`).value === DA_SESSION); From d01bfa219be92b4fa3c8a2e094495ff692ffb8a7 Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 1 Dec 2026 08:19:33 +0000 Subject: [PATCH 08/10] fix(pm): issue-create judges only the analysis half, so a card body quoting a contract review record is not refused Claude-Session: https://claude.ai/code/session_01WGufzfWWgrLkABDvbRjhAk Co-authored-by: Claude --- scripts/pm/issue-create.mjs | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/scripts/pm/issue-create.mjs b/scripts/pm/issue-create.mjs index 08d4ae19f90..969b505a23c 100644 --- a/scripts/pm/issue-create.mjs +++ b/scripts/pm/issue-create.mjs @@ -44,9 +44,11 @@ * their workflows, never through here; * - a body that is a DECISION ANALYSIS declaring `Served-tier: * CONTRACT_REVIEW_TIER` with no `--tier-evidence=PATH`, or with one - * `verify-review-tier.mjs` refuses — `recordTierEvidenceRefusal` - * (`post-stamped.mjs`), the judge a comment meets, imported and ⛔ never - * restated. The transcript stays local; neither it nor a model identifier + * `verify-review-tier.mjs` refuses — `analysisTierEvidenceRefusal` + * (`post-stamped.mjs`), the analysis half of the judge a comment meets, + * imported and ⛔ never restated. Only that half: a `## Contract review` + * record is a comment, never a card body, so a body QUOTING one is not + * judged as a record. The transcript stays local; neither it nor a model identifier * enters the card. A body that is not an analysis, or names another tier, * is untouched. * @@ -116,7 +118,7 @@ import { fileURLToPath } from 'node:url'; import { isEntrypoint } from '../invoked-as.mjs'; import { DECISION_FACET_MARKER, EXIT_PREREQUISITE_NOT_MET, PROXY_FLAG, SEAT_SIGNATURE_SHAPE, proxyRearmPlan, resolveSweepRepo, signatureRefusal } from './check-half-states.mjs'; -import { recordTierEvidenceRefusal, recordTierEvidenceRefusalText } from './post-stamped.mjs'; +import { analysisTierEvidenceRefusal, recordTierEvidenceRefusalText } from './post-stamped.mjs'; // The self-test's transcript fixtures name the tier by the constants' own values, ⛔ never a spelled model id. import { CONTRACT_REVIEW_TIER, CONTRACT_REVIEW_TIER_NAME } from './dispatch-gates.mjs'; import { EXIT_UNCONFIRMED, exitForResult, matchRunAnnotations, packRequest, parseRelayAnnotation, relayAnnotationMessage, resolveRoute, retiredLaneRewriteLine, rewriteRetiredLaneLabels, sendFleetWrite, unconfirmedText } from './fleet-write/dispatch.mjs'; @@ -240,7 +242,8 @@ export function planFrom(opts, { read = (p) => readFileSync(p, 'utf8'), env = pr // A decision analysis at the contract-review tier carries local evidence that passes — post-stamped's own judge (header). if (opts.tierEvidence === '') errors.push('--tier-evidence= names no file. Pass the analysing run\'s transcript (a sub-agent\'s output file, or this session\'s own): --tier-evidence=PATH'); else { - const tier = recordTierEvidenceRefusal(body, opts.tierEvidence ?? null); + // The ANALYSIS half only: a record is a comment, never a card body, so a body quoting one is not judged as one. + const tier = analysisTierEvidenceRefusal(body, opts.tierEvidence ?? null); if (tier !== null) errors.push(recordTierEvidenceRefusalText(tier, { tool: 'issue-create' })); } } @@ -478,7 +481,7 @@ const SELF_TEST_BATTERIES = Object.freeze({ 'the relay transport: ONE dispatch carrying the create, the card found by title since the dispatch, and an accepted dispatch with no run UNCONFIRMED under auto too — never the direct POST': 9, 'the retired lane aliases: a domain:engine / services / cli / rest --label is sent as domain:server on either transport, the dry run and the read-back say so, a live domain:* label passes untouched, and nothing is refused': 8, "the relay annotation: the number the relay run's annotation carries is read first — the card read back at it with NO list; absent, the title finds it as before; the read-back still judges the annotated card": 5, - 'the analysis tier: a card body that is a decision analysis declaring CONTRACT_REVIEW_TIER is planned only on a transcript verify-review-tier.mjs passes — post-stamped\'s own judge; another tier and a body that is no analysis are untouched': 8, + 'the analysis tier: a card body that is a decision analysis declaring CONTRACT_REVIEW_TIER is planned only on a transcript verify-review-tier.mjs passes — post-stamped\'s own judge; another tier, a body that is no analysis and a body quoting a record are untouched': 10, }); const SELF_TEST_BATTERY_FLOOR = 9; const UNATTRIBUTED_BATTERY = '(unattributed)'; @@ -554,7 +557,7 @@ export async function selfTest() { } // ── the analysis tier ───────────────────────────────────────────────────── - battery('the analysis tier: a card body that is a decision analysis declaring CONTRACT_REVIEW_TIER is planned only on a transcript verify-review-tier.mjs passes — post-stamped\'s own judge; another tier and a body that is no analysis are untouched'); + battery('the analysis tier: a card body that is a decision analysis declaring CONTRACT_REVIEW_TIER is planned only on a transcript verify-review-tier.mjs passes — post-stamped\'s own judge; another tier, a body that is no analysis and a body quoting a record are untouched'); { const tierDir = mkdtempSync(join(tmpdir(), 'issue-create-tier-')); try { @@ -564,7 +567,10 @@ export async function selfTest() { writeFileSync(atTier, [JSON.stringify({ type: 'user', message: { role: 'user', content: 'analyse' } }), turn(CONTRACT_REVIEW_TIER), turn(CONTRACT_REVIEW_TIER)].join('\n')); writeFileSync(offTier, [turn(CONTRACT_REVIEW_TIER), turn('other-model-for-the-self-test')].join('\n')); const analysis = (tier) => `${SIG}\n## 维护者速读\n- 问题:一句话。\n\nServed-tier: \`${tier}\`\nAnalysed-by: \`session_01AnalysisFixture9Qx\`\n\n${DECISION_FACET_MARKER}\n- ① 项目长远合理性:不扩大特例。\n`; - const tierFiles = { 't.txt': 'A decision card', 'at.md': analysis(CONTRACT_REVIEW_TIER_NAME), 'default.md': analysis('TIER_DEFAULT'), 'plain.md': `${SIG}\nA note: Served-tier: \`${CONTRACT_REVIEW_TIER_NAME}\` is what analyses carry.\n` }; + const tierFiles = { 't.txt': 'A decision card', 'at.md': analysis(CONTRACT_REVIEW_TIER_NAME), 'default.md': analysis('TIER_DEFAULT'), 'plain.md': `${SIG}\nA note: Served-tier: \`${CONTRACT_REVIEW_TIER_NAME}\` is what analyses carry.\n`, + 'quoted-record.md': `${SIG}\nThe record below was refused by the guard:\n\n## Contract review\n\nServed-tier: \`${CONTRACT_REVIEW_TIER_NAME}\`\nLocal-runs: none\n\n**VERDICT: PASS**\n`, + 'fenced-record.md': `${SIG}\nThe record:\n\n\`\`\`\n## Contract review\nServed-tier: \`${CONTRACT_REVIEW_TIER_NAME}\`\n\`\`\`\n`, + 'analysis-quoting.md': `${analysis(CONTRACT_REVIEW_TIER_NAME)}\n\`\`\`\n## Contract review\nServed-tier: \`TIER_DEFAULT\`\n\`\`\`\n` }; const tierRead = (p) => { if (!(p in tierFiles)) throw new Error('ENOENT'); return tierFiles[p]; @@ -579,7 +585,9 @@ export async function selfTest() { t('⭐ a body that is no analysis is untouched, with no evidence', plan('plain.md').ok); t('⛔ --tier-evidence= with no path is refused, never read as absent', plan('default.md', '--tier-evidence=').errors.some((e) => e.includes('names no file'))); const own = readReal(SELF_PATH, 'utf8'); - t('structural: the judge is post-stamped.mjs\'s, imported — ⛔ never restated here', /import \{[^}]*\brecordTierEvidenceRefusal\b[^}]*\} from '\.\/post-stamped\.mjs';/u.test(own) && !/function\s+(recordTierEvidenceRefusal|readDecisionAnalysisTier)\b/u.test(own)); + t('structural: the judge is post-stamped.mjs\'s analysis half, imported — ⛔ never restated here, and ⛔ never the record half', /import \{[^}]*\banalysisTierEvidenceRefusal\b[^}]*\} from '\.\/post-stamped\.mjs';/u.test(own) && !/function\s+(analysisTierEvidenceRefusal|recordTierEvidenceRefusal|readDecisionAnalysisTier)\b/u.test(own) && !/\brecordTierEvidenceRefusal\(/u.test(own)); + t('⭐ a card body QUOTING a `## Contract review` record with an at-tier line is planned with no evidence — bare or fenced', plan('quoted-record.md').ok && plan('fenced-record.md').ok, true, [...plan('quoted-record.md').errors, ...plan('fenced-record.md').errors].join(' | ')); + t('⛔ …while an analysis body that quotes a fenced record is still judged on its own at-tier line', plan('analysis-quoting.md').ok === false && plan('analysis-quoting.md', `--tier-evidence=${atTier}`).ok === true); } finally { rmSync(tierDir, { recursive: true, force: true }); } From 3e39c9bba644c743bed25c954419ea9041cebfdc Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 1 Dec 2026 08:20:04 +0000 Subject: [PATCH 09/10] docs(pm-dispatch): bound the --tier-evidence sentence to the three writes that judge an analysis The decision-analysis.md ceiling follows the landed bytes: 5580 -> 5855 (+275), ruling record 7303021478. Claude-Session: https://claude.ai/code/session_01WGufzfWWgrLkABDvbRjhAk Co-authored-by: Claude --- .claude/skills/pm-dispatch/references/decision-analysis.md | 2 +- scripts/pm/check-skill-line-ratchet.mjs | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.claude/skills/pm-dispatch/references/decision-analysis.md b/.claude/skills/pm-dispatch/references/decision-analysis.md index 83523d2a35c..3067c48de04 100644 --- a/.claude/skills/pm-dispatch/references/decision-analysis.md +++ b/.claude/skills/pm-dispatch/references/decision-analysis.md @@ -19,7 +19,7 @@ - 问题写客户看到的症状、谁碰到、多频繁;选项句写选了客户看到什么、约几个 PR。 - ⛔ 速读不写代码名、文件路径、命令、裁决字母、裸卡号;点到的卡配一句中文说明。 - 四轴、四棱块、自检行、置信缺口、工作量先例归英文分析段,⛔ 不删。 -- 英文段首两行 `Served-tier: `、`Analysed-by: `(执笔会话或子代理),⛔ 不写模型 id;标 `CONTRACT_REVIEW_TIER` 须执笔转录过 `verify-review-tier.mjs`(`--tier-evidence=` 写入即判)。 +- 英文段首两行 `Served-tier: `、`Analysed-by: `(执笔会话或子代理),⛔ 不写模型 id;标 `CONTRACT_REVIEW_TIER` 须执笔转录过 `verify-review-tier.mjs`(评论、新卡、新引入该行的正文刷新经 `--tier-evidence=` 写入即判)。 - 呈维护者前读该行(`check-owed-reviews.mjs --decisions` 逐卡列):缺或未达档 ⇒ 达档重跑,贴带两行的 delta 评论(逐棱同异)再呈;⛔ 永不呈读不出档的分析。 - 达档且仍现行(载行后无裁决、正文未改)⇒ 照原样呈,只跑前提 re-check,⛔ 不重跑;前提已变 ⇒ 达档重跑。 diff --git a/scripts/pm/check-skill-line-ratchet.mjs b/scripts/pm/check-skill-line-ratchet.mjs index f41500b4568..1e0a0d38abc 100644 --- a/scripts/pm/check-skill-line-ratchet.mjs +++ b/scripts/pm/check-skill-line-ratchet.mjs @@ -85,7 +85,7 @@ export const CEILINGS = new Map([ ['.claude/skills/pm-dispatch/references/dispatch-runbook.md', 20483], // raised 20070 → 20354 (+284) by ruling record 7075909669 (#36203 items 1-5: 「同意五条都改」): a card thread confirms Actions started after each push; the seat reads pr-state of every in-flight card PR; lowered 20354 → 20344 by the PR that moved the tier and effort values to the one home; raised 20344 → 20483 (+139) by ruling record 7076315104 (Q13, the decision card 「定一下:五条新增规则要不要写进技能」: 「五条都写」): the thread's first report carries the served tier and the seat writes it into the claim ['.claude/skills/pm-dispatch/references/state-machine.md', 4243], // raised 4189 → 4243 (+54, the landed bytes) by the maintainer's ruling quoted in the body of the rule card and recorded by triage record 7254553088 (「立卡改技能,现在就派发」): lane seats unlock their own blocked cards every round and first-touch the cards they file ['.claude/skills/pm-dispatch/references/contract-review.md', 6420], // raised 6419 → 6420 (+1) by ruling record 7249169754 (Q1 A: 「同意,立卡派发」): the hand-off line names its target seat `LANE@ACCOUNT`, the template `record-recognisers.mjs` holds verbatim - ['.claude/skills/pm-dispatch/references/decision-analysis.md', 5803], // raised 5580 → 5803 (+223, the landed bytes) by ruling record 7303021478 (「升 p2,交 fleet 区现在做」, with the maintainer's 「之前已经用 fable 分析过的不用重复分析吧?」): an analysis at tier and still current is presented as it stands with a premise re-check, the per-card reading that says so is named, and the `--tier-evidence=` parenthetical now says the writer judges an analysis — recorded under `ruledRaises` on this file's move declaration below; before that: lowered 5589 → 5580 by the decision-analysis tier-line PR (its worked 速读 example deleted to pay for the `Served-tier:` / `Analysed-by:` lines); before that: raised 5023 → 5589 (+566) by the declared cross-file move from SKILL.md (CROSS_FILE_MOVES below); before that: raised 4892 → 5023 (+131) by ruling record 7076338827, the addendum to 7076315104 (a simple question goes to the maintainer in chat after the at-tier analysis: 「不一定要写成文件吧?简单的问题是不是直接和我沟通就可以」) + ['.claude/skills/pm-dispatch/references/decision-analysis.md', 5855], // raised 5580 → 5855 (+275, the landed bytes) by ruling record 7303021478 (「升 p2,交 fleet 区现在做」, with the maintainer's 「之前已经用 fable 分析过的不用重复分析吧?」): an analysis at tier and still current is presented as it stands with a premise re-check, the per-card reading that says so is named, and the `--tier-evidence=` parenthetical now names the three writes that judge an analysis (a comment, a new card, a body refresh introducing the line) — recorded under `ruledRaises` on this file's move declaration below; before that: lowered 5589 → 5580 by the decision-analysis tier-line PR (its worked 速读 example deleted to pay for the `Served-tier:` / `Analysed-by:` lines); before that: raised 5023 → 5589 (+566) by the declared cross-file move from SKILL.md (CROSS_FILE_MOVES below); before that: raised 4892 → 5023 (+131) by ruling record 7076338827, the addendum to 7076315104 (a simple question goes to the maintainer in chat after the at-tier analysis: 「不一定要写成文件吧?简单的问题是不是直接和我沟通就可以」) ['.claude/skills/pm-dispatch/references/platform-readings.md', 1082], ['.claude/skills/pm-dispatch/references/readings-queue.md', 9074], ['.claude/skills/pm-dispatch/references/readings-channels.md', 7138], @@ -198,7 +198,7 @@ export const CROSS_FILE_MOVES = new Map([ was: 5023, sources: [['.claude/skills/pm-dispatch/SKILL.md', 33919]], ruledRaises: [ - { ruling: 'ruling record 7303021478 — 「升 p2,交 fleet 区现在做」: an at-tier, still-current analysis is presented as it stands, with a premise re-check', date: '2026-12-01', delta: 223 }, + { ruling: 'ruling record 7303021478 — 「升 p2,交 fleet 区现在做」: an at-tier, still-current analysis is presented as it stands, with a premise re-check', date: '2026-12-01', delta: 275 }, ], }], ]); From 00fbbe54eb8c2d33cc3e2522c62a5880b7d785ea Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 1 Dec 2026 08:46:54 +0000 Subject: [PATCH 10/10] fix(pm): judge a comment's at-tier analysis before its record branch, so a fenced quoted record cannot hide the pair recordTierEvidenceRefusal tested the record heading on the raw comment and returned without the analysis half, while readDecisionAnalysisTier reads the heading with fences blanked. A comment quoting a record in a fence above its own at-tier pair was written unjudged and listed at-tier. The analysis is now judged first (a true record is never an analysis to that reader, so records keep their branch), and the refusal names an analysis in that case. Claude-Session: https://claude.ai/code/session_01WGufzfWWgrLkABDvbRjhAk Co-authored-by: Claude --- scripts/pm/post-stamped.mjs | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/scripts/pm/post-stamped.mjs b/scripts/pm/post-stamped.mjs index b96a5fe188a..960f17532ae 100644 --- a/scripts/pm/post-stamped.mjs +++ b/scripts/pm/post-stamped.mjs @@ -2350,11 +2350,14 @@ export function recordLineRefusalText(rows) { * An analysis is what `readDecisionAnalysisTier` (`record-recognisers.mjs`) calls one — the four-facet marker outside * code, or an `Analysed-by:` line — and its `Served-tier:` line is that reader's, read with fences blanked: the reading * the presenting seat's listing gives the same text later (`check-owed-reviews.mjs --decisions`), ⛔ never a second - * parser. `kind` names which of the two the refusal is about. + * parser. `kind` names which of the two the refusal is about. The analysis is judged FIRST: a comment that quotes a + * record in a fence ahead of its own at-tier pair is an analysis to that reader, so it is judged, and refused, as one. A + * true record (heading outside fences) is never an analysis there, so the record branch below keeps reading it raw. */ export function recordTierEvidenceRefusal(body, tierEvidence) { const text = String(body ?? ''); - if (!CONTRACT_REVIEW_HEADING_MARKER.test(text)) return analysisTierEvidenceRefusal(text, tierEvidence); + if (declaresAtTierAnalysis(text)) return tierEvidenceVerdict('analysis', tierEvidence); + if (!CONTRACT_REVIEW_HEADING_MARKER.test(text)) return null; const served = readServedTier(text); if (served.state !== 'read' || served.value !== CONTRACT_REVIEW_TIER_NAME) return null; return tierEvidenceVerdict('record', tierEvidence); @@ -4486,7 +4489,7 @@ const SELF_TEST_BATTERIES = Object.freeze({ 'the one judge: every body refusal on ONE path — `main` and `label-write.mjs --comment-file` call `judgeBody`, never a copy': 14, 'the review route: a `Request: contract-review` knock addressed to triage is refused; to a review or sibling seat, and every other key to triage, it passes': 13, 'the record tier: a record naming `CONTRACT_REVIEW_TIER` is written only on a transcript `verify-review-tier.mjs` passes; another tier and a non-record comment are untouched': 16, - 'the analysis tier: a decision analysis naming `CONTRACT_REVIEW_TIER` is written only on a transcript `verify-review-tier.mjs` passes, read by the listing\'s own reader; another tier, no line, a quotation and a non-analysis are untouched': 17, + 'the analysis tier: a decision analysis naming `CONTRACT_REVIEW_TIER` is written only on a transcript `verify-review-tier.mjs` passes, read by the listing\'s own reader; another tier, no line, a quotation and a non-analysis are untouched': 19, 'the claim stroke: a comment opening `Claim:` is refused on every route but `direct`, pointing at the `label-write` fold; the same body through that fold passes': 21, }); const SELF_TEST_BATTERY_FLOOR = 30; @@ -6263,6 +6266,11 @@ export function selfTest() { t('⛔ …and so is one replacing a TIER_DEFAULT line with the contract tier, while at-tier evidence passes it and off-tier evidence does not', bodyTierEvidenceRefusal(ANALYSIS(CONTRACT_REVIEW_TIER_NAME), ANALYSIS('TIER_DEFAULT'), null) !== null && bodyTierEvidenceRefusal(ANALYSIS(CONTRACT_REVIEW_TIER_NAME), ANALYSIS(null), atTier) === null && bodyTierEvidenceRefusal(ANALYSIS(CONTRACT_REVIEW_TIER_NAME), ANALYSIS(null), offTier) !== null); t('⭐ a refresh KEEPING an at-tier line already on the stored body is untouched — it has no transcript to show', bodyTierEvidenceRefusal(`${ANALYSIS(CONTRACT_REVIEW_TIER_NAME)}\n\nRuled: 7302999 · letter A · 2026-11-30T10:05Z`, ANALYSIS(CONTRACT_REVIEW_TIER_NAME), null) === null); t('⭐ a refresh that is no analysis, or names another tier, is untouched; a card body quoting a record is no record', bodyTierEvidenceRefusal(ANALYSIS(CONTRACT_REVIEW_TIER_NAME, { by: null, marker: false }), '', null) === null && bodyTierEvidenceRefusal(ANALYSIS('TIER_DEFAULT'), '', null) === null && analysisTierEvidenceRefusal(`${SIG}\nA tooling card quoting a record:\n\n## Contract review\nServed-tier: \`${CONTRACT_REVIEW_TIER_NAME}\`\n\n**VERDICT: PASS**`, null) === null); + const QUOTED = (served) => [SIG, '## 决策:空闲清理放在哪一层', '', 'The record this answers:', '', '```', '## Contract review', `Served-tier: \`${served}\``, '', '**VERDICT: PASS**', '```', '', `Served-tier: \`${CONTRACT_REVIEW_TIER_NAME}\``, 'Analysed-by: `session_01AnalysisWriterFixture7Q`', '', 'Background prose.'].join('\n'); + const quotedOff = judged(QUOTED('TIER_DEFAULT'), null); + t('⛔ a comment quoting a record in a FENCE ahead of its own at-tier pair is an analysis, refused without evidence as one — the listing reads it at-tier', !quotedOff.ok && quotedOff.text.startsWith('post-stamped: REFUSED — this decision analysis') && readDecisionAnalysisTier(QUOTED('TIER_DEFAULT')).state === 'at-tier' && judged(QUOTED('TIER_DEFAULT'), atTier).ok); + const quotedAt = judged(QUOTED(CONTRACT_REVIEW_TIER_NAME), null); + t('⛔ …and when the quoted record names the contract tier too, the refusal still speaks of an analysis, not a record', !quotedAt.ok && quotedAt.text.startsWith('post-stamped: REFUSED — this decision analysis')); t('structural: main judges a --body refresh with bodyTierEvidenceRefusal on the stored body it read, right after the unread check', /unreadComments\(\{ storedBody: tail\.card\?\.body[^]*?const introduced = bodyTierEvidenceRefusal\(rendered\.body, tail\.card\?\.body, options\.tierEvidence \?\? null\);/u.test(own)); t('structural: the analysis reading is `readDecisionAnalysisTier`, imported from record-recognisers.mjs — ⛔ no second reader of the pair here', /import \{[^}]*\breadDecisionAnalysisTier\b[^}]*\} from '\.\/record-recognisers\.mjs';/u.test(own) && !/function\s+(readDecisionAnalysisTier|readAnalysedBy)\b/u.test(own)); } finally {