Skip to content

Commit b4c170a

Browse files
committed
fix(pm): settle the decision-analysis tier-line gaps — the newest analysis governs, a Ruling-ref comment is a ruling, the sub-agent Analysed-by value
- decision-analysis.md: Analysed-by is one session id (a sub-agent's analysis carries the session that dispatched and posts it, as Reviewed-by does); a refused transcript means a sub-agent re-run at tier, never a relabel; the newest analysis governs, and a changed recommendation refreshes the card-top summary body first, the delta in a later minute. - check-owed-reviews --decisions: a newer analysis with no line of the pair supersedes the older carrier and reads missing; a comment whose first content line is Ruling-ref: is a ruling after the carrier (stale). Self-test +5. - label-write: usage and both --tier-evidence refusals name the decision analysis beside the contract review record. - ratchet: decision-analysis.md 5855 -> 6146 (+291) under ruling 7303021478. Refs #38874 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Utp6CaUYMgihyBHZ33ewFC
1 parent 850d240 commit b4c170a

4 files changed

Lines changed: 52 additions & 18 deletions

File tree

‎.claude/skills/pm-dispatch/references/decision-analysis.md‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,10 @@
1919
- 问题写客户看到的症状、谁碰到、多频繁;选项句写选了客户看到什么、约几个 PR。
2020
- ⛔ 速读不写代码名、文件路径、命令、裁决字母、裸卡号;点到的卡配一句中文说明。
2121
- 四轴、四棱块、自检行、置信缺口、工作量先例归英文分析段,⛔ 不删。
22-
- 英文段首两行 `Served-tier: <CONTRACT_REVIEW_TIER | TIER_DEFAULT>`、`Analysed-by: <session>`(执笔会话或子代理),⛔ 不写模型 id;标 `CONTRACT_REVIEW_TIER` 须执笔转录过 `verify-review-tier.mjs`(评论、新卡、新引入该行的正文刷新经 `--tier-evidence=` 写入即判)。
22+
- 英文段首两行 `Served-tier: <CONTRACT_REVIEW_TIER | TIER_DEFAULT>`、`Analysed-by: <session>`(执笔会话;子代理执笔写派它并贴出的会话,同 `Reviewed-by:`),值恰一 token,⛔ 不写散文、模型 id;标 `CONTRACT_REVIEW_TIER` 须执笔转录过 `verify-review-tier.mjs`(评论、新卡、新引入该行的正文刷新经 `--tier-evidence=` 写入即判),拒即子代理达档重跑 ⛔ 不改档名。
2323
- 呈维护者前读该行(`check-owed-reviews.mjs --decisions` 逐卡列):缺或未达档 ⇒ 达档重跑,贴带两行的 delta 评论(逐棱同异)再呈;⛔ 永不呈读不出档的分析。
2424
- 达档且仍现行(载行后无裁决、正文未改)⇒ 照原样呈,只跑前提 re-check,⛔ 不重跑;前提已变 ⇒ 达档重跑。
25+
- 最新一份分析为准:读最新带两行者,其后无行的分析读作缺行;推荐变了同笔改速读,先刷正文、隔分钟再贴 delta(同分钟读 stale)。
2526

2627
分析段骨架:背景 / Governing text(引文 + grep,或 none found + 检索式)/ 协议声明、是否改协议 /
2728
带 re-check 命令的前提 / 具体问题 / 选项 / 推荐 / 相关单与 PR。正文六项:

‎scripts/pm/check-owed-reviews.mjs‎

Lines changed: 41 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -109,11 +109,15 @@
109109
* the NEWEST text on the card that carries a line of the pair — the body, or a comment (a delta
110110
* re-analysis is newer than the body it re-runs): `at-tier`, `below-tier`, `unreadable`, `missing`
111111
* (no line anywhere; the row says whether the card carries an analysis at all), or `unjudged` (the
112-
* thread could not be read). Read through the queue guard's author binding, as records are: a body
112+
* thread could not be read). ⛔ The newest ANALYSIS governs, not the newest line: an analysis posted
113+
* after the carrier with no line of the pair reads `missing` (it names the analysis it supersedes and
114+
* the line it leaves unread), never the older line it was written to replace. Read through the queue guard's author binding, as records are: a body
113115
* or comment by any other author is never the carrier, and the drops are counted on the row.
114116
* carrier the comment id that carries the line, or `body`.
115117
* current whether the analysis is still the card's question: `stale` when a ruling comment
116-
* (`classifyRulingComment`, the prior-rulings reader's three measured shapes) follows the carrier,
118+
* (`classifyRulingComment`, the prior-rulings reader's three measured shapes, or a comment whose first
119+
* content line is `Ruling-ref:` — the maintainer ruling a seat records on the card, a grade ruling
120+
* included: the safe direction) follows the carrier,
117121
* when the body carries a `Ruled:` record (`ruledRecords`) at or after it, or, for a comment
118122
* carrier, when the body's newest protocol stamp (`lastWriteStamp`) is at or after its minute — a
119123
* body written since. ⚠️ A body edit that writes no stamp is NOT seen: the REST issue carries no
@@ -137,7 +141,7 @@ import process from 'node:process';
137141

138142
import { isEntrypoint } from '../invoked-as.mjs';
139143
import { cardIntakeKeys, CONTRACT_REVIEW_HEADING_MARKER, contractReviewVerdictLines, DECISION_INBOX_LABEL, latestMarkedComment, readSignatureLine, ruledRecords, seatNameId, seatIntakeKeys, signedSeatId, withSeatNumbers } from './check-half-states.mjs';
140-
import { classifyRulingComment } from './check-prior-rulings.mjs';
144+
import { classifyRulingComment, firstContentLine } from './check-prior-rulings.mjs';
141145
import { lastWriteStamp } from './post-stamped.mjs';
142146
import { repoIdForSlug } from './check-governed-merges.mjs';
143147
import { GOVERNED_APPROVERS, NARROWING_FACE_LINE, narrowingDeclarationsIn, recordAuthorTrusted, recordTrustedAuthors } from './check-governed-queue-guard.mjs';
@@ -572,6 +576,16 @@ const createdMs = (row) => {
572576
const byThreadOrder = (a, b) => createdMs(a) - createdMs(b) || Number(a?.id) - Number(b?.id);
573577
const minuteFloor = (ms) => Math.floor(ms / 60000) * 60000;
574578

579+
/**
580+
* A comment that records a maintainer ruling on its first content line, `Ruling-ref: …` (a grade set on a decision
581+
* card, a ruling quoted where a seat executes it). ⛔ Read on the first content line only, after the signature line
582+
* (`firstContentLine`): a claim or a triage audit carrying a `Ruling-ref:` line further down cites a ruling, and is
583+
* not one. Local to this reader: the prior-rulings reader keeps its three shapes.
584+
*/
585+
export function isRulingRefComment(body) {
586+
return /^Ruling-ref\s*[::]/.test(firstContentLine(body));
587+
}
588+
575589
/**
576590
* Whether the analysis on `carrier` is still the card's question — the reasons it is not, empty when it is. Pure.
577591
* The bound (an unstamped body edit is unseen) is the header's.
@@ -580,8 +594,8 @@ export function decisionCurrency(card, comments, carrier) {
580594
const reasons = [];
581595
const at = carrier.where === 'body' ? Number.NEGATIVE_INFINITY : createdMs(carrier.row);
582596
const after = carrier.where === 'body' ? comments : comments.filter((c) => byThreadOrder(c, carrier.row) > 0);
583-
const ruling = after.find((c) => classifyRulingComment(c?.body) !== null);
584-
if (ruling) reasons.push(`ruling comment ${ruling.id ?? '?'} after it`);
597+
const ruling = after.find((c) => classifyRulingComment(c?.body) !== null || isRulingRefComment(c?.body));
598+
if (ruling) reasons.push(`ruling comment ${ruling.id ?? '?'} after it${isRulingRefComment(ruling.body) ? ' (`Ruling-ref:`)' : ''}`);
585599
const ruled = ruledRecords(card?.body ?? '').find((r) => r.at === null || r.at >= minuteFloor(at));
586600
if (ruled) reasons.push(`body \`Ruled: ${ruled.id}\`${ruled.at === null ? ' (unstamped)' : ''} at or after it`);
587601
if (carrier.where === 'comment') {
@@ -597,14 +611,18 @@ export function decisionCurrency(card, comments, carrier) {
597611
*/
598612
export function decisionAnalysisRow(card, comments, trusted = RECORD_AUTHORS) {
599613
const base = { card: card?.number ?? null, title: String(card?.title ?? '') };
600-
if (!Array.isArray(comments)) return { ...base, state: 'unjudged', analysis: null, carrier: null, analysedBy: null, current: null, act: DECISION_ACT_RERUN, ignored: 0, bodyRead: false };
614+
if (!Array.isArray(comments)) return { ...base, state: 'unjudged', analysis: null, carrier: null, uncarried: null, analysedBy: null, current: null, act: DECISION_ACT_RERUN, ignored: 0, bodyRead: false };
601615
const kept = comments.filter((c) => recordAuthorTrusted(c, trusted)).sort(byThreadOrder);
602616
const bodyRead = recordAuthorTrusted(card, trusted);
603617
const texts = [
604618
...(bodyRead ? [{ where: 'body', id: null, row: card, reading: readDecisionAnalysisTier(card.body) }] : []),
605619
...kept.map((c) => ({ where: 'comment', id: c.id ?? null, row: c, reading: readDecisionAnalysisTier(c.body) })),
606620
];
607-
const carrier = [...texts].reverse().find((x) => x.reading.carriesLine) ?? null;
621+
// The newest ANALYSIS governs: one with no line of the pair supersedes an older carrier and reads `missing`.
622+
const newest = [...texts].reverse().find((x) => x.reading.analysis) ?? null;
623+
const older = [...texts].reverse().find((x) => x.reading.carriesLine) ?? null;
624+
const carrier = newest?.reading.carriesLine ? newest : null; // a line rides only on an analysis, so no analysis ⇒ no line
625+
const uncarried = carrier === null && newest !== null && older !== null ? { where: newest.where, id: newest.id, supersedes: older.where === 'body' ? 'body' : older.id } : null;
608626
const state = carrier === null ? 'missing' : carrier.reading.state;
609627
const current = carrier === null ? null : decisionCurrency(card, kept, carrier);
610628
const by = carrier?.reading.analysedBy;
@@ -613,6 +631,7 @@ export function decisionAnalysisRow(card, comments, trusted = RECORD_AUTHORS) {
613631
state,
614632
analysis: texts.some((x) => x.reading.analysis),
615633
carrier: carrier === null ? null : { where: carrier.where, id: carrier.id, at: carrier.row?.created_at ?? null },
634+
uncarried,
616635
analysedBy: by === undefined ? null : by.state === 'read' ? by.value : by.state,
617636
current,
618637
act: state === 'at-tier' && current?.state === 'current' ? DECISION_ACT_PRESENT : DECISION_ACT_RERUN,
@@ -633,6 +652,7 @@ export function renderDecisionRow(row) {
633652
const where = row.carrier === null ? null : row.carrier.where === 'body' ? 'line in the body' : `line on comment ${row.carrier.id}`;
634653
const parts = [`#${row.card} ${row.state}`];
635654
if (row.state === 'unjudged') parts.push('thread not read');
655+
else if (row.uncarried) parts.push(`newer analysis ${row.uncarried.where === 'body' ? 'in the body' : `on comment ${row.uncarried.id}`} carries no Served-tier / Analysed-by line (supersedes the line ${row.uncarried.supersedes === 'body' ? 'in the body' : `on comment ${row.uncarried.supersedes}`})`);
636656
else if (row.carrier === null) parts.push(row.analysis ? 'analysis carries no Served-tier / Analysed-by line' : 'no analysis found on the card');
637657
else parts.push(`${where} (Analysed-by ${row.analysedBy})`, row.current.state === 'current' ? 'current' : `stale: ${row.current.reasons.join('; ')}`);
638658
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)` : '';
@@ -653,7 +673,7 @@ export function renderDecisionReport(rows, { repo, now, gaps }) {
653673
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}`));
654674
lines.push(
655675
'',
656-
'`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.',
676+
'`current` reads ruling comments (a first-line `Ruling-ref:` too), `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.',
657677
'Report-only: exit 0, nothing written. The rule is `references/decision-analysis.md` 〈落卡分析模板〉.',
658678
);
659679
return lines;
@@ -807,7 +827,7 @@ const SELF_TEST_BATTERIES = Object.freeze({
807827
'the report: one line per owing PR, TAKE first, exit 0': 5,
808828
'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,
809829
// The decision box (`--decisions`): the analysis tier read by the record's own parser, its carrier, its currency.
810-
'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,
830+
'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': 21,
811831
});
812832
const SELF_TEST_BATTERY_FLOOR = 10;
813833
const UNATTRIBUTED_BATTERY = '(no battery open)';
@@ -1074,6 +1094,17 @@ export function selfTest() {
10741094
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'));
10751095
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'));
10761096
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');
1097+
// A later analysis with no line of the pair supersedes the older carrier (#38874 N-a): the newest ANALYSIS governs.
1098+
const bare = (id, at) => cmt(id, at, `${DSIG}\n## Re-analysis\n\nos-decision-facets\n- ① 项目长远合理性:changed.\n\nThis seat now recommends **B**.`);
1099+
const r5 = decisionAnalysisRow(card(), [delta(7301, '2026-11-30T09:00:00Z'), bare(7303, '2026-11-30T11:00:00Z')]);
1100+
t('⛔ a NEWER analysis with no line supersedes the at-tier carrier ⇒ missing, re-run; the row names both comments', r5.state === 'missing' && r5.carrier === null && r5.act === DECISION_ACT_RERUN && r5.uncarried?.id === 7303 && r5.uncarried?.supersedes === 7301 && renderDecisionRow(r5).includes('newer analysis on comment 7303') && renderDecisionRow(r5).includes('line on comment 7301'), JSON.stringify(r5));
1101+
t('…while a newer comment that is no analysis (a plain note) leaves the carrier governing', decisionAnalysisRow(card(), [delta(7301, '2026-11-30T09:00:00Z'), cmt(7304, '2026-11-30T11:00:00Z', `${DSIG}\nPremise re-checked: holds.`)]).act === DECISION_ACT_PRESENT);
1102+
// A maintainer ruling recorded on its first content line as `Ruling-ref:` (#38874 N-b, e.g. a grade ruling).
1103+
const ref = (id, at, first) => cmt(id, at, `${DSIG}\n\n${first}\nQuestion, verbatim: 「x」`);
1104+
t('⛔ a comment whose FIRST content line is `Ruling-ref:` after the carrier is a ruling ⇒ stale, and the reason says so', (() => { const r = decisionAnalysisRow(card(), [delta(7301, '2026-11-30T09:00:00Z'), ref(7305, '2026-11-30T10:00:00Z', 'Ruling-ref: priority:p2 · 2026-11-30T09:59Z · a grade set by the maintainer.')]); return r.current.state === 'stale' && r.current.reasons[0].includes('7305') && r.current.reasons[0].includes('Ruling-ref') && r.act === DECISION_ACT_RERUN; })());
1105+
t('…while a claim that CITES a ruling on a later line is not one ⇒ still current', decisionAnalysisRow(card(), [delta(7301, '2026-11-30T09:00:00Z'), ref(7306, '2026-11-30T10:00:00Z', 'Claim: PM loop round 4\nRuling-ref: 7300000001')]).current.state === 'current' && isRulingRefComment(`${DSIG}\n**Ruling-ref:** 7303021478`) && !isRulingRefComment('Claim: x\nRuling-ref: 1'));
1106+
// The refresh order the rule states (#38874 N-c): body first, the delta in a LATER minute; the same minute reads stale.
1107+
t('⭐ body refreshed first, delta posted in a later minute ⇒ current; the same minute ⇒ stale (stamps read to the minute, the safe direction)', decisionAnalysisRow(card({ body: analysisBody(null, 'Refreshed 2026-11-30T09:00Z.') }), [delta(7301, '2026-11-30T09:01:10Z')]).current.state === 'current' && decisionAnalysisRow(card({ body: analysisBody(null, 'Refreshed 2026-11-30T09:01Z.') }), [delta(7301, '2026-11-30T09:01:50Z')]).current.state === 'stale');
10771108
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'); })());
10781109
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'); })());
10791110
t('⛔ a `## Contract review` record on the card is not an analysis\'s carrier', decisionAnalysisRow(card(), [recordRow(HEAD)]).state === 'missing');
@@ -1112,7 +1143,7 @@ export function selfTest() {
11121143
+ '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; '
11131144
+ 'every read through one reader with failures as gaps; the report, exit 0; a lane\'s live hold holding (b) alone, '
11141145
+ 'cleared by a new head, an unreadable hold line voiding nothing and printed, listed at 24 hours and still WAIT; '
1115-
+ '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).',
1146+
+ 'the decision box — each analysis\'s tier on its newest trusted carrier, at tier, below, missing or unjudged, a newer analysis with no line reading missing, stale after a ruling (a first-line `Ruling-ref:` too) or a body written since, and present-as-it-stands only at tier and current).',
11161147
);
11171148
selfTestReachedVerdict = true;
11181149
return 0;

0 commit comments

Comments
 (0)