|
41 | 41 | * Each is its own `facades` row, and an exception row in such a file names its |
42 | 42 | * `class` (in a file with one facade the `class` may be left out). |
43 | 43 | * |
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 |
45 | 47 | * facade form on `main`, so the gate never reds `main` ahead of a landing: the |
46 | 48 | * PR that lands the facade (or the first PR after it) adds the row. |
47 | 49 | * |
@@ -170,6 +172,30 @@ const HERE = dirname(fileURLToPath(import.meta.url)); |
170 | 172 | const REPO_ROOT = resolve(HERE, '..'); |
171 | 173 | export const REGISTRY_FILE = 'scripts/facade-delegation-registry.json'; |
172 | 174 |
|
| 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 | + |
173 | 199 | const CARD_REF = /^#[1-9][0-9]*$/; |
174 | 200 | const FACADE_KEYS = Object.freeze(['file', 'class', 'card']); |
175 | 201 | const EXCEPTION_KEYS = Object.freeze(['file', 'class', 'member', 'card', 'reason']); |
@@ -824,8 +850,9 @@ const SELF_TEST_BATTERIES = Object.freeze({ |
824 | 850 | 'N4 a facade row without its card → RED': 1, |
825 | 851 | 'N5 an empty registry → GREEN with nothing guarded, never a crash': 1, |
826 | 852 | '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, |
827 | 854 | }); |
828 | | -const SELF_TEST_BATTERY_FLOOR = 37; |
| 855 | +const SELF_TEST_BATTERY_FLOOR = 38; |
829 | 856 |
|
830 | 857 | function selfTest() { |
831 | 858 | const FILE = 'pkg/src/facade.ts'; |
@@ -1020,6 +1047,23 @@ function selfTest() { |
1020 | 1047 | const r = runGate({ root: REPO_ROOT, registryPath: join(REPO_ROOT, REGISTRY_FILE) }); |
1021 | 1048 | return r.loadError ?? (r.result.problems.length === 0 ? null : `the committed registry is red: ${r.result.problems.map((p) => p.message).join(' | ')}`); |
1022 | 1049 | } }, |
| 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 | + } }, |
1023 | 1067 | ]; |
1024 | 1068 |
|
1025 | 1069 | const batterySeen = new Map(); |
|
0 commit comments