mirror of
https://github.com/morluto/rea
synced 2026-10-27 14:42:18 -04:00
6bae774328
Authenticate residual unknown IDs against their immutable identity fields. Permit valid empty ZIP extraction manifests and join firmware child provenance to parent-owned chunk and multi-file reports without inventing missing source ranges. Validated with focused identity, archive, cleanup, and firmware normalization tests. Firmware joins were checked against the pinned Unblob producer; no real Unblob extraction was run.
44 lines
1.7 KiB
TypeScript
44 lines
1.7 KiB
TypeScript
import { join } from "node:path";
|
|
|
|
import { describe, expect, it } from "vitest";
|
|
|
|
import { writeOrderedZip } from "../../../fixtures/artifactEntryOrder.js";
|
|
import { createTestTempDirectory } from "../../../fixtures/temporaryDirectory.js";
|
|
|
|
import { ArtifactProvider } from "../../../../src/artifacts/ArtifactProvider.js";
|
|
import { artifactExtractionExecutionSchema } from "../../../../src/contracts/artifactToolContracts.js";
|
|
import { artifactExtractionResultSchema } from "../../../../src/domain/artifactGraph.js";
|
|
import type { BinaryTarget } from "../../../../src/domain/binaryTargetTypes.js";
|
|
|
|
describe("artifact extraction identity", () => {
|
|
it("uses code-point order for path-independent extraction identities", async () => {
|
|
const root = await createTestTempDirectory("rea-extract-order-");
|
|
const source = join(root, "source.zip");
|
|
await writeOrderedZip(source, ["ä.js", "a.js", "Z.js"]);
|
|
const result = await new ArtifactProvider(process.env)
|
|
.createClient(archiveTarget(source))
|
|
.execute(
|
|
"extract_artifact",
|
|
artifactExtractionExecutionSchema.parse({
|
|
output_root: join(root, "output"),
|
|
}),
|
|
);
|
|
if (!result.ok) throw result.error;
|
|
const extracted = artifactExtractionResultSchema.parse(result.value.result);
|
|
expect(
|
|
extracted.artifacts.map(({ relative_path }) => relative_path),
|
|
).toEqual(["Z.js", "a.js", "ä.js"]);
|
|
expect(extracted.extraction_manifest.selected_occurrence_ids).toEqual(
|
|
[...extracted.extraction_manifest.selected_occurrence_ids].sort(),
|
|
);
|
|
});
|
|
});
|
|
|
|
const archiveTarget = (path: string): BinaryTarget => ({
|
|
path,
|
|
sourcePath: path,
|
|
sha256: "0".repeat(64),
|
|
kind: "archive",
|
|
format: "zip",
|
|
});
|