mirror of
https://github.com/morluto/rea
synced 2026-10-27 14:42:18 -04:00
5fa4defcbc
* feat(artifacts): read Godot PCK packs Add a Godot Engine PCK artifact reader for standalone packs and packs embedded behind an executable trailer (formats 2 and 3). Members are uncompressed byte ranges verified against their declared MD5 on read. Encrypted directories, sparse bundles, patch removal entries, unknown flags and format 1 fail closed as unavailable; encrypted members are reported without being read. inspect-artifact and extract-artifact recognize standalone packs by their GDPC magic. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(artifacts): bound Godot PCK metadata and own member streams Cap member paths at 4096 bytes and the retained directory at 64 MiB before allocation. Read members with positional chunk reads through pipeline so cancellation is typed, abandoned consumers release their source, and the shared descriptor stays reader-owned. Retain the root descriptor for godot-pck inventory, as for ZIP and universal Mach-O. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * feat(artifacts): complete Godot PCK facts, integrity and selected views * fix(artifacts): preserve atomic-root inventory Evidence * fix(artifacts): bound aggregate PCK member expansion --------- Co-authored-by: Samucahub <151155051+Samucahub@users.noreply.github.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: gensokyo-dev <342580529+gensokyo-dev@users.noreply.github.com>
64 lines
2.3 KiB
TypeScript
64 lines
2.3 KiB
TypeScript
import { writeFile, stat } from "node:fs/promises";
|
|
import { join } from "node:path";
|
|
import { expect, it } from "vitest";
|
|
import { createTestTempDirectory } from "../../fixtures/temporaryDirectory.js";
|
|
import { buildGodotPck, pckU64 } from "../../fixtures/godotPck.js";
|
|
import {
|
|
scanArtifactInventory,
|
|
materializeArtifactInventory,
|
|
} from "../../fixtures/artifactInventory.js";
|
|
import { parseBinaryTarget } from "../../../src/application/BinaryTargetResolver.js";
|
|
import { elf } from "../../../src/domain/binaryTarget.fixture.js";
|
|
|
|
it("binds extraction to the original carrier even if a changed directory names identical payloads", async () => {
|
|
const root = await createTestTempDirectory("rea-pck-extraction-identity-");
|
|
const source = join(root, "game.pck");
|
|
const bytes = buildGodotPck(4, [{ path: "res://a.txt", data: "unchanged" }]);
|
|
await writeFile(source, bytes);
|
|
const snapshot = await scanArtifactInventory(source);
|
|
// A version field changes the carrier identity without changing any member's
|
|
// path, length or bytes. Per-member SHA-256 checks alone cannot detect this.
|
|
bytes.writeUInt32LE(7, 12);
|
|
await writeFile(source, bytes);
|
|
const output = join(root, "out");
|
|
await expect(
|
|
materializeArtifactInventory(
|
|
{
|
|
inputPath: source,
|
|
inputFormat: "godot-pck",
|
|
outputRoot: output,
|
|
environment: {},
|
|
integrityPolicy: "fail",
|
|
},
|
|
source,
|
|
snapshot,
|
|
),
|
|
).rejects.toMatchObject({ reason: "integrity" });
|
|
await expect(stat(output)).rejects.toMatchObject({ code: "ENOENT" });
|
|
});
|
|
|
|
it("preserves native defaults and explicit native selection for embedded carriers", async () => {
|
|
const root = await createTestTempDirectory("rea-pck-native-selection-");
|
|
const source = join(root, "game.x86_64");
|
|
const pack = buildGodotPck(4, [{ path: "res://a.txt", data: "a" }]);
|
|
await writeFile(
|
|
source,
|
|
Buffer.concat([
|
|
elf(2, 1, 62),
|
|
pack,
|
|
pckU64(pack.length),
|
|
Buffer.from("GDPC"),
|
|
]),
|
|
);
|
|
expect(await parseBinaryTarget(source)).toMatchObject({
|
|
ok: true,
|
|
value: { kind: "executable", format: "elf" },
|
|
});
|
|
expect(
|
|
await parseBinaryTarget(source, { targetKind: "executable" }),
|
|
).toMatchObject({
|
|
ok: true,
|
|
value: { kind: "executable", format: "elf", architecture: "x86_64" },
|
|
});
|
|
});
|