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:35:19 +08:00
parent 3283a45d09
commit 765e809e36
119 changed files with 577 additions and 629 deletions
+10 -5
View File
@@ -2,7 +2,8 @@ import { posix } from "node:path";
import { z } from "zod";
import { canonicalDigest, canonicalJson } from "./comparisonSemantics.js";
import { canonicalJson } from "./comparisonSemantics.js";
import { digestCanonicalValue } from "./canonicalDigest.js";
import { compareUnicodeCodePoints } from "./unicodeCodePointOrder.js";
import { digestSchema } from "./../domain/digests.js";
import { prefixedDigestSchema } from "./../domain/digests.js";
@@ -473,7 +474,7 @@ const computeRootSha256 = (
entries: readonly z.infer<typeof sourceEntrySchema>[],
exclusions: readonly z.infer<typeof exclusionSchema>[],
): string =>
canonicalDigest(
digestCanonicalValue(
rootCommitment(entries, exclusions),
"Reference source graph",
);
@@ -496,7 +497,10 @@ export const parseHistoricalSourceGraph = (
/** Compute a deterministic graph commitment containing no absolute root path. */
export const computeHistoricalSourceGraphSha256 = (input: unknown): string =>
canonicalDigest(parseHistoricalSourceGraph(input), "Reference source graph");
digestCanonicalValue(
parseHistoricalSourceGraph(input),
"Reference source graph",
);
/** Build a deterministic, relocation-independent manifest for a source graph. */
export const createHistoricalSourceManifest = (
@@ -514,7 +518,7 @@ export const createHistoricalSourceManifest = (
};
return historicalSourceManifestBaseSchema.parse({
...semantic,
manifest_id: `hsm_${canonicalDigest(semantic, "Reference source graph")}`,
manifest_id: `hsm_${digestCanonicalValue(semantic, "Reference source graph")}`,
});
};
@@ -525,7 +529,8 @@ export const parseHistoricalSourceManifest = (
const manifest = historicalSourceManifestBaseSchema.parse(input);
const { manifest_id: manifestId, ...semantic } = manifest;
if (
`hsm_${canonicalDigest(semantic, "Reference source graph")}` !== manifestId
`hsm_${digestCanonicalValue(semantic, "Reference source graph")}` !==
manifestId
)
throw new TypeError("Historical source manifest identifier does not match");
return manifest;