Skip to content

Commit 0c9c1c5

Browse files
committed
pm-dispatch(review): record-recognisers reads the Contract-review-hold line; check-owed-reviews lets a live hold hold trigger (b) and lists a hold at 24 hours
record-recognisers.mjs: readContractReviewHold reads the line (session, head 7-40 hex by prefix, reason, until CONDITION; a missing fact or a fifth part is unreadable and holds nothing); contractReviewHold reads the thread, newest governs: live on the current head, stale once the head moved, its age from the comment's created_at a reading (overdue at 24 hours), never a lapse. Self-test: a hold-line battery of 19 cases, the template and its 24-hour listing pinned verbatim in contract-review.md; floor 16 -> 17. check-owed-reviews.mjs: the row carries a hold field; trigger (b) yields to a live hold while (a) and (c) still fire; status stays one of four (WAIT for a held head); a live hold 24 hours or older on a WAIT row is listed, in the row and under the report, for the triage round record. Self-test: a hold battery of 13 cases; floor 8 -> 9. Claude-Session: https://claude.ai/code/session_01QSeKYmhU5KEj1nukYhp1Tg Co-authored-by: Claude <noreply@anthropic.com>
1 parent 5e9ad6c commit 0c9c1c5

2 files changed

Lines changed: 261 additions & 11 deletions

File tree

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

