Skip to content

Commit 2bc5ece

Browse files
committed
feat(pm): teach bare-root-worklist the wide-population declaration
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012zGPuVVX3deAx9LdjK8jCk
1 parent e591804 commit 2bc5ece

1 file changed

Lines changed: 111 additions & 8 deletions

File tree

scripts/pm/bare-root-worklist.mjs

Lines changed: 111 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -70,12 +70,14 @@ import { isEntrypoint } from '../invoked-as.mjs';
7070
import { auditSource } from '../check-watch-hint-literal.mjs';
7171
import {
7272
collapseHint,
73+
declaredWidePopulation,
7374
discoverFamilies,
7475
extractWatchHints,
7576
hintCovers,
7677
maskComments,
7778
maskSelfTests,
7879
trackedFiles,
80+
widePopulationRefusal,
7981
} from './dispatch-gates.mjs';
8082

8183
const ROOT = new URL('../..', import.meta.url).pathname;
@@ -1345,7 +1347,14 @@ export function sweep(families, files, { restrict = true } = {}) {
13451347
for (const file of entry.files ?? []) {
13461348
const abs = join(ROOT, file);
13471349
if (!existsSync(abs)) continue;
1348-
const body = maskSelfTests(maskComments(readFileSync(abs, 'utf8')));
1350+
// The RAW source, read once and used twice. The literal sweep below needs
1351+
// it masked; the `wide-population` marker (#15341) is a COMMENT, so it
1352+
// only exists in the unmasked text -- reading it off `body` would find
1353+
// nothing, every row would read as undeclared, and the acceptance below
1354+
// would be silently vacuous rather than measurably so.
1355+
const raw = readFileSync(abs, 'utf8');
1356+
const wideDeclared = declaredWidePopulation(raw) !== null;
1357+
const body = maskSelfTests(maskComments(raw));
13491358
const spans = restrict ? populationSpans(body) : [];
13501359
for (const { word, index } of bareRootLiterals(body, dirs)) {
13511360
let constant = null;
@@ -1355,7 +1364,7 @@ export function sweep(families, files, { restrict = true } = {}) {
13551364
constant = span.name;
13561365
}
13571366
const key = restrict ? rowKey({ file, constant, word }) : `${file} ${word}`;
1358-
if (!byKey.has(key)) byKey.set(key, { file, constant, word, checks: [], coveringChecks: 0, key });
1367+
if (!byKey.has(key)) byKey.set(key, { file, constant, word, checks: [], coveringChecks: 0, key, wideDeclared });
13591368
const row = byKey.get(key);
13601369
if (row.checks.includes(check)) continue;
13611370
row.checks.push(check);
@@ -1368,6 +1377,47 @@ export function sweep(families, files, { restrict = true } = {}) {
13681377
.sort((a, b) => a.key.localeCompare(b.key));
13691378
}
13701379

1380+
/**
1381+
* The rows a recorded verdict CONTRADICTS — pure, so the live sweep and the
1382+
* fixture cases beside it cannot disagree about what a contradiction IS.
1383+
*
1384+
* A row is contradicted when the sweep now finds it REACHABLE and a verdict is
1385+
* still recorded for it: the row then asserts both that the population is
1386+
* reachable by declaration and, in its own recorded reason, that it is not.
1387+
*
1388+
* ## The `wide-population` marker is the deliberate-declaration form (#15341)
1389+
*
1390+
* The message below has always offered two honest resolutions, and the second
1391+
* is "withdraw the VERDICT, if the declaration is deliberate". That resolution
1392+
* cost the row: withdrawing a verdict on a shrink-only map leaves the row
1393+
* printing REACHABLE with no reason under it, and a refusal that was measured
1394+
* per row stops being readable anywhere. Maintainer ruling, 2026-09-05
1395+
* (decision batch #43, verbatim reply 「同意」): `dispatch-gates.mjs` gains a
1396+
* third derivation channel, `wide-population`, the refused families move onto
1397+
* it, and ⛔ this file's rows are NOT deleted.
1398+
*
1399+
* So the marker IS that deliberate-declaration form, and it resolves the
1400+
* contradiction without withdrawing anything: a gate carrying it has declared,
1401+
* in its own source, the very fact the verdict records — that CI runs it over a
1402+
* population no subtree glob places. The two halves stop contradicting because
1403+
* they are now the same statement said twice, in the two places that need it,
1404+
* and the row keeps its measured reason where a reader can still find it.
1405+
*
1406+
* ⛔ What it is NOT is an escape from the refusal it accompanies. A gate that
1407+
* declares a real subtree hint reaching an arbitrary file at the top of the
1408+
* root is contradicted exactly as before, marker or no marker — that gate has
1409+
* taken the declaration the verdict refused, which is the FIRST resolution and
1410+
* a different decision. The marker resolves the pair only by agreeing with the
1411+
* verdict; a hint disagrees with it, and disagreement is what this assertion is
1412+
* for.
1413+
*/
1414+
export function contradictedRows(rows, triage = TRIAGE) {
1415+
return rows
1416+
.filter((r) => r.covered && triage.has(r.key) && !r.wideDeclared)
1417+
.map((r) => `${r.key} [recorded ${triage.get(r.key).verdict}]`)
1418+
.sort();
1419+
}
1420+
13711421
function report({ wide = false } = {}) {
13721422
const files = trackedFiles();
13731423
const families = [...discoverFamilies().byCheck];
@@ -1757,10 +1807,7 @@ function selfTest() {
17571807
// can honestly wear any of the three, and choosing between the two honest
17581808
// resolutions RE-DECIDES a verdict on a shrink-only map — not something this
17591809
// assertion may do quietly, so it names both and picks neither.
1760-
const contradicted = rows
1761-
.filter((r) => r.covered && TRIAGE.has(r.key))
1762-
.map((r) => `${r.key} [recorded ${TRIAGE.get(r.key).verdict}]`)
1763-
.sort();
1810+
const contradicted = contradictedRows(rows);
17641811
t(`no recorded verdict sits on a row the sweep now finds REACHABLE${contradicted.length
17651812
? ` — CONTRADICTED: ${contradicted.join(' · ')}. That gate now declares a hint reaching an `
17661813
+ 'arbitrary file at the top of the root, so the row claims BOTH that the population is '
@@ -1773,9 +1820,62 @@ function selfTest() {
17731820
+ 'REACHABLE with no reason beneath it: that is the shrink this map already permits, and the '
17741821
+ 'seven reachable rows carrying no verdict today are its live shape. ⛔ Do NOT re-point the '
17751822
+ 'row at DECLARED-NARROWER: that verdict is defined for a row that stays UNCOVERED, and a '
1776-
+ 'covered row is the bare root wearing a glob, not a narrower subtree.'
1823+
+ 'covered row is the bare root wearing a glob, not a narrower subtree. A THIRD resolution '
1824+
+ 'exists since 2026-09-05 and costs the row nothing: the gate declares `dispatch-gates: '
1825+
+ 'wide-population -- REASON` in its own source, which AGREES with the refusal instead of '
1826+
+ 'overriding it, and `contradictedRows` excuses the pair without any verdict being withdrawn.'
17771827
: ''}`, contradicted.length === 0);
17781828

1829+
// The `wide-population` acceptance (#15341), both directions, on fixtures —
1830+
// because the live direction is VACUOUS on this tree and saying so is the
1831+
// point: no covered row carries the marker today, so a live-only pin would be
1832+
// an assertion over an empty set that reads exactly like a pass. The fixtures
1833+
// are what make the rule falsifiable, and the control under them names the
1834+
// gate that owns the shape this one excuses.
1835+
t('a covered row whose gate DECLARES a wide population is accepted — the deliberate-declaration form, '
1836+
+ 'agreeing with the recorded refusal rather than withdrawing it',
1837+
contradictedRows(
1838+
[{ key: 'k', covered: true, wideDeclared: true }],
1839+
new Map([['k', { verdict: 'REFUSE-WIDE' }]]),
1840+
).length === 0);
1841+
t('…and a covered row with NO such declaration is still CONTRADICTED — the refusal this assertion '
1842+
+ 'has always made, unmoved by the acceptance above',
1843+
(() => {
1844+
const out = contradictedRows(
1845+
[{ key: 'k', covered: true, wideDeclared: false }],
1846+
new Map([['k', { verdict: 'REFUSE-WIDE' }]]),
1847+
);
1848+
return out.length === 1 && out[0].includes('REFUSE-WIDE');
1849+
})());
1850+
t('an UNCOVERED row is contradicted by neither — the marker changes nothing about a row that was '
1851+
+ 'never reachable, which is every row this map actually holds today',
1852+
contradictedRows(
1853+
[{ key: 'k', covered: false, wideDeclared: false }, { key: 'j', covered: false, wideDeclared: true }],
1854+
new Map([['k', { verdict: 'REFUSE-WIDE' }], ['j', { verdict: 'REFUSE-UNSPELLABLE' }]]),
1855+
).length === 0);
1856+
// The handoff. The shape excused above — a marker sitting above a hint that
1857+
// reaches the top of the root — is not unowned: `dispatch-gates` REFUSES it,
1858+
// in the file that owns markers, as a gate claiming two population shapes at
1859+
// once. This assertion excuses it HERE only because naming it here would name
1860+
// it wrongly, as a verdict problem rather than a declaration problem.
1861+
t('the excused shape is refused by the gate that owns markers, so no configuration is excused by both',
1862+
(widePopulationRefusal({ widePopulationReason: 'walks packages entire', hints: ['packages/**'] }) ?? '')
1863+
.includes('NAMES paths'));
1864+
t('CONTROL: and that refusal really can come back null, so the pin above is discriminating',
1865+
widePopulationRefusal({ widePopulationReason: 'walks packages entire', hints: [] }) === null);
1866+
// The live direction, stated as the measurement it is rather than left to
1867+
// read as a silent pass: this tree has no covered row carrying the marker, so
1868+
// the acceptance above is currently doing nothing to the report — which is
1869+
// exactly what "the rows are not deleted" was ruled to mean.
1870+
const wideCovered = rows.filter((r) => r.wideDeclared && r.covered).map((r) => r.key).sort();
1871+
const wideRows = rows.filter((r) => r.wideDeclared).map((r) => r.key).sort();
1872+
t(`the ten declaring gates reach ${wideRows.length} row(s) here and ${wideCovered.length} of them is covered, so the `
1873+
+ 'acceptance withdraws no verdict on this tree — every recorded refusal still prints against its row'
1874+
+ (wideCovered.length ? ` — covered-and-declared: ${wideCovered.join(' · ')}` : ''),
1875+
wideCovered.length === 0);
1876+
t(`control: the marker IS being read off the live sweep (${wideRows.length} row(s) carry it), so the case above is `
1877+
+ 'measuring something rather than reporting a field nothing ever sets', wideRows.length > 0);
1878+
17791879
// The spelling rule the triage docblock states, held mechanically: a key
17801880
// spelled as a bare path would enter this file's own declared population.
17811881
const asHints = (s) => extractWatchHints(`const L = ${JSON.stringify(s)};`);
@@ -2073,7 +2173,10 @@ function selfTest() {
20732173
}
20742174
console.log(
20752175
`OK self-test: ${rows.length} live row(s), ${open.length} unreachable as spelled, `
2076-
+ `${TRIAGE.size} recorded verdict(s) — none stale, none missing, none contradicted. `
2176+
+ `${TRIAGE.size} recorded verdict(s) — none stale, none missing, none contradicted `
2177+
+ `(${rows.filter((r) => r.wideDeclared).length} row(s) whose gate carries the dispatch-gates `
2178+
+ 'wide-population declaration, the deliberate-declaration form this file accepts without '
2179+
+ 'withdrawing a verdict; none of them is covered, so none is excused by it today). '
20772180
+ `Each row is one literal in one gate source file: ${perInvocation.size} invocation(s) of `
20782181
+ `those literals fold onto them, ${twins} of them as twins of a row that already existed, `
20792182
+ "and no folded row's invocations disagree about reachability. "

0 commit comments

Comments
 (0)