@ttt-productions/repo-guards 0.1.35 → 0.1.37

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.
@@ -65,6 +65,7 @@ export declare function exportsOf(file: FileView): {
65
65
  unreadable: ts.Node[];
66
66
  };
67
67
  export declare const lightFunctionGuard: GenericGuardDefinition<LightFunctionFacts>;
68
+ export declare const MAX_FUNCTIONS_PER_CODEBASE = 55;
68
69
  export interface CodebaseManifestFacts {
69
70
  manifest: string;
70
71
  entryIndex: string;
@@ -1 +1 @@
1
- {"version":3,"file":"functions-build.d.ts","sourceRoot":"","sources":["../../../src/modules/backend/functions-build.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,YAAY,CAAC;AAC5B,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,4BAA4B,CAAC;AAGzE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAc,KAAK,QAAQ,EAAE,KAAK,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAwBhF,MAAM,WAAW,cAAc;IAC7B,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,aAAa,EAAE,MAAM,CAAC;IACtB,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;CACrB;AAOD,wBAAgB,oBAAoB,CAClC,IAAI,EAAE,QAAQ,EACd,KAAK,EAAE,IAAI,CAAC,cAAc,EAAE,WAAW,GAAG,YAAY,CAAC,GACtD,KAAK,CAAC;IAAE,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC,CAgB1C;AAED,wBAAgB,YAAY,CAAC,IAAI,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,GAAG,MAAM,EAAE,CAMxE;AAED,wBAAgB,mBAAmB,CAAC,KAAK,EAAE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A2BA;AAED,eAAO,MAAM,kBAAkB,EAAE,sBAAsB,CAAC,kBAAkB,CAkHzE,CAAC;AAIF,eAAO,MAAM,0BAA0B,KAAK,CAAC;AAE7C,MAAM,WAAW,qBAAqB;IACpC,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,EAAE,MAAM,CAAC;IACrB,cAAc,EAAE,MAAM,CAAC;IACvB,iBAAiB,EAAE,SAAS,MAAM,EAAE,CAAC;CACtC;AAeD,eAAO,MAAM,qBAAqB,EAAE,sBAAsB,CAAC,qBAAqB,CA+I/E,CAAC"}
@@ -527,6 +527,9 @@ export const lightFunctionGuard = {
527
527
  ];
528
528
  },
529
529
  };
530
+ // Google allows 60 Cloud Functions mutations per minute per project and region, and a deploy
531
+ // changes every function of the codebase it targets; 55 leaves room for that pass's deletions.
532
+ export const MAX_FUNCTIONS_PER_CODEBASE = 55;
530
533
  function readJson(context, path, findings) {
531
534
  if (!context.reader.exists(path)) {
532
535
  findings.push({ file: path, detail: 'the file no longer exists' });
@@ -659,6 +662,27 @@ export const codebaseManifestGuard = {
659
662
  return findings;
660
663
  },
661
664
  },
665
+ {
666
+ title: `no Functions codebase holds more than ${MAX_FUNCTIONS_PER_CODEBASE} functions`,
667
+ description: `Each codebase in ${facts.manifest} deploys as one pass that changes every function it holds, ` +
668
+ `so a codebase over ${MAX_FUNCTIONS_PER_CODEBASE} functions outruns the platform's per-minute ` +
669
+ 'mutation budget and its creates are dropped. A codebase that grows past the cap is split.',
670
+ run(context) {
671
+ const findings = [];
672
+ const manifest = readJson(context, facts.manifest, findings);
673
+ if (!manifest || typeof manifest.codebases !== 'object' || !manifest.codebases)
674
+ return findings;
675
+ for (const [codebase, list] of Object.entries(manifest.codebases)) {
676
+ if (!isList(list) || list.length <= MAX_FUNCTIONS_PER_CODEBASE)
677
+ continue;
678
+ findings.push({
679
+ file: facts.manifest,
680
+ detail: `codebase ${codebase} holds ${list.length} functions; split it so each codebase holds at most ${MAX_FUNCTIONS_PER_CODEBASE}`,
681
+ });
682
+ }
683
+ return findings;
684
+ },
685
+ },
662
686
  ];
663
687
  },
664
688
  };
