@ttt-productions/repo-guards 0.1.4 → 0.1.5

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.
@@ -44,8 +44,9 @@ export interface LazyLoaderFacts {
44
44
  /** The roots whose code and tests the guard reads; `functions` alone when absent. */
45
45
  roots?: readonly RootRole[];
46
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.
47
+ * Other module-level loaders whose `const x = name(() => import('…'), …options)` is accepted — the
48
+ * import may be projected with one `.then(…)` — each with its why (a framework's own memoized
49
+ * component loader); one used nowhere is stale.
49
50
  */
50
51
  otherLoaders?: ReadonlyArray<{
51
52
  name: string;
@@ -58,8 +59,11 @@ export interface LazyLoaderFacts {
58
59
  }
59
60
  /**
60
61
  * 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.
62
+ * for one of `names`. `names[0]` is the main loader and takes exactly that one-argument shape; every
63
+ * other name is a framework's memoized loader, which may take further arguments after the loader
64
+ * function (its options) and may project the module with one `.then(…)` (`import('x').then((m) =>
65
+ * m.X)`) — the framework still memoizes that one import. `loaders` counts the uses of `names[0]`;
66
+ * `used` holds every name that wrapped an import.
63
67
  */
64
68
  export declare function strayDynamicImports(file: FileView, names: string | readonly string[]): {
65
69
  loaders: number;
@@ -1 +1 @@
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,CAA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;IAAE,KAAK,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC,CAAC;IAAC,UAAU,EAAE,EAAE,CAAC,IAAI,EAAE,CAAA;CAAE,CAgBtG;AAED,eAAO,MAAM,kBAAkB,EAAE,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"}
@@ -161,8 +161,11 @@ export const rateLimitGuard = {
161
161
  const isDynamicImport = (node) => ts.isCallExpression(node) && node.expression.kind === ts.SyntaxKind.ImportKeyword;
162
162
  /**
163
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.
164
+ * for one of `names`. `names[0]` is the main loader and takes exactly that one-argument shape; every
165
+ * other name is a framework's memoized loader, which may take further arguments after the loader
166
+ * function (its options) and may project the module with one `.then(…)` (`import('x').then((m) =>
167
+ * m.X)`) — the framework still memoizes that one import. `loaders` counts the uses of `names[0]`;
168
+ * `used` holds every name that wrapped an import.
166
169
  */
167
170
  export function strayDynamicImports(file, names) {
168
171
  const accepted = typeof names === 'string' ? [names] : names;
@@ -173,31 +176,8 @@ export function strayDynamicImports(file, names) {
173
176
  forEachNode(sf, (node) => {
174
177
  if (!isDynamicImport(node))
175
178
  return;
176
- const arrow = node.parent;
177
- const call = arrow?.parent;
178
- const declaration = call?.parent;
179
- const statement = declaration?.parent?.parent;
180
- const ok = !!arrow &&
181
- ts.isArrowFunction(arrow) &&
182
- arrow.body === node &&
183
- arrow.parameters.length === 0 &&
184
- !!call &&
185
- ts.isCallExpression(call) &&
186
- ts.isIdentifier(call.expression) &&
187
- accepted.includes(call.expression.text) &&
188
- call.arguments.length === 1 &&
189
- call.arguments[0] === arrow &&
190
- !!declaration &&
191
- ts.isVariableDeclaration(declaration) &&
192
- declaration.initializer === call &&
193
- (declaration.parent.flags & ts.NodeFlags.Const) !== 0 &&
194
- statement !== undefined &&
195
- ts.isVariableStatement(statement) &&
196
- statement.parent === sf &&
197
- node.arguments.length === 1 &&
198
- ts.isStringLiteralLike(node.arguments[0]);
199
- if (ok) {
200
- const name = call.expression.text;
179
+ const name = moduleLevelLoaderName(node, accepted);
180
+ if (name !== null) {
201
181
  used.add(name);
202
182
  if (name === accepted[0])
203
183
  loaders += 1;
@@ -207,6 +187,44 @@ export function strayDynamicImports(file, names) {
207
187
  });
208
188
  return { loaders, used, stray };
209
189
  }
190
+ /** The loader wrapping `node` when it is an accepted module-level loader, else null. */
191
+ function moduleLevelLoaderName(node, accepted) {
192
+ if (node.arguments.length !== 1 || !ts.isStringLiteralLike(node.arguments[0]))
193
+ return null;
194
+ // The arrow's body is the import itself, or — for an other loader only — `import(…).then(cb)`.
195
+ let body = node;
196
+ const access = node.parent;
197
+ const projected = !!access &&
198
+ ts.isPropertyAccessExpression(access) &&
199
+ access.expression === node &&
200
+ access.name.text === 'then' &&
201
+ ts.isCallExpression(access.parent) &&
202
+ access.parent.expression === access &&
203
+ access.parent.arguments.length === 1;
204
+ if (projected)
205
+ body = access.parent;
206
+ const arrow = body.parent;
207
+ if (!arrow || !ts.isArrowFunction(arrow) || arrow.body !== body || arrow.parameters.length !== 0)
208
+ return null;
209
+ const call = arrow.parent;
210
+ if (!call || !ts.isCallExpression(call) || !ts.isIdentifier(call.expression) || call.arguments[0] !== arrow)
211
+ return null;
212
+ const name = call.expression.text;
213
+ if (!accepted.includes(name))
214
+ return null;
215
+ const isMain = name === accepted[0];
216
+ if (isMain && (projected || call.arguments.length !== 1))
217
+ return null;
218
+ const declaration = call.parent;
219
+ if (!declaration || !ts.isVariableDeclaration(declaration) || declaration.initializer !== call)
220
+ return null;
221
+ if ((declaration.parent.flags & ts.NodeFlags.Const) === 0)
222
+ return null;
223
+ const statement = declaration.parent.parent;
224
+ if (!statement || !ts.isVariableStatement(statement) || statement.parent !== node.getSourceFile())
225
+ return null;
226
+ return name;
227
+ }
210
228
  const COMBINATORS = new Set(['Promise.all', 'Promise.allSettled', 'Promise.race', 'Promise.any']);
211
229
  /** Every place a test overlaps its own imports: a concurrent test, or `import()` inside a Promise combinator. */
212
230
  export function overlappingTestImports(file) {
@@ -1 +1 @@
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,OAA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AC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC;wBACrF,IAAI,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,SAAS,IAAI,EAAE,CAAC,KAAK,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC,EAAE,CAAC;4BACxE,QAAQ,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,KAAK,CAAC,YAAY,EAAE,MAAM,EAAE,YAAY,EAAE,uBAAuB,IAAI,CAAC,SAAS,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 (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"]}
1
+ {"version":3,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,YAAY,EAAE,MAAM,EAAE,YAAY,EAAE,yBAAyB,EAAE,CAAC,CAAC;oBACrJ,KAAK,MAAM,KAAK,IAAI,OAAO,EAAE,CAAC;wBAC5B,MAAM,EAAE,GAAG,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;wBAClC,MAAM,MAAM,GAAG,KAAK,CAAC,cAAc,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;wBACjE,IAAI,KAAK,CAAC,MAAM,KAAK,MAAM;4BAAE,QAAQ,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,KAAK,CAAC,YAAY,EAAE,MAAM,EAAE,YAAY,EAAE,iBAAiB,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,SAAS,MAAM,EAAE,EAAE,CAAC,CAAC;wBACvJ,MAAM,SAAS,GAAG,KAAK,CAAC,iBAAiB,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC;wBACrF,IAAI,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,SAAS,IAAI,EAAE,CAAC,KAAK,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC,EAAE,CAAC;4BACxE,QAAQ,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,KAAK,CAAC,YAAY,EAAE,MAAM,EAAE,YAAY,EAAE,uBAAuB,IAAI,CAAC,SAAS,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 (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('…'), …options)` is accepted — the\n * import may be projected with one `.then(…)` — each with its why (a framework's own memoized\n * 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`. `names[0]` is the main loader and takes exactly that one-argument shape; every\n * other name is a framework's memoized loader, which may take further arguments after the loader\n * function (its options) and may project the module with one `.then(…)` (`import('x').then((m) =>\n * m.X)`) — the framework still memoizes that one import. `loaders` counts the uses of `names[0]`;\n * `used` holds every 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 name = moduleLevelLoaderName(node, accepted);\n if (name !== null) {\n used.add(name);\n if (name === accepted[0]) loaders += 1;\n } else stray.push(node);\n });\n return { loaders, used, stray };\n}\n\n/** The loader wrapping `node` when it is an accepted module-level loader, else null. */\nfunction moduleLevelLoaderName(node: ts.CallExpression, accepted: readonly string[]): string | null {\n if (node.arguments.length !== 1 || !ts.isStringLiteralLike(node.arguments[0]!)) return null;\n // The arrow's body is the import itself, or — for an other loader only — `import(…).then(cb)`.\n let body: ts.Node = node;\n const access = node.parent;\n const projected =\n !!access &&\n ts.isPropertyAccessExpression(access) &&\n access.expression === node &&\n access.name.text === 'then' &&\n ts.isCallExpression(access.parent) &&\n access.parent.expression === access &&\n access.parent.arguments.length === 1;\n if (projected) body = access.parent;\n const arrow = body.parent;\n if (!arrow || !ts.isArrowFunction(arrow) || arrow.body !== body || arrow.parameters.length !== 0) return null;\n const call = arrow.parent;\n if (!call || !ts.isCallExpression(call) || !ts.isIdentifier(call.expression) || call.arguments[0] !== arrow) return null;\n const name = call.expression.text;\n if (!accepted.includes(name)) return null;\n const isMain = name === accepted[0];\n if (isMain && (projected || call.arguments.length !== 1)) return null;\n const declaration = call.parent;\n if (!declaration || !ts.isVariableDeclaration(declaration) || declaration.initializer !== call) return null;\n if ((declaration.parent.flags & ts.NodeFlags.Const) === 0) return null;\n const statement = declaration.parent.parent;\n if (!statement || !ts.isVariableStatement(statement) || statement.parent !== node.getSourceFile()) return null;\n return name;\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"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ttt-productions/repo-guards",
3
- "version": "0.1.4",
3
+ "version": "0.1.5",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/ttt-productions/ttt-packages.git",