Files
reverse-engineering-anything/tests/boundary/model/modelArtifactViewIdentity.test.ts
T
1201c25542 fix(ci): align static checks and regression fixtures with current contracts (#7349)
* fix(ci): retire unused internal analysis declarations

* test: use an admitted app bundle for provider routing

(cherry picked from commit 00aa17f12a)

* test: keep bundle routing coverage outside oversized group

(cherry picked from commit 8658353b0d)

* fix(ci): align regression fixtures with current admission contracts

* test: bind extraction close fixtures to their ZIP digest

(cherry picked from commit 626d0250db)

* test(cli): match typed analysis outcomes in function detail fixture

* test(ghidra): preserve empty Java property separator framing

* test(electron): retain unknown IPC ownership for native module gaps

* fix(electron): share source-scoped call path identity

* test(captures): assert safe source identity on SAZ refusal

* test(apple): match root occurrence kind to inventory manifest

* fix(examples): align directory root occurrence identity

* test(electron): align equivalent fixture assertions with upstream

* test(process): assert retained capture root identity

* test(windows): declare the PE fixture optional header

* test(ci): refresh owned registration and verifier fixtures

* test(setup): use owned registrations for refresh fixtures

* test(process): control unavailable ownership in CLI cleanup fixture

* test(process): guard controlled compiler output arguments

* test(setup): align equivalent entrypoint guards with upstream

* test(process): release the cleanup target through an owned gate

* test(ci): align semantic identities and owned fixture facts

* test(pcap): retain the upstream DNS wire fixture branch

* test(pcap): use the canonical wire ownership fixture

* test(pcap): assert exact DNS wire query labels

* test(ci): preserve admission and ownership fixture prerequisites

* test(ci): align authenticated fixture and cleanup boundaries

* test(windows): align native artifact fixtures with upstream

* test(android): request complete evidence for inline MCP contracts

* test: avoid pinning diagnostic wording

* test: verify cleanup diagnostics at their source

* test: strengthen evidence and cleanup checks

* test: avoid pinning registration guidance

---------

Co-authored-by: Plastic-time <Plastic-time@users.noreply.github.com>
Co-authored-by: morluto <76467478+morluto@users.noreply.github.com>
2026-10-27 21:24:30 +08:00

84 lines
3.2 KiB
TypeScript

import { writeFile } from "node:fs/promises";
import { join } from "node:path";
import { expect, it } from "vitest";
import { inspectAnalysisView } from "../../../src/application/analysisView/AnalysisViewService.js";
import { createModelArtifactService } from "../../../src/composition/model.js";
import { createEvidence } from "../../../src/domain/evidence.js";
import { freezeJsonSnapshot } from "../../../src/domain/immutableJson.js";
import { ggufFixture } from "../../fixtures/model/model.js";
import { createTestTempDirectory } from "../../fixtures/temporaryDirectory.js";
it("checks each model parent digest independently of cached declarations and display paths", async () => {
const root = await createTestTempDirectory("rea-model-view-identity-");
const path = join(root, "selected.gguf");
await writeFile(path, ggufFixture().bytes);
const service = createModelArtifactService();
try {
const inspected = await service.inspect({
path,
hash: "full",
detail: "complete",
});
if (!inspected.ok) throw inspected.error;
const original = inspected.value;
if (original.subject === null) throw new Error("Missing full-file subject");
const report = freezeJsonSnapshot(original.normalized_result);
const parent = (name: string, targetPath: string, digest: string) =>
createEvidence(
{ path: targetPath, sha256: digest, format: "file" },
original.provider,
{
operation: original.operation,
parameters: { path, hash: "full", fixture: name },
result: report,
confidence: "observed",
limitations: original.limitations,
},
);
const digest = original.subject.digest.sha256;
const valid = parent("valid", path, digest);
const aliasPath = join(root, "other.gguf");
const rebound = parent("rebound-path", aliasPath, digest);
const conflicting = [
parent("wrong-digest", path, "00".repeat(32)),
parent("wrong-digest-rebound", aliasPath, "00".repeat(32)),
];
const project = (record: typeof valid) =>
inspectAnalysisView(
{
source: {
kind: "retained-evidence",
evidence_id: record.evidence_id,
},
view: { kind: "summary" },
},
(id) => (id === record.evidence_id ? record : undefined),
);
for (const record of [...conflicting, rebound])
expect(record.normalized_result).toBe(report);
for (const phase of ["cold", "warm"]) {
for (const record of conflicting) {
expect(await project(record), phase).toMatchObject({
ok: false,
error: {
_tag: "AnalysisInputError",
issues: [{ path: ["source", "subject"], reason: "invalid_value" }],
},
});
}
for (const record of [valid, rebound]) {
const projected = await project(record);
if (!projected.ok) throw projected.error;
expect(projected.value.subject).toEqual(record.subject);
expect(projected.value.evidence_links).toEqual([record.evidence_id]);
expect(projected.value.normalized_result).toMatchObject({
artifact: { path, sha256: digest },
});
}
}
} finally {
await service.close();
}
});