@@ -1 +1 @@
1
- {"version":3,"file":"functions-build.js","sourceRoot":"","sources":["../../../src/modules/backend/functions-build.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,WAAW,CAAC;AAClC,OAAO,EAAE,MAAM,YAAY,CAAC;AAK5B,OAAO,EAAE,UAAU,EAAgC,MAAM,sBAAsB,CAAC;AAChF,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAC3E,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAC7F,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;AACzC,OAAO,EAAE,2BAA2B,EAAE,MAAM,2BAA2B,CAAC;AAExE,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,SAAS,aAAa,CAAC,OAAqB;IAC1C,MAAM,IAAI,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,SAAS,CAAC;IACnD,IAAI,CAAC,IAAI;QACP,MAAM,IAAI,KAAK,CACb,+EAA+E,CAChF,CAAC;IACJ,OAAO,IAAI,CAAC,IAAI,CAAC;AACnB,CAAC;AAED,MAAM,UAAU,GAAG,CAAC,IAAY,EAAE,IAAY,EAAE,EAAE,CAChD,KAAK,CAAC,QAAQ,CAAC,IAAI,EAAE,IAAI,CAA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E,YAAY,EAAE,yBAAyB;6BAChD,CAAC,CAAC;oBACP,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;4BACzB,QAAQ,CAAC,IAAI,CAAC;gCACZ,IAAI,EAAE,KAAK,CAAC,YAAY;gCACxB,MAAM,EAAE,YAAY,EAAE,iBAAiB,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,SAAS,MAAM,EAAE;6BAC7E,CAAC,CAAC;wBACL,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;gCACZ,IAAI,EAAE,KAAK,CAAC,YAAY;gCACxB,MAAM,EAAE,YAAY,EAAE,uBAAuB,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC,EAAE;6BACzE,CAAC,CAAC;wBACL,CAAC;oBACH,CAAC;oBACD,OAAO,QAAQ,CAAC;gBAClB,CAAC;aACF;SACF,CAAC;IACJ,CAAC;CACF,CAAC","sourcesContent":["import { posix } from 'node:path';\nimport ts from 'typescript';\nimport type { GenericGuardDefinition } from '../../node/suite/config.js';\nimport type { Finding, GuardContext } from '../../guard.js';\nimport type { Scope } from '../../node/reader.js';\nimport type { FileView } from '../../reader/view.js';\nimport { ROOT_ROLES, type Reviewed, type RootRole } from '../../node/layout.js';\nimport { calleeName, forEachNode, lineOfNode } from '../../support/ast.js';\nimport { namesProblem, reviewedProblems, textProblem, isList } from '../../support/facts.js';\nimport { moduleImports, namesModule } from '../../support/imports.js';\nimport { resolveRelative } from '../../support/paths.js';\nimport { calleePath } from './shared.js';\nimport { REPOSITORY_GUARD_TIMEOUT_MS } from '../../support/timeouts.js';\n\nconst FUNCTIONS_CODE: Scope = { roots: ['functions'], kinds: ['code'], tests: false };\n\nconst CODE_EXTENSION = /\\.(?:[cm]?[jt]sx?)$/;\n\nfunction functionsRoot(context: GuardContext): string {\n const root = context.reader.layout.roots.functions;\n if (!root)\n throw new Error(\n 'repo-guards: a Functions guard runs and the layout declares no functions root',\n );\n return root.path;\n}\n\nconst moduleIdOf = (root: string, file: string) =>\n posix.relative(root, file).replace(CODE_EXTENSION, '');\n\nexport interface RateLimitFacts {\n owner: string;\n presetMap: string;\n surfaceMap: string;\n sharedPresets: string;\n chargeCall: string;\n prefixField: string;\n}\n\nconst isMapAccess = (node: ts.Node, map: string): node is ts.PropertyAccessExpression =>\n ts.isPropertyAccessExpression(node) &&\n ts.isIdentifier(node.expression) &&\n node.expression.text === map;\n\nexport function inlineLimiterConfigs(\n file: FileView,\n facts: Pick<RateLimitFacts, 'presetMap' | 'chargeCall'>,\n): 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 (\n ts.isCallExpression(node) &&\n calleeName(node) === facts.chargeCall &&\n node.arguments.some((a) => ts.isObjectLiteralExpression(a))\n ) {\n out.push({ node, detail: `passes an inline config to ${facts.chargeCall}` });\n }\n });\n return out;\n}\n\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\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)\n ? node.elements.filter(ts.isStringLiteralLike).map((e) => e.text)\n : [];\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 (\n ts.isPropertyAssignment(inner) &&\n inner.name.getText() === facts.prefixField &&\n ts.isStringLiteralLike(inner.initializer)\n ) {\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 (\n ts.isPropertyAssignment(p) &&\n (ts.isIdentifier(p.name) || ts.isStringLiteralLike(p.name))\n )\n surfaces.set(p.name.text, strings(bare(p.initializer)));\n }\n }\n });\n return { prefixes, surfaces, shared, presetMapFound, surfaceMapFound, sharedFound };\n}\n\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 [\n 'owner',\n 'presetMap',\n 'surfaceMap',\n 'sharedPresets',\n 'chargeCall',\n 'prefixField',\n ] as const)\n 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))\n 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)\n return [\n ...findings,\n {\n file: facts.owner,\n detail: 'the limiter owner is gone or outside the Functions tree',\n },\n ];\n const declared = limiterDeclarations(ownerFile, facts);\n if (!declared.presetMapFound || !declared.prefixes.length)\n findings.push({\n file: facts.owner,\n detail: `no ${facts.presetMap} with a ${facts.prefixField} found`,\n });\n if (!declared.surfaceMapFound)\n findings.push({ file: facts.owner, detail: `no ${facts.surfaceMap} object found` });\n if (!declared.sharedFound)\n 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))\n findings.push({\n file: facts.owner,\n detail: `two presets share the ${facts.prefixField} ${p}`,\n });\n for (const offense of offendingCharges(charges, declared.surfaces, declared.shared))\n 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)\n if (!charged.get(module)?.includes(preset))\n findings.push({\n file: facts.owner,\n detail: `${preset} lists ${module}, which does not charge it`,\n });\n }\n return findings;\n },\n },\n ];\n },\n};\n\nexport interface LazyLoaderFacts {\n loader: string;\n roots?: readonly RootRole[];\n otherLoaders?: ReadonlyArray<{ name: string; why: string }>;\n testRunnerConfigs: readonly string[];\n testExceptions: readonly Reviewed[];\n}\n\nconst isDynamicImport = (node: ts.Node): node is ts.CallExpression =>\n ts.isCallExpression(node) && node.expression.kind === ts.SyntaxKind.ImportKeyword;\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\nfunction moduleLevelLoaderName(\n node: ts.CallExpression,\n accepted: readonly string[],\n): string | null {\n if (node.arguments.length !== 1 || !ts.isStringLiteralLike(node.arguments[0]!)) return null;\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)\n return null;\n const call = arrow.parent;\n if (\n !call ||\n !ts.isCallExpression(call) ||\n !ts.isIdentifier(call.expression) ||\n call.arguments[0] !== arrow\n )\n 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)\n 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())\n return null;\n return name;\n}\n\nconst COMBINATORS = new Set(['Promise.all', 'Promise.allSettled', 'Promise.race', 'Promise.any']);\n\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')\n out.push({ node, detail: `${node.getText(sf)} runs tests concurrently` });\n if (\n ts.isPropertyAssignment(node) &&\n ts.isIdentifier(node.name) &&\n node.name.text === 'concurrent'\n )\n out.push({ node, detail: 'a concurrent test option' });\n if (ts.isCallExpression(node) && COMBINATORS.has(calleePath(node) ?? '')) combinator = true;\n if (inCombinator && isDynamicImport(node))\n out.push({\n node,\n detail: `${node.getText(sf)} overlaps the other imports of a Promise combinator`,\n });\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 (isList(facts.roots)) {\n for (const root of facts.roots)\n if (!ROOT_ROLES.includes(root))\n problems.push(`roots names ${String(root)}, which is not a root role`);\n }\n }\n if (facts?.otherLoaders !== undefined)\n 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({\n file: file.path,\n line: lineOfNode(file, node),\n detail: `${node.getText(file.sourceFile).slice(0, 80)} is not a module-level ${facts.loader} loader`,\n });\n }\n }\n if (!loaders)\n findings.push({\n file: `(${roots.join(', ')})`,\n detail: `no ${facts.loader} loader found, so the guard checks nothing`,\n });\n for (const name of others)\n if (!used.has(name))\n findings.push({\n file: '(otherLoaders)',\n detail: `stale other loader: ${name} wraps no import`,\n });\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)\n findings.push({ file: file.path, line: lineOfNode(file, node), detail });\n }\n for (const path of exceptions)\n if (!overlapping.has(path))\n findings.push({\n file: path,\n detail: 'stale test exception: the file overlaps no import',\n });\n for (const config of facts.testRunnerConfigs) {\n if (!context.reader.exists(config))\n 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)\n findings.push({\n file: config,\n line: view.lineOf(m.index),\n detail: 'the runner config makes tests concurrent',\n });\n }\n }\n return findings;\n },\n },\n ];\n },\n};\n\nexport interface LightFunctionFacts {\n entryIndex: string;\n lightFunctions: readonly string[];\n heavyPackages: ReadonlyArray<{\n specifier: string;\n lightSubpaths: readonly string[];\n why: string;\n }>;\n heavyFiles: readonly Reviewed[];\n}\n\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\nexport function resolveModule(\n fromPath: string,\n spec: string,\n known: ReadonlySet<string>,\n): 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 = [\n base,\n `${stem}.ts`,\n `${stem}.tsx`,\n `${stem}.mts`,\n `${stem}.cts`,\n `${base}.ts`,\n `${base}.tsx`,\n `${base}/index.ts`,\n `${base}/index.tsx`,\n ];\n return candidates.find((c) => known.has(c)) ?? null;\n}\n\nexport function exportsOf(file: FileView): {\n names: Map<string, string | null>;\n unreadable: ts.Node[];\n} {\n const names = new Map<string, string | null>();\n const unreadable: ts.Node[] = [];\n const exported = (node: ts.Node) =>\n ts.canHaveModifiers(node) &&\n !!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 =\n stmt.moduleSpecifier && ts.isStringLiteral(stmt.moduleSpecifier)\n ? stmt.moduleSpecifier.text\n : null;\n if (stmt.exportClause && ts.isNamedExports(stmt.exportClause))\n 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)\n if (ts.isIdentifier(d.name)) names.set(d.name.text, null);\n } else if (\n (ts.isFunctionDeclaration(stmt) || ts.isClassDeclaration(stmt)) &&\n exported(stmt) &&\n stmt.name\n ) {\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 ?? [])\n if (!isList(p?.lightSubpaths))\n problems.push(\n `heavy package ${String(p?.specifier)} needs lightSubpaths (declare [] when none)`,\n );\n reviewedProblems(facts?.heavyFiles, 'heavyFiles', problems);\n if (!facts?.heavyPackages?.length && !facts?.heavyFiles?.length)\n problems.push(\n 'neither heavyPackages nor heavyFiles names anything, so the guard checks nothing',\n );\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: REPOSITORY_GUARD_TIMEOUT_MS,\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\n findings.push({\n file: file.path,\n detail: `cannot resolve ${spec}, so the closure through it is unread`,\n });\n }\n }\n graph.set(file.path, { internal, external });\n }\n for (const { path } of facts.heavyFiles)\n if (!known.has(path))\n findings.push({\n file: path,\n detail: 'stale heavy file: it is not a Functions module',\n });\n if (!known.has(facts.entryIndex))\n return [\n ...findings,\n {\n file: facts.entryIndex,\n detail: 'the entry module is gone or outside the Functions tree',\n },\n ];\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({\n file: facts.entryIndex,\n detail: `light function ${fn} is not re-exported from a Functions module`,\n });\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(\n (p) => namesModule(spec, p.specifier) && !p.lightSubpaths.includes(spec),\n );\n if (heavy)\n findings.push({\n file: start,\n detail: `light function ${fn} statically reaches ${spec}`,\n });\n }\n for (const { path } of facts.heavyFiles)\n if (seen.has(path))\n findings.push({\n file: start,\n detail: `light function ${fn} statically reaches ${path}`,\n });\n }\n return findings;\n },\n },\n ];\n },\n};\n\nexport interface CodebaseManifestFacts {\n manifest: string;\n entryIndex: string;\n deployConfig: string;\n sourceTemplate: string;\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)\n textProblem(facts?.[key], key, problems);\n if (typeof facts?.sourceTemplate === 'string' && !facts.sourceTemplate.includes('{codebase}'))\n 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\n { codebases?: Record<string, unknown> } | undefined;\n const deploy = readJson(context, facts.deployConfig, findings) as\n { functions?: unknown } | undefined;\n if (!context.reader.exists(facts.entryIndex))\n return [\n ...findings,\n { file: facts.entryIndex, detail: 'the entry module no longer exists' },\n ];\n const index = context.file(facts.entryIndex);\n const { names, unreadable } = exportsOf(index);\n for (const node of unreadable)\n findings.push({\n file: index.path,\n line: lineOfNode(index, node),\n detail: 'export * hides which functions the module deploys',\n });\n if (!names.size)\n findings.push({\n file: index.path,\n detail: 'no export found, so the guard checks nothing',\n });\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 (!isList(list)) {\n findings.push({\n file: facts.manifest,\n detail: `codebase ${codebase} is not a list of exports`,\n });\n continue;\n }\n for (const name of list as unknown[]) {\n if (typeof name !== 'string') continue;\n if (seen.has(name))\n findings.push({\n file: facts.manifest,\n detail: `${name} is in two codebases (${seen.get(name)} and ${codebase})`,\n });\n seen.set(name, codebase);\n }\n }\n for (const name of names.keys())\n if (!seen.has(name))\n findings.push({\n file: facts.manifest,\n detail: `${name} is exported but in no codebase`,\n });\n for (const name of seen.keys())\n if (!names.has(name))\n findings.push({\n file: facts.manifest,\n detail: `stale entry ${name}: the entry module does not export it`,\n });\n if (!deploy) return findings;\n const entries = isList(deploy.functions)\n ? (deploy.functions as Array<Record<string, unknown>>)\n : null;\n if (!entries)\n return [\n ...findings,\n { file: facts.deployConfig, detail: 'functions is not a list of codebase entries' },\n ];\n const declared = entries.map((e) => String(e.codebase));\n const codebases = Object.keys(manifest.codebases);\n for (const cb of codebases)\n if (!declared.includes(cb))\n findings.push({ file: facts.deployConfig, detail: `codebase ${cb} is not declared` });\n for (const cb of declared)\n if (!codebases.includes(cb))\n findings.push({\n file: facts.deployConfig,\n detail: `codebase ${cb} is not in the manifest`,\n });\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)\n findings.push({\n file: facts.deployConfig,\n detail: `codebase ${cb} deploys from ${String(entry.source)}, not ${source}`,\n });\n const predeploy = facts.predeployTemplate.map((t) => t.split('{codebase}').join(cb));\n if (JSON.stringify(entry.predeploy ?? []) !== JSON.stringify(predeploy)) {\n findings.push({\n file: facts.deployConfig,\n detail: `codebase ${cb}'s predeploy is not ${JSON.stringify(predeploy)}`,\n });\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":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AC;oBACtD,IAAI,CAAC,QAAQ,IAAI,OAAO,QAAQ,CAAC,SAAS,KAAK,QAAQ,IAAI,CAAC,QAAQ,CAAC,SAAS;wBAC5E,OAAO,QAAQ,CAAC;oBAClB,KAAK,MAAM,CAAC,QAAQ,EAAE,IAAI,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAC,EAAE,CAAC;wBAClE,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,MAAM,IAAI,0BAA0B;4BAAE,SAAS;wBACzE,QAAQ,CAAC,IAAI,CAAC;4BACZ,IAAI,EAAE,KAAK,CAAC,QAAQ;4BACpB,MAAM,EAAE,YAAY,QAAQ,UAAU,IAAI,CAAC,MAAM,uDAAuD,0BAA0B,EAAE;yBACrI,CAAC,CAAC;oBACL,CAAC;oBACD,OAAO,QAAQ,CAAC;gBAClB,CAAC;aACF;SACF,CAAC;IACJ,CAAC;CACF,CAAC","sourcesContent":["import { posix } from 'node:path';\nimport ts from 'typescript';\nimport type { GenericGuardDefinition } from '../../node/suite/config.js';\nimport type { Finding, GuardContext } from '../../guard.js';\nimport type { Scope } from '../../node/reader.js';\nimport type { FileView } from '../../reader/view.js';\nimport { ROOT_ROLES, type Reviewed, type RootRole } from '../../node/layout.js';\nimport { calleeName, forEachNode, lineOfNode } from '../../support/ast.js';\nimport { namesProblem, reviewedProblems, textProblem, isList } from '../../support/facts.js';\nimport { moduleImports, namesModule } from '../../support/imports.js';\nimport { resolveRelative } from '../../support/paths.js';\nimport { calleePath } from './shared.js';\nimport { REPOSITORY_GUARD_TIMEOUT_MS } from '../../support/timeouts.js';\n\nconst FUNCTIONS_CODE: Scope = { roots: ['functions'], kinds: ['code'], tests: false };\n\nconst CODE_EXTENSION = /\\.(?:[cm]?[jt]sx?)$/;\n\nfunction functionsRoot(context: GuardContext): string {\n const root = context.reader.layout.roots.functions;\n if (!root)\n throw new Error(\n 'repo-guards: a Functions guard runs and the layout declares no functions root',\n );\n return root.path;\n}\n\nconst moduleIdOf = (root: string, file: string) =>\n posix.relative(root, file).replace(CODE_EXTENSION, '');\n\nexport interface RateLimitFacts {\n owner: string;\n presetMap: string;\n surfaceMap: string;\n sharedPresets: string;\n chargeCall: string;\n prefixField: string;\n}\n\nconst isMapAccess = (node: ts.Node, map: string): node is ts.PropertyAccessExpression =>\n ts.isPropertyAccessExpression(node) &&\n ts.isIdentifier(node.expression) &&\n node.expression.text === map;\n\nexport function inlineLimiterConfigs(\n file: FileView,\n facts: Pick<RateLimitFacts, 'presetMap' | 'chargeCall'>,\n): 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 (\n ts.isCallExpression(node) &&\n calleeName(node) === facts.chargeCall &&\n node.arguments.some((a) => ts.isObjectLiteralExpression(a))\n ) {\n out.push({ node, detail: `passes an inline config to ${facts.chargeCall}` });\n }\n });\n return out;\n}\n\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\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)\n ? node.elements.filter(ts.isStringLiteralLike).map((e) => e.text)\n : [];\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 (\n ts.isPropertyAssignment(inner) &&\n inner.name.getText() === facts.prefixField &&\n ts.isStringLiteralLike(inner.initializer)\n ) {\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 (\n ts.isPropertyAssignment(p) &&\n (ts.isIdentifier(p.name) || ts.isStringLiteralLike(p.name))\n )\n surfaces.set(p.name.text, strings(bare(p.initializer)));\n }\n }\n });\n return { prefixes, surfaces, shared, presetMapFound, surfaceMapFound, sharedFound };\n}\n\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 [\n 'owner',\n 'presetMap',\n 'surfaceMap',\n 'sharedPresets',\n 'chargeCall',\n 'prefixField',\n ] as const)\n 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))\n 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)\n return [\n ...findings,\n {\n file: facts.owner,\n detail: 'the limiter owner is gone or outside the Functions tree',\n },\n ];\n const declared = limiterDeclarations(ownerFile, facts);\n if (!declared.presetMapFound || !declared.prefixes.length)\n findings.push({\n file: facts.owner,\n detail: `no ${facts.presetMap} with a ${facts.prefixField} found`,\n });\n if (!declared.surfaceMapFound)\n findings.push({ file: facts.owner, detail: `no ${facts.surfaceMap} object found` });\n if (!declared.sharedFound)\n 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))\n findings.push({\n file: facts.owner,\n detail: `two presets share the ${facts.prefixField} ${p}`,\n });\n for (const offense of offendingCharges(charges, declared.surfaces, declared.shared))\n 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)\n if (!charged.get(module)?.includes(preset))\n findings.push({\n file: facts.owner,\n detail: `${preset} lists ${module}, which does not charge it`,\n });\n }\n return findings;\n },\n },\n ];\n },\n};\n\nexport interface LazyLoaderFacts {\n loader: string;\n roots?: readonly RootRole[];\n otherLoaders?: ReadonlyArray<{ name: string; why: string }>;\n testRunnerConfigs: readonly string[];\n testExceptions: readonly Reviewed[];\n}\n\nconst isDynamicImport = (node: ts.Node): node is ts.CallExpression =>\n ts.isCallExpression(node) && node.expression.kind === ts.SyntaxKind.ImportKeyword;\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\nfunction moduleLevelLoaderName(\n node: ts.CallExpression,\n accepted: readonly string[],\n): string | null {\n if (node.arguments.length !== 1 || !ts.isStringLiteralLike(node.arguments[0]!)) return null;\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)\n return null;\n const call = arrow.parent;\n if (\n !call ||\n !ts.isCallExpression(call) ||\n !ts.isIdentifier(call.expression) ||\n call.arguments[0] !== arrow\n )\n 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)\n 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())\n return null;\n return name;\n}\n\nconst COMBINATORS = new Set(['Promise.all', 'Promise.allSettled', 'Promise.race', 'Promise.any']);\n\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')\n out.push({ node, detail: `${node.getText(sf)} runs tests concurrently` });\n if (\n ts.isPropertyAssignment(node) &&\n ts.isIdentifier(node.name) &&\n node.name.text === 'concurrent'\n )\n out.push({ node, detail: 'a concurrent test option' });\n if (ts.isCallExpression(node) && COMBINATORS.has(calleePath(node) ?? '')) combinator = true;\n if (inCombinator && isDynamicImport(node))\n out.push({\n node,\n detail: `${node.getText(sf)} overlaps the other imports of a Promise combinator`,\n });\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 (isList(facts.roots)) {\n for (const root of facts.roots)\n if (!ROOT_ROLES.includes(root))\n problems.push(`roots names ${String(root)}, which is not a root role`);\n }\n }\n if (facts?.otherLoaders !== undefined)\n 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({\n file: file.path,\n line: lineOfNode(file, node),\n detail: `${node.getText(file.sourceFile).slice(0, 80)} is not a module-level ${facts.loader} loader`,\n });\n }\n }\n if (!loaders)\n findings.push({\n file: `(${roots.join(', ')})`,\n detail: `no ${facts.loader} loader found, so the guard checks nothing`,\n });\n for (const name of others)\n if (!used.has(name))\n findings.push({\n file: '(otherLoaders)',\n detail: `stale other loader: ${name} wraps no import`,\n });\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)\n findings.push({ file: file.path, line: lineOfNode(file, node), detail });\n }\n for (const path of exceptions)\n if (!overlapping.has(path))\n findings.push({\n file: path,\n detail: 'stale test exception: the file overlaps no import',\n });\n for (const config of facts.testRunnerConfigs) {\n if (!context.reader.exists(config))\n 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)\n findings.push({\n file: config,\n line: view.lineOf(m.index),\n detail: 'the runner config makes tests concurrent',\n });\n }\n }\n return findings;\n },\n },\n ];\n },\n};\n\nexport interface LightFunctionFacts {\n entryIndex: string;\n lightFunctions: readonly string[];\n heavyPackages: ReadonlyArray<{\n specifier: string;\n lightSubpaths: readonly string[];\n why: string;\n }>;\n heavyFiles: readonly Reviewed[];\n}\n\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\nexport function resolveModule(\n fromPath: string,\n spec: string,\n known: ReadonlySet<string>,\n): 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 = [\n base,\n `${stem}.ts`,\n `${stem}.tsx`,\n `${stem}.mts`,\n `${stem}.cts`,\n `${base}.ts`,\n `${base}.tsx`,\n `${base}/index.ts`,\n `${base}/index.tsx`,\n ];\n return candidates.find((c) => known.has(c)) ?? null;\n}\n\nexport function exportsOf(file: FileView): {\n names: Map<string, string | null>;\n unreadable: ts.Node[];\n} {\n const names = new Map<string, string | null>();\n const unreadable: ts.Node[] = [];\n const exported = (node: ts.Node) =>\n ts.canHaveModifiers(node) &&\n !!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 =\n stmt.moduleSpecifier && ts.isStringLiteral(stmt.moduleSpecifier)\n ? stmt.moduleSpecifier.text\n : null;\n if (stmt.exportClause && ts.isNamedExports(stmt.exportClause))\n 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)\n if (ts.isIdentifier(d.name)) names.set(d.name.text, null);\n } else if (\n (ts.isFunctionDeclaration(stmt) || ts.isClassDeclaration(stmt)) &&\n exported(stmt) &&\n stmt.name\n ) {\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 ?? [])\n if (!isList(p?.lightSubpaths))\n problems.push(\n `heavy package ${String(p?.specifier)} needs lightSubpaths (declare [] when none)`,\n );\n reviewedProblems(facts?.heavyFiles, 'heavyFiles', problems);\n if (!facts?.heavyPackages?.length && !facts?.heavyFiles?.length)\n problems.push(\n 'neither heavyPackages nor heavyFiles names anything, so the guard checks nothing',\n );\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: REPOSITORY_GUARD_TIMEOUT_MS,\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\n findings.push({\n file: file.path,\n detail: `cannot resolve ${spec}, so the closure through it is unread`,\n });\n }\n }\n graph.set(file.path, { internal, external });\n }\n for (const { path } of facts.heavyFiles)\n if (!known.has(path))\n findings.push({\n file: path,\n detail: 'stale heavy file: it is not a Functions module',\n });\n if (!known.has(facts.entryIndex))\n return [\n ...findings,\n {\n file: facts.entryIndex,\n detail: 'the entry module is gone or outside the Functions tree',\n },\n ];\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({\n file: facts.entryIndex,\n detail: `light function ${fn} is not re-exported from a Functions module`,\n });\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(\n (p) => namesModule(spec, p.specifier) && !p.lightSubpaths.includes(spec),\n );\n if (heavy)\n findings.push({\n file: start,\n detail: `light function ${fn} statically reaches ${spec}`,\n });\n }\n for (const { path } of facts.heavyFiles)\n if (seen.has(path))\n findings.push({\n file: start,\n detail: `light function ${fn} statically reaches ${path}`,\n });\n }\n return findings;\n },\n },\n ];\n },\n};\n\n// Google allows 60 Cloud Functions mutations per minute per project and region, and a deploy\n// changes every function of the codebase it targets; 55 leaves room for that pass's deletions.\nexport const MAX_FUNCTIONS_PER_CODEBASE = 55;\n\nexport interface CodebaseManifestFacts {\n manifest: string;\n entryIndex: string;\n deployConfig: string;\n sourceTemplate: string;\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)\n textProblem(facts?.[key], key, problems);\n if (typeof facts?.sourceTemplate === 'string' && !facts.sourceTemplate.includes('{codebase}'))\n 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\n { codebases?: Record<string, unknown> } | undefined;\n const deploy = readJson(context, facts.deployConfig, findings) as\n { functions?: unknown } | undefined;\n if (!context.reader.exists(facts.entryIndex))\n return [\n ...findings,\n { file: facts.entryIndex, detail: 'the entry module no longer exists' },\n ];\n const index = context.file(facts.entryIndex);\n const { names, unreadable } = exportsOf(index);\n for (const node of unreadable)\n findings.push({\n file: index.path,\n line: lineOfNode(index, node),\n detail: 'export * hides which functions the module deploys',\n });\n if (!names.size)\n findings.push({\n file: index.path,\n detail: 'no export found, so the guard checks nothing',\n });\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 (!isList(list)) {\n findings.push({\n file: facts.manifest,\n detail: `codebase ${codebase} is not a list of exports`,\n });\n continue;\n }\n for (const name of list as unknown[]) {\n if (typeof name !== 'string') continue;\n if (seen.has(name))\n findings.push({\n file: facts.manifest,\n detail: `${name} is in two codebases (${seen.get(name)} and ${codebase})`,\n });\n seen.set(name, codebase);\n }\n }\n for (const name of names.keys())\n if (!seen.has(name))\n findings.push({\n file: facts.manifest,\n detail: `${name} is exported but in no codebase`,\n });\n for (const name of seen.keys())\n if (!names.has(name))\n findings.push({\n file: facts.manifest,\n detail: `stale entry ${name}: the entry module does not export it`,\n });\n if (!deploy) return findings;\n const entries = isList(deploy.functions)\n ? (deploy.functions as Array<Record<string, unknown>>)\n : null;\n if (!entries)\n return [\n ...findings,\n { file: facts.deployConfig, detail: 'functions is not a list of codebase entries' },\n ];\n const declared = entries.map((e) => String(e.codebase));\n const codebases = Object.keys(manifest.codebases);\n for (const cb of codebases)\n if (!declared.includes(cb))\n findings.push({ file: facts.deployConfig, detail: `codebase ${cb} is not declared` });\n for (const cb of declared)\n if (!codebases.includes(cb))\n findings.push({\n file: facts.deployConfig,\n detail: `codebase ${cb} is not in the manifest`,\n });\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)\n findings.push({\n file: facts.deployConfig,\n detail: `codebase ${cb} deploys from ${String(entry.source)}, not ${source}`,\n });\n const predeploy = facts.predeployTemplate.map((t) => t.split('{codebase}').join(cb));\n if (JSON.stringify(entry.predeploy ?? []) !== JSON.stringify(predeploy)) {\n findings.push({\n file: facts.deployConfig,\n detail: `codebase ${cb}'s predeploy is not ${JSON.stringify(predeploy)}`,\n });\n }\n }\n return findings;\n },\n },\n {\n title: `no Functions codebase holds more than ${MAX_FUNCTIONS_PER_CODEBASE} functions`,\n description:\n `Each codebase in ${facts.manifest} deploys as one pass that changes every function it holds, ` +\n `so a codebase over ${MAX_FUNCTIONS_PER_CODEBASE} functions outruns the platform's per-minute ` +\n 'mutation budget and its creates are dropped. A codebase that grows past the cap is split.',\n run(context) {\n const findings: Finding[] = [];\n const manifest = readJson(context, facts.manifest, findings) as\n { codebases?: Record<string, unknown> } | undefined;\n if (!manifest || typeof manifest.codebases !== 'object' || !manifest.codebases)\n return findings;\n for (const [codebase, list] of Object.entries(manifest.codebases)) {\n if (!isList(list) || list.length <= MAX_FUNCTIONS_PER_CODEBASE) continue;\n findings.push({\n file: facts.manifest,\n detail: `codebase ${codebase} holds ${list.length} functions; split it so each codebase holds at most ${MAX_FUNCTIONS_PER_CODEBASE}`,\n });\n }\n return findings;\n },\n },\n ];\n },\n};\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"read-failures.d.ts","sourceRoot":"","sources":["../../../src/modules/frontend-reads/read-failures.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,4BAA4B,CAAC;AAEzE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAA8C,KAAK,GAAG,EAAE,MAAM,wBAAwB,CAAC;AAC9F,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAiBrD,MAAM,WAAW,WAAW;IAC1B,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;CACrB;AAWD,MAAM,WAAW,mBAAmB;IAClC,MAAM,EAAE,MAAM,CAAC;IACf,aAAa,EAAE,MAAM,CAAC;IACtB,cAAc,EAAE,MAAM,CAAC;CACxB;AAED,eAAO,MAAM,mBAAmB,EAAE,sBAAsB,CAAC,mBAAmB,CAoC3E,CAAC;AAEF,MAAM,WAAW,mBAAmB;IAClC,IAAI,EAAE,WAAW,CAAC;IAClB,kBAAkB,EAAE,MAAM,CAAC;CAC5B;AAmHD,wBAAgB,wBAAwB,CAAC,IAAI,EAAE,QAAQ,EAAE,kBAAkB,EAAE,MAAM,GAAG,GAAG,EAAE,CAqB1F;AAoHD,wBAAgB,wBAAwB,CAAC,IAAI,EAAE,QAAQ,GAAG,GAAG,EAAE,CAuB9D;AAED,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,WAAW,GAAG,GAAG,EAAE,CA6B5E;AAaD,wBAAgB,4BAA4B,CAAC,IAAI,EAAE,QAAQ,GAAG,GAAG,EAAE,CA+BlE;AAED,wBAAgB,yB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O,MAAM,yBAAyB,EAAE,sBAAsB,CAAC,yBAAyB,CAoDvF,CAAC;AAEF,MAAM,WAAW,qBAAqB;IACpC,SAAS,EAAE,MAAM,CAAC;IAClB,eAAe,EAAE,MAAM,CAAC;IACxB,UAAU,EAAE,aAAa,CAAC;QAAE,SAAS,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAChE,WAAW,EAAE,MAAM,CAAC;CACrB;AAgBD,wBAAgB,sBAAsB,CACpC,KAAK,EAAE,SAAS,QAAQ,EAAE,EAC1B,KAAK,EAAE,qBAAqB,GAC3B,QAAQ,EAAE,CAcZ;AAED,eAAO,MAAM,qBAAqB,EAAE,sBAAsB,CAAC,qBAAqB,CA8C/E,CAAC;AAEF,MAAM,WAAW,oBAAoB;IACnC,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,SAAS,QAAQ,EAAE,CAAC;CAChC;AAED,eAAO,MAAM,qBAAqB,QACqH,CAAC;AAExJ,eAAO,MAAM,oBAAoB,EAAE,sBAAsB,CAAC,oBAAoB,CAqC7E,CAAC;AAEF,eAAO,MAAM,mBAAmB,mSAOtB,CAAC"}
@@ -421,12 +421,26 @@ function enclosingFunction(node) {
421
421
  current = current.parent;
422
422
  return current;
423
423
  }