Lines changed: 90 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -41,15 +41,25 @@
4141
* `unreadable`.
4242
* claim the `Contract-review-claim:` lines: `live` (who holds the head,
4343
* the lane winning a tie), `lapsed`, `none`.
44+
* hold the newest `Contract-review-hold:` line, as `contractReviewHold`
45+
* reads it: `live` (it names the current head: trigger (b) does not
46+
* fire, and its age is printed), `stale` (the head moved: cleared),
47+
* `absent`, `unreadable` (it holds nothing). A live hold at
48+
* `CONTRACT_REVIEW_HOLD_LIST_HOURS` or older on a WAIT row is LISTED,
49+
* for the triage round record — the age is a reading, never a lapse.
4450
* lane seat the lane of the PR's card (`domain:*`) against the open seat
4551
* posts: `seated`, `stood-down`, `absent`, `unknown`.
4652
* status `TAKE` (owed, nobody on it, a trigger holds), `WAIT` (owed,
47-
* nobody on it, no trigger yet — the lane's own), `HELD` (a live
48-
* claim on this head), `DONE` (a record on this head).
53+
* nobody on it, no trigger yet — the lane's own, a lane's live hold
54+
* included), `HELD` (a live claim on this head), `DONE` (a record on
55+
* this head). Four, ⛔ no fifth for a hold: a held head is the lane's
56+
* own wait, and a `HOLD` beside `HELD` is one letter from a misread.
4957
* trigger the first that holds: (a) a hand-off line naming the current
5058
* head, or the waiting label — taken the same round; (b) the head
51-
* has waited a full triage round (`TRIAGE_ROUND_MINUTES`); (c) the
52-
* lane's seat has stood down or is absent from the seat roster.
59+
* has waited a full triage round (`TRIAGE_ROUND_MINUTES`) and no
60+
* live hold names it; (c) the lane's seat has stood down or is
61+
* absent from the seat roster. A live hold holds (b) alone: the
62+
* lane that holds ends it with (a), and a lane gone is (c).
5363
*
5464
* ## Report-only — the exit is 0 on every completed or incomplete read
5565
*
@@ -70,9 +80,11 @@ import { readClause2Line } from './clause2-line.mjs';
7080
import { parseSeat } from './fleet-roster.mjs';
7181
import { ghApi, readAllPages } from './gh-pages.mjs';
7282
import {
83+
CONTRACT_REVIEW_HOLD_LIST_HOURS,
7384
REVIEWED_BY_LINE,
7485
contractReviewClaims,
7586
contractReviewHandoff,
87+
contractReviewHold,
7688
deliveredCardNumber,
7789
locateReviewOfRecord,
7890
reviewFace,
@@ -229,16 +241,21 @@ export function owedReviewRow(pull, { now, seats, repo = DEFAULT_REPO }) {
229241
const record = recordReading(pull);
230242
const handoff = contractReviewHandoff(pull.comments, head);
231243
const claim = contractReviewClaims(pull.comments, head, { now });
244+
const hold = contractReviewHold(pull.comments, head, { now });
232245
const lane = laneSeatOf(pull.cardLabels, seats);
233246
const triggers = [];
234247
if (handoff.state === 'triage') triggers.push('(a) hand-off');
235248
if (owed.limbs.includes('label')) triggers.push('(a) label');
236-
if (waited !== null && waited >= TRIAGE_ROUND_MINUTES) triggers.push(`(b) waited ${waited} min`);
249+
// (b) alone yields to a live hold: the lane said "not this head yet", and only (a) or (c) overrides that.
250+
const roundWaited = waited !== null && waited >= TRIAGE_ROUND_MINUTES ? `(b) waited ${waited} min` : null;
251+
if (roundWaited !== null && hold.state !== 'live') triggers.push(roundWaited);
237252
if (lane.seat === 'stood-down' || lane.seat === 'absent') triggers.push(`(c) lane seat ${lane.seat}`);
238253
let status;
239254
if (record.state === 'current') status = 'DONE';
240255
else if (claim.state === 'live') status = 'HELD';
241256
else status = triggers.length > 0 ? 'TAKE' : 'WAIT';
257+
// Listed for the round record: a live hold the age reading calls overdue — or cannot time — on a row it keeps waiting.
258+
const listed = status === 'WAIT' && hold.state === 'live' && hold.overdue !== false;
242259
return {
243260
pr: pull.number,
244261
draft: pull.draft === true,
@@ -249,6 +266,19 @@ export function owedReviewRow(pull, { now, seats, repo = DEFAULT_REPO }) {
249266
record,
250267
handoff: { state: handoff.state, id: handoff.id ?? null },
251268
claim: { state: claim.state, holder: claim.holder ?? null, tie: claim.tie ?? false, unreadable: claim.unreadable ?? [] },
269+
hold: {
270+
state: hold.state,
271+
id: hold.id ?? null,
272+
session: hold.session ?? null,
273+
reason: hold.reason ?? null,
274+
until: hold.until ?? null,
275+
at: hold.at ?? null,
276+
ageMinutes: hold.ageMinutes ?? null,
277+
overdue: hold.overdue ?? null,
278+
holds: hold.state === 'live' ? roundWaited : null,
279+
listed,
280+
gaps: hold.gaps ?? [],
281+
},
252282
lane: lane.lane,
253283
laneSeat: lane.seat,
254284
status,
@@ -285,11 +315,28 @@ export function renderRow(row) {
285315
`record ${record}`,
286316
`hand-off ${row.handoff.state}${row.handoff.id === null ? '' : ` (${row.handoff.id})`}`,
287317
`claim ${claim}`,
318+
`hold ${holdText(row.hold)}`,
288319
`lane ${row.lane ?? '?'} ${row.laneSeat}`,
289320
];
290321
const tail = row.trigger === null ? '' : ` → ${row.trigger}`;
322+
const listed = row.hold.listed ? ` ⏳ HOLD ${holdAge(row.hold)} — list it in the triage round record` : '';
291323
const gaps = row.gaps.length > 0 ? ` ⚠️ UNREAD: ${row.gaps.join('; ')}` : '';
292-
return `${parts.join(' · ')}${tail}${gaps}`;
324+
return `${parts.join(' · ')}${tail}${listed}${gaps}`;
325+
}
326+
327+
/** The hold's age as printed: hours, or that it could not be timed. Pure. */
328+
function holdAge(hold) {
329+
return hold.ageMinutes === null ? 'age unknown' : `${Math.floor(hold.ageMinutes / 60)} h old`;
330+
}
331+
332+
/** The hold part of a row: who holds, since when, until what, and the (b) it holds. Pure. */
333+
function holdText(hold) {
334+
if (hold.state === 'live') {
335+
const holds = hold.holds === null ? '' : `, holds ${hold.holds}`;
336+
return `live ${hold.session} (${hold.id}, ${holdAge(hold)}${holds}) until ${hold.until}`;
337+
}
338+
if (hold.state === 'stale' || hold.state === 'unreadable') return `${hold.state}${hold.id === null ? '' : ` (${hold.id})`}`;
339+
return hold.state;
293340
}
294341

295342
/** The printed report. Pure. */
@@ -301,6 +348,14 @@ export function renderReport(rows, { repo, now, read, gaps }) {
301348
'',
302349
...rows.map(renderRow),
303350
];
351+
const listed = rows.filter((r) => r.hold.listed);
352+
if (listed.length > 0) {
353+
lines.push(
354+
'',
355+
`⏳ ${listed.length} hold(s) ${CONTRACT_REVIEW_HOLD_LIST_HOURS} h or older keep a PR waiting — list each in the triage round record:`,
356+
...listed.map((r) => ` - #${r.pr} held by ${r.hold.session} since ${r.hold.at ?? '?'} (${holdAge(r.hold)}) until ${r.hold.until}`),
357+
);
358+
}
304359
if (gaps.length > 0) {
305360
lines.push('', `⚠️ sweep INCOMPLETE — ${gaps.length} read(s) failed; the rows above are not the whole answer:`, ...gaps.map((g) => ` - ${g}`));
306361
}
@@ -408,8 +463,9 @@ const SELF_TEST_BATTERIES = Object.freeze({
408463
'the live instance: two Tier H drafts with a hand-off on the current head list as TAKE under (a)': 4,
409464
'the live read: every read through one reader; a failed read is INCOMPLETE, never clean': 6,
410465
'the report: one line per owing PR, TAKE first, exit 0': 5,
466+
'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': 13,
411467
});
412-
const SELF_TEST_BATTERY_FLOOR = 8;
468+
const SELF_TEST_BATTERY_FLOOR = 9;
413469
const UNATTRIBUTED_BATTERY = '(no battery open)';
414470

415471
export function selfTest() {
@@ -553,6 +609,31 @@ export function selfTest() {
553609
t('--json prints the rows as one JSON document, still exit 0', main(['--repo', DEFAULT_REPO, '--json', '--now', '2026-10-28T13:00:00Z'], { get: fake(routes), log: (l) => jsonOut.push(l) }) === EXIT_OK && JSON.parse(jsonOut.join('\n')).rows[0].pr === 27136);
554610
t('a usage error exits 2 and prints the usage', main(['--bogus'], { get: fake({}), log: () => {}, error: () => {} }) === EXIT_USAGE);
555611

612+
battery('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');
613+
// The lane's "not this head yet", posted as the lane posts it: signature, then the one line.
614+
const LANE_SIG = `domain:ui#1 · os-bill · ${LANE}`;
615+
const holdRow = (head, at, id = 6472451890) => ({ id, created_at: at, body: `${LANE_SIG}\n\nContract-review-hold: \`${LANE}\` · head \`${head}\` · the stack still lands under it · until the last sibling PR merges` });
616+
const ripe = '2026-10-28T11:59:00Z'; // committed 61 minutes before NOW: (b) holds when nothing holds it
617+
const heldAt = '2026-10-28T12:10:00Z';
618+
const held = row({ headCommittedAt: ripe, comments: [holdRow(HEAD, heldAt)] });
619+
t('⭐ a live hold on the current head holds (b): a full round waited, no record, no claim ⇒ WAIT, not TAKE — and with no hold the same row is TAKE under (b)', held.status === 'WAIT' && held.trigger === 'none yet' && held.hold.state === 'live' && held.hold.holds === '(b) waited 61 min' && row({ headCommittedAt: ripe }).status === 'TAKE' && row({ headCommittedAt: ripe }).trigger === '(b) waited 61 min', JSON.stringify(held.hold));
620+
t('the row prints the hold: who holds, the comment, its age, the (b) it holds and until what', renderRow(held).includes(`hold live ${LANE} (6472451890, 0 h old, holds (b) waited 61 min) until the last sibling PR merges`), renderRow(held));
621+
t('⛔ a hold on an EARLIER head holds nothing — the head moved, (b) fires ⇒ TAKE', (() => { const r = row({ headCommittedAt: ripe, comments: [holdRow(HEAD2, heldAt)] }); return r.hold.state === 'stale' && r.status === 'TAKE' && r.trigger === '(b) waited 61 min' && r.hold.holds === null; })());
622+
t('⭐ (a) still fires under a live hold — the label or a hand-off on this head is the holding lane ending its hold ⇒ TAKE', row({ headCommittedAt: ripe, labels: [{ name: WAITING_LABEL }], comments: [holdRow(HEAD, heldAt)] }).trigger === '(a) label' && row({ headCommittedAt: ripe, comments: [holdRow(HEAD, heldAt), handoff(HEAD, '2026-10-28T12:40:00Z')] }).trigger === '(a) hand-off');
623+
t('(c) still fires under a live hold — a lane seat that is gone holds nothing', row({ headCommittedAt: ripe, comments: [holdRow(HEAD, heldAt)] }, [{ lane: 'domain:ui', status: 'paused' }]).trigger === '(c) lane seat stood-down');
624+
t('⛔ an unreadable hold holds nothing ⇒ (b) fires, and the row names the hold comment as unreadable', (() => { const r = row({ headCommittedAt: ripe, comments: [{ id: 7701, created_at: heldAt, body: 'Contract-review-hold: soon' }] }); return r.hold.state === 'unreadable' && r.status === 'TAKE' && renderRow(r).includes('hold unreadable (7701)'); })());
625+
t('a hold changes neither a live claim (HELD) nor a record on this head (DONE)', row({ headCommittedAt: ripe, comments: [holdRow(HEAD, heldAt), claimRow(TRIAGE, HEAD, '2026-10-28T12:18:56Z', `triage#1 · os-zhuang · ${TRIAGE}`)] }).status === 'HELD' && row({ headCommittedAt: ripe, comments: [holdRow(HEAD, heldAt), recordRow(HEAD)] }).status === 'DONE');
626+
const aged = row({ headCommittedAt: '2026-10-27T08:00:00Z', comments: [holdRow(HEAD, '2026-10-27T13:00:00Z')] });
627+
t('⭐ at 24 hours the hold reads overdue and STILL holds — the row stays WAIT, no fifth status — and the row is LISTED for the round record', aged.status === 'WAIT' && aged.hold.state === 'live' && aged.hold.overdue === true && aged.hold.listed === true && renderRow(aged).includes('⏳ HOLD 24 h old — list it in the triage round record'), renderRow(aged));
628+
const report = renderReport([aged], { repo: DEFAULT_REPO, now: NOW, read: { pulls: 1, drafts: 1 }, gaps: [] });
629+
t('⭐ the report lists it under the rows: the PR, the holder, when it was posted, its age and the condition', report.some((l) => l.startsWith('⏳ 1 hold(s) 24 h or older keep a PR waiting')) && report.includes(` - #27136 held by ${LANE} since 2026-10-27T13:00:00Z (24 h old) until the last sibling PR merges`), report.join(' | '));
630+
t('under 24 hours nothing is listed; an overdue hold on a DONE or HELD row is not listed — nothing waits on it', held.hold.listed === false && !renderReport([held], { repo: DEFAULT_REPO, now: NOW, read: { pulls: 1, drafts: 1 }, gaps: [] }).some((l) => l.startsWith('⏳')) && row({ headCommittedAt: '2026-10-27T08:00:00Z', comments: [holdRow(HEAD, '2026-10-27T13:00:00Z'), recordRow(HEAD)] }).hold.listed === false && row({ headCommittedAt: '2026-10-27T08:00:00Z', comments: [holdRow(HEAD, '2026-10-27T13:00:00Z'), claimRow(TRIAGE, HEAD, '2026-10-28T12:18:56Z', `triage#1 · os-zhuang · ${TRIAGE}`)] }).hold.listed === false);
631+
t('⛔ a live hold whose age cannot be timed is LISTED as unknown, never dropped as young', (() => { const r = row({ headCommittedAt: ripe, comments: [{ id: 9, body: holdRow(HEAD, heldAt).body }] }); return r.status === 'WAIT' && r.hold.overdue === null && r.hold.listed === true && renderRow(r).includes('⏳ HOLD age unknown'); })());
632+
const holdJson = [];
633+
main(['--repo', DEFAULT_REPO, '--json', '--now', '2026-10-28T13:00:00Z'], { get: fake({ ...routes, '/repos/objectstack-ai/objectstack/issues/27136/comments': { ok: true, value: [holdRow(HEAD, '2026-10-27T13:00:00Z')] } }), log: (l) => holdJson.push(l) });
634+
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); })());
635+
t('⛔ the status vocabulary stays exactly four, in order — a hold is the lane\'s own WAIT', STATUS_ORDER.join() === 'TAKE,WAIT,HELD,DONE');
636+
556637
// Floor: the opened set equals the declared set, each battery at or above its pin.
557638
const declared = Object.keys(SELF_TEST_BATTERIES);
558639
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 });
@@ -572,7 +653,8 @@ export function selfTest() {
572653
`✓ check-owed-reviews self-test: ${cases.length} cases pass in ${declared.length} batteries (the owed face from paths, `
573654
+ 'the Clause-② line and the label, drafts included; the record on this head, an earlier head, none, unjudged; '
574655
+ 'the (a) / (b) / (c) triggers; claims holding and lapsing, the lane winning a tie; the two live drafts as TAKE; '
575-
+ 'every read through one reader with failures as gaps; the report, exit 0).',
656+
+ 'every read through one reader with failures as gaps; the report, exit 0; a lane\'s live hold holding (b) alone, '
657+
+ 'cleared by a new head, listed at 24 hours and still WAIT).',
576658
);
577659
selfTestReachedVerdict = true;
578660
return 0;

0 commit comments

Comments
 (0)