Skip to content

Commit 2b6764e

Browse files
committed
test(spec): the allowOrgOverride absence walk asks the new name only of the readers it asserts
The new-name readers are asserted by containment of a three-file list, so only those three files are parsed for the new name; the old name is still read off every file in the radius that mentions it. Every expect keeps its meaning. Co-authored-by: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VTJ1Sey3QK5wZbayQXfFfH
1 parent 785590f commit 2b6764e

1 file changed

Lines changed: 16 additions & 8 deletions

File tree

‎packages/spec/src/kernel/metadata-type-registry-allow-org-override-absence.test.ts‎

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,18 @@ describe('tree-scoped absence: no TypeScript source in the declared radius reads
4747
const IN_RADIUS = (rel: string) =>
4848
(rel.startsWith('packages/') && rel.endsWith('.ts'))
4949
|| /^examples\/[^/]+\/src\/.+\.ts$/.test(rel);
50+
/**
51+
* Hand-renamed readers the walk must see as code references under the NEW
52+
* name (anti-vacuity, asserted below). Only these files are asked the new
53+
* name: the assertion is containment of exactly this list, so no other file
54+
* can change its verdict, and parsing every other file that mentions the new
55+
* name was about a third of the walk's parsing.
56+
*/
57+
const NEW_READERS = [
58+
'packages/metadata-protocol/src/protocol.ts',
59+
'packages/metadata-protocol/src/sys-metadata-repository.ts',
60+
'packages/spec/src/kernel/metadata-plugin.zod.ts',
61+
];
5062
/** Build, SCM and cache state — not authored sources. */
5163
const SKIPPED_DIRS = new Set(['node_modules', 'dist', '.git', '.turbo', '.cache', '.objectstack', 'coverage', '.next', '.source']);
5264

@@ -61,8 +73,8 @@ describe('tree-scoped absence: no TypeScript source in the declared radius reads
6173
/**
6274
* Every CODE reference to each of `names` in `text`, as `line:col` per name —
6375
* identifiers and quoted keys, never comments or prose strings. One parse
64-
* serves every name: the walk below asks two names of the same file, and the
65-
* files holding both are the largest in the radius (megabytes each).
76+
* serves every name: the walk below can ask two names of the same file, and
77+
* the files holding both are the largest in the radius (megabytes each).
6678
*/
6779
const codeReferencesByName = (fileName: string, text: string, names: readonly string[]): Map<string, string[]> => {
6880
const sf = ts.createSourceFile(fileName, text, ts.ScriptTarget.Latest, true, ts.ScriptKind.TS);
@@ -130,7 +142,7 @@ describe('tree-scoped absence: no TypeScript source in the declared radius reads
130142
if ((err as NodeJS.ErrnoException)?.code === 'ENOENT') continue;
131143
throw err;
132144
}
133-
const names = [NEW, OLD].filter((name) => text.includes(name));
145+
const names = [OLD, ...(NEW_READERS.includes(rel) ? [NEW] : [])].filter((name) => text.includes(name));
134146
if (names.length === 0) continue;
135147
const refs = codeReferencesByName(rel, text, names);
136148
if ((refs.get(NEW)?.length ?? 0) > 0) newReaders.add(rel);
@@ -150,11 +162,7 @@ describe('tree-scoped absence: no TypeScript source in the declared radius reads
150162
// Live positive control: the refusal pin's deliberate `allowOrgOverride: true`
151163
// and `: false` are real code references, and the walk found them.
152164
expect(refusalPinReferences.length).toBeGreaterThanOrEqual(2);
153-
expect([...newReaders]).toEqual(expect.arrayContaining([
154-
'packages/metadata-protocol/src/protocol.ts',
155-
'packages/metadata-protocol/src/sys-metadata-repository.ts',
156-
'packages/spec/src/kernel/metadata-plugin.zod.ts',
157-
]));
165+
expect([...newReaders]).toEqual(expect.arrayContaining(NEW_READERS));
158166
expect(
159167
offenders,
160168
'a code reference to `allowOrgOverride` reads `undefined` against the tombstone and closes every type — read `allowEnvironmentOverlay`',

0 commit comments

Comments
 (0)