refactor: use canonical implementations and types directly

Remove forwarding wrappers and shadow aliases, migrate callers and verification scripts to their owners, and share one exhaustive semantic resource-bound projection.
This commit is contained in:
morluto
2026-10-09 23:17:17 +08:00
parent 3283a45d09
commit 765e809e36
119 changed files with 577 additions and 629 deletions
@@ -1,4 +1,10 @@
import type { JavaScriptSemanticResourceLimit } from "./javascriptSemanticValueTypes.js";
import type { ApplicationCoverage } from "./javascriptApplicationEvidenceSchemas.js";
import {
SEMANTIC_EXPRESSION_DEPTH_LIMIT,
SEMANTIC_PRIMITIVE_CANDIDATE_LIMIT,
SEMANTIC_PRIMITIVE_JSON_BYTES_LIMIT,
} from "./javascriptSemanticResourceLimits.js";
/** Exact retention state for one callable's direct returns. */
export type JavaScriptSemanticReturnCoverage = {
@@ -40,6 +46,33 @@ export const semanticCoverageResourceLimits = (
coverage: JavaScriptSemanticCoverage,
): readonly JavaScriptSemanticResourceLimit[] => coverage.resourceLimits ?? [];
const semanticResourceBounds: Record<
JavaScriptSemanticResourceLimit,
Pick<ApplicationCoverage["limits"][number], "value" | "unit">
> = {
"primitive-candidates": {
value: SEMANTIC_PRIMITIVE_CANDIDATE_LIMIT,
unit: "items",
},
"primitive-bytes": {
value: SEMANTIC_PRIMITIVE_JSON_BYTES_LIMIT,
unit: "bytes",
},
"expression-depth": {
value: SEMANTIC_EXPRESSION_DEPTH_LIMIT,
unit: "depth",
},
};
/** Map semantic evaluator bounds to their caller-visible application coverage. */
export const semanticResourceLimitCoverage = (
resourceLimits: readonly JavaScriptSemanticResourceLimit[],
): ApplicationCoverage["limits"] =>
resourceLimits.map((resourceLimit) => ({
name: `javascript_semantic_${resourceLimit.replaceAll("-", "_")}`,
...semanticResourceBounds[resourceLimit],
}));
/** Classify one callable's direct-return coverage. */
export const semanticReturnCoverage = (
retainedCount: number,