* refactor(test): colocate pure-domain tests and reduce test debt Move focused immutable domain/contracts/adapter tests from tests/composition/** beside their production owners under src/** as colocated *.test.ts/*.fixture.ts, and relocate persistence-shaped composition tests under tests/boundary/filesystem/**. Update import paths, the Vitest project topology (shared worker context for pure domain/contracts and recording-port service projects), the test migration ledger, testing docs, and AGENTS.md to match. Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com> * docs: remove test migration ledger The cutover is complete and the ledger is no longer referenced anywhere in source, scripts, or the docs gate. Drop the standalone artifact. Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com> * docs: clean up stale migration artifacts Remove empty directories left by the test migration and replace the "final cutover" language in docs/testing.md with standing PR guidance that no longer references the completed migration. Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com> * fix: repair CI failures from schema, knip, and stale generated artifacts Three root causes fixed: 1. catalog-schemas.mjs: valuesAt only traversed anyOf from Zod's toJSONSchema, not oneOf. The webScreenshotDiffSchema change to a discriminated union produces oneOf, so the product catalog generator could not derive the web_screenshot_diff schema version. Add oneOf traversal. 2. conformancePackage.ts: the test rewrite removed the only imports of ScenarioManifest, ReplayPlan, ShimPlan, and ExpectedEvidence, making them unused exports that knip flags. Remove the dead type aliases. 3. Regenerate stale artifacts (product catalog, MCP tool catalog, skill metadata, conformance manifest) that drifted from the source changes. Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com> --------- Co-authored-by: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
80 lines
3.0 KiB
TypeScript
80 lines
3.0 KiB
TypeScript
import type {
|
|
JavaScriptBindingProvenance,
|
|
JavaScriptModuleOrigin,
|
|
JavaScriptSemanticPrimitive,
|
|
} from "./javascriptSemanticIr.js";
|
|
import type { JavaScriptSemanticAnalysisState } from "./javascriptSemanticState.js";
|
|
import { compareCodePoints } from "./javascriptStaticAnalysisHelpers.js";
|
|
|
|
/** Construct exact local provenance without inventing module origins. */
|
|
export const semanticLocalProvenance = (): JavaScriptBindingProvenance => ({
|
|
status: "local",
|
|
origins: [],
|
|
reason: null,
|
|
});
|
|
|
|
/** Construct an unresolved provenance outcome with an actionable reason. */
|
|
export const semanticUnresolvedProvenance = (
|
|
status: "unknown" | "cycle" | "limit-reached",
|
|
reason: string,
|
|
): JavaScriptBindingProvenance => ({ status, origins: [], reason });
|
|
|
|
/** Construct ambiguous provenance while retaining every bounded origin. */
|
|
export const semanticAmbiguousProvenance = (
|
|
origins: readonly JavaScriptModuleOrigin[],
|
|
reason: string,
|
|
): JavaScriptBindingProvenance => ({ status: "ambiguous", origins, reason });
|
|
|
|
/** Normalize bounded exact module origins into one provenance classification. */
|
|
export const semanticOriginsProvenance = (
|
|
origins: readonly JavaScriptModuleOrigin[],
|
|
state: JavaScriptSemanticAnalysisState,
|
|
): JavaScriptBindingProvenance => {
|
|
const unique = uniqueSemanticOrigins(origins);
|
|
if (unique.length > state.limits.maxUnionValues)
|
|
return semanticLimitProvenance(state, "maxUnionValues");
|
|
const origin = unique[0];
|
|
return unique.length === 1 && origin !== undefined
|
|
? { status: "module", origins: [origin], reason: null }
|
|
: semanticAmbiguousProvenance(unique, "Multiple module origins.");
|
|
};
|
|
|
|
/** Deduplicate and canonically order module origins. */
|
|
export const uniqueSemanticOrigins = (
|
|
origins: readonly JavaScriptModuleOrigin[],
|
|
): JavaScriptModuleOrigin[] =>
|
|
[
|
|
...new Map(
|
|
origins.map((origin) => [semanticOriginKey(origin), origin]),
|
|
).values(),
|
|
].sort((left, right) =>
|
|
compareCodePoints(semanticOriginKey(left), semanticOriginKey(right)),
|
|
);
|
|
|
|
/** Mark and return an explicit provenance-limit value. */
|
|
export const semanticLimitProvenance = (
|
|
state: JavaScriptSemanticAnalysisState,
|
|
limit: "maxValueDepth" | "maxUnionValues",
|
|
): JavaScriptBindingProvenance => {
|
|
reachSemanticValueLimit(state, limit);
|
|
return semanticUnresolvedProvenance("limit-reached", `${limit} reached.`);
|
|
};
|
|
|
|
/** Record one value-lattice limit against the shared semantic analysis state. */
|
|
export const reachSemanticValueLimit = (
|
|
state: JavaScriptSemanticAnalysisState,
|
|
limit: keyof JavaScriptSemanticAnalysisState["limits"],
|
|
): void => {
|
|
state.limitsReached.add(limit);
|
|
state.omittedCount += 1;
|
|
};
|
|
|
|
const semanticOriginKey = (origin: JavaScriptModuleOrigin): string =>
|
|
`${origin.specifier}\0${origin.importedPath.join("\0")}`;
|
|
|
|
/** Canonically distinguish primitive values across type boundaries. */
|
|
export const semanticPrimitiveKey = (
|
|
value: JavaScriptSemanticPrimitive,
|
|
): string =>
|
|
`${value === null ? "null" : typeof value}:${JSON.stringify(value)}`;
|