Skip to content

Commit f0d76f2

Browse files
committed
test(spec): the census masks only files that spell the key, so the walk fits the repo tier's timeout
Claude-Session: https://claude.ai/code/session_012uFegdfR6K6uqvLzt7XsdZ Co-authored-by: Claude <noreply@anthropic.com>
1 parent ebcdce5 commit f0d76f2

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

‎packages/spec/src/contracts/record-share-guest-recipient-census.test.ts‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,11 @@ const lineOf = (text: string, index: number): number => text.slice(0, index).spl
8080
/** Extensions read as JS/TS source: their comments are blanked first, since a comment writes no row. */
8181
const CODE_EXT = new Set(['.ts', '.mts', '.cts', '.js', '.mjs', '.cjs']);
8282

83+
/** Cheap pre-filter: a file that never spells the key cannot hold a producer (and is never masked). */
84+
const SPELLS_RECIPIENT_KEY = /recipient_?[tT]ype/;
85+
8386
const producersIn = (ext: string, raw: string, live = 'guest'): number[] => {
84-
if (!raw.includes(live)) return [];
87+
if (!raw.includes(live) || !SPELLS_RECIPIENT_KEY.test(raw)) return [];
8588
// `maskComments` blanks comment content and keeps offsets and line numbers.
8689
const text = CODE_EXT.has(ext) ? maskComments(raw) : raw;
8790
const out: number[] = [];
@@ -108,6 +111,7 @@ const literalsInBrackets = (text: string, open: number): string[] => {
108111

109112
/** Leg 2: the options of the `recipient_type` select in a file that declares `sys_record_share`, or `null`. */
110113
const recordShareSelectOptions = (raw: string): string[] | null => {
114+
if (!raw.includes('sys_record_share') || !raw.includes('recipient_type')) return null;
111115
const text = maskComments(raw);
112116
if (!/name:\s*['"]sys_record_share['"]/.test(text)) return null;
113117
const at = text.search(/recipient_type\s*:\s*Field\.select\(/);
@@ -118,6 +122,7 @@ const recordShareSelectOptions = (raw: string): string[] | null => {
118122

119123
/** Leg 3: the literal members of `RecordShareRecipientType`, or `null` when the file does not declare it. */
120124
const unionMembers = (raw: string): string[] | null => {
125+
if (!raw.includes('RecordShareRecipientType')) return null;
121126
const m = /export\s+type\s+RecordShareRecipientType\s*=([^;]*);/.exec(maskComments(raw));
122127
if (!m) return null;
123128
return [...m[1]!.matchAll(/'([^']*)'/g)].map((x) => x[1]!);

0 commit comments

Comments
 (0)