Repository navigation
refactor(artifacts): break the artifacts-firmware and artifacts-gpu import cycles - #11331
Merged
Merged
Conversation
BinaryContainer imports only domain modules and is shared by artifacts, firmware, gpu, go, il2cpp, python, rust and native. Living under src/native made artifacts and firmware import native for its failure types and BinaryReader. Pure move: git mv plus import specifier updates.
The FIT artifact reader in src/artifacts parses embedded devicetree blobs with the parser that lived under src/firmware, while firmware's providers import src/artifacts: the two units imported each other. The parser and its fixture are pure and now sit beside domain/firmware/devicetree.ts. Pure move: git mv plus import specifier and baseline key updates.
Codex Review Summary: ❌ FailedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
19 tasks
Contributor
[Medium impact] The PR appears safe to merge; no actionable issues were found. SummaryMoves shared binary and device-tree code into the domain layer, and moves PE resource readers and LZ4 decoding into artifacts.
Diagram%%{init: {'theme': 'neutral'}}%%
flowchart TD
FIT["Artifacts: FIT reader"] --> DT["Domain: device-tree parser"]
FW["Firmware provider"] --> DT
DT --> BC["Domain: binary readers and failures"]
PE["Artifacts: PE resource readers"] --> BC
NP["Native PE providers"] --> PE
U["UnityFS: 64 MiB budget"] --> LZ["Artifacts: shared LZ4 decoder"]
G["GPU: 128 MiB budget"] --> LZ
LZ --> BC
Reviews (4) · Last reviewed commit: "Merge branch 'main' into refactor/domain..." · Reviewed by Greptile |
* refactor(artifacts): move the LZ4 block decoder into src/artifacts Pure move: git mv plus import specifier updates. The next commit removes its GPU-specific budget. * refactor(artifacts): take the LZ4 output budget from the caller decodeLz4Block bounded every decode by the GPU object budget and threw through rejectGpu, so UnityFS decoding in src/artifacts imported src/gpu while gpu imports artifacts. Callers now pass their budget: GPU payloads keep GPU_OBJECT_BYTES; UnityFS passes its 64 MiB block bound, which its size checks already enforce before decoding. Malformed blocks still throw BinaryFormatFailure with the same messages.
…les from the layer baseline
19 tasks
#11347) refactor(artifacts): move the PE resource layout and parser into src/artifacts/pe The Node SEA and Deno standalone readers in src/artifacts locate PE resources with the layout and parser that lived under src/native/pe, while those modules already read through src/artifacts (ArtifactReaderFailure, assertArtifactReadActive). Pure move: git mv plus import specifier, baseline key and spec path updates.
This was referenced Nov 15, 2026
Merged
12 of 22 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Breaks the
artifacts <-> firmwareandartifacts <-> gpumutual imports.BinaryContainer(failure types,BinaryReader, file-mapping helpers) moves fromsrc/native/metadata/tosrc/domain/binaryContainer.ts; the devicetree parser and its fixture move fromsrc/firmware/devicetree/tosrc/domain/firmware/; the raw LZ4 block decoder moves fromsrc/gpu/tosrc/artifacts/and takes its output budget from the caller. Part of plan W9 (layer enforcement). Carries collapsed #11335.Problem and expected behavior
Firmware and GPU providers read targets through
src/artifacts/, but artifacts imported back:src/artifacts/fit/FitStructure.ts) parsed embedded devicetree blobs withsrc/firmware/devicetree/DevicetreeParser.ts. The parser imports only domain modules plusBinaryFormatFailurefromsrc/native/metadata/BinaryContainer.ts, which itself imports only domain modules but sat undersrc/native/, making artifacts and firmware import native for a failure type andBinaryReader.src/artifacts/UnityFsStructures.ts) importeddecodeLz4Blockfromsrc/gpu/. The decoder bounded every decode byGPU_OBJECT_BYTES(128 MiB) and threw throughrejectGpu, so UnityFS inherited a GPU budget it never meant to use (its own checks cap blocks at 64 MiB before decoding).Expected: the pure modules live in the domain layer beside the format declarations they implement (
domain/firmware/devicetree.ts,domain/virtualFileMapping.ts); the shared LZ4 decoder lives in the shared reader unit and each caller states its budget; artifacts imports neither firmware nor gpu. Behaviour is unchanged.Change and scope
Commit 1 (pure move):
src/native/metadata/BinaryContainer.tstosrc/domain/binaryContainer.tswithgit mv, specifier rewrites in its importers, and the path in theraw-buffer-readarchitecture guard anddocs/development/tool-design.md.BinaryContainer.test.tsstays insrc/native/metadata/because it also exercisesreadBinaryContainer.Commit 2 (pure move):
DevicetreeParser.ts,DevicetreeParser.test.tsandDevicetree.fixture.tstosrc/domain/firmware/devicetreeParser.ts,devicetreeParser.test.tsanddevicetree.fixture.ts, specifier rewrites, and the two per-guard baseline keys renamed (counts unchanged).Collapsed refactor(artifacts): break the artifacts-gpu import cycle #11335, commit 1 (pure move):
src/gpu/Lz4Block.tsand its test tosrc/artifacts/.Collapsed refactor(artifacts): break the artifacts-gpu import cycle #11335, commit 2:
decodeLz4Block(input, expected, maximumBytes, signal?). Malformed blocks throwBinaryFormatFailure("malformed", …)with unchanged messages (exactly whatrejectGputhrew); an over-budget declaration throwsBinaryResourceFailurenaming the caller's budget. GPU payloads passGPU_OBJECT_BYTES(unchanged); UnityFS passes its 64 MiBMAX_BLOCK_UNCOMPRESSED_BYTES, which its table and block checks already enforce.Last commit:
scripts/lib/module-layers.baseline.jsondropsartifacts <-> firmwareandartifacts <-> gpu.Collapsed refactor(artifacts): move the PE resource reader into src/artifacts/pe #11347 (pure move): the PE resource layout, parser and tree facts (with test and fixture) to
src/artifacts/pe/, specifier rewrites, threeraw-buffer-readbaseline keys renamed and the path indocs/specs/artifacts/deno-standalone/plan.md.artifacts -> nativeis down to the twolipoimports ofMachOSliceArtifactReader.The pure-move commits will be listed in
.git-blame-ignore-revsafter merge.docs/verification/gpu-code-objects-2026-10-21.jsonkeeps the old test path because it records a past run.Not included:
artifacts <-> javascriptand the remainingartifacts <-> nativeimports (follow-ups; both need an injected port rather than a move) andcatalogIdentity.ts <-> recordedCatalogDigests.ts(#11339).Contribution scope: maintainer-approved W9 approach; no new capability.
Contract and boundary impact
decodeLz4Block, whose callers now own their budget.src/domain/purity holds (the moved modules import only domain).docs/public/product-catalog.json), package, or installation impact: none.Expected effects (check known effects; use documentation-only on its own).
Unchecked items do not establish absence; leave uncertainties visible.
No target interaction changes.
Evidence and regression coverage
src/artifacts/Lz4Block.test.tspasses the budget explicitly and adds a refusal case (a declared length above the caller's budget reportsBinaryResourceFailurewithmaximum_bytesequal to that budget).verify:module-boundaries(pure-layer rule) rejected movingBinaryContainer.test.tsbecause the test importsreadBinaryContainer, so that test stays.resolveModuleImports) has noartifacts -> firmwareorartifacts -> gpuedge after the change (before:FitStructure.ts -> firmware/devicetree/DevicetreeParser.ts,UnityFsStructures.ts -> gpu/Lz4Block.ts);verify:module-boundariesreported both recorded cycles as gone.Validation performed
npm run check:fast(typecheck, lint, module boundaries, architecture guards) — passed after each commit.npm run test:local -- src/native/metadata/BinaryContainer.test.ts src/artifacts/fit/FitStructure.test.ts src/gpu/Lz4Block.test.ts— 65 passed.npm run test:local -- src/domain/firmware/devicetreeParser.test.ts src/artifacts/fit/FitStructure.test.ts src/artifacts/FitArtifactReader.test.ts— 97 passed.npm run test:local -- src/artifacts/Lz4Block.test.ts src/gpu/GpuPayloadCodec.test.ts src/artifacts/UnityFsArtifactReader.test.ts— 36 passed.npm run verify:module-boundaries— passed after the baseline edit.npm run test:local -- src/artifacts/pe/PeResourceParser.test.ts src/artifacts/NodeSeaArtifactReader.test.ts src/artifacts/deno/DenoStandaloneArtifactReader.test.ts src/native/pe/PeResourcesProvider.test.ts(collapsed refactor(artifacts): move the PE resource reader into src/artifacts/pe #11347) — 203 passed.Compatibility, safety, and release
Author readiness
Human owner:
Before merge
type(scope): outcome.