mirror of
https://github.com/morluto/rea
synced 2026-10-26 22:28:27 -04:00
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:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user