@ttt-productions/repo-guards 0.1.3 → 0.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/modules/backend/functions-build.d.ts +19 -4
- package/dist/modules/backend/functions-build.d.ts.map +1 -1
- package/dist/modules/backend/functions-build.js +44 -14
- package/dist/modules/backend/functions-build.js.map +1 -1
- package/dist/modules/frontend-actions/callables.d.ts +5 -2
- package/dist/modules/frontend-actions/callables.d.ts.map +1 -1
- package/dist/modules/frontend-actions/callables.js +12 -6
- package/dist/modules/frontend-actions/callables.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import ts from 'typescript';
|
|
2
2
|
import type { GenericGuardDefinition } from '../../config.js';
|
|
3
3
|
import type { FileView } from '../../reader/view.js';
|
|
4
|
-
import type
|
|
4
|
+
import { type Reviewed, type RootRole } from '../../reader/layout.js';
|
|
5
5
|
export interface RateLimitFacts {
|
|
6
6
|
/** The module that declares the presets and the surface map. */
|
|
7
7
|
owner: string;
|
|
@@ -41,14 +41,29 @@ export declare const rateLimitGuard: GenericGuardDefinition<RateLimitFacts>;
|
|
|
41
41
|
export interface LazyLoaderFacts {
|
|
42
42
|
/** The memoizing loader every lazy import goes through (`lazyModule`). */
|
|
43
43
|
loader: string;
|
|
44
|
-
/** The
|
|
44
|
+
/** The roots whose code and tests the guard reads; `functions` alone when absent. */
|
|
45
|
+
roots?: readonly RootRole[];
|
|
46
|
+
/**
|
|
47
|
+
* Other module-level loaders whose `const x = name(() => import('…'))` is accepted, each with its
|
|
48
|
+
* why (a framework's own memoized component loader); one used nowhere is stale.
|
|
49
|
+
*/
|
|
50
|
+
otherLoaders?: ReadonlyArray<{
|
|
51
|
+
name: string;
|
|
52
|
+
why: string;
|
|
53
|
+
}>;
|
|
54
|
+
/** The test runner configs, which never make every test concurrent. */
|
|
45
55
|
testRunnerConfigs: readonly string[];
|
|
46
56
|
/** Test files that overlap imports on purpose (the loader's own premise test), each with its why. */
|
|
47
57
|
testExceptions: readonly Reviewed[];
|
|
48
58
|
}
|
|
49
|
-
/**
|
|
50
|
-
|
|
59
|
+
/**
|
|
60
|
+
* Every dynamic import in production code that is not a module-level `const x = name(() => import('…'))`
|
|
61
|
+
* for one of `names`. `loaders` counts the uses of `names[0]`, the main loader; `used` holds every
|
|
62
|
+
* name that wrapped an import.
|
|
63
|
+
*/
|
|
64
|
+
export declare function strayDynamicImports(file: FileView, names: string | readonly string[]): {
|
|
51
65
|
loaders: number;
|
|
66
|
+
used: Set<string>;
|
|
52
67
|
stray: ts.Node[];
|
|
53
68
|
};
|
|
54
69
|
/** Every place a test overlaps its own imports: a concurrent test, or `import()` inside a Promise combinator. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"functions-build.d.ts","sourceRoot":"","sources":["../../../src/modules/backend/functions-build.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"functions-build.d.ts","sourceRoot":"","sources":["../../../src/modules/backend/functions-build.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,MAAM,YAAY,CAAC;AAC5B,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAC;AAG9D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAc,KAAK,QAAQ,EAAE,KAAK,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAuBlF,MAAM,WAAW,cAAc;IAC7B,gEAAgE;IAChE,KAAK,EAAE,MAAM,CAAC;IACd,6CAA6C;IAC7C,SAAS,EAAE,MAAM,CAAC;IAClB,6GAA6G;IAC7G,UAAU,EAAE,MAAM,CAAC;IACnB,+EAA+E;IAC/E,aAAa,EAAE,MAAM,CAAC;IACtB,oEAAoE;IACpE,UAAU,EAAE,MAAM,CAAC;IACnB,wEAAwE;IACxE,WAAW,EAAE,MAAM,CAAC;CACrB;AAKD,6FAA6F;AAC7F,wBAAgB,oBAAoB,C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AAE,sBAAsB,CAAC,kBAAkB,CA6EzE,CAAC;AAKF,MAAM,WAAW,qBAAqB;IACpC,qHAAqH;IACrH,QAAQ,EAAE,MAAM,CAAC;IACjB,uEAAuE;IACvE,UAAU,EAAE,MAAM,CAAC;IACnB,yEAAyE;IACzE,YAAY,EAAE,MAAM,CAAC;IACrB,2EAA2E;IAC3E,cAAc,EAAE,MAAM,CAAC;IACvB,gFAAgF;IAChF,iBAAiB,EAAE,SAAS,MAAM,EAAE,CAAC;CACtC;AAeD,eAAO,MAAM,qBAAqB,EAAE,sBAAsB,CAAC,qBAAqB,CAmE/E,CAAC"}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
// The guards over how the Functions tree is built and loaded: limiter charges name their preset and
|
|
2
|
-
// their surface, every dynamic import is a module-level lazy loader
|
|
3
|
-
// heavy modules, and a split-codebase manifest covers
|
|
2
|
+
// their surface, every dynamic import is a module-level lazy loader (in Functions and any other tree
|
|
3
|
+
// the app names), light functions never reach heavy modules, and a split-codebase manifest covers
|
|
4
|
+
// every export exactly once.
|
|
4
5
|
import ts from 'typescript';
|
|
6
|
+
import { ROOT_ROLES } from '../../reader/layout.js';
|
|
5
7
|
import { calleeName, forEachNode, lineOfNode } from '../../support/ast.js';
|
|
6
8
|
import { namesProblem, reviewedProblems, textProblem } from '../../support/facts.js';
|
|
7
9
|
import { moduleImports, namesModule } from '../../support/imports.js';
|
|
@@ -157,10 +159,16 @@ export const rateLimitGuard = {
|
|
|
157
159
|
},
|
|
158
160
|
};
|
|
159
161
|
const isDynamicImport = (node) => ts.isCallExpression(node) && node.expression.kind === ts.SyntaxKind.ImportKeyword;
|
|
160
|
-
/**
|
|
161
|
-
|
|
162
|
+
/**
|
|
163
|
+
* Every dynamic import in production code that is not a module-level `const x = name(() => import('…'))`
|
|
164
|
+
* for one of `names`. `loaders` counts the uses of `names[0]`, the main loader; `used` holds every
|
|
165
|
+
* name that wrapped an import.
|
|
166
|
+
*/
|
|
167
|
+
export function strayDynamicImports(file, names) {
|
|
168
|
+
const accepted = typeof names === 'string' ? [names] : names;
|
|
162
169
|
const sf = file.sourceFile;
|
|
163
170
|
const stray = [];
|
|
171
|
+
const used = new Set();
|
|
164
172
|
let loaders = 0;
|
|
165
173
|
forEachNode(sf, (node) => {
|
|
166
174
|
if (!isDynamicImport(node))
|
|
@@ -176,7 +184,7 @@ export function strayDynamicImports(file, loader) {
|
|
|
176
184
|
!!call &&
|
|
177
185
|
ts.isCallExpression(call) &&
|
|
178
186
|
ts.isIdentifier(call.expression) &&
|
|
179
|
-
call.expression.text
|
|
187
|
+
accepted.includes(call.expression.text) &&
|
|
180
188
|
call.arguments.length === 1 &&
|
|
181
189
|
call.arguments[0] === arrow &&
|
|
182
190
|
!!declaration &&
|
|
@@ -188,12 +196,16 @@ export function strayDynamicImports(file, loader) {
|
|
|
188
196
|
statement.parent === sf &&
|
|
189
197
|
node.arguments.length === 1 &&
|
|
190
198
|
ts.isStringLiteralLike(node.arguments[0]);
|
|
191
|
-
if (ok)
|
|
192
|
-
|
|
199
|
+
if (ok) {
|
|
200
|
+
const name = call.expression.text;
|
|
201
|
+
used.add(name);
|
|
202
|
+
if (name === accepted[0])
|
|
203
|
+
loaders += 1;
|
|
204
|
+
}
|
|
193
205
|
else
|
|
194
206
|
stray.push(node);
|
|
195
207
|
});
|
|
196
|
-
return { loaders, stray };
|
|
208
|
+
return { loaders, used, stray };
|
|
197
209
|
}
|
|
198
210
|
const COMBINATORS = new Set(['Promise.all', 'Promise.allSettled', 'Promise.race', 'Promise.any']);
|
|
199
211
|
/** Every place a test overlaps its own imports: a concurrent test, or `import()` inside a Promise combinator. */
|
|
@@ -221,15 +233,27 @@ export const lazyLoaderGuard = {
|
|
|
221
233
|
factProblems(facts) {
|
|
222
234
|
const problems = [];
|
|
223
235
|
textProblem(facts?.loader, 'loader', problems);
|
|
236
|
+
if (facts?.roots !== undefined) {
|
|
237
|
+
namesProblem(facts.roots, 'roots', problems);
|
|
238
|
+
if (Array.isArray(facts.roots)) {
|
|
239
|
+
for (const root of facts.roots)
|
|
240
|
+
if (!ROOT_ROLES.includes(root))
|
|
241
|
+
problems.push(`roots names ${String(root)}, which is not a root role`);
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
if (facts?.otherLoaders !== undefined)
|
|
245
|
+
reviewedProblems(facts.otherLoaders, 'otherLoaders', problems, { key: 'name' });
|
|
224
246
|
namesProblem(facts?.testRunnerConfigs, 'testRunnerConfigs', problems);
|
|
225
247
|
reviewedProblems(facts?.testExceptions, 'testExceptions', problems);
|
|
226
248
|
return problems;
|
|
227
249
|
},
|
|
228
250
|
build(facts) {
|
|
251
|
+
const roots = facts.roots ?? ['functions'];
|
|
252
|
+
const others = (facts.otherLoaders ?? []).map((other) => other.name);
|
|
229
253
|
return [
|
|
230
254
|
{
|
|
231
|
-
title: 'no
|
|
232
|
-
description: `Every dynamic import in
|
|
255
|
+
title: 'no code can overlap two dynamic imports of one module',
|
|
256
|
+
description: `Every dynamic import in production code is a module-level \`const load… = ${facts.loader}(() => import('…'))\` ` +
|
|
233
257
|
'(or a static import when laziness buys nothing): its first call starts the one import and every concurrent call ' +
|
|
234
258
|
'awaits it. A bare `import()` lets two concurrent calls overlap, and the test runner hands the second the REAL ' +
|
|
235
259
|
'module for a mocked one. Tests never overlap their own imports — no concurrent tests, no concurrent runner ' +
|
|
@@ -238,18 +262,24 @@ export const lazyLoaderGuard = {
|
|
|
238
262
|
run(context) {
|
|
239
263
|
const findings = [];
|
|
240
264
|
let loaders = 0;
|
|
241
|
-
|
|
242
|
-
|
|
265
|
+
const used = new Set();
|
|
266
|
+
for (const file of context.files({ roots, kinds: ['code'], tests: false })) {
|
|
267
|
+
const result = strayDynamicImports(file, [facts.loader, ...others]);
|
|
243
268
|
loaders += result.loaders;
|
|
269
|
+
for (const name of result.used)
|
|
270
|
+
used.add(name);
|
|
244
271
|
for (const node of result.stray) {
|
|
245
272
|
findings.push({ file: file.path, line: lineOfNode(file, node), detail: `${node.getText(file.sourceFile).slice(0, 80)} is not a module-level ${facts.loader} loader` });
|
|
246
273
|
}
|
|
247
274
|
}
|
|
248
275
|
if (!loaders)
|
|
249
|
-
findings.push({ file:
|
|
276
|
+
findings.push({ file: `(${roots.join(', ')})`, detail: `no ${facts.loader} loader found, so the guard checks nothing` });
|
|
277
|
+
for (const name of others)
|
|
278
|
+
if (!used.has(name))
|
|
279
|
+
findings.push({ file: '(otherLoaders)', detail: `stale other loader: ${name} wraps no import` });
|
|
250
280
|
const exceptions = new Set(facts.testExceptions.map((e) => e.path));
|
|
251
281
|
const overlapping = new Set();
|
|
252
|
-
for (const file of context.files({ roots
|
|
282
|
+
for (const file of context.files({ roots, kinds: ['code'], tests: 'only' })) {
|
|
253
283
|
const hits = overlappingTestImports(file);
|
|
254
284
|
if (hits.length)
|
|
255
285
|
overlapping.add(file.path);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"functions-build.js","sourceRoot":"","sources":["../../../src/modules/backend/functions-build.ts"],"names":[],"mappings":"AAAA,oGAAoG;AACpG,iGAAiG;AACjG,iFAAiF;AAEjF,OAAO,EAAE,MAAM,YAAY,CAAC;AAM5B,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAC3E,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrF,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AACtE,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEzC,MAAM,cAAc,GAAU,EAAE,KAAK,EAAE,CAAC,WAAW,CAAC,EAAE,KAAK,EAAE,CAAC,MAAM,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC;AAEtF,MAAM,cAAc,GAAG,qBAAqB,CAAC;AAE7C,oGAAoG;AACpG,SAAS,aA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AS,CAAC,SAAS,CAAC,EAAE,EAAE,CAAC,CAAC;wBACxH,CAAC;oBACH,CAAC;oBACD,OAAO,QAAQ,CAAC;gBAClB,CAAC;aACF;SACF,CAAC;IACJ,CAAC;CACF,CAAC","sourcesContent":["// The guards over how the Functions tree is built and loaded: limiter charges name their preset and\n// their surface, every dynamic import is a module-level lazy loader, light functions never reach\n// heavy modules, and a split-codebase manifest covers every export exactly once.\n\nimport ts from 'typescript';\nimport type { GenericGuardDefinition } from '../../config.js';\nimport type { Finding, GuardContext } from '../../guard.js';\nimport type { Scope } from '../../reader/reader.js';\nimport type { FileView } from '../../reader/view.js';\nimport type { Reviewed } from '../../reader/layout.js';\nimport { calleeName, forEachNode, lineOfNode } from '../../support/ast.js';\nimport { namesProblem, reviewedProblems, textProblem } from '../../support/facts.js';\nimport { moduleImports, namesModule } from '../../support/imports.js';\nimport { resolveRelative } from '../../support/paths.js';\nimport { calleePath } from './shared.js';\n\nconst FUNCTIONS_CODE: Scope = { roots: ['functions'], kinds: ['code'], tests: false };\n\nconst CODE_EXTENSION = /\\.(?:[cm]?[jt]sx?)$/;\n\n/** The functions root's path; every module id in this file is relative to it, extension dropped. */\nfunction functionsRoot(context: GuardContext): string {\n const root = context.reader.layout.roots.functions;\n if (!root) throw new Error('repo-guards: a Functions guard runs and the layout declares no functions root');\n return root.path;\n}\n\nconst moduleIdOf = (root: string, path: string) => path.slice(root.length + 1).replace(CODE_EXTENSION, '');\n\n// ---------------------------------------------------------------------------------------------\n// Rate-limit charges name a preset, and each preset is charged only by its own surface.\n\nexport interface RateLimitFacts {\n /** The module that declares the presets and the surface map. */\n owner: string;\n /** The preset map's name (`RATE_LIMITS`). */\n presetMap: string;\n /** The map from a dedicated preset to the modules (Functions-root-relative, no extension) that charge it. */\n surfaceMap: string;\n /** The list of presets any module the surface map does not name may charge. */\n sharedPresets: string;\n /** The limiter call a module charges through (`checkRateLimit`). */\n chargeCall: string;\n /** The field each preset carries its store key prefix in (`prefix`). */\n prefixField: string;\n}\n\nconst isMapAccess = (node: ts.Node, map: string): node is ts.PropertyAccessExpression =>\n ts.isPropertyAccessExpression(node) && ts.isIdentifier(node.expression) && node.expression.text === map;\n\n/** Every place a module builds a limiter config itself instead of passing a named preset. */\nexport function inlineLimiterConfigs(file: FileView, facts: Pick<RateLimitFacts, 'presetMap' | 'chargeCall'>): Array<{ node: ts.Node; detail: string }> {\n const sf = file.sourceFile;\n const out: Array<{ node: ts.Node; detail: string }> = [];\n forEachNode(sf, (node) => {\n if (ts.isSpreadAssignment(node) && isMapAccess(node.expression, facts.presetMap)) {\n out.push({ node, detail: `spreads ${node.expression.getText(sf)} into a new config` });\n }\n if (ts.isCallExpression(node) && calleeName(node) === facts.chargeCall && node.arguments.some((a) => ts.isObjectLiteralExpression(a))) {\n out.push({ node, detail: `passes an inline config to ${facts.chargeCall}` });\n }\n });\n return out;\n}\n\n/** The presets a module charges: every `PRESET_MAP.X` its code names. */\nexport function presetsNamed(file: FileView, presetMap: string): string[] {\n const out = new Set<string>();\n forEachNode(file.sourceFile, (node) => {\n if (isMapAccess(node, presetMap)) out.add(node.name.text);\n });\n return [...out];\n}\n\n/** The owner's declarations: each preset's prefix, the surface map, and the shared presets. */\nexport function limiterDeclarations(owner: FileView, facts: RateLimitFacts) {\n const prefixes: string[] = [];\n const surfaces = new Map<string, string[]>();\n const shared = new Set<string>();\n let presetMapFound = false;\n let surfaceMapFound = false;\n let sharedFound = false;\n const strings = (node: ts.Expression): string[] =>\n ts.isArrayLiteralExpression(node) ? node.elements.filter(ts.isStringLiteralLike).map((e) => e.text) : [];\n const bare = (e: ts.Expression) => {\n let out = e;\n while (ts.isAsExpression(out) || ts.isSatisfiesExpression(out)) out = out.expression;\n return out;\n };\n forEachNode(owner.sourceFile, (node) => {\n if (!ts.isVariableDeclaration(node) || !ts.isIdentifier(node.name) || !node.initializer) return;\n const init = bare(node.initializer);\n if (node.name.text === facts.presetMap) {\n presetMapFound = true;\n forEachNode(init, (inner) => {\n if (ts.isPropertyAssignment(inner) && inner.name.getText() === facts.prefixField && ts.isStringLiteralLike(inner.initializer)) {\n prefixes.push(inner.initializer.text);\n }\n });\n }\n if (node.name.text === facts.sharedPresets) {\n sharedFound = true;\n strings(init).forEach((name) => shared.add(name));\n }\n if (node.name.text === facts.surfaceMap && ts.isObjectLiteralExpression(init)) {\n surfaceMapFound = true;\n for (const p of init.properties) {\n if (ts.isPropertyAssignment(p) && (ts.isIdentifier(p.name) || ts.isStringLiteralLike(p.name))) surfaces.set(p.name.text, strings(bare(p.initializer)));\n }\n }\n });\n return { prefixes, surfaces, shared, presetMapFound, surfaceMapFound, sharedFound };\n}\n\n/** Each charge that breaks the declared map: a dedicated preset from another module, or a listed module charging another preset. */\nexport function offendingCharges(\n charges: ReadonlyArray<{ module: string; presets: readonly string[] }>,\n surfaces: ReadonlyMap<string, readonly string[]>,\n shared: ReadonlySet<string>,\n): string[] {\n const listed = new Set([...surfaces.values()].flat());\n const out: string[] = [];\n for (const { module, presets } of charges) {\n for (const preset of presets) {\n const owners = surfaces.get(preset);\n const allowed = owners ? owners.includes(module) : shared.has(preset) && !listed.has(module);\n if (!allowed) out.push(`${module} charges ${preset}`);\n }\n }\n return out;\n}\n\nexport const rateLimitGuard: GenericGuardDefinition<RateLimitFacts> = {\n id: 'rateLimitSurfaces',\n absentWhen: 'the app runs no rate limiter',\n factProblems(facts) {\n const problems: string[] = [];\n for (const key of ['owner', 'presetMap', 'surfaceMap', 'sharedPresets', 'chargeCall', 'prefixField'] as const) textProblem(facts?.[key], key, problems);\n return problems;\n },\n build(facts) {\n return [\n {\n title: 'every rate-limit charge names its own preset',\n description:\n `Every limiter charge passes a named ${facts.presetMap} preset — never an inline config to ${facts.chargeCall}, and ` +\n `never a preset spread into a new one — and every preset owns a distinct ${facts.prefixField}. A dedicated preset ` +\n `is charged only by the modules ${facts.surfaceMap} lists for it, and a listed module charges only its own presets; ` +\n `any other module charges only the ${facts.sharedPresets}. Otherwise two surfaces share one sliding window sized ` +\n `for neither. Every module the map lists must exist and charge its preset. Declare a new preset in ${facts.owner}.`,\n run(context) {\n const root = functionsRoot(context);\n const findings: Finding[] = [];\n const charges: Array<{ module: string; presets: string[] }> = [];\n let ownerFile: FileView | undefined;\n for (const file of context.files(FUNCTIONS_CODE)) {\n if (file.path === facts.owner) {\n ownerFile = file;\n continue;\n }\n for (const { node, detail } of inlineLimiterConfigs(file, facts)) findings.push({ file: file.path, line: lineOfNode(file, node), detail });\n const presets = presetsNamed(file, facts.presetMap);\n if (presets.length) charges.push({ module: moduleIdOf(root, file.path), presets });\n }\n if (!ownerFile) return [...findings, { file: facts.owner, detail: 'the limiter owner is gone or outside the Functions tree' }];\n const declared = limiterDeclarations(ownerFile, facts);\n if (!declared.presetMapFound || !declared.prefixes.length) findings.push({ file: facts.owner, detail: `no ${facts.presetMap} with a ${facts.prefixField} found` });\n if (!declared.surfaceMapFound) findings.push({ file: facts.owner, detail: `no ${facts.surfaceMap} object found` });\n if (!declared.sharedFound) findings.push({ file: facts.owner, detail: `no ${facts.sharedPresets} list found` });\n const dup = declared.prefixes.filter((p, i) => declared.prefixes.indexOf(p) !== i);\n for (const p of new Set(dup)) findings.push({ file: facts.owner, detail: `two presets share the ${facts.prefixField} ${p}` });\n for (const offense of offendingCharges(charges, declared.surfaces, declared.shared)) findings.push({ file: facts.owner, detail: offense });\n const charged = new Map(charges.map((c) => [c.module, c.presets]));\n for (const [preset, modules] of declared.surfaces) {\n for (const module of modules) if (!charged.get(module)?.includes(preset)) findings.push({ file: facts.owner, detail: `${preset} lists ${module}, which does not charge it` });\n }\n return findings;\n },\n },\n ];\n },\n};\n\n// ---------------------------------------------------------------------------------------------\n// Every dynamic import is a module-level lazy loader.\n\nexport interface LazyLoaderFacts {\n /** The memoizing loader every lazy import goes through (`lazyModule`). */\n loader: string;\n /** The Functions test runner configs, which never make every test concurrent. */\n testRunnerConfigs: readonly string[];\n /** Test files that overlap imports on purpose (the loader's own premise test), each with its why. */\n testExceptions: readonly Reviewed[];\n}\n\nconst isDynamicImport = (node: ts.Node): node is ts.CallExpression => ts.isCallExpression(node) && node.expression.kind === ts.SyntaxKind.ImportKeyword;\n\n/** Every dynamic import in production code that is not a module-level `const x = loader(() => import('…'))`. */\nexport function strayDynamicImports(file: FileView, loader: string): { loaders: number; stray: ts.Node[] } {\n const sf = file.sourceFile;\n const stray: ts.Node[] = [];\n let loaders = 0;\n forEachNode(sf, (node) => {\n if (!isDynamicImport(node)) return;\n const arrow = node.parent;\n const call = arrow?.parent;\n const declaration = call?.parent;\n const statement = declaration?.parent?.parent;\n const ok =\n !!arrow &&\n ts.isArrowFunction(arrow) &&\n arrow.body === node &&\n arrow.parameters.length === 0 &&\n !!call &&\n ts.isCallExpression(call) &&\n ts.isIdentifier(call.expression) &&\n call.expression.text === loader &&\n call.arguments.length === 1 &&\n call.arguments[0] === arrow &&\n !!declaration &&\n ts.isVariableDeclaration(declaration) &&\n declaration.initializer === call &&\n (declaration.parent.flags & ts.NodeFlags.Const) !== 0 &&\n statement !== undefined &&\n ts.isVariableStatement(statement) &&\n statement.parent === sf &&\n node.arguments.length === 1 &&\n ts.isStringLiteralLike(node.arguments[0]!);\n if (ok) loaders += 1;\n else stray.push(node);\n });\n return { loaders, stray };\n}\n\nconst COMBINATORS = new Set(['Promise.all', 'Promise.allSettled', 'Promise.race', 'Promise.any']);\n\n/** Every place a test overlaps its own imports: a concurrent test, or `import()` inside a Promise combinator. */\nexport function overlappingTestImports(file: FileView): Array<{ node: ts.Node; detail: string }> {\n const sf = file.sourceFile;\n const out: Array<{ node: ts.Node; detail: string }> = [];\n const visit = (node: ts.Node, inCombinator: boolean) => {\n let combinator = inCombinator;\n if (ts.isPropertyAccessExpression(node) && node.name.text === 'concurrent') out.push({ node, detail: `${node.getText(sf)} runs tests concurrently` });\n if (ts.isPropertyAssignment(node) && ts.isIdentifier(node.name) && node.name.text === 'concurrent') out.push({ node, detail: 'a concurrent test option' });\n if (ts.isCallExpression(node) && COMBINATORS.has(calleePath(node) ?? '')) combinator = true;\n if (inCombinator && isDynamicImport(node)) out.push({ node, detail: `${node.getText(sf)} overlaps the other imports of a Promise combinator` });\n ts.forEachChild(node, (child) => visit(child, combinator));\n };\n visit(sf, false);\n return out;\n}\n\nexport const lazyLoaderGuard: GenericGuardDefinition<LazyLoaderFacts> = {\n id: 'lazyLoader',\n absentWhen: false,\n factProblems(facts) {\n const problems: string[] = [];\n textProblem(facts?.loader, 'loader', problems);\n namesProblem(facts?.testRunnerConfigs, 'testRunnerConfigs', problems);\n reviewedProblems(facts?.testExceptions, 'testExceptions', problems);\n return problems;\n },\n build(facts) {\n return [\n {\n title: 'no Functions code can overlap two dynamic imports of one module',\n description:\n `Every dynamic import in Functions production code is a module-level \\`const load… = ${facts.loader}(() => import('…'))\\` ` +\n '(or a static import when laziness buys nothing): its first call starts the one import and every concurrent call ' +\n 'awaits it. A bare `import()` lets two concurrent calls overlap, and the test runner hands the second the REAL ' +\n 'module for a mocked one. Tests never overlap their own imports — no concurrent tests, no concurrent runner ' +\n 'config, no `import()` inside a Promise combinator; a test that does so on purpose is a reviewed exception with ' +\n 'its why, stale once it no longer does.',\n run(context) {\n const findings: Finding[] = [];\n let loaders = 0;\n for (const file of context.files(FUNCTIONS_CODE)) {\n const result = strayDynamicImports(file, facts.loader);\n loaders += result.loaders;\n for (const node of result.stray) {\n findings.push({ file: file.path, line: lineOfNode(file, node), detail: `${node.getText(file.sourceFile).slice(0, 80)} is not a module-level ${facts.loader} loader` });\n }\n }\n if (!loaders) findings.push({ file: '(functions)', detail: `no ${facts.loader} loader found, so the guard checks nothing` });\n const exceptions = new Set(facts.testExceptions.map((e) => e.path));\n const overlapping = new Set<string>();\n for (const file of context.files({ roots: ['functions'], kinds: ['code'], tests: 'only' })) {\n const hits = overlappingTestImports(file);\n if (hits.length) overlapping.add(file.path);\n if (exceptions.has(file.path)) continue;\n for (const { node, detail } of hits) findings.push({ file: file.path, line: lineOfNode(file, node), detail });\n }\n for (const path of exceptions) if (!overlapping.has(path)) findings.push({ file: path, detail: 'stale test exception: the file overlaps no import' });\n for (const config of facts.testRunnerConfigs) {\n if (!context.reader.exists(config)) findings.push({ file: config, detail: 'the test runner config no longer exists' });\n else {\n const view = context.file(config);\n const m = /\\bconcurrent\\s*:/.exec(view.code);\n if (m) findings.push({ file: config, line: view.lineOf(m.index), detail: 'the runner config makes tests concurrent' });\n }\n }\n return findings;\n },\n },\n ];\n },\n};\n\n// ---------------------------------------------------------------------------------------------\n// Light functions never reach heavy modules.\n\nexport interface LightFunctionFacts {\n /** The Functions entry module that exports every deployed function. */\n entryIndex: string;\n /** Exported functions whose static import closure is kept small. */\n lightFunctions: readonly string[];\n /** Packages a light closure never imports statically, with any subpath that is light, each with its why. */\n heavyPackages: ReadonlyArray<{ specifier: string; lightSubpaths: readonly string[]; why: string }>;\n /** Functions modules a light closure never reaches statically, each with its why. */\n heavyFiles: readonly Reviewed[];\n}\n\n/** A file's static runtime import edges: no `import()` (the lazy path), no `import type` / `export type`. */\nexport function staticEdges(file: FileView): string[] {\n return moduleImports(file.sourceFile, ['import', 'export'])\n .filter((site) => site.topLevel && !site.typeOnly)\n .map((site) => site.spec);\n}\n\n/** The repo-relative file a relative specifier names among `known`, or null. */\nexport function resolveModule(fromPath: string, spec: string, known: ReadonlySet<string>): string | null {\n const base = resolveRelative(fromPath, spec)?.path;\n if (base === undefined) return null;\n const stem = base.replace(/\\.[cm]?jsx?$/, '');\n const candidates = [base, `${stem}.ts`, `${stem}.tsx`, `${stem}.mts`, `${stem}.cts`, `${base}.ts`, `${base}.tsx`, `${base}/index.ts`, `${base}/index.tsx`];\n return candidates.find((c) => known.has(c)) ?? null;\n}\n\n/** Each exported name of a module, with the specifier it is re-exported from (when it is). */\nexport function exportsOf(file: FileView): { names: Map<string, string | null>; unreadable: ts.Node[] } {\n const names = new Map<string, string | null>();\n const unreadable: ts.Node[] = [];\n const exported = (node: ts.Node) => ts.canHaveModifiers(node) && !!ts.getModifiers(node)?.some((m) => m.kind === ts.SyntaxKind.ExportKeyword);\n for (const stmt of file.sourceFile.statements) {\n if (ts.isExportDeclaration(stmt)) {\n const from = stmt.moduleSpecifier && ts.isStringLiteral(stmt.moduleSpecifier) ? stmt.moduleSpecifier.text : null;\n if (stmt.exportClause && ts.isNamedExports(stmt.exportClause)) for (const e of stmt.exportClause.elements) names.set(e.name.text, from);\n else unreadable.push(stmt);\n } else if (ts.isVariableStatement(stmt) && exported(stmt)) {\n for (const d of stmt.declarationList.declarations) if (ts.isIdentifier(d.name)) names.set(d.name.text, null);\n } else if ((ts.isFunctionDeclaration(stmt) || ts.isClassDeclaration(stmt)) && exported(stmt) && stmt.name) {\n names.set(stmt.name.text, null);\n }\n }\n return { names, unreadable };\n}\n\nexport const lightFunctionGuard: GenericGuardDefinition<LightFunctionFacts> = {\n id: 'lightFunctions',\n absentWhen: 'the app designates no light functions',\n factProblems(facts) {\n const problems: string[] = [];\n textProblem(facts?.entryIndex, 'entryIndex', problems);\n namesProblem(facts?.lightFunctions, 'lightFunctions', problems);\n reviewedProblems(facts?.heavyPackages, 'heavyPackages', problems, { key: 'specifier' });\n for (const p of facts?.heavyPackages ?? []) if (!Array.isArray(p?.lightSubpaths)) problems.push(`heavy package ${String(p?.specifier)} needs lightSubpaths (declare [] when none)`);\n reviewedProblems(facts?.heavyFiles, 'heavyFiles', problems);\n if (!facts?.heavyPackages?.length && !facts?.heavyFiles?.length) problems.push('neither heavyPackages nor heavyFiles names anything, so the guard checks nothing');\n return problems;\n },\n build(facts) {\n return [\n {\n title: 'light functions never statically reach a heavy module',\n description:\n `The light functions (${facts.lightFunctions.join(', ')}) are hot interactive paths whose static import closure ` +\n 'is small by design: walking the static import graph from each one\\'s module (dynamic `import()` and type-only ' +\n 'imports are not edges) never reaches a heavy package or a heavy Functions module, which would load on every ' +\n 'cold start. Cut the edge — load the heavy module through the module-level lazy loader at its true usage site — ' +\n 'instead of relaxing the list. Every relative import must resolve, every light function must be exported by ' +\n 'the entry module, and every heavy file must exist.',\n timeoutMs: 120_000,\n run(context) {\n const findings: Finding[] = [];\n const files = context.files(FUNCTIONS_CODE);\n const known = new Set(files.map((f) => f.path));\n const graph = new Map<string, { internal: string[]; external: string[] }>();\n for (const file of files) {\n const internal: string[] = [];\n const external: string[] = [];\n for (const spec of staticEdges(file)) {\n if (!spec.startsWith('.')) external.push(spec);\n else {\n const target = resolveModule(file.path, spec, known);\n if (target) internal.push(target);\n else findings.push({ file: file.path, detail: `cannot resolve ${spec}, so the closure through it is unread` });\n }\n }\n graph.set(file.path, { internal, external });\n }\n for (const { path } of facts.heavyFiles) if (!known.has(path)) findings.push({ file: path, detail: 'stale heavy file: it is not a Functions module' });\n if (!known.has(facts.entryIndex)) return [...findings, { file: facts.entryIndex, detail: 'the entry module is gone or outside the Functions tree' }];\n const { names } = exportsOf(files.find((f) => f.path === facts.entryIndex)!);\n for (const fn of facts.lightFunctions) {\n const from = names.get(fn);\n const start = from ? resolveModule(facts.entryIndex, from, known) : null;\n if (!start) {\n findings.push({ file: facts.entryIndex, detail: `light function ${fn} is not re-exported from a Functions module` });\n continue;\n }\n const seen = new Set([start]);\n const externals = new Set<string>();\n const stack = [start];\n while (stack.length) {\n const node = graph.get(stack.pop()!);\n if (!node) continue;\n node.external.forEach((e) => externals.add(e));\n for (const next of node.internal) {\n if (seen.has(next)) continue;\n seen.add(next);\n stack.push(next);\n }\n }\n for (const spec of externals) {\n const heavy = facts.heavyPackages.find((p) => namesModule(spec, p.specifier) && !p.lightSubpaths.includes(spec));\n if (heavy) findings.push({ file: start, detail: `light function ${fn} statically reaches ${spec}` });\n }\n for (const { path } of facts.heavyFiles) if (seen.has(path)) findings.push({ file: start, detail: `light function ${fn} statically reaches ${path}` });\n }\n return findings;\n },\n },\n ];\n },\n};\n\n// ---------------------------------------------------------------------------------------------\n// The split-codebase manifest.\n\nexport interface CodebaseManifestFacts {\n /** The JSON manifest mapping each codebase name to the exports it deploys (`{ codebases: { name: [exports] } }`). */\n manifest: string;\n /** The Functions entry module that exports every deployed function. */\n entryIndex: string;\n /** The deploy config whose `functions` entries declare each codebase. */\n deployConfig: string;\n /** Each codebase entry's source folder, with `{codebase}` for its name. */\n sourceTemplate: string;\n /** Each codebase entry's predeploy commands, with `{codebase}` for its name. */\n predeployTemplate: readonly string[];\n}\n\nfunction readJson(context: GuardContext, path: string, findings: Finding[]): unknown {\n if (!context.reader.exists(path)) {\n findings.push({ file: path, detail: 'the file no longer exists' });\n return undefined;\n }\n try {\n return JSON.parse(context.file(path).text);\n } catch (err) {\n findings.push({ file: path, detail: `cannot be read as JSON (${(err as Error).message})` });\n return undefined;\n }\n}\n\nexport const codebaseManifestGuard: GenericGuardDefinition<CodebaseManifestFacts> = {\n id: 'codebaseManifest',\n absentWhen: 'the app deploys its Functions as one codebase',\n factProblems(facts) {\n const problems: string[] = [];\n for (const key of ['manifest', 'entryIndex', 'deployConfig', 'sourceTemplate'] as const) textProblem(facts?.[key], key, problems);\n if (typeof facts?.sourceTemplate === 'string' && !facts.sourceTemplate.includes('{codebase}')) problems.push('sourceTemplate names no {codebase}');\n namesProblem(facts?.predeployTemplate, 'predeployTemplate', problems, { nonEmpty: false });\n return problems;\n },\n build(facts) {\n return [\n {\n title: 'the codebase manifest deploys every function exactly once',\n description:\n `${facts.manifest} maps every export of ${facts.entryIndex} to exactly one Functions codebase — none missing, none ` +\n `stale, none in two — and ${facts.deployConfig} declares exactly the manifest's codebases, each from its source ` +\n 'folder with its predeploy build. A function in no codebase never deploys; one in two deploys twice; a codebase ' +\n 'the deploy config does not declare is never built. The entry module re-exports by name, never `export *`.',\n run(context) {\n const findings: Finding[] = [];\n const manifest = readJson(context, facts.manifest, findings) as { codebases?: Record<string, unknown> } | undefined;\n const deploy = readJson(context, facts.deployConfig, findings) as { functions?: unknown } | undefined;\n if (!context.reader.exists(facts.entryIndex)) return [...findings, { file: facts.entryIndex, detail: 'the entry module no longer exists' }];\n const index = context.file(facts.entryIndex);\n const { names, unreadable } = exportsOf(index);\n for (const node of unreadable) findings.push({ file: index.path, line: lineOfNode(index, node), detail: 'export * hides which functions the module deploys' });\n if (!names.size) findings.push({ file: index.path, detail: 'no export found, so the guard checks nothing' });\n if (!manifest || typeof manifest.codebases !== 'object' || !manifest.codebases) {\n if (manifest) findings.push({ file: facts.manifest, detail: 'no codebases object' });\n return findings;\n }\n const seen = new Map<string, string>();\n for (const [codebase, list] of Object.entries(manifest.codebases)) {\n if (!Array.isArray(list)) {\n findings.push({ file: facts.manifest, detail: `codebase ${codebase} is not a list of exports` });\n continue;\n }\n for (const name of list as unknown[]) {\n if (typeof name !== 'string') continue;\n if (seen.has(name)) findings.push({ file: facts.manifest, detail: `${name} is in two codebases (${seen.get(name)} and ${codebase})` });\n seen.set(name, codebase);\n }\n }\n for (const name of names.keys()) if (!seen.has(name)) findings.push({ file: facts.manifest, detail: `${name} is exported but in no codebase` });\n for (const name of seen.keys()) if (!names.has(name)) findings.push({ file: facts.manifest, detail: `stale entry ${name}: the entry module does not export it` });\n if (!deploy) return findings;\n const entries = Array.isArray(deploy.functions) ? (deploy.functions as Array<Record<string, unknown>>) : null;\n if (!entries) return [...findings, { file: facts.deployConfig, detail: 'functions is not a list of codebase entries' }];\n const declared = entries.map((e) => String(e.codebase));\n const codebases = Object.keys(manifest.codebases);\n for (const cb of codebases) if (!declared.includes(cb)) findings.push({ file: facts.deployConfig, detail: `codebase ${cb} is not declared` });\n for (const cb of declared) if (!codebases.includes(cb)) findings.push({ file: facts.deployConfig, detail: `codebase ${cb} is not in the manifest` });\n for (const entry of entries) {\n const cb = String(entry.codebase);\n const source = facts.sourceTemplate.split('{codebase}').join(cb);\n if (entry.source !== source) findings.push({ file: facts.deployConfig, detail: `codebase ${cb} deploys from ${String(entry.source)}, not ${source}` });\n const predeploy = facts.predeployTemplate.map((t) => t.split('{codebase}').join(cb));\n if (JSON.stringify(entry.predeploy ?? []) !== JSON.stringify(predeploy)) {\n findings.push({ file: facts.deployConfig, detail: `codebase ${cb}'s predeploy is not ${JSON.stringify(predeploy)}` });\n }\n }\n return findings;\n },\n },\n ];\n },\n};\n"]}
|
|
1
|
+
{"version":3,"file":"functions-build.js","sourceRoot":"","sources":["../../../src/modules/backend/functions-build.ts"],"names":[],"mappings":"AAAA,oGAAoG;AACpG,qGAAqG;AACrG,kGAAkG;AAClG,6BAA6B;AAE7B,OAAO,EAAE,MAAM,YAAY,CAAC;AAK5B,OAAO,EAAE,UAAU,EAAgC,MAAM,wBAAwB,CAAC;AAClF,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAC3E,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrF,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AACtE,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEzC,MAAM,cAAc,GAAU,EAAE,KAAK,EAAE,CAAC,WAAW,CAAC,EAAE,KAAK,EAAE,CAAC,MAAM,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC;AAEtF,MAAM,cAAc,GAAG,qBAAqB,CAAC;AAE7C,oGAAoG;AACpG,SAAS,aAAa,CAAC,OAAqB;IAC1C,MAAM,IAAI,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,SAAS,CAAC;IACnD,IAAI,CAAC,IAAI;QAAE,MAAM,IAAI,KAAK,CAAC,+EAA+E,CAAC,CAAC;IAC5G,OAAO,IAAI,CAAC,IAAI,CAAC;AACnB,CAAC;AAED,MAAM,UAAU,GAAG,CAAC,IAAY,EAAE,IAAY,EAAE,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,OAAO,CAAC,cAAc,EAAE,EAAE,CAAC,CAAC;AAoB3G,MAAM,WAAW,GAAG,CAAC,IAAa,EAA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AAE,EAAE,CAAC,CAAC;wBACxH,CAAC;oBACH,CAAC;oBACD,OAAO,QAAQ,CAAC;gBAClB,CAAC;aACF;SACF,CAAC;IACJ,CAAC;CACF,CAAC","sourcesContent":["// The guards over how the Functions tree is built and loaded: limiter charges name their preset and\n// their surface, every dynamic import is a module-level lazy loader (in Functions and any other tree\n// the app names), light functions never reach heavy modules, and a split-codebase manifest covers\n// every export exactly once.\n\nimport ts from 'typescript';\nimport type { GenericGuardDefinition } from '../../config.js';\nimport type { Finding, GuardContext } from '../../guard.js';\nimport type { Scope } from '../../reader/reader.js';\nimport type { FileView } from '../../reader/view.js';\nimport { ROOT_ROLES, type Reviewed, type RootRole } from '../../reader/layout.js';\nimport { calleeName, forEachNode, lineOfNode } from '../../support/ast.js';\nimport { namesProblem, reviewedProblems, textProblem } from '../../support/facts.js';\nimport { moduleImports, namesModule } from '../../support/imports.js';\nimport { resolveRelative } from '../../support/paths.js';\nimport { calleePath } from './shared.js';\n\nconst FUNCTIONS_CODE: Scope = { roots: ['functions'], kinds: ['code'], tests: false };\n\nconst CODE_EXTENSION = /\\.(?:[cm]?[jt]sx?)$/;\n\n/** The functions root's path; every module id in this file is relative to it, extension dropped. */\nfunction functionsRoot(context: GuardContext): string {\n const root = context.reader.layout.roots.functions;\n if (!root) throw new Error('repo-guards: a Functions guard runs and the layout declares no functions root');\n return root.path;\n}\n\nconst moduleIdOf = (root: string, path: string) => path.slice(root.length + 1).replace(CODE_EXTENSION, '');\n\n// ---------------------------------------------------------------------------------------------\n// Rate-limit charges name a preset, and each preset is charged only by its own surface.\n\nexport interface RateLimitFacts {\n /** The module that declares the presets and the surface map. */\n owner: string;\n /** The preset map's name (`RATE_LIMITS`). */\n presetMap: string;\n /** The map from a dedicated preset to the modules (Functions-root-relative, no extension) that charge it. */\n surfaceMap: string;\n /** The list of presets any module the surface map does not name may charge. */\n sharedPresets: string;\n /** The limiter call a module charges through (`checkRateLimit`). */\n chargeCall: string;\n /** The field each preset carries its store key prefix in (`prefix`). */\n prefixField: string;\n}\n\nconst isMapAccess = (node: ts.Node, map: string): node is ts.PropertyAccessExpression =>\n ts.isPropertyAccessExpression(node) && ts.isIdentifier(node.expression) && node.expression.text === map;\n\n/** Every place a module builds a limiter config itself instead of passing a named preset. */\nexport function inlineLimiterConfigs(file: FileView, facts: Pick<RateLimitFacts, 'presetMap' | 'chargeCall'>): Array<{ node: ts.Node; detail: string }> {\n const sf = file.sourceFile;\n const out: Array<{ node: ts.Node; detail: string }> = [];\n forEachNode(sf, (node) => {\n if (ts.isSpreadAssignment(node) && isMapAccess(node.expression, facts.presetMap)) {\n out.push({ node, detail: `spreads ${node.expression.getText(sf)} into a new config` });\n }\n if (ts.isCallExpression(node) && calleeName(node) === facts.chargeCall && node.arguments.some((a) => ts.isObjectLiteralExpression(a))) {\n out.push({ node, detail: `passes an inline config to ${facts.chargeCall}` });\n }\n });\n return out;\n}\n\n/** The presets a module charges: every `PRESET_MAP.X` its code names. */\nexport function presetsNamed(file: FileView, presetMap: string): string[] {\n const out = new Set<string>();\n forEachNode(file.sourceFile, (node) => {\n if (isMapAccess(node, presetMap)) out.add(node.name.text);\n });\n return [...out];\n}\n\n/** The owner's declarations: each preset's prefix, the surface map, and the shared presets. */\nexport function limiterDeclarations(owner: FileView, facts: RateLimitFacts) {\n const prefixes: string[] = [];\n const surfaces = new Map<string, string[]>();\n const shared = new Set<string>();\n let presetMapFound = false;\n let surfaceMapFound = false;\n let sharedFound = false;\n const strings = (node: ts.Expression): string[] =>\n ts.isArrayLiteralExpression(node) ? node.elements.filter(ts.isStringLiteralLike).map((e) => e.text) : [];\n const bare = (e: ts.Expression) => {\n let out = e;\n while (ts.isAsExpression(out) || ts.isSatisfiesExpression(out)) out = out.expression;\n return out;\n };\n forEachNode(owner.sourceFile, (node) => {\n if (!ts.isVariableDeclaration(node) || !ts.isIdentifier(node.name) || !node.initializer) return;\n const init = bare(node.initializer);\n if (node.name.text === facts.presetMap) {\n presetMapFound = true;\n forEachNode(init, (inner) => {\n if (ts.isPropertyAssignment(inner) && inner.name.getText() === facts.prefixField && ts.isStringLiteralLike(inner.initializer)) {\n prefixes.push(inner.initializer.text);\n }\n });\n }\n if (node.name.text === facts.sharedPresets) {\n sharedFound = true;\n strings(init).forEach((name) => shared.add(name));\n }\n if (node.name.text === facts.surfaceMap && ts.isObjectLiteralExpression(init)) {\n surfaceMapFound = true;\n for (const p of init.properties) {\n if (ts.isPropertyAssignment(p) && (ts.isIdentifier(p.name) || ts.isStringLiteralLike(p.name))) surfaces.set(p.name.text, strings(bare(p.initializer)));\n }\n }\n });\n return { prefixes, surfaces, shared, presetMapFound, surfaceMapFound, sharedFound };\n}\n\n/** Each charge that breaks the declared map: a dedicated preset from another module, or a listed module charging another preset. */\nexport function offendingCharges(\n charges: ReadonlyArray<{ module: string; presets: readonly string[] }>,\n surfaces: ReadonlyMap<string, readonly string[]>,\n shared: ReadonlySet<string>,\n): string[] {\n const listed = new Set([...surfaces.values()].flat());\n const out: string[] = [];\n for (const { module, presets } of charges) {\n for (const preset of presets) {\n const owners = surfaces.get(preset);\n const allowed = owners ? owners.includes(module) : shared.has(preset) && !listed.has(module);\n if (!allowed) out.push(`${module} charges ${preset}`);\n }\n }\n return out;\n}\n\nexport const rateLimitGuard: GenericGuardDefinition<RateLimitFacts> = {\n id: 'rateLimitSurfaces',\n absentWhen: 'the app runs no rate limiter',\n factProblems(facts) {\n const problems: string[] = [];\n for (const key of ['owner', 'presetMap', 'surfaceMap', 'sharedPresets', 'chargeCall', 'prefixField'] as const) textProblem(facts?.[key], key, problems);\n return problems;\n },\n build(facts) {\n return [\n {\n title: 'every rate-limit charge names its own preset',\n description:\n `Every limiter charge passes a named ${facts.presetMap} preset — never an inline config to ${facts.chargeCall}, and ` +\n `never a preset spread into a new one — and every preset owns a distinct ${facts.prefixField}. A dedicated preset ` +\n `is charged only by the modules ${facts.surfaceMap} lists for it, and a listed module charges only its own presets; ` +\n `any other module charges only the ${facts.sharedPresets}. Otherwise two surfaces share one sliding window sized ` +\n `for neither. Every module the map lists must exist and charge its preset. Declare a new preset in ${facts.owner}.`,\n run(context) {\n const root = functionsRoot(context);\n const findings: Finding[] = [];\n const charges: Array<{ module: string; presets: string[] }> = [];\n let ownerFile: FileView | undefined;\n for (const file of context.files(FUNCTIONS_CODE)) {\n if (file.path === facts.owner) {\n ownerFile = file;\n continue;\n }\n for (const { node, detail } of inlineLimiterConfigs(file, facts)) findings.push({ file: file.path, line: lineOfNode(file, node), detail });\n const presets = presetsNamed(file, facts.presetMap);\n if (presets.length) charges.push({ module: moduleIdOf(root, file.path), presets });\n }\n if (!ownerFile) return [...findings, { file: facts.owner, detail: 'the limiter owner is gone or outside the Functions tree' }];\n const declared = limiterDeclarations(ownerFile, facts);\n if (!declared.presetMapFound || !declared.prefixes.length) findings.push({ file: facts.owner, detail: `no ${facts.presetMap} with a ${facts.prefixField} found` });\n if (!declared.surfaceMapFound) findings.push({ file: facts.owner, detail: `no ${facts.surfaceMap} object found` });\n if (!declared.sharedFound) findings.push({ file: facts.owner, detail: `no ${facts.sharedPresets} list found` });\n const dup = declared.prefixes.filter((p, i) => declared.prefixes.indexOf(p) !== i);\n for (const p of new Set(dup)) findings.push({ file: facts.owner, detail: `two presets share the ${facts.prefixField} ${p}` });\n for (const offense of offendingCharges(charges, declared.surfaces, declared.shared)) findings.push({ file: facts.owner, detail: offense });\n const charged = new Map(charges.map((c) => [c.module, c.presets]));\n for (const [preset, modules] of declared.surfaces) {\n for (const module of modules) if (!charged.get(module)?.includes(preset)) findings.push({ file: facts.owner, detail: `${preset} lists ${module}, which does not charge it` });\n }\n return findings;\n },\n },\n ];\n },\n};\n\n// ---------------------------------------------------------------------------------------------\n// Every dynamic import is a module-level lazy loader.\n\nexport interface LazyLoaderFacts {\n /** The memoizing loader every lazy import goes through (`lazyModule`). */\n loader: string;\n /** The roots whose code and tests the guard reads; `functions` alone when absent. */\n roots?: readonly RootRole[];\n /**\n * Other module-level loaders whose `const x = name(() => import('…'))` is accepted, each with its\n * why (a framework's own memoized component loader); one used nowhere is stale.\n */\n otherLoaders?: ReadonlyArray<{ name: string; why: string }>;\n /** The test runner configs, which never make every test concurrent. */\n testRunnerConfigs: readonly string[];\n /** Test files that overlap imports on purpose (the loader's own premise test), each with its why. */\n testExceptions: readonly Reviewed[];\n}\n\nconst isDynamicImport = (node: ts.Node): node is ts.CallExpression => ts.isCallExpression(node) && node.expression.kind === ts.SyntaxKind.ImportKeyword;\n\n/**\n * Every dynamic import in production code that is not a module-level `const x = name(() => import('…'))`\n * for one of `names`. `loaders` counts the uses of `names[0]`, the main loader; `used` holds every\n * name that wrapped an import.\n */\nexport function strayDynamicImports(\n file: FileView,\n names: string | readonly string[],\n): { loaders: number; used: Set<string>; stray: ts.Node[] } {\n const accepted = typeof names === 'string' ? [names] : names;\n const sf = file.sourceFile;\n const stray: ts.Node[] = [];\n const used = new Set<string>();\n let loaders = 0;\n forEachNode(sf, (node) => {\n if (!isDynamicImport(node)) return;\n const arrow = node.parent;\n const call = arrow?.parent;\n const declaration = call?.parent;\n const statement = declaration?.parent?.parent;\n const ok =\n !!arrow &&\n ts.isArrowFunction(arrow) &&\n arrow.body === node &&\n arrow.parameters.length === 0 &&\n !!call &&\n ts.isCallExpression(call) &&\n ts.isIdentifier(call.expression) &&\n accepted.includes(call.expression.text) &&\n call.arguments.length === 1 &&\n call.arguments[0] === arrow &&\n !!declaration &&\n ts.isVariableDeclaration(declaration) &&\n declaration.initializer === call &&\n (declaration.parent.flags & ts.NodeFlags.Const) !== 0 &&\n statement !== undefined &&\n ts.isVariableStatement(statement) &&\n statement.parent === sf &&\n node.arguments.length === 1 &&\n ts.isStringLiteralLike(node.arguments[0]!);\n if (ok) {\n const name = (call as ts.CallExpression & { expression: ts.Identifier }).expression.text;\n used.add(name);\n if (name === accepted[0]) loaders += 1;\n } else stray.push(node);\n });\n return { loaders, used, stray };\n}\n\nconst COMBINATORS = new Set(['Promise.all', 'Promise.allSettled', 'Promise.race', 'Promise.any']);\n\n/** Every place a test overlaps its own imports: a concurrent test, or `import()` inside a Promise combinator. */\nexport function overlappingTestImports(file: FileView): Array<{ node: ts.Node; detail: string }> {\n const sf = file.sourceFile;\n const out: Array<{ node: ts.Node; detail: string }> = [];\n const visit = (node: ts.Node, inCombinator: boolean) => {\n let combinator = inCombinator;\n if (ts.isPropertyAccessExpression(node) && node.name.text === 'concurrent') out.push({ node, detail: `${node.getText(sf)} runs tests concurrently` });\n if (ts.isPropertyAssignment(node) && ts.isIdentifier(node.name) && node.name.text === 'concurrent') out.push({ node, detail: 'a concurrent test option' });\n if (ts.isCallExpression(node) && COMBINATORS.has(calleePath(node) ?? '')) combinator = true;\n if (inCombinator && isDynamicImport(node)) out.push({ node, detail: `${node.getText(sf)} overlaps the other imports of a Promise combinator` });\n ts.forEachChild(node, (child) => visit(child, combinator));\n };\n visit(sf, false);\n return out;\n}\n\nexport const lazyLoaderGuard: GenericGuardDefinition<LazyLoaderFacts> = {\n id: 'lazyLoader',\n absentWhen: false,\n factProblems(facts) {\n const problems: string[] = [];\n textProblem(facts?.loader, 'loader', problems);\n if (facts?.roots !== undefined) {\n namesProblem(facts.roots, 'roots', problems);\n if (Array.isArray(facts.roots)) {\n for (const root of facts.roots) if (!ROOT_ROLES.includes(root)) problems.push(`roots names ${String(root)}, which is not a root role`);\n }\n }\n if (facts?.otherLoaders !== undefined) reviewedProblems(facts.otherLoaders, 'otherLoaders', problems, { key: 'name' });\n namesProblem(facts?.testRunnerConfigs, 'testRunnerConfigs', problems);\n reviewedProblems(facts?.testExceptions, 'testExceptions', problems);\n return problems;\n },\n build(facts) {\n const roots = facts.roots ?? ['functions'];\n const others = (facts.otherLoaders ?? []).map((other) => other.name);\n return [\n {\n title: 'no code can overlap two dynamic imports of one module',\n description:\n `Every dynamic import in production code is a module-level \\`const load… = ${facts.loader}(() => import('…'))\\` ` +\n '(or a static import when laziness buys nothing): its first call starts the one import and every concurrent call ' +\n 'awaits it. A bare `import()` lets two concurrent calls overlap, and the test runner hands the second the REAL ' +\n 'module for a mocked one. Tests never overlap their own imports — no concurrent tests, no concurrent runner ' +\n 'config, no `import()` inside a Promise combinator; a test that does so on purpose is a reviewed exception with ' +\n 'its why, stale once it no longer does.',\n run(context) {\n const findings: Finding[] = [];\n let loaders = 0;\n const used = new Set<string>();\n for (const file of context.files({ roots, kinds: ['code'], tests: false })) {\n const result = strayDynamicImports(file, [facts.loader, ...others]);\n loaders += result.loaders;\n for (const name of result.used) used.add(name);\n for (const node of result.stray) {\n findings.push({ file: file.path, line: lineOfNode(file, node), detail: `${node.getText(file.sourceFile).slice(0, 80)} is not a module-level ${facts.loader} loader` });\n }\n }\n if (!loaders) findings.push({ file: `(${roots.join(', ')})`, detail: `no ${facts.loader} loader found, so the guard checks nothing` });\n for (const name of others) if (!used.has(name)) findings.push({ file: '(otherLoaders)', detail: `stale other loader: ${name} wraps no import` });\n const exceptions = new Set(facts.testExceptions.map((e) => e.path));\n const overlapping = new Set<string>();\n for (const file of context.files({ roots, kinds: ['code'], tests: 'only' })) {\n const hits = overlappingTestImports(file);\n if (hits.length) overlapping.add(file.path);\n if (exceptions.has(file.path)) continue;\n for (const { node, detail } of hits) findings.push({ file: file.path, line: lineOfNode(file, node), detail });\n }\n for (const path of exceptions) if (!overlapping.has(path)) findings.push({ file: path, detail: 'stale test exception: the file overlaps no import' });\n for (const config of facts.testRunnerConfigs) {\n if (!context.reader.exists(config)) findings.push({ file: config, detail: 'the test runner config no longer exists' });\n else {\n const view = context.file(config);\n const m = /\\bconcurrent\\s*:/.exec(view.code);\n if (m) findings.push({ file: config, line: view.lineOf(m.index), detail: 'the runner config makes tests concurrent' });\n }\n }\n return findings;\n },\n },\n ];\n },\n};\n\n// ---------------------------------------------------------------------------------------------\n// Light functions never reach heavy modules.\n\nexport interface LightFunctionFacts {\n /** The Functions entry module that exports every deployed function. */\n entryIndex: string;\n /** Exported functions whose static import closure is kept small. */\n lightFunctions: readonly string[];\n /** Packages a light closure never imports statically, with any subpath that is light, each with its why. */\n heavyPackages: ReadonlyArray<{ specifier: string; lightSubpaths: readonly string[]; why: string }>;\n /** Functions modules a light closure never reaches statically, each with its why. */\n heavyFiles: readonly Reviewed[];\n}\n\n/** A file's static runtime import edges: no `import()` (the lazy path), no `import type` / `export type`. */\nexport function staticEdges(file: FileView): string[] {\n return moduleImports(file.sourceFile, ['import', 'export'])\n .filter((site) => site.topLevel && !site.typeOnly)\n .map((site) => site.spec);\n}\n\n/** The repo-relative file a relative specifier names among `known`, or null. */\nexport function resolveModule(fromPath: string, spec: string, known: ReadonlySet<string>): string | null {\n const base = resolveRelative(fromPath, spec)?.path;\n if (base === undefined) return null;\n const stem = base.replace(/\\.[cm]?jsx?$/, '');\n const candidates = [base, `${stem}.ts`, `${stem}.tsx`, `${stem}.mts`, `${stem}.cts`, `${base}.ts`, `${base}.tsx`, `${base}/index.ts`, `${base}/index.tsx`];\n return candidates.find((c) => known.has(c)) ?? null;\n}\n\n/** Each exported name of a module, with the specifier it is re-exported from (when it is). */\nexport function exportsOf(file: FileView): { names: Map<string, string | null>; unreadable: ts.Node[] } {\n const names = new Map<string, string | null>();\n const unreadable: ts.Node[] = [];\n const exported = (node: ts.Node) => ts.canHaveModifiers(node) && !!ts.getModifiers(node)?.some((m) => m.kind === ts.SyntaxKind.ExportKeyword);\n for (const stmt of file.sourceFile.statements) {\n if (ts.isExportDeclaration(stmt)) {\n const from = stmt.moduleSpecifier && ts.isStringLiteral(stmt.moduleSpecifier) ? stmt.moduleSpecifier.text : null;\n if (stmt.exportClause && ts.isNamedExports(stmt.exportClause)) for (const e of stmt.exportClause.elements) names.set(e.name.text, from);\n else unreadable.push(stmt);\n } else if (ts.isVariableStatement(stmt) && exported(stmt)) {\n for (const d of stmt.declarationList.declarations) if (ts.isIdentifier(d.name)) names.set(d.name.text, null);\n } else if ((ts.isFunctionDeclaration(stmt) || ts.isClassDeclaration(stmt)) && exported(stmt) && stmt.name) {\n names.set(stmt.name.text, null);\n }\n }\n return { names, unreadable };\n}\n\nexport const lightFunctionGuard: GenericGuardDefinition<LightFunctionFacts> = {\n id: 'lightFunctions',\n absentWhen: 'the app designates no light functions',\n factProblems(facts) {\n const problems: string[] = [];\n textProblem(facts?.entryIndex, 'entryIndex', problems);\n namesProblem(facts?.lightFunctions, 'lightFunctions', problems);\n reviewedProblems(facts?.heavyPackages, 'heavyPackages', problems, { key: 'specifier' });\n for (const p of facts?.heavyPackages ?? []) if (!Array.isArray(p?.lightSubpaths)) problems.push(`heavy package ${String(p?.specifier)} needs lightSubpaths (declare [] when none)`);\n reviewedProblems(facts?.heavyFiles, 'heavyFiles', problems);\n if (!facts?.heavyPackages?.length && !facts?.heavyFiles?.length) problems.push('neither heavyPackages nor heavyFiles names anything, so the guard checks nothing');\n return problems;\n },\n build(facts) {\n return [\n {\n title: 'light functions never statically reach a heavy module',\n description:\n `The light functions (${facts.lightFunctions.join(', ')}) are hot interactive paths whose static import closure ` +\n 'is small by design: walking the static import graph from each one\\'s module (dynamic `import()` and type-only ' +\n 'imports are not edges) never reaches a heavy package or a heavy Functions module, which would load on every ' +\n 'cold start. Cut the edge — load the heavy module through the module-level lazy loader at its true usage site — ' +\n 'instead of relaxing the list. Every relative import must resolve, every light function must be exported by ' +\n 'the entry module, and every heavy file must exist.',\n timeoutMs: 120_000,\n run(context) {\n const findings: Finding[] = [];\n const files = context.files(FUNCTIONS_CODE);\n const known = new Set(files.map((f) => f.path));\n const graph = new Map<string, { internal: string[]; external: string[] }>();\n for (const file of files) {\n const internal: string[] = [];\n const external: string[] = [];\n for (const spec of staticEdges(file)) {\n if (!spec.startsWith('.')) external.push(spec);\n else {\n const target = resolveModule(file.path, spec, known);\n if (target) internal.push(target);\n else findings.push({ file: file.path, detail: `cannot resolve ${spec}, so the closure through it is unread` });\n }\n }\n graph.set(file.path, { internal, external });\n }\n for (const { path } of facts.heavyFiles) if (!known.has(path)) findings.push({ file: path, detail: 'stale heavy file: it is not a Functions module' });\n if (!known.has(facts.entryIndex)) return [...findings, { file: facts.entryIndex, detail: 'the entry module is gone or outside the Functions tree' }];\n const { names } = exportsOf(files.find((f) => f.path === facts.entryIndex)!);\n for (const fn of facts.lightFunctions) {\n const from = names.get(fn);\n const start = from ? resolveModule(facts.entryIndex, from, known) : null;\n if (!start) {\n findings.push({ file: facts.entryIndex, detail: `light function ${fn} is not re-exported from a Functions module` });\n continue;\n }\n const seen = new Set([start]);\n const externals = new Set<string>();\n const stack = [start];\n while (stack.length) {\n const node = graph.get(stack.pop()!);\n if (!node) continue;\n node.external.forEach((e) => externals.add(e));\n for (const next of node.internal) {\n if (seen.has(next)) continue;\n seen.add(next);\n stack.push(next);\n }\n }\n for (const spec of externals) {\n const heavy = facts.heavyPackages.find((p) => namesModule(spec, p.specifier) && !p.lightSubpaths.includes(spec));\n if (heavy) findings.push({ file: start, detail: `light function ${fn} statically reaches ${spec}` });\n }\n for (const { path } of facts.heavyFiles) if (seen.has(path)) findings.push({ file: start, detail: `light function ${fn} statically reaches ${path}` });\n }\n return findings;\n },\n },\n ];\n },\n};\n\n// ---------------------------------------------------------------------------------------------\n// The split-codebase manifest.\n\nexport interface CodebaseManifestFacts {\n /** The JSON manifest mapping each codebase name to the exports it deploys (`{ codebases: { name: [exports] } }`). */\n manifest: string;\n /** The Functions entry module that exports every deployed function. */\n entryIndex: string;\n /** The deploy config whose `functions` entries declare each codebase. */\n deployConfig: string;\n /** Each codebase entry's source folder, with `{codebase}` for its name. */\n sourceTemplate: string;\n /** Each codebase entry's predeploy commands, with `{codebase}` for its name. */\n predeployTemplate: readonly string[];\n}\n\nfunction readJson(context: GuardContext, path: string, findings: Finding[]): unknown {\n if (!context.reader.exists(path)) {\n findings.push({ file: path, detail: 'the file no longer exists' });\n return undefined;\n }\n try {\n return JSON.parse(context.file(path).text);\n } catch (err) {\n findings.push({ file: path, detail: `cannot be read as JSON (${(err as Error).message})` });\n return undefined;\n }\n}\n\nexport const codebaseManifestGuard: GenericGuardDefinition<CodebaseManifestFacts> = {\n id: 'codebaseManifest',\n absentWhen: 'the app deploys its Functions as one codebase',\n factProblems(facts) {\n const problems: string[] = [];\n for (const key of ['manifest', 'entryIndex', 'deployConfig', 'sourceTemplate'] as const) textProblem(facts?.[key], key, problems);\n if (typeof facts?.sourceTemplate === 'string' && !facts.sourceTemplate.includes('{codebase}')) problems.push('sourceTemplate names no {codebase}');\n namesProblem(facts?.predeployTemplate, 'predeployTemplate', problems, { nonEmpty: false });\n return problems;\n },\n build(facts) {\n return [\n {\n title: 'the codebase manifest deploys every function exactly once',\n description:\n `${facts.manifest} maps every export of ${facts.entryIndex} to exactly one Functions codebase — none missing, none ` +\n `stale, none in two — and ${facts.deployConfig} declares exactly the manifest's codebases, each from its source ` +\n 'folder with its predeploy build. A function in no codebase never deploys; one in two deploys twice; a codebase ' +\n 'the deploy config does not declare is never built. The entry module re-exports by name, never `export *`.',\n run(context) {\n const findings: Finding[] = [];\n const manifest = readJson(context, facts.manifest, findings) as { codebases?: Record<string, unknown> } | undefined;\n const deploy = readJson(context, facts.deployConfig, findings) as { functions?: unknown } | undefined;\n if (!context.reader.exists(facts.entryIndex)) return [...findings, { file: facts.entryIndex, detail: 'the entry module no longer exists' }];\n const index = context.file(facts.entryIndex);\n const { names, unreadable } = exportsOf(index);\n for (const node of unreadable) findings.push({ file: index.path, line: lineOfNode(index, node), detail: 'export * hides which functions the module deploys' });\n if (!names.size) findings.push({ file: index.path, detail: 'no export found, so the guard checks nothing' });\n if (!manifest || typeof manifest.codebases !== 'object' || !manifest.codebases) {\n if (manifest) findings.push({ file: facts.manifest, detail: 'no codebases object' });\n return findings;\n }\n const seen = new Map<string, string>();\n for (const [codebase, list] of Object.entries(manifest.codebases)) {\n if (!Array.isArray(list)) {\n findings.push({ file: facts.manifest, detail: `codebase ${codebase} is not a list of exports` });\n continue;\n }\n for (const name of list as unknown[]) {\n if (typeof name !== 'string') continue;\n if (seen.has(name)) findings.push({ file: facts.manifest, detail: `${name} is in two codebases (${seen.get(name)} and ${codebase})` });\n seen.set(name, codebase);\n }\n }\n for (const name of names.keys()) if (!seen.has(name)) findings.push({ file: facts.manifest, detail: `${name} is exported but in no codebase` });\n for (const name of seen.keys()) if (!names.has(name)) findings.push({ file: facts.manifest, detail: `stale entry ${name}: the entry module does not export it` });\n if (!deploy) return findings;\n const entries = Array.isArray(deploy.functions) ? (deploy.functions as Array<Record<string, unknown>>) : null;\n if (!entries) return [...findings, { file: facts.deployConfig, detail: 'functions is not a list of codebase entries' }];\n const declared = entries.map((e) => String(e.codebase));\n const codebases = Object.keys(manifest.codebases);\n for (const cb of codebases) if (!declared.includes(cb)) findings.push({ file: facts.deployConfig, detail: `codebase ${cb} is not declared` });\n for (const cb of declared) if (!codebases.includes(cb)) findings.push({ file: facts.deployConfig, detail: `codebase ${cb} is not in the manifest` });\n for (const entry of entries) {\n const cb = String(entry.codebase);\n const source = facts.sourceTemplate.split('{codebase}').join(cb);\n if (entry.source !== source) findings.push({ file: facts.deployConfig, detail: `codebase ${cb} deploys from ${String(entry.source)}, not ${source}` });\n const predeploy = facts.predeployTemplate.map((t) => t.split('{codebase}').join(cb));\n if (JSON.stringify(entry.predeploy ?? []) !== JSON.stringify(predeploy)) {\n findings.push({ file: facts.deployConfig, detail: `codebase ${cb}'s predeploy is not ${JSON.stringify(predeploy)}` });\n }\n }\n return findings;\n },\n },\n ];\n },\n};\n"]}
|
|
@@ -13,11 +13,14 @@ export interface CallableErrorCopyFacts {
|
|
|
13
13
|
}
|
|
14
14
|
export declare const callableErrorCopyGuard: GenericGuardDefinition<CallableErrorCopyFacts>;
|
|
15
15
|
export interface CallableTransportFacts {
|
|
16
|
-
/**
|
|
16
|
+
/**
|
|
17
|
+
* Each module that reaches a callable, the symbols that do, and the one file that may name them.
|
|
18
|
+
* A transport with no owner is named by no app file: the app reaches it only through a package.
|
|
19
|
+
*/
|
|
17
20
|
transports: ReadonlyArray<{
|
|
18
21
|
module: string;
|
|
19
22
|
symbols: readonly string[];
|
|
20
|
-
owner
|
|
23
|
+
owner?: string;
|
|
21
24
|
}>;
|
|
22
25
|
}
|
|
23
26
|
export declare const callableTransportGuard: GenericGuardDefinition<CallableTransportFacts>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"callables.d.ts","sourceRoot":"","sources":["../../../src/modules/frontend-actions/callables.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAC;AAG9D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAqB,KAAK,cAAc,EAAE,KAAK,GAAG,EAAE,MAAM,wBAAwB,CAAC;AAI1F,OAAO,EAA6D,KAAK,wBAAwB,EAAE,KAAK,YAAY,EAAE,MAAM,mBAAmB,CAAC;AA4ChJ,MAAM,WAAW,sBAAsB;IACrC,uGAAuG;IACvG,KAAK,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,UAAU,EAAE,MAAM,CAAA;KAAE,CAAC;IAC5C,uEAAuE;IACvE,SAAS,EAAE,SAAS,cAAc,EAAE,CAAC;CACtC;AAaD,eAAO,MAAM,sBAAsB,EAAE,sBAAsB,CAAC,sBAAsB,CAkDjF,CAAC;
|
|
1
|
+
{"version":3,"file":"callables.d.ts","sourceRoot":"","sources":["../../../src/modules/frontend-actions/callables.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAC;AAG9D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAqB,KAAK,cAAc,EAAE,KAAK,GAAG,EAAE,MAAM,wBAAwB,CAAC;AAI1F,OAAO,EAA6D,KAAK,wBAAwB,EAAE,KAAK,YAAY,EAAE,MAAM,mBAAmB,CAAC;AA4ChJ,MAAM,WAAW,sBAAsB;IACrC,uGAAuG;IACvG,KAAK,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,UAAU,EAAE,MAAM,CAAA;KAAE,CAAC;IAC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Q,EAAE,aAAa,EACvB,KAAK,EAAE,IAAI,CAAC,kBAAkB,EAAE,WAAW,GAAG,sBAAsB,GAAG,mBAAmB,CAAC,GAC1F,KAAK,CAAC;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC,CA0C1C;AAED,eAAO,MAAM,kBAAkB,EAAE,sBAAsB,CAAC,kBAAkB,CAyCzE,CAAC;AAKF,MAAM,WAAW,mBAAmB;IAClC,kDAAkD;IAClD,WAAW,EAAE,SAAS,MAAM,EAAE,CAAC;IAC/B,0FAA0F;IAC1F,YAAY,EAAE,SAAS,MAAM,EAAE,CAAC;IAChC,SAAS,EAAE,SAAS,cAAc,EAAE,CAAC;CACtC;AAKD,0HAA0H;AAC1H,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,MAAM,EAAE,YAAY,EAAE,SAAS,MAAM,EAAE,GAAG,MAAM,GAAG,IAAI,CAWjG;AAED,eAAO,MAAM,mBAAmB,EAAE,sBAAsB,CAAC,mBAAmB,CAuC3E,CAAC"}
|
|
@@ -131,7 +131,8 @@ export const callableTransportGuard = {
|
|
|
131
131
|
return ['transports is missing or empty'];
|
|
132
132
|
for (const t of facts.transports) {
|
|
133
133
|
textProblem(t?.module, 'a transport module', problems);
|
|
134
|
-
|
|
134
|
+
if (t?.owner !== undefined)
|
|
135
|
+
textProblem(t.owner, `transport ${String(t?.module)}'s owner`, problems);
|
|
135
136
|
namesProblem(t?.symbols, `transport ${String(t?.module)}'s symbols`, problems);
|
|
136
137
|
}
|
|
137
138
|
return problems;
|
|
@@ -141,8 +142,9 @@ export const callableTransportGuard = {
|
|
|
141
142
|
{
|
|
142
143
|
title: 'a callable is reached only through its transport owner',
|
|
143
144
|
description: 'The callable SDK and each transport helper are named only inside their owner module, which holds the ' +
|
|
144
|
-
"invocation deadline, the error normalization, and the one capture
|
|
145
|
-
'reaches through a namespace, or calls them: call the
|
|
145
|
+
"invocation deadline, the error normalization, and the one capture — or, for a transport with no owner, by " +
|
|
146
|
+
'no app file at all. Nothing else imports, re-exports, reaches through a namespace, or calls them: call the ' +
|
|
147
|
+
'hook or function the owner exports.',
|
|
146
148
|
run(context) {
|
|
147
149
|
const findings = [];
|
|
148
150
|
const held = new Set();
|
|
@@ -151,14 +153,18 @@ export const callableTransportGuard = {
|
|
|
151
153
|
const hits = transportHits(file, transport);
|
|
152
154
|
if (!hits.length)
|
|
153
155
|
continue;
|
|
154
|
-
if (file.path === transport.owner)
|
|
156
|
+
if (transport.owner !== undefined && file.path === transport.owner)
|
|
155
157
|
held.add(transport.owner);
|
|
156
|
-
else
|
|
158
|
+
else {
|
|
159
|
+
const where = transport.owner === undefined ? 'no app file may name it' : `outside its owner ${transport.owner}`;
|
|
157
160
|
for (const hit of hits)
|
|
158
|
-
findings.push({ file: file.path, line: file.lineOf(hit.index), detail:
|
|
161
|
+
findings.push({ file: file.path, line: file.lineOf(hit.index), detail: `${where}: ${hit.detail}` });
|
|
162
|
+
}
|
|
159
163
|
}
|
|
160
164
|
}
|
|
161
165
|
for (const transport of facts.transports) {
|
|
166
|
+
if (transport.owner === undefined)
|
|
167
|
+
continue;
|
|
162
168
|
if (!context.reader.exists(transport.owner))
|
|
163
169
|
findings.push({ file: transport.owner, detail: 'the transport owner no longer exists' });
|
|
164
170
|
else if (!held.has(transport.owner))
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"callables.js","sourceRoot":"","sources":["../../../src/modules/frontend-actions/callables.ts"],"names":[],"mappings":"AAAA,iGAAiG;AACjG,+FAA+F;AAC/F,gEAAgE;AAMhE,OAAO,EAAE,iBAAiB,EAAiC,MAAM,wBAAwB,CAAC;AAC1F,OAAO,EAAE,iBAAiB,EAAE,YAAY,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrG,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AACtF,OAAO,EAAE,YAAY,EAAE,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AE,0CAA0C,EAAE;oBAC/F,EAAE,IAAI,EAAE,GAAG,KAAK,CAAC,WAAW,CAAC,CAAC,CAAC,YAAY,EAAE,IAAI,EAAE,wBAAwB,EAAE;oBAC7E,EAAE,IAAI,EAAE,GAAG,KAAK,CAAC,WAAW,CAAC,CAAC,CAAC,YAAY,EAAE,IAAI,EAAE,gCAAgC,EAAE;iBACtF;gBACD,MAAM,EAAE;oBACN,EAAE,IAAI,EAAE,GAAG,KAAK,CAAC,WAAW,CAAC,CAAC,CAAC,YAAY,EAAE,IAAI,EAAE,qDAAqD,EAAE;oBAC1G,EAAE,IAAI,EAAE,GAAG,KAAK,CAAC,WAAW,CAAC,CAAC,CAAC,YAAY,EAAE,IAAI,EAAE,8CAA8C,EAAE;oBACnG,EAAE,IAAI,EAAE,GAAG,KAAK,CAAC,WAAW,CAAC,CAAC,CAAC,YAAY,EAAE,IAAI,EAAE,+BAA+B,EAAE;iBACrF;aACF;SACF,CAAC,CAAC;QACH,OAAO,CAAC,KAAK,CAAC,CAAC;IACjB,CAAC;CACF,CAAC","sourcesContent":["// The guards over how the client reaches a callable and surfaces its failure: one transport, one\n// copy owner, callable names written only in their declarations, one toast and one capture per\n// failure, and reads that live in hooks and go through readers.\n\nimport type { GenericGuardDefinition } from '../../config.js';\nimport type { Finding, Guard, GuardContext } from '../../guard.js';\nimport type { Scope } from '../../reader/reader.js';\nimport type { FileView } from '../../reader/view.js';\nimport { reviewedAllowlist, type AllowlistEntry, type Hit } from '../../shapes/shapes.js';\nimport { allowlistProblems, namesProblem, objectProblem, textProblem } from '../../support/facts.js';\nimport { fromStatements, moduleImports, namesModule } from '../../support/imports.js';\nimport { escapeRegExp, isUnder } from '../../support/text.js';\nimport { CALLABLE_KINDS, declarationFactProblems, readDeclarations, type CallableDeclarationFacts, type CallableKind } from './declarations.js';\nimport {\n balancedArgs,\n callArgs,\n exportBlocks,\n exportedName,\n handlersFor,\n localDeclarations,\n memberOrBareCalls,\n throughNamespace,\n tryCatchPairs,\n} from './text.js';\nimport { forEachNode, isPlainString } from '../../support/ast.js';\n\nconst APP_CODE: Scope = { roots: ['app'], kinds: ['code'], tests: false };\nconst REACT_HOOK = 'use[A-Z]\\\\w*';\n\n/** Runs a shape-built guard and adds the findings of an extra check to it. */\nconst withExtraCheck = (guard: Guard, extra: (context: GuardContext) => Finding[]): Guard => ({\n ...guard,\n async run(context) {\n return [...(await guard.run(context)), ...extra(context)];\n },\n});\n\n/** Each line of a file's code that one of `shapes` matches, at the line's index. */\nconst lineHits = (file: FileView, test: (line: string) => string | null): Hit[] => {\n const hits: Hit[] = [];\n let index = 0;\n for (const line of file.code.split('\\n')) {\n const detail = test(line);\n if (detail !== null) hits.push({ index, detail });\n index += line.length + 1;\n }\n return hits;\n};\n\nconst declaresExport = (code: string, name: string) =>\n new RegExp(`\\\\bexport\\\\s+(?:async\\\\s+)?(?:function\\\\s*\\\\*?|const|let)\\\\s+${escapeRegExp(name)}\\\\b`).test(code) ||\n new RegExp(`\\\\bexport\\\\s*\\\\{[^}]*\\\\b${escapeRegExp(name)}\\\\b[^}]*\\\\}`).test(code);\n\n// ---------------------------------------------------------------------------------------------\n// Callable error copy: a failure surface never shows a raw error message.\n\nexport interface CallableErrorCopyFacts {\n /** The one module that turns a callable failure into user-facing copy, and the function it exports. */\n owner: { file: string; exportName: string };\n /** Surfaces whose error is not a callable rejection, each with why. */\n allowlist: readonly AllowlistEntry[];\n}\n\n/** An error-ish receiver followed immediately by `.message`, so `errors.title.message` never matches. */\nconst ERRISH = String.raw`(?:\\w*[Ee]rror\\w*|err|e)`;\nconst RAW_MESSAGE_SHAPES = [\n new RegExp(String.raw`description:\\s*${ERRISH}\\s*\\??\\.\\s*message\\b`),\n new RegExp(String.raw`\\btitle:\\s*${ERRISH}\\s*\\??\\.\\s*message\\b`),\n new RegExp(String.raw`\\bset\\w*Error\\(\\s*${ERRISH}\\s*\\??\\.\\s*message\\s*\\)`),\n new RegExp(String.raw`\\b${ERRISH}\\s+instanceof Error\\s*\\?\\s*${ERRISH}\\s*\\.\\s*message\\b`),\n new RegExp(String.raw`\\b${ERRISH}\\s*\\?\\.\\s*message\\s*\\|\\|`),\n new RegExp(String.raw`\\{\\s*${ERRISH}\\s*\\??\\.\\s*message\\s*\\}`),\n];\n\nexport const callableErrorCopyGuard: GenericGuardDefinition<CallableErrorCopyFacts> = {\n id: 'callableErrorCopy',\n absentWhen: false,\n factProblems(facts) {\n const problems: string[] = [];\n if (objectProblem(facts?.owner, 'owner', problems)) {\n textProblem(facts.owner.file, 'owner.file', problems);\n textProblem(facts.owner.exportName, 'owner.exportName', problems);\n }\n allowlistProblems(facts?.allowlist, 'allowlist', problems);\n return problems;\n },\n build(facts) {\n const { file: owner, exportName } = facts.owner;\n const guard = reviewedAllowlist({\n title: 'a failure surface describes a callable failure through its one copy owner',\n description:\n `A toast, an error state, or a rendered element never shows a raw error message (\\`error.message\\`): ` +\n `route the failure through \\`${exportName}\\` (${owner}), so a transport failure shows its canonical copy instead ` +\n 'of an SDK string. A surface whose error is genuinely not a callable rejection is a reviewed allowlist entry ' +\n 'with its why; an entry whose file no longer holds the shape is stale.',\n scope: APP_CODE,\n match: (file) =>\n file.path === owner ? [] : lineHits(file, (line) => (RAW_MESSAGE_SHAPES.some((re) => re.test(line)) ? 'raw error message' : null)),\n allowlist: facts.allowlist,\n samples: {\n flags: [\n \"toast({ title: 'Failed', description: error.message, variant: 'destructive' });\",\n 'onError: (e) => setError(e.message),',\n \"const message = error instanceof Error ? error.message : 'Failed.';\",\n \"? linkError?.message || 'This link is invalid.'\",\n '<div>Error: {errorContent.message}</div>',\n ],\n passes: [\n `description: ${exportName}(error),`,\n '<p>{errors.title.message}</p>',\n 'captureException(error, { extra: { message: error.message } });',\n \"if (error?.message === 'content-rejected') {}\",\n ],\n },\n });\n return [\n withExtraCheck(guard, (context) => {\n if (!context.reader.exists(owner)) return [{ file: owner, detail: 'the copy owner no longer exists' }];\n return declaresExport(context.file(owner).code, exportName)\n ? []\n : [{ file: owner, detail: `the copy owner no longer exports ${exportName}` }];\n }),\n ];\n },\n};\n\n// ---------------------------------------------------------------------------------------------\n// Callable transport: the callable SDK and its transport helpers are named only by their owner.\n\nexport interface CallableTransportFacts {\n /** Each module that reaches a callable, the symbols that do, and the one file that may name them. */\n transports: ReadonlyArray<{ module: string; symbols: readonly string[]; owner: string }>;\n}\n\n/** Each reach of a transport symbol: imported, through a namespace, or called bare or as a member (`sdk.f(`). */\nfunction transportHits(file: FileView, transport: { module: string; symbols: readonly string[] }): Hit[] {\n const { code, sourceFile } = file;\n const hits: Hit[] = [];\n const namespaces: string[] = [];\n for (const site of fromStatements(sourceFile)) {\n if (!namesModule(site.spec, transport.module)) continue;\n if (site.namespace) namespaces.push(site.namespace);\n for (const symbol of transport.symbols) {\n if (site.named.some((n) => n.imported === symbol || n.local === symbol)) {\n hits.push({ index: site.node.getStart(sourceFile), detail: `imports ${symbol} from ${site.spec}` });\n }\n }\n }\n for (const namespace of namespaces) {\n for (const symbol of transport.symbols) {\n const re = new RegExp(`\\\\b${escapeRegExp(namespace)}\\\\s*\\\\.\\\\s*${escapeRegExp(symbol)}\\\\b`, 'g');\n for (let m = re.exec(code); m; m = re.exec(code)) hits.push({ index: m.index, detail: `reaches ${namespace}.${symbol}` });\n }\n }\n for (const symbol of transport.symbols) {\n for (const index of memberOrBareCalls(code, symbol)) {\n if (!throughNamespace(code, index, namespaces)) hits.push({ index, detail: `calls ${symbol}(` });\n }\n }\n return hits;\n}\n\nexport const callableTransportGuard: GenericGuardDefinition<CallableTransportFacts> = {\n id: 'callableTransport',\n absentWhen: false,\n factProblems(facts) {\n const problems: string[] = [];\n if (!Array.isArray(facts?.transports) || !facts.transports.length) return ['transports is missing or empty'];\n for (const t of facts.transports) {\n textProblem(t?.module, 'a transport module', problems);\n textProblem(t?.owner, `transport ${String(t?.module)}'s owner`, problems);\n namesProblem(t?.symbols, `transport ${String(t?.module)}'s symbols`, problems);\n }\n return problems;\n },\n build(facts) {\n return [\n {\n title: 'a callable is reached only through its transport owner',\n description:\n 'The callable SDK and each transport helper are named only inside their owner module, which holds the ' +\n \"invocation deadline, the error normalization, and the one capture. Nothing else imports, re-exports, \" +\n 'reaches through a namespace, or calls them: call the hook or function the owner exports.',\n run(context) {\n const findings: Finding[] = [];\n const held = new Set<string>();\n for (const file of context.files(APP_CODE)) {\n for (const transport of facts.transports) {\n const hits = transportHits(file, transport);\n if (!hits.length) continue;\n if (file.path === transport.owner) held.add(transport.owner);\n else for (const hit of hits) findings.push({ file: file.path, line: file.lineOf(hit.index), detail: `outside its owner ${transport.owner}: ${hit.detail}` });\n }\n }\n for (const transport of facts.transports) {\n if (!context.reader.exists(transport.owner)) findings.push({ file: transport.owner, detail: 'the transport owner no longer exists' });\n else if (!held.has(transport.owner)) findings.push({ file: transport.owner, detail: `stale owner: it no longer names any of ${transport.symbols.join(', ')}` });\n }\n return findings;\n },\n },\n ];\n },\n};\n\n// ---------------------------------------------------------------------------------------------\n// The declared hooks a component holds, shared by the name, read, and double-surface guards.\n\n/** The call-site option that turns a declared hook's error toast off. */\nconst TOAST_OPTION = 'showErrorToast';\n/** The call-site option naming the answers a caller surfaces itself. */\nconst ANSWER_OPTION = 'isAnswerSurfacedByCaller';\n/** The members of an action's result that start it. */\nconst ACTION_MEMBERS = ['mutate', 'mutateAsync'];\n\n/** One place a file binds a hook's result: the local name, how it is invoked, and the hook's arguments. */\ninterface HookBinding {\n /** The local name, as a finding shows it. */\n name: string;\n /** The names a call through this binding is written as (`b.mutate`, `b.mutateAsync`, `b`). */\n calls: readonly string[];\n hook: string;\n args: string;\n index: number;\n}\n\n/** Every binding of one of `hooks` in `code`: a whole result, or an action's start members destructured. */\nfunction hookBindings(code: string, hooks: ReadonlySet<string>): HookBinding[] {\n const out: HookBinding[] = [];\n const whole = new RegExp(`(?:const|let|var)\\\\s+([\\\\w$]+)\\\\s*=\\\\s*(${REACT_HOOK})\\\\s*(?:<[^()]*?>)?\\\\s*\\\\(`, 'g');\n for (let m = whole.exec(code); m; m = whole.exec(code)) {\n if (!hooks.has(m[2])) continue;\n const args = balancedArgs(code, m.index + m[0].length - 1);\n out.push({ name: m[1], calls: [...ACTION_MEMBERS.map((member) => `${m![1]}.${member}`), m[1]], hook: m[2], args, index: m.index });\n }\n const destructured = new RegExp(`(?:const|let|var)\\\\s*\\\\{([^}]*)\\\\}\\\\s*=\\\\s*(${REACT_HOOK})\\\\s*(?:<[^()]*?>)?\\\\s*\\\\(`, 'g');\n for (let m = destructured.exec(code); m; m = destructured.exec(code)) {\n if (!hooks.has(m[2])) continue;\n const args = balancedArgs(code, m.index + m[0].length - 1);\n for (const part of m[1].split(',')) {\n const [key, alias] = part.split(':').map((p) => p.trim());\n if (!ACTION_MEMBERS.includes(key)) continue;\n const local = alias || key;\n if (/^[\\w$]+$/.test(local)) out.push({ name: local, calls: [local], hook: m[2], args, index: m.index });\n }\n }\n return out;\n}\n\n/** A hook's options text for its argument, a same-file constant resolved; null when it cannot be seen. */\nfunction resolveOptions(args: string, code: string): string | null {\n const trimmed = args.trim();\n if (trimmed === '' || trimmed.startsWith('{')) return trimmed;\n if (!/^\\w+$/.test(trimmed)) return null;\n const decl = new RegExp(`(?:const|let|var)\\\\s+${trimmed}\\\\s*(?::[^=]+)?=\\\\s*(\\\\{[^}]*\\\\})`).exec(code);\n return decl ? decl[1] : null;\n}\n\n/** True unless the call site visibly turns the declared hook's error toast off. */\nconst toastIsOn = (args: string, code: string) => {\n const options = resolveOptions(args, code);\n return options === null || !new RegExp(`\\\\b${TOAST_OPTION}\\\\s*:\\\\s*false\\\\b`).test(options);\n};\n\n// ---------------------------------------------------------------------------------------------\n// Callable names: a callable's name is written only in its declaration.\n\nexport interface CallableNameFacts {\n declarations: CallableDeclarationFacts;\n /** Files that hold a string equal to a callable's name for another reason, each with why. */\n allowlist: readonly AllowlistEntry[];\n}\n\n/** Each string literal in a file whose text is one of `names`. */\nexport function callableNameHits(file: FileView, names: ReadonlyMap<string, string>): Hit[] {\n const hits: Hit[] = [];\n const sf = file.sourceFile;\n forEachNode(sf, (node) => {\n if (isPlainString(node) && names.has(node.text)) {\n hits.push({ index: node.getStart(sf), detail: `names the callable ${node.text}: call its declared hook ${names.get(node.text)}` });\n }\n });\n return hits;\n}\n\nexport const callableNameGuard: GenericGuardDefinition<CallableNameFacts> = {\n id: 'callableNames',\n absentWhen: false,\n factProblems(facts) {\n const problems: string[] = [];\n declarationFactProblems(facts?.declarations, 'declarations', problems);\n allowlistProblems(facts?.allowlist, 'allowlist', problems);\n return problems;\n },\n build(facts) {\n return [\n {\n title: \"a callable's name is written only in its declaration\",\n description:\n `Each callable is declared once, in ${facts.declarations.modules.join(', ')}, as a named hook built by one of the ` +\n `callable factories (${CALLABLE_KINDS.map((k) => facts.declarations.factories[k]).join(', ')}), with its name ` +\n 'as a string literal. No other app source writes that name: call the declared hook, so a renamed or removed ' +\n 'callable fails to compile in one place instead of failing when clicked. A file that holds the same string ' +\n 'for another reason is a reviewed allowlist entry with its why; an entry whose file no longer holds it is stale.',\n run(context) {\n const { declared, findings } = readDeclarations(context, facts.declarations);\n const names = new Map(declared.filter((d) => d.callable !== null).map((d) => [d.callable!, d.hook]));\n const modules = new Set(facts.declarations.modules);\n const reviewed = new Map(facts.allowlist.map((e) => [e.path, e]));\n const held = new Map<string, number>();\n for (const file of context.files(APP_CODE)) {\n if (modules.has(file.path)) continue;\n const hits = callableNameHits(file, names);\n if (!hits.length) continue;\n const entry = reviewed.get(file.path);\n const allowed = entry ? (entry.count ?? hits.length) : 0;\n if (entry) held.set(file.path, hits.length);\n for (const hit of hits.slice(allowed)) {\n findings.push({ file: file.path, line: file.lineOf(hit.index), detail: entry ? `more than the ${allowed} reviewed: ${hit.detail}` : hit.detail! });\n }\n }\n for (const entry of facts.allowlist) {\n const found = held.get(entry.path) ?? 0;\n if (!found) findings.push({ file: entry.path, detail: 'stale entry: the file no longer holds a callable name (or is gone)' });\n else if (entry.count !== undefined && found < entry.count) findings.push({ file: entry.path, detail: `stale count: reviewed ${entry.count}, found ${found}` });\n }\n return findings;\n },\n },\n ];\n },\n};\n\n// ---------------------------------------------------------------------------------------------\n// Callable-backed reads: live in the hooks folder, go through a reader, and hand their failure to\n// the read-failure surface.\n\nexport interface CallableReadFacts {\n declarations: CallableDeclarationFacts;\n /** The folder every read hook lives in. */\n hooksRoot: string;\n /** The component that renders a read failure, and the prop it takes the read's error through. */\n readFailureSurface: { component: string; errorProp: string };\n /** Hooks the detector must find a callable-backed read in — proof it still recognizes the reads. */\n anchorReads: readonly string[];\n}\n\ninterface CallableRead {\n path: string;\n /** The exported hook or component the read is in. */\n where: string;\n binding: string;\n hook: string;\n kind: CallableKind;\n index: number;\n}\n\n/** Each React Query read call's argument text, with where the call starts. */\nfunction readQueryCalls(block: string): Array<{ args: string; index: number }> {\n const out: Array<{ args: string; index: number }> = [];\n const re = /\\b(?:useQuery|useInfiniteQuery|useQueries|useSuspenseQuery|useSuspenseInfiniteQuery)\\b/g;\n for (let m = re.exec(block); m; m = re.exec(block)) {\n let i = m.index + m[0].length;\n while (/\\s/.test(block[i] ?? '')) i++;\n if (block[i] === '<') {\n let depth = 0;\n for (; i < block.length; i++) {\n if (block[i] === '=' && block[i + 1] === '>') {\n i++;\n continue;\n }\n if (block[i] === '<') depth++;\n else if (block[i] === '>' && --depth === 0) break;\n }\n i++;\n while (/\\s/.test(block[i] ?? '')) i++;\n }\n if (block[i] === '(') out.push({ args: balancedArgs(block, i), index: m.index });\n }\n return out;\n}\n\n/** Every React Query read that reaches a declared hook, directly or through a block-local helper. */\nexport function callableReadsIn(file: { path: string; code: string }, kinds: ReadonlyMap<string, CallableKind>): CallableRead[] {\n const reads: CallableRead[] = [];\n const hooks = new Set(kinds.keys());\n for (const block of exportBlocks(file.code)) {\n const text = block.text;\n const bindings = hookBindings(text, hooks);\n if (!bindings.length) continue;\n const where = exportedName(text) ?? new RegExp(`\\\\bfunction\\\\s+(${REACT_HOOK})`).exec(text)?.[1] ?? '(module scope)';\n const decls = localDeclarations(text);\n for (const call of readQueryCalls(text)) {\n for (const binding of bindings) {\n const ref = new RegExp(`(?<![\\\\w$.])${escapeRegExp(binding.name)}\\\\b`);\n const direct = ref.test(call.args);\n const viaHelper = [...decls].some(([name, decl]) => name !== binding.name && new RegExp(`\\\\b${escapeRegExp(name)}\\\\b`).test(call.args) && ref.test(decl));\n if (direct || viaHelper) {\n reads.push({ path: file.path, where, binding: binding.name, hook: binding.hook, kind: kinds.get(binding.hook)!, index: block.start + call.index });\n }\n }\n }\n }\n return reads;\n}\n\n/** Every finding about one read: where it lives, and the kind it reads through. */\nexport function callableReadFindings(read: CallableRead, hooksRoot: string): string[] {\n const where = `${read.where} (${read.binding})`;\n return [\n ...(isUnder(read.path, hooksRoot) ? [] : [`${where} is a callable read outside ${hooksRoot}`]),\n ...(read.kind === 'reader' ? [] : [`${where} reads through ${read.hook}, a declared ${read.kind}: declare the callable as a reader`]),\n ];\n}\n\n/** Each read-failure element rendering a read hook's failure without being handed the read's error. */\nexport function unhandedReadFailures(code: string, readHooks: readonly string[], surface: CallableReadFacts['readFailureSurface']): Array<{ index: number; binding: string }> {\n const names: string[] = [];\n for (const hook of readHooks) {\n const h = escapeRegExp(hook);\n for (const m of code.matchAll(new RegExp(`(?:const|let)\\\\s+(\\\\w+)\\\\s*=\\\\s*${h}\\\\s*[(<]`, 'g'))) names.push(m[1]);\n for (const m of code.matchAll(new RegExp(`(?:const|let)\\\\s*\\\\{([^}]*)\\\\}\\\\s*=\\\\s*${h}\\\\s*[(<]`, 'g'))) {\n for (const part of m[1].split(',')) {\n const [key, alias] = part.split(':').map((s) => s.trim().replace(/\\s*=.*$/, ''));\n if (key && key !== 'data') names.push(alias || key);\n }\n }\n }\n if (!names.length) return [];\n const out: Array<{ index: number; binding: string }> = [];\n const tag = `<${surface.component}`;\n for (let i = code.indexOf(tag); i >= 0; i = code.indexOf(tag, i + tag.length)) {\n if (/[\\w$]/.test(code[i + tag.length] ?? '')) continue;\n let j = i + tag.length;\n let depth = 0;\n for (; j < code.length; j++) {\n const c = code[j];\n if (c === '{') depth++;\n else if (c === '}') depth--;\n else if (depth === 0 && (c === '>' || (c === '/' && code[j + 1] === '>'))) break;\n }\n const lead = code.slice(Math.max(0, i - 250), i);\n const attrs = code.slice(i + tag.length, j);\n const bound = names.find((name) => new RegExp(`\\\\b${escapeRegExp(name)}\\\\b`).test(lead + attrs));\n if (bound && !new RegExp(`\\\\b${escapeRegExp(surface.errorProp)}\\\\s*=`).test(attrs)) out.push({ index: i, binding: bound });\n }\n return out;\n}\n\nexport const callableReadGuard: GenericGuardDefinition<CallableReadFacts> = {\n id: 'callableReads',\n absentWhen: false,\n factProblems(facts) {\n const problems: string[] = [];\n declarationFactProblems(facts?.declarations, 'declarations', problems);\n textProblem(facts?.hooksRoot, 'hooksRoot', problems);\n if (objectProblem(facts?.readFailureSurface, 'readFailureSurface', problems)) {\n textProblem(facts.readFailureSurface.component, 'readFailureSurface.component', problems);\n textProblem(facts.readFailureSurface.errorProp, 'readFailureSurface.errorProp', problems);\n }\n namesProblem(facts?.anchorReads, 'anchorReads', problems);\n return problems;\n },\n build(facts) {\n const reader = facts.declarations.factories.reader;\n return [\n {\n title: 'a callable-backed read lives in a hook and goes through a reader',\n description:\n `A React Query read that reaches a callable lives in ${facts.hooksRoot} and calls a hook declared with ` +\n `\\`${reader}\\`: a reader shows no toast and captures nothing, because the read's failure renders through ` +\n `${facts.readFailureSurface.component} and the query layer captures it once. An action, a resumable action, ` +\n `or an invoker inside a read toasts and captures that failure a second time — declare the callable with ` +\n `\\`${reader}\\` instead. Every ${facts.readFailureSurface.component} that renders a callable-backed read's ` +\n `failure is handed that read's error through \\`${facts.readFailureSurface.errorProp}\\`, so an answer the ` +\n 'server refused renders as that answer, never as a load failure.',\n run(context) {\n const { declared, findings } = readDeclarations(context, facts.declarations);\n const kinds = new Map(declared.map((d) => [d.hook, d.kind]));\n const modules = new Set(facts.declarations.modules);\n const files = context.files(APP_CODE).filter((f) => !modules.has(f.path));\n const reads = files.flatMap((file) => callableReadsIn(file, kinds));\n const byFile = new Map(files.map((f) => [f.path, f]));\n for (const read of reads) {\n for (const detail of callableReadFindings(read, facts.hooksRoot)) {\n findings.push({ file: read.path, line: byFile.get(read.path)!.lineOf(read.index), detail });\n }\n }\n const readHooks = [...new Set(reads.map((r) => r.where))];\n for (const anchor of facts.anchorReads) {\n if (!readHooks.includes(anchor)) findings.push({ file: '(anchorReads)', detail: `no callable-backed read found in ${anchor} — the detector no longer recognizes it, or the anchor is stale` });\n }\n for (const file of files) {\n if (isUnder(file.path, facts.hooksRoot)) continue;\n for (const hit of unhandedReadFailures(file.code, readHooks, facts.readFailureSurface)) {\n findings.push({ file: file.path, line: file.lineOf(hit.index), detail: `${facts.readFailureSurface.component} renders ${hit.binding}'s failure without its ${facts.readFailureSurface.errorProp}` });\n }\n }\n return findings;\n },\n },\n ];\n },\n};\n\n// ---------------------------------------------------------------------------------------------\n// Double surface: a declared action's rejection is surfaced once — by its toast, or by the caller.\n\nexport interface DoubleSurfaceFacts {\n declarations: CallableDeclarationFacts;\n /** The function that raises a toast. */\n toastCall: string;\n /** Predicates that gate a local toast to a leg the declared hook's toast cannot see. */\n nonCallableLegGuards: readonly string[];\n /** Import specifier prefixes that reach app source (relative imports always do). */\n appImportPrefixes: readonly string[];\n}\n\n/** Where a declared hook or an app hook over one comes from, for a finding. */\ntype ToastingHooks = ReadonlyMap<string, string>;\n\n/** Exported app hooks that hold a toasting declared hook with its toast on, so each toasts every rejection. */\nexport function wrappingHooks(files: ReadonlyArray<{ path: string; code: string }>, declared: ToastingHooks): Map<string, string> {\n const hooks = new Map<string, string>();\n const names = new Set(declared.keys());\n for (const file of files) {\n for (const block of exportBlocks(file.code)) {\n const name = new RegExp(`export\\\\s+(?:async\\\\s+)?(?:function|const)\\\\s+(${REACT_HOOK})`).exec(block.text)?.[1];\n if (!name || names.has(name)) continue;\n if (hookBindings(block.text, names).some((b) => toastIsOn(b.args, file.code))) hooks.set(name, file.path);\n }\n }\n return hooks;\n}\n\n/** Every place a file surfaces a rejection a toasting hook it holds has already toasted. */\nexport function doubleSurfaces(\n file: FileView,\n toasting: ToastingHooks,\n wrappers: ToastingHooks,\n facts: Pick<DoubleSurfaceFacts, 'toastCall' | 'nonCallableLegGuards' | 'appImportPrefixes'>,\n): Array<{ index: number; detail: string }> {\n const code = file.code;\n const imported = new Set<string>();\n for (const site of moduleImports(file.sourceFile, ['import'])) {\n const fromApp = site.spec.startsWith('.') || facts.appImportPrefixes.some((p) => site.spec.startsWith(p));\n if (fromApp) for (const name of site.named) imported.add(name.local);\n }\n const visible = new Map<string, string>(toasting);\n for (const [hook, origin] of wrappers) if (origin !== file.path && imported.has(hook)) visible.set(hook, origin);\n const toast = new RegExp(`\\\\b${escapeRegExp(facts.toastCall)}\\\\s*\\\\(`);\n const out: Array<{ index: number; detail: string }> = [];\n const seen = new Set<string>();\n const report = (index: number, detail: string) => {\n if (seen.has(`${index}:${detail}`)) return;\n seen.add(`${index}:${detail}`);\n out.push({ index, detail });\n };\n for (const binding of hookBindings(code, new Set(visible.keys()))) {\n if (!wrappers.has(binding.hook) && !toastIsOn(binding.args, code)) continue;\n const answer = new RegExp(`\\\\b${ANSWER_OPTION}\\\\s*:\\\\s*([\\\\w$]+)`).exec(binding.args)?.[1];\n const gated = (text: string) =>\n facts.nonCallableLegGuards.some((g) => new RegExp(`\\\\b${escapeRegExp(g)}\\\\b`).test(text)) ||\n (!!answer && new RegExp(`\\\\b${escapeRegExp(answer)}\\\\s*\\\\(`).test(text));\n const surfaces = (handler: string) => toast.test(handler) && !gated(handler);\n const who = `${binding.name} (${binding.hook}, ${visible.get(binding.hook)})`;\n if (handlersFor(binding.args, 'onError').some(surfaces)) report(binding.index, `${who} toasts again in the onError it hands the hook`);\n for (const name of binding.calls) {\n for (const call of callArgs(code, name)) {\n if (handlersFor(call.args, 'onError').some(surfaces)) report(call.index, `${who} toasts again in its onError`);\n }\n }\n const ref = new RegExp(`(?<![\\\\w$.])${escapeRegExp(binding.name)}\\\\b`);\n for (const pair of tryCatchPairs(code)) {\n if (ref.test(pair.tryBody) && surfaces(pair.catchBody)) report(pair.index, `${who} toasts again in a catch`);\n }\n for (const mutation of callArgs(code, 'useMutation')) {\n if (ref.test(mutation.args) && handlersFor(mutation.args, 'onError').some(surfaces)) {\n report(mutation.index, `${who} toasts again in the onError of the mutation that calls it`);\n }\n }\n }\n return out;\n}\n\nexport const doubleSurfaceGuard: GenericGuardDefinition<DoubleSurfaceFacts> = {\n id: 'callableDoubleSurface',\n absentWhen: false,\n factProblems(facts) {\n const problems: string[] = [];\n declarationFactProblems(facts?.declarations, 'declarations', problems);\n textProblem(facts?.toastCall, 'toastCall', problems);\n namesProblem(facts?.nonCallableLegGuards, 'nonCallableLegGuards', problems);\n namesProblem(facts?.appImportPrefixes, 'appImportPrefixes', problems, { nonEmpty: false });\n return problems;\n },\n build(facts) {\n return [\n {\n title: 'one callable rejection surfaces exactly once',\n description:\n 'A hook declared as an action, a resumable action, or an invoker shows the shared error toast for every ' +\n `rejection unless its call site passes \\`{ ${TOAST_OPTION}: false }\\`, and so does an app hook built over one. ` +\n `While that toast is on, nothing toasts the same rejection again — not an onError handed to the hook or to ` +\n 'its mutate call, not a catch around it, and not the onError of a mutation that calls it. Fix one of: pass ' +\n `\\`{ ${TOAST_OPTION}: false }\\` and own the only surface; drop the local toast (an empty catch keeps any ` +\n 'finally reset); or gate the local toast on a predicate that sees only the leg the shared toast cannot ' +\n `(${facts.nonCallableLegGuards.join(', ')}), or on the predicate the call site hands \\`${ANSWER_OPTION}\\`, ` +\n \"which makes the caller that answer's only surface.\",\n run(context) {\n const { declared, findings } = readDeclarations(context, facts.declarations);\n const toasting = new Map(declared.filter((d) => d.kind !== 'reader').map((d) => [d.hook, d.file]));\n if (!toasting.size && !findings.length) {\n findings.push({ file: '(declarations)', detail: 'no action, resumable action, or invoker is declared, so the check sees no toasting hook' });\n }\n const modules = new Set(facts.declarations.modules);\n const files = context.files(APP_CODE).filter((f) => !modules.has(f.path));\n const wrappers = wrappingHooks(files, toasting);\n for (const file of files) {\n for (const hit of doubleSurfaces(file, toasting, wrappers, facts)) findings.push({ file: file.path, line: file.lineOf(hit.index), detail: hit.detail });\n }\n return findings;\n },\n },\n ];\n },\n};\n\n// ---------------------------------------------------------------------------------------------\n// Error internals: a rendered element never shows a thrown error's message or stringification.\n\nexport interface ErrorInternalsFacts {\n /** The folders whose files render to the user. */\n renderRoots: readonly string[];\n /** Monitoring calls where error internals belong (besides `console.*` and `logger.*`). */\n captureCalls: readonly string[];\n allowlist: readonly AllowlistEntry[];\n}\n\nconst LEAK = /(?:\\b(?:\\w*[Ee]rror|err|e)\\s*\\??\\.\\s*message\\b|as\\s+Error\\s*\\)\\s*\\.\\s*message\\b|\\bString\\s*\\(\\s*(?:\\w*[Ee]rror|err|e)\\s*\\))/;\nconst BRACE_GROUP = /\\{[^{}]*\\}/g;\n\n/** The render of error internals on one line, or null: a brace group holding one that is not an object property value. */\nexport function errorInternalsOnLine(line: string, captureCalls: readonly string[]): string | null {\n const logging = new RegExp(`\\\\b(?:console\\\\s*\\\\.\\\\s*\\\\w+|logger\\\\s*\\\\.\\\\s*\\\\w+${captureCalls.map((c) => `|${escapeRegExp(c)}`).join('')})\\\\s*\\\\(`);\n if (logging.test(line)) return null;\n for (const match of line.matchAll(BRACE_GROUP)) {\n const inner = match[0].slice(1, -1);\n const hit = LEAK.exec(inner);\n if (!hit) continue;\n if (/\\w+\\s*:/.test(inner.slice(0, hit.index))) continue;\n return hit[0];\n }\n return null;\n}\n\nexport const errorInternalsGuard: GenericGuardDefinition<ErrorInternalsFacts> = {\n id: 'errorInternalsRender',\n absentWhen: false,\n factProblems(facts) {\n const problems: string[] = [];\n namesProblem(facts?.renderRoots, 'renderRoots', problems);\n namesProblem(facts?.captureCalls, 'captureCalls', problems, { nonEmpty: false });\n allowlistProblems(facts?.allowlist, 'allowlist', problems);\n return problems;\n },\n build(facts) {\n const guard = reviewedAllowlist({\n title: \"a rendered element never shows a thrown error's internals\",\n description:\n `A surface under ${facts.renderRoots.join(', ')} never renders an error's message, an \\`(x as Error).message\\`, or a ` +\n \"`String(error)` — in JSX, a template hole, or a prop. A thrown error's text leaks infrastructure detail and \" +\n 'tells the user nothing they can act on: render a fixed title naming what failed and a next-step sentence. ' +\n 'Error internals belong in logging and monitoring capture, which this check leaves alone, as it does an ' +\n 'object property value (a toast description, which the callable policy owns).',\n scope: APP_CODE,\n match: (file) =>\n facts.renderRoots.some((root) => isUnder(file.path, root)) ? lineHits(file, (line) => errorInternalsOnLine(line, facts.captureCalls)) : [],\n allowlist: facts.allowlist,\n samples: {\n flags: [\n { path: `${facts.renderRoots[0]}/probe.tsx`, text: '<p>Failed: {error.message}</p>' },\n { path: `${facts.renderRoots[0]}/probe.tsx`, text: '<p>{(result.error as Error).message}</p>' },\n { path: `${facts.renderRoots[0]}/probe.tsx`, text: '<p>{String(error)}</p>' },\n { path: `${facts.renderRoots[0]}/probe.tsx`, text: 'error={error?.message || null}' },\n ],\n passes: [\n { path: `${facts.renderRoots[0]}/probe.tsx`, text: \"toast({ title: 'Failed', description: e.message });\" },\n { path: `${facts.renderRoots[0]}/probe.tsx`, text: \"console.error('read failed', error.message);\" },\n { path: `${facts.renderRoots[0]}/probe.tsx`, text: '<p>{errors.title.message}</p>' },\n ],\n },\n });\n return [guard];\n },\n};\n"]}
|
|
1
|
+
{"version":3,"file":"callables.js","sourceRoot":"","sources":["../../../src/modules/frontend-actions/callables.ts"],"names":[],"mappings":"AAAA,iGAAiG;AACjG,+FAA+F;AAC/F,gEAAgE;AAMhE,OAAO,EAAE,iBAAiB,EAAiC,MAAM,wBAAwB,CAAC;AAC1F,OAAO,EAAE,iBAAiB,EAAE,YAAY,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrG,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AACtF,OAAO,EAAE,YAAY,EAAE,OAAO,EAAE,MAA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CAAC,CAAC,EAAE;YAC5I,SAAS,EAAE,KAAK,CAAC,SAAS;YAC1B,OAAO,EAAE;gBACP,KAAK,EAAE;oBACL,EAAE,IAAI,EAAE,GAAG,KAAK,CAAC,WAAW,CAAC,CAAC,CAAC,YAAY,EAAE,IAAI,EAAE,gCAAgC,EAAE;oBACrF,EAAE,IAAI,EAAE,GAAG,KAAK,CAAC,WAAW,CAAC,CAAC,CAAC,YAAY,EAAE,IAAI,EAAE,0CAA0C,EAAE;oBAC/F,EAAE,IAAI,EAAE,GAAG,KAAK,CAAC,WAAW,CAAC,CAAC,CAAC,YAAY,EAAE,IAAI,EAAE,wBAAwB,EAAE;oBAC7E,EAAE,IAAI,EAAE,GAAG,KAAK,CAAC,WAAW,CAAC,CAAC,CAAC,YAAY,EAAE,IAAI,EAAE,gCAAgC,EAAE;iBACtF;gBACD,MAAM,EAAE;oBACN,EAAE,IAAI,EAAE,GAAG,KAAK,CAAC,WAAW,CAAC,CAAC,CAAC,YAAY,EAAE,IAAI,EAAE,qDAAqD,EAAE;oBAC1G,EAAE,IAAI,EAAE,GAAG,KAAK,CAAC,WAAW,CAAC,CAAC,CAAC,YAAY,EAAE,IAAI,EAAE,8CAA8C,EAAE;oBACnG,EAAE,IAAI,EAAE,GAAG,KAAK,CAAC,WAAW,CAAC,CAAC,CAAC,YAAY,EAAE,IAAI,EAAE,+BAA+B,EAAE;iBACrF;aACF;SACF,CAAC,CAAC;QACH,OAAO,CAAC,KAAK,CAAC,CAAC;IACjB,CAAC;CACF,CAAC","sourcesContent":["// The guards over how the client reaches a callable and surfaces its failure: one transport, one\n// copy owner, callable names written only in their declarations, one toast and one capture per\n// failure, and reads that live in hooks and go through readers.\n\nimport type { GenericGuardDefinition } from '../../config.js';\nimport type { Finding, Guard, GuardContext } from '../../guard.js';\nimport type { Scope } from '../../reader/reader.js';\nimport type { FileView } from '../../reader/view.js';\nimport { reviewedAllowlist, type AllowlistEntry, type Hit } from '../../shapes/shapes.js';\nimport { allowlistProblems, namesProblem, objectProblem, textProblem } from '../../support/facts.js';\nimport { fromStatements, moduleImports, namesModule } from '../../support/imports.js';\nimport { escapeRegExp, isUnder } from '../../support/text.js';\nimport { CALLABLE_KINDS, declarationFactProblems, readDeclarations, type CallableDeclarationFacts, type CallableKind } from './declarations.js';\nimport {\n balancedArgs,\n callArgs,\n exportBlocks,\n exportedName,\n handlersFor,\n localDeclarations,\n memberOrBareCalls,\n throughNamespace,\n tryCatchPairs,\n} from './text.js';\nimport { forEachNode, isPlainString } from '../../support/ast.js';\n\nconst APP_CODE: Scope = { roots: ['app'], kinds: ['code'], tests: false };\nconst REACT_HOOK = 'use[A-Z]\\\\w*';\n\n/** Runs a shape-built guard and adds the findings of an extra check to it. */\nconst withExtraCheck = (guard: Guard, extra: (context: GuardContext) => Finding[]): Guard => ({\n ...guard,\n async run(context) {\n return [...(await guard.run(context)), ...extra(context)];\n },\n});\n\n/** Each line of a file's code that one of `shapes` matches, at the line's index. */\nconst lineHits = (file: FileView, test: (line: string) => string | null): Hit[] => {\n const hits: Hit[] = [];\n let index = 0;\n for (const line of file.code.split('\\n')) {\n const detail = test(line);\n if (detail !== null) hits.push({ index, detail });\n index += line.length + 1;\n }\n return hits;\n};\n\nconst declaresExport = (code: string, name: string) =>\n new RegExp(`\\\\bexport\\\\s+(?:async\\\\s+)?(?:function\\\\s*\\\\*?|const|let)\\\\s+${escapeRegExp(name)}\\\\b`).test(code) ||\n new RegExp(`\\\\bexport\\\\s*\\\\{[^}]*\\\\b${escapeRegExp(name)}\\\\b[^}]*\\\\}`).test(code);\n\n// ---------------------------------------------------------------------------------------------\n// Callable error copy: a failure surface never shows a raw error message.\n\nexport interface CallableErrorCopyFacts {\n /** The one module that turns a callable failure into user-facing copy, and the function it exports. */\n owner: { file: string; exportName: string };\n /** Surfaces whose error is not a callable rejection, each with why. */\n allowlist: readonly AllowlistEntry[];\n}\n\n/** An error-ish receiver followed immediately by `.message`, so `errors.title.message` never matches. */\nconst ERRISH = String.raw`(?:\\w*[Ee]rror\\w*|err|e)`;\nconst RAW_MESSAGE_SHAPES = [\n new RegExp(String.raw`description:\\s*${ERRISH}\\s*\\??\\.\\s*message\\b`),\n new RegExp(String.raw`\\btitle:\\s*${ERRISH}\\s*\\??\\.\\s*message\\b`),\n new RegExp(String.raw`\\bset\\w*Error\\(\\s*${ERRISH}\\s*\\??\\.\\s*message\\s*\\)`),\n new RegExp(String.raw`\\b${ERRISH}\\s+instanceof Error\\s*\\?\\s*${ERRISH}\\s*\\.\\s*message\\b`),\n new RegExp(String.raw`\\b${ERRISH}\\s*\\?\\.\\s*message\\s*\\|\\|`),\n new RegExp(String.raw`\\{\\s*${ERRISH}\\s*\\??\\.\\s*message\\s*\\}`),\n];\n\nexport const callableErrorCopyGuard: GenericGuardDefinition<CallableErrorCopyFacts> = {\n id: 'callableErrorCopy',\n absentWhen: false,\n factProblems(facts) {\n const problems: string[] = [];\n if (objectProblem(facts?.owner, 'owner', problems)) {\n textProblem(facts.owner.file, 'owner.file', problems);\n textProblem(facts.owner.exportName, 'owner.exportName', problems);\n }\n allowlistProblems(facts?.allowlist, 'allowlist', problems);\n return problems;\n },\n build(facts) {\n const { file: owner, exportName } = facts.owner;\n const guard = reviewedAllowlist({\n title: 'a failure surface describes a callable failure through its one copy owner',\n description:\n `A toast, an error state, or a rendered element never shows a raw error message (\\`error.message\\`): ` +\n `route the failure through \\`${exportName}\\` (${owner}), so a transport failure shows its canonical copy instead ` +\n 'of an SDK string. A surface whose error is genuinely not a callable rejection is a reviewed allowlist entry ' +\n 'with its why; an entry whose file no longer holds the shape is stale.',\n scope: APP_CODE,\n match: (file) =>\n file.path === owner ? [] : lineHits(file, (line) => (RAW_MESSAGE_SHAPES.some((re) => re.test(line)) ? 'raw error message' : null)),\n allowlist: facts.allowlist,\n samples: {\n flags: [\n \"toast({ title: 'Failed', description: error.message, variant: 'destructive' });\",\n 'onError: (e) => setError(e.message),',\n \"const message = error instanceof Error ? error.message : 'Failed.';\",\n \"? linkError?.message || 'This link is invalid.'\",\n '<div>Error: {errorContent.message}</div>',\n ],\n passes: [\n `description: ${exportName}(error),`,\n '<p>{errors.title.message}</p>',\n 'captureException(error, { extra: { message: error.message } });',\n \"if (error?.message === 'content-rejected') {}\",\n ],\n },\n });\n return [\n withExtraCheck(guard, (context) => {\n if (!context.reader.exists(owner)) return [{ file: owner, detail: 'the copy owner no longer exists' }];\n return declaresExport(context.file(owner).code, exportName)\n ? []\n : [{ file: owner, detail: `the copy owner no longer exports ${exportName}` }];\n }),\n ];\n },\n};\n\n// ---------------------------------------------------------------------------------------------\n// Callable transport: the callable SDK and its transport helpers are named only by their owner, or\n// by no app file at all.\n\nexport interface CallableTransportFacts {\n /**\n * Each module that reaches a callable, the symbols that do, and the one file that may name them.\n * A transport with no owner is named by no app file: the app reaches it only through a package.\n */\n transports: ReadonlyArray<{ module: string; symbols: readonly string[]; owner?: string }>;\n}\n\n/** Each reach of a transport symbol: imported, through a namespace, or called bare or as a member (`sdk.f(`). */\nfunction transportHits(file: FileView, transport: { module: string; symbols: readonly string[] }): Hit[] {\n const { code, sourceFile } = file;\n const hits: Hit[] = [];\n const namespaces: string[] = [];\n for (const site of fromStatements(sourceFile)) {\n if (!namesModule(site.spec, transport.module)) continue;\n if (site.namespace) namespaces.push(site.namespace);\n for (const symbol of transport.symbols) {\n if (site.named.some((n) => n.imported === symbol || n.local === symbol)) {\n hits.push({ index: site.node.getStart(sourceFile), detail: `imports ${symbol} from ${site.spec}` });\n }\n }\n }\n for (const namespace of namespaces) {\n for (const symbol of transport.symbols) {\n const re = new RegExp(`\\\\b${escapeRegExp(namespace)}\\\\s*\\\\.\\\\s*${escapeRegExp(symbol)}\\\\b`, 'g');\n for (let m = re.exec(code); m; m = re.exec(code)) hits.push({ index: m.index, detail: `reaches ${namespace}.${symbol}` });\n }\n }\n for (const symbol of transport.symbols) {\n for (const index of memberOrBareCalls(code, symbol)) {\n if (!throughNamespace(code, index, namespaces)) hits.push({ index, detail: `calls ${symbol}(` });\n }\n }\n return hits;\n}\n\nexport const callableTransportGuard: GenericGuardDefinition<CallableTransportFacts> = {\n id: 'callableTransport',\n absentWhen: false,\n factProblems(facts) {\n const problems: string[] = [];\n if (!Array.isArray(facts?.transports) || !facts.transports.length) return ['transports is missing or empty'];\n for (const t of facts.transports) {\n textProblem(t?.module, 'a transport module', problems);\n if (t?.owner !== undefined) textProblem(t.owner, `transport ${String(t?.module)}'s owner`, problems);\n namesProblem(t?.symbols, `transport ${String(t?.module)}'s symbols`, problems);\n }\n return problems;\n },\n build(facts) {\n return [\n {\n title: 'a callable is reached only through its transport owner',\n description:\n 'The callable SDK and each transport helper are named only inside their owner module, which holds the ' +\n \"invocation deadline, the error normalization, and the one capture — or, for a transport with no owner, by \" +\n 'no app file at all. Nothing else imports, re-exports, reaches through a namespace, or calls them: call the ' +\n 'hook or function the owner exports.',\n run(context) {\n const findings: Finding[] = [];\n const held = new Set<string>();\n for (const file of context.files(APP_CODE)) {\n for (const transport of facts.transports) {\n const hits = transportHits(file, transport);\n if (!hits.length) continue;\n if (transport.owner !== undefined && file.path === transport.owner) held.add(transport.owner);\n else {\n const where = transport.owner === undefined ? 'no app file may name it' : `outside its owner ${transport.owner}`;\n for (const hit of hits) findings.push({ file: file.path, line: file.lineOf(hit.index), detail: `${where}: ${hit.detail}` });\n }\n }\n }\n for (const transport of facts.transports) {\n if (transport.owner === undefined) continue;\n if (!context.reader.exists(transport.owner)) findings.push({ file: transport.owner, detail: 'the transport owner no longer exists' });\n else if (!held.has(transport.owner)) findings.push({ file: transport.owner, detail: `stale owner: it no longer names any of ${transport.symbols.join(', ')}` });\n }\n return findings;\n },\n },\n ];\n },\n};\n\n// ---------------------------------------------------------------------------------------------\n// The declared hooks a component holds, shared by the name, read, and double-surface guards.\n\n/** The call-site option that turns a declared hook's error toast off. */\nconst TOAST_OPTION = 'showErrorToast';\n/** The call-site option naming the answers a caller surfaces itself. */\nconst ANSWER_OPTION = 'isAnswerSurfacedByCaller';\n/** The members of an action's result that start it. */\nconst ACTION_MEMBERS = ['mutate', 'mutateAsync'];\n\n/** One place a file binds a hook's result: the local name, how it is invoked, and the hook's arguments. */\ninterface HookBinding {\n /** The local name, as a finding shows it. */\n name: string;\n /** The names a call through this binding is written as (`b.mutate`, `b.mutateAsync`, `b`). */\n calls: readonly string[];\n hook: string;\n args: string;\n index: number;\n}\n\n/** Every binding of one of `hooks` in `code`: a whole result, or an action's start members destructured. */\nfunction hookBindings(code: string, hooks: ReadonlySet<string>): HookBinding[] {\n const out: HookBinding[] = [];\n const whole = new RegExp(`(?:const|let|var)\\\\s+([\\\\w$]+)\\\\s*=\\\\s*(${REACT_HOOK})\\\\s*(?:<[^()]*?>)?\\\\s*\\\\(`, 'g');\n for (let m = whole.exec(code); m; m = whole.exec(code)) {\n if (!hooks.has(m[2])) continue;\n const args = balancedArgs(code, m.index + m[0].length - 1);\n out.push({ name: m[1], calls: [...ACTION_MEMBERS.map((member) => `${m![1]}.${member}`), m[1]], hook: m[2], args, index: m.index });\n }\n const destructured = new RegExp(`(?:const|let|var)\\\\s*\\\\{([^}]*)\\\\}\\\\s*=\\\\s*(${REACT_HOOK})\\\\s*(?:<[^()]*?>)?\\\\s*\\\\(`, 'g');\n for (let m = destructured.exec(code); m; m = destructured.exec(code)) {\n if (!hooks.has(m[2])) continue;\n const args = balancedArgs(code, m.index + m[0].length - 1);\n for (const part of m[1].split(',')) {\n const [key, alias] = part.split(':').map((p) => p.trim());\n if (!ACTION_MEMBERS.includes(key)) continue;\n const local = alias || key;\n if (/^[\\w$]+$/.test(local)) out.push({ name: local, calls: [local], hook: m[2], args, index: m.index });\n }\n }\n return out;\n}\n\n/** A hook's options text for its argument, a same-file constant resolved; null when it cannot be seen. */\nfunction resolveOptions(args: string, code: string): string | null {\n const trimmed = args.trim();\n if (trimmed === '' || trimmed.startsWith('{')) return trimmed;\n if (!/^\\w+$/.test(trimmed)) return null;\n const decl = new RegExp(`(?:const|let|var)\\\\s+${trimmed}\\\\s*(?::[^=]+)?=\\\\s*(\\\\{[^}]*\\\\})`).exec(code);\n return decl ? decl[1] : null;\n}\n\n/** True unless the call site visibly turns the declared hook's error toast off. */\nconst toastIsOn = (args: string, code: string) => {\n const options = resolveOptions(args, code);\n return options === null || !new RegExp(`\\\\b${TOAST_OPTION}\\\\s*:\\\\s*false\\\\b`).test(options);\n};\n\n// ---------------------------------------------------------------------------------------------\n// Callable names: a callable's name is written only in its declaration.\n\nexport interface CallableNameFacts {\n declarations: CallableDeclarationFacts;\n /** Files that hold a string equal to a callable's name for another reason, each with why. */\n allowlist: readonly AllowlistEntry[];\n}\n\n/** Each string literal in a file whose text is one of `names`. */\nexport function callableNameHits(file: FileView, names: ReadonlyMap<string, string>): Hit[] {\n const hits: Hit[] = [];\n const sf = file.sourceFile;\n forEachNode(sf, (node) => {\n if (isPlainString(node) && names.has(node.text)) {\n hits.push({ index: node.getStart(sf), detail: `names the callable ${node.text}: call its declared hook ${names.get(node.text)}` });\n }\n });\n return hits;\n}\n\nexport const callableNameGuard: GenericGuardDefinition<CallableNameFacts> = {\n id: 'callableNames',\n absentWhen: false,\n factProblems(facts) {\n const problems: string[] = [];\n declarationFactProblems(facts?.declarations, 'declarations', problems);\n allowlistProblems(facts?.allowlist, 'allowlist', problems);\n return problems;\n },\n build(facts) {\n return [\n {\n title: \"a callable's name is written only in its declaration\",\n description:\n `Each callable is declared once, in ${facts.declarations.modules.join(', ')}, as a named hook built by one of the ` +\n `callable factories (${CALLABLE_KINDS.map((k) => facts.declarations.factories[k]).join(', ')}), with its name ` +\n 'as a string literal. No other app source writes that name: call the declared hook, so a renamed or removed ' +\n 'callable fails to compile in one place instead of failing when clicked. A file that holds the same string ' +\n 'for another reason is a reviewed allowlist entry with its why; an entry whose file no longer holds it is stale.',\n run(context) {\n const { declared, findings } = readDeclarations(context, facts.declarations);\n const names = new Map(declared.filter((d) => d.callable !== null).map((d) => [d.callable!, d.hook]));\n const modules = new Set(facts.declarations.modules);\n const reviewed = new Map(facts.allowlist.map((e) => [e.path, e]));\n const held = new Map<string, number>();\n for (const file of context.files(APP_CODE)) {\n if (modules.has(file.path)) continue;\n const hits = callableNameHits(file, names);\n if (!hits.length) continue;\n const entry = reviewed.get(file.path);\n const allowed = entry ? (entry.count ?? hits.length) : 0;\n if (entry) held.set(file.path, hits.length);\n for (const hit of hits.slice(allowed)) {\n findings.push({ file: file.path, line: file.lineOf(hit.index), detail: entry ? `more than the ${allowed} reviewed: ${hit.detail}` : hit.detail! });\n }\n }\n for (const entry of facts.allowlist) {\n const found = held.get(entry.path) ?? 0;\n if (!found) findings.push({ file: entry.path, detail: 'stale entry: the file no longer holds a callable name (or is gone)' });\n else if (entry.count !== undefined && found < entry.count) findings.push({ file: entry.path, detail: `stale count: reviewed ${entry.count}, found ${found}` });\n }\n return findings;\n },\n },\n ];\n },\n};\n\n// ---------------------------------------------------------------------------------------------\n// Callable-backed reads: live in the hooks folder, go through a reader, and hand their failure to\n// the read-failure surface.\n\nexport interface CallableReadFacts {\n declarations: CallableDeclarationFacts;\n /** The folder every read hook lives in. */\n hooksRoot: string;\n /** The component that renders a read failure, and the prop it takes the read's error through. */\n readFailureSurface: { component: string; errorProp: string };\n /** Hooks the detector must find a callable-backed read in — proof it still recognizes the reads. */\n anchorReads: readonly string[];\n}\n\ninterface CallableRead {\n path: string;\n /** The exported hook or component the read is in. */\n where: string;\n binding: string;\n hook: string;\n kind: CallableKind;\n index: number;\n}\n\n/** Each React Query read call's argument text, with where the call starts. */\nfunction readQueryCalls(block: string): Array<{ args: string; index: number }> {\n const out: Array<{ args: string; index: number }> = [];\n const re = /\\b(?:useQuery|useInfiniteQuery|useQueries|useSuspenseQuery|useSuspenseInfiniteQuery)\\b/g;\n for (let m = re.exec(block); m; m = re.exec(block)) {\n let i = m.index + m[0].length;\n while (/\\s/.test(block[i] ?? '')) i++;\n if (block[i] === '<') {\n let depth = 0;\n for (; i < block.length; i++) {\n if (block[i] === '=' && block[i + 1] === '>') {\n i++;\n continue;\n }\n if (block[i] === '<') depth++;\n else if (block[i] === '>' && --depth === 0) break;\n }\n i++;\n while (/\\s/.test(block[i] ?? '')) i++;\n }\n if (block[i] === '(') out.push({ args: balancedArgs(block, i), index: m.index });\n }\n return out;\n}\n\n/** Every React Query read that reaches a declared hook, directly or through a block-local helper. */\nexport function callableReadsIn(file: { path: string; code: string }, kinds: ReadonlyMap<string, CallableKind>): CallableRead[] {\n const reads: CallableRead[] = [];\n const hooks = new Set(kinds.keys());\n for (const block of exportBlocks(file.code)) {\n const text = block.text;\n const bindings = hookBindings(text, hooks);\n if (!bindings.length) continue;\n const where = exportedName(text) ?? new RegExp(`\\\\bfunction\\\\s+(${REACT_HOOK})`).exec(text)?.[1] ?? '(module scope)';\n const decls = localDeclarations(text);\n for (const call of readQueryCalls(text)) {\n for (const binding of bindings) {\n const ref = new RegExp(`(?<![\\\\w$.])${escapeRegExp(binding.name)}\\\\b`);\n const direct = ref.test(call.args);\n const viaHelper = [...decls].some(([name, decl]) => name !== binding.name && new RegExp(`\\\\b${escapeRegExp(name)}\\\\b`).test(call.args) && ref.test(decl));\n if (direct || viaHelper) {\n reads.push({ path: file.path, where, binding: binding.name, hook: binding.hook, kind: kinds.get(binding.hook)!, index: block.start + call.index });\n }\n }\n }\n }\n return reads;\n}\n\n/** Every finding about one read: where it lives, and the kind it reads through. */\nexport function callableReadFindings(read: CallableRead, hooksRoot: string): string[] {\n const where = `${read.where} (${read.binding})`;\n return [\n ...(isUnder(read.path, hooksRoot) ? [] : [`${where} is a callable read outside ${hooksRoot}`]),\n ...(read.kind === 'reader' ? [] : [`${where} reads through ${read.hook}, a declared ${read.kind}: declare the callable as a reader`]),\n ];\n}\n\n/** Each read-failure element rendering a read hook's failure without being handed the read's error. */\nexport function unhandedReadFailures(code: string, readHooks: readonly string[], surface: CallableReadFacts['readFailureSurface']): Array<{ index: number; binding: string }> {\n const names: string[] = [];\n for (const hook of readHooks) {\n const h = escapeRegExp(hook);\n for (const m of code.matchAll(new RegExp(`(?:const|let)\\\\s+(\\\\w+)\\\\s*=\\\\s*${h}\\\\s*[(<]`, 'g'))) names.push(m[1]);\n for (const m of code.matchAll(new RegExp(`(?:const|let)\\\\s*\\\\{([^}]*)\\\\}\\\\s*=\\\\s*${h}\\\\s*[(<]`, 'g'))) {\n for (const part of m[1].split(',')) {\n const [key, alias] = part.split(':').map((s) => s.trim().replace(/\\s*=.*$/, ''));\n if (key && key !== 'data') names.push(alias || key);\n }\n }\n }\n if (!names.length) return [];\n const out: Array<{ index: number; binding: string }> = [];\n const tag = `<${surface.component}`;\n for (let i = code.indexOf(tag); i >= 0; i = code.indexOf(tag, i + tag.length)) {\n if (/[\\w$]/.test(code[i + tag.length] ?? '')) continue;\n let j = i + tag.length;\n let depth = 0;\n for (; j < code.length; j++) {\n const c = code[j];\n if (c === '{') depth++;\n else if (c === '}') depth--;\n else if (depth === 0 && (c === '>' || (c === '/' && code[j + 1] === '>'))) break;\n }\n const lead = code.slice(Math.max(0, i - 250), i);\n const attrs = code.slice(i + tag.length, j);\n const bound = names.find((name) => new RegExp(`\\\\b${escapeRegExp(name)}\\\\b`).test(lead + attrs));\n if (bound && !new RegExp(`\\\\b${escapeRegExp(surface.errorProp)}\\\\s*=`).test(attrs)) out.push({ index: i, binding: bound });\n }\n return out;\n}\n\nexport const callableReadGuard: GenericGuardDefinition<CallableReadFacts> = {\n id: 'callableReads',\n absentWhen: false,\n factProblems(facts) {\n const problems: string[] = [];\n declarationFactProblems(facts?.declarations, 'declarations', problems);\n textProblem(facts?.hooksRoot, 'hooksRoot', problems);\n if (objectProblem(facts?.readFailureSurface, 'readFailureSurface', problems)) {\n textProblem(facts.readFailureSurface.component, 'readFailureSurface.component', problems);\n textProblem(facts.readFailureSurface.errorProp, 'readFailureSurface.errorProp', problems);\n }\n namesProblem(facts?.anchorReads, 'anchorReads', problems);\n return problems;\n },\n build(facts) {\n const reader = facts.declarations.factories.reader;\n return [\n {\n title: 'a callable-backed read lives in a hook and goes through a reader',\n description:\n `A React Query read that reaches a callable lives in ${facts.hooksRoot} and calls a hook declared with ` +\n `\\`${reader}\\`: a reader shows no toast and captures nothing, because the read's failure renders through ` +\n `${facts.readFailureSurface.component} and the query layer captures it once. An action, a resumable action, ` +\n `or an invoker inside a read toasts and captures that failure a second time — declare the callable with ` +\n `\\`${reader}\\` instead. Every ${facts.readFailureSurface.component} that renders a callable-backed read's ` +\n `failure is handed that read's error through \\`${facts.readFailureSurface.errorProp}\\`, so an answer the ` +\n 'server refused renders as that answer, never as a load failure.',\n run(context) {\n const { declared, findings } = readDeclarations(context, facts.declarations);\n const kinds = new Map(declared.map((d) => [d.hook, d.kind]));\n const modules = new Set(facts.declarations.modules);\n const files = context.files(APP_CODE).filter((f) => !modules.has(f.path));\n const reads = files.flatMap((file) => callableReadsIn(file, kinds));\n const byFile = new Map(files.map((f) => [f.path, f]));\n for (const read of reads) {\n for (const detail of callableReadFindings(read, facts.hooksRoot)) {\n findings.push({ file: read.path, line: byFile.get(read.path)!.lineOf(read.index), detail });\n }\n }\n const readHooks = [...new Set(reads.map((r) => r.where))];\n for (const anchor of facts.anchorReads) {\n if (!readHooks.includes(anchor)) findings.push({ file: '(anchorReads)', detail: `no callable-backed read found in ${anchor} — the detector no longer recognizes it, or the anchor is stale` });\n }\n for (const file of files) {\n if (isUnder(file.path, facts.hooksRoot)) continue;\n for (const hit of unhandedReadFailures(file.code, readHooks, facts.readFailureSurface)) {\n findings.push({ file: file.path, line: file.lineOf(hit.index), detail: `${facts.readFailureSurface.component} renders ${hit.binding}'s failure without its ${facts.readFailureSurface.errorProp}` });\n }\n }\n return findings;\n },\n },\n ];\n },\n};\n\n// ---------------------------------------------------------------------------------------------\n// Double surface: a declared action's rejection is surfaced once — by its toast, or by the caller.\n\nexport interface DoubleSurfaceFacts {\n declarations: CallableDeclarationFacts;\n /** The function that raises a toast. */\n toastCall: string;\n /** Predicates that gate a local toast to a leg the declared hook's toast cannot see. */\n nonCallableLegGuards: readonly string[];\n /** Import specifier prefixes that reach app source (relative imports always do). */\n appImportPrefixes: readonly string[];\n}\n\n/** Where a declared hook or an app hook over one comes from, for a finding. */\ntype ToastingHooks = ReadonlyMap<string, string>;\n\n/** Exported app hooks that hold a toasting declared hook with its toast on, so each toasts every rejection. */\nexport function wrappingHooks(files: ReadonlyArray<{ path: string; code: string }>, declared: ToastingHooks): Map<string, string> {\n const hooks = new Map<string, string>();\n const names = new Set(declared.keys());\n for (const file of files) {\n for (const block of exportBlocks(file.code)) {\n const name = new RegExp(`export\\\\s+(?:async\\\\s+)?(?:function|const)\\\\s+(${REACT_HOOK})`).exec(block.text)?.[1];\n if (!name || names.has(name)) continue;\n if (hookBindings(block.text, names).some((b) => toastIsOn(b.args, file.code))) hooks.set(name, file.path);\n }\n }\n return hooks;\n}\n\n/** Every place a file surfaces a rejection a toasting hook it holds has already toasted. */\nexport function doubleSurfaces(\n file: FileView,\n toasting: ToastingHooks,\n wrappers: ToastingHooks,\n facts: Pick<DoubleSurfaceFacts, 'toastCall' | 'nonCallableLegGuards' | 'appImportPrefixes'>,\n): Array<{ index: number; detail: string }> {\n const code = file.code;\n const imported = new Set<string>();\n for (const site of moduleImports(file.sourceFile, ['import'])) {\n const fromApp = site.spec.startsWith('.') || facts.appImportPrefixes.some((p) => site.spec.startsWith(p));\n if (fromApp) for (const name of site.named) imported.add(name.local);\n }\n const visible = new Map<string, string>(toasting);\n for (const [hook, origin] of wrappers) if (origin !== file.path && imported.has(hook)) visible.set(hook, origin);\n const toast = new RegExp(`\\\\b${escapeRegExp(facts.toastCall)}\\\\s*\\\\(`);\n const out: Array<{ index: number; detail: string }> = [];\n const seen = new Set<string>();\n const report = (index: number, detail: string) => {\n if (seen.has(`${index}:${detail}`)) return;\n seen.add(`${index}:${detail}`);\n out.push({ index, detail });\n };\n for (const binding of hookBindings(code, new Set(visible.keys()))) {\n if (!wrappers.has(binding.hook) && !toastIsOn(binding.args, code)) continue;\n const answer = new RegExp(`\\\\b${ANSWER_OPTION}\\\\s*:\\\\s*([\\\\w$]+)`).exec(binding.args)?.[1];\n const gated = (text: string) =>\n facts.nonCallableLegGuards.some((g) => new RegExp(`\\\\b${escapeRegExp(g)}\\\\b`).test(text)) ||\n (!!answer && new RegExp(`\\\\b${escapeRegExp(answer)}\\\\s*\\\\(`).test(text));\n const surfaces = (handler: string) => toast.test(handler) && !gated(handler);\n const who = `${binding.name} (${binding.hook}, ${visible.get(binding.hook)})`;\n if (handlersFor(binding.args, 'onError').some(surfaces)) report(binding.index, `${who} toasts again in the onError it hands the hook`);\n for (const name of binding.calls) {\n for (const call of callArgs(code, name)) {\n if (handlersFor(call.args, 'onError').some(surfaces)) report(call.index, `${who} toasts again in its onError`);\n }\n }\n const ref = new RegExp(`(?<![\\\\w$.])${escapeRegExp(binding.name)}\\\\b`);\n for (const pair of tryCatchPairs(code)) {\n if (ref.test(pair.tryBody) && surfaces(pair.catchBody)) report(pair.index, `${who} toasts again in a catch`);\n }\n for (const mutation of callArgs(code, 'useMutation')) {\n if (ref.test(mutation.args) && handlersFor(mutation.args, 'onError').some(surfaces)) {\n report(mutation.index, `${who} toasts again in the onError of the mutation that calls it`);\n }\n }\n }\n return out;\n}\n\nexport const doubleSurfaceGuard: GenericGuardDefinition<DoubleSurfaceFacts> = {\n id: 'callableDoubleSurface',\n absentWhen: false,\n factProblems(facts) {\n const problems: string[] = [];\n declarationFactProblems(facts?.declarations, 'declarations', problems);\n textProblem(facts?.toastCall, 'toastCall', problems);\n namesProblem(facts?.nonCallableLegGuards, 'nonCallableLegGuards', problems);\n namesProblem(facts?.appImportPrefixes, 'appImportPrefixes', problems, { nonEmpty: false });\n return problems;\n },\n build(facts) {\n return [\n {\n title: 'one callable rejection surfaces exactly once',\n description:\n 'A hook declared as an action, a resumable action, or an invoker shows the shared error toast for every ' +\n `rejection unless its call site passes \\`{ ${TOAST_OPTION}: false }\\`, and so does an app hook built over one. ` +\n `While that toast is on, nothing toasts the same rejection again — not an onError handed to the hook or to ` +\n 'its mutate call, not a catch around it, and not the onError of a mutation that calls it. Fix one of: pass ' +\n `\\`{ ${TOAST_OPTION}: false }\\` and own the only surface; drop the local toast (an empty catch keeps any ` +\n 'finally reset); or gate the local toast on a predicate that sees only the leg the shared toast cannot ' +\n `(${facts.nonCallableLegGuards.join(', ')}), or on the predicate the call site hands \\`${ANSWER_OPTION}\\`, ` +\n \"which makes the caller that answer's only surface.\",\n run(context) {\n const { declared, findings } = readDeclarations(context, facts.declarations);\n const toasting = new Map(declared.filter((d) => d.kind !== 'reader').map((d) => [d.hook, d.file]));\n if (!toasting.size && !findings.length) {\n findings.push({ file: '(declarations)', detail: 'no action, resumable action, or invoker is declared, so the check sees no toasting hook' });\n }\n const modules = new Set(facts.declarations.modules);\n const files = context.files(APP_CODE).filter((f) => !modules.has(f.path));\n const wrappers = wrappingHooks(files, toasting);\n for (const file of files) {\n for (const hit of doubleSurfaces(file, toasting, wrappers, facts)) findings.push({ file: file.path, line: file.lineOf(hit.index), detail: hit.detail });\n }\n return findings;\n },\n },\n ];\n },\n};\n\n// ---------------------------------------------------------------------------------------------\n// Error internals: a rendered element never shows a thrown error's message or stringification.\n\nexport interface ErrorInternalsFacts {\n /** The folders whose files render to the user. */\n renderRoots: readonly string[];\n /** Monitoring calls where error internals belong (besides `console.*` and `logger.*`). */\n captureCalls: readonly string[];\n allowlist: readonly AllowlistEntry[];\n}\n\nconst LEAK = /(?:\\b(?:\\w*[Ee]rror|err|e)\\s*\\??\\.\\s*message\\b|as\\s+Error\\s*\\)\\s*\\.\\s*message\\b|\\bString\\s*\\(\\s*(?:\\w*[Ee]rror|err|e)\\s*\\))/;\nconst BRACE_GROUP = /\\{[^{}]*\\}/g;\n\n/** The render of error internals on one line, or null: a brace group holding one that is not an object property value. */\nexport function errorInternalsOnLine(line: string, captureCalls: readonly string[]): string | null {\n const logging = new RegExp(`\\\\b(?:console\\\\s*\\\\.\\\\s*\\\\w+|logger\\\\s*\\\\.\\\\s*\\\\w+${captureCalls.map((c) => `|${escapeRegExp(c)}`).join('')})\\\\s*\\\\(`);\n if (logging.test(line)) return null;\n for (const match of line.matchAll(BRACE_GROUP)) {\n const inner = match[0].slice(1, -1);\n const hit = LEAK.exec(inner);\n if (!hit) continue;\n if (/\\w+\\s*:/.test(inner.slice(0, hit.index))) continue;\n return hit[0];\n }\n return null;\n}\n\nexport const errorInternalsGuard: GenericGuardDefinition<ErrorInternalsFacts> = {\n id: 'errorInternalsRender',\n absentWhen: false,\n factProblems(facts) {\n const problems: string[] = [];\n namesProblem(facts?.renderRoots, 'renderRoots', problems);\n namesProblem(facts?.captureCalls, 'captureCalls', problems, { nonEmpty: false });\n allowlistProblems(facts?.allowlist, 'allowlist', problems);\n return problems;\n },\n build(facts) {\n const guard = reviewedAllowlist({\n title: \"a rendered element never shows a thrown error's internals\",\n description:\n `A surface under ${facts.renderRoots.join(', ')} never renders an error's message, an \\`(x as Error).message\\`, or a ` +\n \"`String(error)` — in JSX, a template hole, or a prop. A thrown error's text leaks infrastructure detail and \" +\n 'tells the user nothing they can act on: render a fixed title naming what failed and a next-step sentence. ' +\n 'Error internals belong in logging and monitoring capture, which this check leaves alone, as it does an ' +\n 'object property value (a toast description, which the callable policy owns).',\n scope: APP_CODE,\n match: (file) =>\n facts.renderRoots.some((root) => isUnder(file.path, root)) ? lineHits(file, (line) => errorInternalsOnLine(line, facts.captureCalls)) : [],\n allowlist: facts.allowlist,\n samples: {\n flags: [\n { path: `${facts.renderRoots[0]}/probe.tsx`, text: '<p>Failed: {error.message}</p>' },\n { path: `${facts.renderRoots[0]}/probe.tsx`, text: '<p>{(result.error as Error).message}</p>' },\n { path: `${facts.renderRoots[0]}/probe.tsx`, text: '<p>{String(error)}</p>' },\n { path: `${facts.renderRoots[0]}/probe.tsx`, text: 'error={error?.message || null}' },\n ],\n passes: [\n { path: `${facts.renderRoots[0]}/probe.tsx`, text: \"toast({ title: 'Failed', description: e.message });\" },\n { path: `${facts.renderRoots[0]}/probe.tsx`, text: \"console.error('read failed', error.message);\" },\n { path: `${facts.renderRoots[0]}/probe.tsx`, text: '<p>{errors.title.message}</p>' },\n ],\n },\n });\n return [guard];\n },\n};\n"]}
|