mirror of
https://github.com/morluto/rea.git
synced 2026-10-28 02:15:44 +00:00
Separate raw SEA names from safe logical extraction paths. Accept empty asset keys, retain absolute main paths and conflicting source spellings, and assign deterministic paths through the shared artifact path registry. Keep duplicate raw keys malformed and include sourcePath in owned entry equality. Validate 102 focused regressions including compiled CLI and stdio MCP inventory and extraction, the canonical SDK schema case, 9 documentation consistency cases, cached build, typecheck/lint and formatting. A pinned Node-generated preparation blob is verified in a synthetic ELF carrier; real injected native executables and the optional Docker lane were not run.
59 lines
1.7 KiB
TypeScript
59 lines
1.7 KiB
TypeScript
import { expect, it } from "vitest";
|
|
import {
|
|
ArtifactReaderFailure,
|
|
copyArtifactEntry,
|
|
sameArtifactEntry,
|
|
type ArtifactEntry,
|
|
} from "./ArtifactReader.js";
|
|
|
|
it("preserves an observed empty source key separately from missing or changed keys", () => {
|
|
const entry: ArtifactEntry = {
|
|
path: "__node_sea__/assets/0",
|
|
sourcePath: "",
|
|
kind: "file",
|
|
declaredSize: 5,
|
|
compressedSize: null,
|
|
executable: false,
|
|
encrypted: false,
|
|
byteOffset: 64,
|
|
declaredIntegrity: null,
|
|
unpacked: false,
|
|
limitations: [],
|
|
adapterKey: "asset:0",
|
|
};
|
|
const copied = copyArtifactEntry(entry);
|
|
expect(copied.sourcePath).toBe("");
|
|
expect(sameArtifactEntry(copied, entry)).toBe(true);
|
|
expect(sameArtifactEntry({ ...copied, sourcePath: "changed" }, entry)).toBe(
|
|
false,
|
|
);
|
|
const { sourcePath: _sourcePath, ...withoutSource } = copied;
|
|
expect(sameArtifactEntry(withoutSource, entry)).toBe(false);
|
|
});
|
|
|
|
it.each([
|
|
undefined,
|
|
null,
|
|
"caller reason",
|
|
new ArtifactReaderFailure("cancelled", "caller-provided error"),
|
|
])(
|
|
"preserves explicit cancellation through repeated cleanup composition: %s",
|
|
(reason) => {
|
|
const primary = new ArtifactReaderFailure("cancelled", "Read cancelled", {
|
|
cause: reason,
|
|
});
|
|
const first = ArtifactReaderFailure.withCleanup(primary, {
|
|
reason: "first close failed",
|
|
resources: ["first"],
|
|
});
|
|
const second = ArtifactReaderFailure.withCleanup(first, {
|
|
reason: "second close failed",
|
|
resources: ["second"],
|
|
});
|
|
expect(second.cancellation).toBe(primary.cancellation);
|
|
expect(second.cancellation?.reason).toBe(reason);
|
|
expect(second.cleanup?.resources).toEqual(["first", "second"]);
|
|
expect(second.cause).toBe(first);
|
|
},
|
|
);
|