Files
rea/tests/analysisProfile.test.ts
T
N0zoM1z0 21da71ec6d refactor(domain): remove provider-specific target and snapshot state
Move Hopper loader derivation and compatibility projection into the Hopper adapter so BinaryTarget carries only provider-neutral identity and format metadata.

Introduce bounded canonical analysis-profile commitments, exact provider/profile snapshot v2 bindings, legacy snapshot rejection guidance, and backward-compatible profiled Evidence v2 records. Partition cache and replay behavior by target, concrete provider build, and profile while preserving custom Hopper loader overrides.

Propagate profiles consistently through CLI, MCP, composed workflows, and session lifecycle; preserve the 78-tool contract and legacy loaderArgs response projection. Add migration documentation, generated API updates, property regressions, package verification, and real Hopper coverage.
2026-07-15 20:31:56 +09:00

65 lines
1.9 KiB
TypeScript

import { describe, expect, it } from "vitest";
import {
analysisProfileSchema,
analysisProfilesEqual,
createAnalysisProfile,
} from "../src/domain/analysisProfile.js";
const PROVIDER = {
id: "fixture",
name: "Fixture analysis provider",
version: "1.2.3",
} as const;
describe("analysis profile commitments", () => {
it("canonicalizes parameter key order and validates its digest", () => {
const first = createAnalysisProfile(PROVIDER, 1, {
architecture: "arm64",
analyzers: { strings: true, functions: true },
});
const reordered = createAnalysisProfile(PROVIDER, 1, {
analyzers: { functions: true, strings: true },
architecture: "arm64",
});
expect(reordered.digest).toBe(first.digest);
expect(analysisProfilesEqual(first, reordered)).toBe(true);
expect(analysisProfileSchema.parse(first)).toEqual(first);
});
it("separates provider builds, profile schemas, and semantic parameters", () => {
const baseline = createAnalysisProfile(PROVIDER, 1, { loader: "default" });
const changedBuild = createAnalysisProfile(
{ ...PROVIDER, version: "1.2.4" },
1,
{ loader: "default" },
);
const changedSchema = createAnalysisProfile(PROVIDER, 2, {
loader: "default",
});
const changedParameters = createAnalysisProfile(PROVIDER, 1, {
loader: "override",
});
expect(
new Set([
baseline.digest,
changedBuild.digest,
changedSchema.digest,
changedParameters.digest,
]).size,
).toBe(4);
});
it("rejects digest tampering and unbounded parameters", () => {
const profile = createAnalysisProfile(PROVIDER, 1, { loader: "default" });
expect(() =>
analysisProfileSchema.parse({ ...profile, digest: "0".repeat(64) }),
).toThrow(/digest/u);
expect(() =>
createAnalysisProfile(PROVIDER, 1, {
oversized: "x".repeat(65 * 1024),
}),
).toThrow(/limit/u);
});
});