Files
rea/src/domain/artifactExpansionBudget.ts
T
5fa4defcbc feat(artifacts): inspect and extract Godot PCK with retained facts (#3634)
* 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>
2026-10-20 09:53:53 +08:00

24 lines
1.0 KiB
TypeScript

/**
* Shared aggregate plaintext-work ceiling for archive-backed operations.
* ZIP compression and PCK aliases can both multiply hashing and output bytes.
* Charge every readable logical occurrence, including repeated physical ranges.
*
* Keep the existing ZIP policy: a 256 MiB floor and 500 times the encoded archive
* size. Large real packages retain proportionally large budgets without granting
* a fixed per-member allowance. PCK callers use the actual pack span, excluding
* an embedded executable carrier. The safe-integer ceiling preserves exact byte
* accounting at the JSON/number boundary.
*/
export const ARTIFACT_EXPANSION_RATIO = 500;
export const MINIMUM_ARTIFACT_EXPANDED_BYTES = 256 * 1024 * 1024;
/** Largest total readable plaintext bytes for this encoded archive span. */
export const artifactExpansionBudgetBytes = (archiveBytes: number): number =>
Math.max(
MINIMUM_ARTIFACT_EXPANDED_BYTES,
Math.min(
Number.MAX_SAFE_INTEGER,
Math.floor(archiveBytes) * ARTIFACT_EXPANSION_RATIO,
),
);