424
+ // A `retryState` carries the failure only where its `error` is read, or where it travels on whole —
425
+ // passed, returned, spread, or destructured with its `error` — so `q.retryState.isLoading` alone does not.
426
+ function carriesRetryFailure(access, sf) {
427
+ const parent = access.parent;
428
+ if ((ts.isPropertyAccessExpression(parent) || ts.isElementAccessExpression(parent)) &&
429
+ parent.expression === access)
430
+ return ts.isPropertyAccessExpression(parent) && parent.name.text === 'error';
431
+ if (ts.isVariableDeclaration(parent) &&
432
+ parent.initializer === access &&
433
+ ts.isObjectBindingPattern(parent.name))
434
+ return parent.name.elements.some((el) => el.dotDotDotToken !== undefined || (el.propertyName ?? el.name).getText(sf) === 'error');
435
+ return true;
436
+ }
424
437
  function readsFailureOf(scope, receiver, sf) {
425
438
  let found = false;
426
439
  forEachNode(scope, (n) => {
427
440
  if (ts.isPropertyAccessExpression(n) &&
428
441
  FAILURE_FIELDS.has(n.name.text) &&
429
- n.expression.getText(sf) === receiver)
442
+ n.expression.getText(sf) === receiver &&
443
+ (n.name.text !== 'retryState' || carriesRetryFailure(n, sf)))
430
444
  found = true;
431
445
  if (ts.isCallExpression(n) &&
432
446
  n.expression.getText(sf) === RETRY_STATE_HELPERS[0] &&
@@ -560,7 +574,7 @@ export const hookReadDefaultGuard = {
560
574
  {
561
575
  title: 'a hook never returns a default its consumers cannot tell from data',
562
576
  description: `In ${facts.hooksTree}, a read's data defaulted to an empty answer (q.data ?? [], const { data = [] } = useQ()) is allowed only ` +
563
- `where the same function also carries that read's failure (error / isError / status / retryState, or the read handed to ${RETRY_STATE_HELPERS[0]}), ` +
577
+ `where the same function also carries that read's failure (error / isError / status, its retryState's error or the whole retryState passed on or returned, or the read handed to ${RETRY_STATE_HELPERS[0]}), ` +
564
578
  'and no exported hook collapses a read into a bare boolean, where an unknown read would read as "no". Return the read state ' +
565
579
  '(pending / failed / answered) or carry the failure beside the defaulted data.',
566
580
  run(context) {