Skip to content

Commit 9fc82cf

Browse files
committed
tooling(facade-delegation-only): declare the facade files as the gate's watch hints
The gate's only path literal was its registry JSON, so dispatch-gates filed the family as an artifact roster and never derived it for a diff to a facade file. Declare the three registered facade files as DECLARED_WATCH_HINTS and pin the declaration to the registry's facades[].file in both directions in the self-test (N7). Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FEkQ5nHcpVKdkynE7zEoAV
1 parent 9728ab1 commit 9fc82cf

1 file changed

Lines changed: 46 additions & 2 deletions

File tree

‎scripts/check-facade-delegation-only.mjs‎

Lines changed: 46 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,9 @@
4141
* Each is its own `facades` row, and an exception row in such a file names its
4242
* `class` (in a file with one facade the `class` may be left out).
4343
*
44-
* The next split adds one `facades` row. ⛔ A file joins only once it is in
44+
* The next split adds one `facades` row, and a NEW facade file also adds its
45+
* path to `DECLARED_WATCH_HINTS` below (the self-test refuses the registry and
46+
* the declaration disagreeing). ⛔ A file joins only once it is in
4547
* facade form on `main`, so the gate never reds `main` ahead of a landing: the
4648
* PR that lands the facade (or the first PR after it) adds the row.
4749
*
@@ -170,6 +172,30 @@ const HERE = dirname(fileURLToPath(import.meta.url));
170172
const REPO_ROOT = resolve(HERE, '..');
171173
export const REGISTRY_FILE = 'scripts/facade-delegation-registry.json';
172174

175+
/**
176+
* The files this gate JUDGES, declared for `scripts/pm/dispatch-gates.mjs`,
177+
* which reads a gate's population from the path literals in its source text.
178+
*
179+
* Without this list the gate's only literal is `REGISTRY_FILE`, so the
180+
* derivation filed the family as an "artifact roster" and stayed silent for a
181+
* diff to `protocol.ts`: the facade files live inside the registry JSON, where
182+
* a text scanner cannot see them. A dev who added two bodies to that facade
183+
* read 102 green derived gates, and CI went red on this one.
184+
*
185+
* The spelling is `DECLARED_WATCH_HINTS` (one repo-relative FILE per string,
186+
* the idiom of `scripts/check-tenant-chokepoint.mjs`) and not a subtree: the
187+
* gate reads the facade file and nothing beside it, so `packages/objectql/**`
188+
* would name it on hundreds of files it never opens. The list must stay a
189+
* literal array (`check:watch-hint-literal`). The self-test holds it EQUAL to
190+
* the registry's `facades[].file` in both directions, so registering a new
191+
* facade file reds until it is added here, and the failure names the string.
192+
*/
193+
const DECLARED_WATCH_HINTS = [
194+
'packages/metadata-protocol/src/protocol.ts',
195+
'packages/objectql/src/engine.ts',
196+
'packages/drivers/driver-sql/src/sql-driver.ts',
197+
];
198+
173199
const CARD_REF = /^#[1-9][0-9]*$/;
174200
const FACADE_KEYS = Object.freeze(['file', 'class', 'card']);
175201
const EXCEPTION_KEYS = Object.freeze(['file', 'class', 'member', 'card', 'reason']);
@@ -824,8 +850,9 @@ const SELF_TEST_BATTERIES = Object.freeze({
824850
'N4 a facade row without its card → RED': 1,
825851
'N5 an empty registry → GREEN with nothing guarded, never a crash': 1,
826852
'N6 the committed registry is well-formed against this checkout': 1,
853+
'N7 the declared watch hints are exactly the committed registry\'s facade files': 1,
827854
});
828-
const SELF_TEST_BATTERY_FLOOR = 37;
855+
const SELF_TEST_BATTERY_FLOOR = 38;
829856

830857
function selfTest() {
831858
const FILE = 'pkg/src/facade.ts';
@@ -1020,6 +1047,23 @@ function selfTest() {
10201047
const r = runGate({ root: REPO_ROOT, registryPath: join(REPO_ROOT, REGISTRY_FILE) });
10211048
return r.loadError ?? (r.result.problems.length === 0 ? null : `the committed registry is red: ${r.result.problems.map((p) => p.message).join(' | ')}`);
10221049
} },
1050+
{ label: 'N7 the declared watch hints are exactly the committed registry\'s facade files', run: () => {
1051+
const registry = JSON.parse(readFileSync(join(REPO_ROOT, REGISTRY_FILE), 'utf8'));
1052+
const registered = [...new Set((registry.facades ?? []).map((f) => f.file))];
1053+
const missing = registered.filter((f) => !DECLARED_WATCH_HINTS.includes(f));
1054+
const unread = DECLARED_WATCH_HINTS.filter((h) => !registered.includes(h));
1055+
const doubled = DECLARED_WATCH_HINTS.filter((h, i) => DECLARED_WATCH_HINTS.indexOf(h) !== i);
1056+
return all(
1057+
registered.length > 0 ? null : `${REGISTRY_FILE} registers no facade file, so there is nothing to hold the declaration to`,
1058+
missing.length === 0 ? null
1059+
: `registered facade file(s) ${missing.map((f) => `'${f}'`).join(', ')} missing from DECLARED_WATCH_HINTS: ` +
1060+
'add each string there, or dispatch-gates never names this gate for a diff to that file',
1061+
unread.length === 0 ? null
1062+
: `DECLARED_WATCH_HINTS names ${unread.map((f) => `'${f}'`).join(', ')}, which ${REGISTRY_FILE} does not register: ` +
1063+
'remove each string, or dispatch-gates names this gate for a file it never reads',
1064+
doubled.length === 0 ? null : `DECLARED_WATCH_HINTS names ${doubled.join(', ')} twice`,
1065+
);
1066+
} },
10231067
];
10241068

10251069
const batterySeen = new Map();

0 commit comments

Comments
 (0)