Files
reverse-engineering-anything/src/domain/analysisView/javascriptApplicationCoverage.ts
T
郭立 Guo Li 7590b50801 perf(schema): reduce retained integer validator allocations (#4360)
Construct integer formats directly while preserving bounds, refinements, metadata and current shared schema owners. Keep Incur-dependent CLI numeric coercion declarations unchanged.

Verify canonical advertisements, 126 numeric boundary cases, 974 actual CLI parser cases, broad source tests and real public-artifact SDK workflows. Record 72 normal tasks and 12 separate owned-inspector heap diagnostics with whole-family resource bounds; distinguish SDK spans and asymmetric audit overhead. Generate numerical report sections from receipts and reject stale tables through documentation conformance checks.

Closes #6236. Current-head CI and Greptile pass; actionable review findings are addressed. Codex review was unavailable due repository usage limits.
2026-10-22 05:11:08 +00:00

40 lines
1.7 KiB
TypeScript

import { z } from "zod";
import { applicationCoverageSchema } from "../javascript/javascriptApplicationEvidenceSchemas.js";
import type { JavaScriptApplicationAnalysisResult } from "../javascript/javascriptApplicationAnalysis.js";
import { javaScriptSemanticGraphInputSchema } from "../javascript/javascriptSemanticGraphSchemas.js";
import { javaScriptSourceSelectionSchema } from "../javascript/javascriptSourceSelection.js";
/** Source completeness is independent of exhausting a selected fact page. */
export const javascriptApplicationSourceCoverageSchema = z.strictObject({
source_selection: javaScriptSourceSelectionSchema.exactOptional(),
application: applicationCoverageSchema,
semantic: javaScriptSemanticGraphInputSchema.shape.coverage.omit({
families: true,
}),
application_unknown_count: z.int().nonnegative(),
semantic_unknown_count: z.int().nonnegative(),
});
export type JavaScriptApplicationSourceCoverage = z.infer<
typeof javascriptApplicationSourceCoverageSchema
>;
/** Reuse retained coverage and count its unknowns once for every view. */
export const javascriptApplicationSourceCoverage = (
analysis: JavaScriptApplicationAnalysisResult,
): JavaScriptApplicationSourceCoverage => {
const { families: _families, ...semantic } = analysis.semantic_graph.coverage;
return {
...(analysis.source_selection === undefined
? {}
: { source_selection: analysis.source_selection }),
application: analysis.graph.coverage,
semantic,
application_unknown_count: analysis.graph.nodes.reduce(
(count, node) => count + Number(node.kind === "unknown"),
0,
),
semantic_unknown_count: analysis.semantic_graph.unknowns.length,
};
};