Skip to content

Commit 9e4e676

Browse files
committed
fix(pm): the owed-review list finds a narrowing declared on the Metadata-protocol line alone, as the queue leg does
Claude-Session: https://claude.ai/code/session_01QsR2jTeURPvEm465RcoYEC Co-authored-by: Claude <noreply@anthropic.com>
1 parent 43c83ca commit 9e4e676

1 file changed

Lines changed: 17 additions & 4 deletions

File tree

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

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ import process from 'node:process';
111111
import { isEntrypoint } from '../invoked-as.mjs';
112112
import { cardIntakeKeys, CONTRACT_REVIEW_HEADING_MARKER, contractReviewVerdictLines, latestMarkedComment, readSignatureLine, seatIntakeKeys } from './check-half-states.mjs';
113113
import { repoIdForSlug } from './check-governed-merges.mjs';
114-
import { GOVERNED_APPROVERS, recordAuthorTrusted, recordTrustedAuthors } from './check-governed-queue-guard.mjs';
114+
import { GOVERNED_APPROVERS, NARROWING_FACE_LINE, narrowingDeclarationsIn, recordAuthorTrusted, recordTrustedAuthors } from './check-governed-queue-guard.mjs';
115115
import { FLEET_BOT_LOGIN } from './check-handover.mjs';
116116
import { readClause2Line } from './clause2-line.mjs';
117117
import { parseSeat } from './fleet-roster.mjs';
@@ -197,17 +197,25 @@ export function parseArgs(argv) {
197197
* path limbs are `reviewFace`'s `hits` (the queue guard's own reading), the
198198
* declaration limbs are `readClause2Line` on the PR body, and the face named
199199
* beside them is `reviewFace`'s answer for the same inputs.
200+
*
201+
* ⭐ A narrowing is found the way the queue's narrowed leg finds one (`narrowingDeclarationsIn`, imported): a
202+
* `Metadata-protocol: narrowed` line counts as well as a `Clause-②:` narrowing arm, and the face is then read with
203+
* the narrowing spelling handed in first (`NARROWING_FACE_LINE`), exactly as that leg holds the record — so a
204+
* narrowing declared on the protocol line alone, on a diff with no schema and no governed path, is listed at the
205+
* narrowing face's tier, never missed (N4 of #35610). One bound, stated: this list reads the body alone; the queue
206+
* leg also reads the changesets its commits touch.
200207
*/
201208
export function owedFace(pull, repo = DEFAULT_REPO) {
202209
const paths = Array.isArray(pull?.files) ? pull.files : [];
203210
const body = String(pull?.body ?? '');
211+
const narrowing = narrowingDeclarationsIn(body).length > 0;
204212
// `reviewFace` takes the register's repository ID; an unregistered slug reaches it as null and is refused there, loudly.
205-
const face = reviewFace(paths, repoIdForSlug(repo), { declaredOn: [body] });
213+
const face = reviewFace(paths, repoIdForSlug(repo), { declaredOn: narrowing ? [NARROWING_FACE_LINE, body] : [body] });
206214
const limbs = [];
207215
if (face.hits.schema.length > 0) limbs.push('schema');
208216
if (face.hits.rules.length > 0) limbs.push('rules');
209217
const declared = readClause2Line(body);
210-
if (declared?.kind === 'declared' && declared.arm === 'narrowing') limbs.push('narrowing');
218+
if (narrowing) limbs.push('narrowing');
211219
else if (declared?.kind === 'declared' && declared.value === 'yes') limbs.push('declaration');
212220
else if (declared?.kind === 'malformed') limbs.push('clause2-unreadable');
213221
if (labelNames(pull).includes(WAITING_LABEL)) limbs.push('label');
@@ -610,7 +618,8 @@ let selfTestReachedVerdict = false;
610618

611619
const SELF_TEST_BATTERIES = Object.freeze({
612620
'arguments: modes and every refusal': 6,
613-
'the owed face: paths, the Clause-② line, the label — drafts included, nothing else owes': 9,
621+
// 9 → 11 (N4 of #35610): a narrowing on the `Metadata-protocol:` line alone owes the narrowing face; its control.
622+
'the owed face: paths, the Clause-② line, the label — drafts included, nothing else owes': 11,
614623
// 8 → 13 (#33705): the queue guard's author binding (an untrusted PASS unread, unable to shadow a trusted FAIL, an
615624
// approver's read) and its counted verdict reading (two lines `ambiguous`, an inline word alone `unstated`).
616625
'the record: on this head (by whom, as stated), on an earlier head, none, unjudged': 13,
@@ -690,6 +699,10 @@ export function selfTest() {
690699
t('a published schema path owes the schema face', owedFace(pull({ files: ['packages/spec/src/data/field.zod.ts'] })).limbs.includes('schema'));
691700
t('⭐ a `Clause-②: no (narrowing)` body owes with no contract path (the narrowing face)', owedFace(pull({ files: ['ui/packages/plugin-ai/package.json'], body: 'Clause-②: no (narrowing)\nMetadata-protocol: narrowed' })).limbs.join() === 'narrowing');
692701
t('a `Clause-②: yes` body owes the declaration face', owedFace(pull({ files: ['packages/runtime/src/x.ts'], body: 'Clause-②: yes\nMetadata-protocol: added' })).limbs.join() === 'declaration');
702+
// N4 of #35610: a narrowing declared on the `Metadata-protocol:` line alone owes, at the narrowing face's tier — as
703+
// the queue's narrowed leg demands; the control, the same body declaring `none`, owes nothing.
704+
t('⭐ a narrowing declared on `Metadata-protocol: narrowed` alone, beside a bare `Clause-②: no`, owes the narrowing face — as the queue leg reads it', ((r, q) => r.limbs.join() === 'narrowing' && r.face === q.face && r.tierName === q.tierName && r.face !== null)(owedFace(pull({ files: ['packages/runtime/src/x.ts'], body: 'Clause-②: no\nMetadata-protocol: narrowed' })), owedFace(pull({ files: ['packages/runtime/src/x.ts'], body: 'Clause-②: no (narrowing)\nMetadata-protocol: narrowed' }))));
705+
t('…the control: the same body with `Metadata-protocol: none` owes nothing, and the unfilled template menu declares nothing', owedFace(pull({ files: ['packages/runtime/src/x.ts'], body: 'Clause-②: no\nMetadata-protocol: none' })).limbs.length === 0 && owedFace(pull({ files: ['packages/runtime/src/x.ts'], body: 'Clause-②: no\nMetadata-protocol: added | narrowed | semantic | none' })).limbs.length === 0);
693706
t('a malformed `Clause-②:` line is listed, never dropped', owedFace(pull({ files: ['packages/runtime/src/x.ts'], body: 'Clause-②: maybe' })).limbs.join() === 'clause2-unreadable');
694707
t('⭐ the waiting label alone owes', owedFace(pull({ files: ['packages/runtime/src/x.ts'], body: 'Clause-②: no', labels: [{ name: WAITING_LABEL }] })).limbs.join() === 'label');
695708
t('⛔ an ordinary runtime diff declaring `Clause-②: no` owes NOTHING — no row', row({ files: ['packages/runtime/src/x.ts'], body: 'Clause-②: no' }) === null);

0 commit comments

Comments
 (0)