Repository navigation
feat(artifacts): inspect and extract Bun standalone module graphs - #6998
Merged
gensokyo-dev merged 7 commits intoOct 29, 2026
Merged
Conversation
…le graphs Adds a Bun standalone artifact reader for Mach-O, PE, ELF and appended trailers, supporting the 36-byte and 52-byte module record layouts. It preserves module names, entry-point details and raw metadata, and exposes contents, sourcemaps, bytecode and module-info as separate entries for safe extraction without executing the binary. Parsing rejects malformed or ambiguous graphs and enforces module-count, retained-byte and expansion limits. Adds synthetic parser tests, CLI and MCP coverage, agent skill guidance, and a verification script for Bun-produced executables. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_016y53PdpyMAp9RSW65fatHe
Codex Review SummaryThis 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. |
Contributor
[Medium impact] The PR appears safe to merge; both numbered findings are fixed and no new actionable issues were found. SummaryAdds static inspection and extraction of Bun standalone module graphs through the existing CLI/MCP artifact tools.
Diagram%%{init: {'theme': 'neutral'}}%%
flowchart TD
A["Native executable"] --> B["Shared section or trailer probe"]
B --> C["Admitted graph claim"]
C --> D["Bounded metadata reads and record decoding"]
D --> E["Combined path-prefix admission"]
E --> F["Inventory and member hashes"]
F --> G["Retained Evidence and selected reads"]
F --> H["Safe output tree"]
H --> I["Extracted stored regions"]
Reviews (4) · Last reviewed commit: "fix(artifacts): bound Bun metadata reads..." · Reviewed by Greptile |
Split Bun recognition into a bounded probe that reads only section headers, length prefixes, and the Offsets/trailer suffix, and a single payload load used by the reader. Inventory classification and extraction admission no longer allocate the whole graph. Match ELF `.bun` section names by comparing only the name bytes and terminator, so many headers sharing one long name cost constant work each. Reject sections whose declared extent ends past EOF instead of reading a silently shortened window. Launch Bun, Docker, and REA in the standalone verifier through the shared owned verifier commands, and release the runtime root only after those command families have settled. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_016y53PdpyMAp9RSW65fatHe
3 tasks done
3 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.
Outcome
CLI/MCP artifact inspection and extraction now recover Bun standalone module graphs from Mach-O
__BUN,__bun, PE/ELF.bunsections and legacy appended trailers. This completes the existing feature PR within static artifact authority; targets are never executed and no provider is added.Known 36/52-byte layouts are structural labels, not detected compiler versions. Inventory retains raw flags/enums, names or lossless hex, module identities, source extents and hashes; bytecode and Bun sourcemaps remain opaque stored regions. Malformed pointers, ambiguous layouts and unsupported formats fail explicitly.
Implementation
The current artifact factory serves both adapters.
ArtifactFileSourceowns selected-path validation, hash binding, buffered streams and cleanup retry. Completed probes are reused only for the same admitted source state. Metadata reads use exact extents with a 256 KiB / 1,024-range cache, plus a 256 MiB cumulative physical-read budget checked before allocation/I/O. Module-count admission precedes table allocation. The shared path owner preflights a 250,000-prefix combined tree budget before allocating destinations; shared prefixes count once.Reader-owned
entry_point_logical_pathenables exact retained-inventory lookup and selected content-node reads without reconstructing virtual paths. Full Evidence remains accessible. Unsafe, non-UTF-8 or deeper-than-256-part virtual names use indexed destinations while retaining original source facts and limitations. Capacity refusals name the effective limit and recovery; no runtime override or partial extraction is claimed.Executed validation
099c511ab: 97 focused tests / 9 files passed, including actual CLI/MCP, shared .NET paths, cleanup and lifecycle checks. Typecheck/lint, docs, catalog generation/check, formatting and discovery of all 2,847 files passed.9bdcf5612and pass after the fix: scattered tiny pointers amplify page reads; disjoint deep paths bypass combined tree admission. A shared-prefix CLI control stays complete. Additional regressions prove cumulative read refusal performs no next I/O and failed path reservations consume no partial capacity. Both threads have root-cause and structural-fix explanations.a108a1b81independently reproduces both variants (39 passed / 2 failed). No Node SEA behavior was changed. Final099c511abpassed every selected upstream CI lane (run 40889395271): 21,960 source tests / 16 skipped and all eight built shards. Final Greptile review completed with 5/5 confidence, 36 files reviewed, zero new comments and no unresolved threads. No merge bypass is needed. An earlier PR-owned description-wording failure was corrected and rechecked, not bypassed.Completed task costs
Two paired fresh-process runs, in alternating/reversed order, found OpenCode's entry module and content digest. Before (
a8bc0859a): generic declared-ID lookup through inventory pages. After (099c511ab): reader-owned exact logical path and the same content-node lookup. Both runs selected theartifact,session,applicationMCP tool families. This includes initialization/instructions, compact input/output schemas and catalog, client validation, open, inspect, retained views and close.Tokenx 1.3.0 estimates count all serialized JSON-RPC frames, including catalog and both text/structured replies; these are not billed model tokens. Catalog contributions are 51,886 before / 51,884 after. This measured ID-scan workflow uses 91.6% fewer estimated tokens; other caller-derived lookup strategies were not measured. Filesystem caches were warm, with fresh client/server processes; true cold-cache and model-inference costs are unmeasured. Small timing differences do not establish a general speedup.
Separate two-CPU CLI summary + retained-Evidence observations: 64 MiB fixture 4.39 s / 5.44 CPU s / 374 MB before versus 4.18 s / 5.34 CPU s / 348 MB after; OpenCode 6.04 s / 7.27 CPU s / 447 MB before versus 6.53 s / 7.62 CPU s / 424 MB after. These are single warm-cache observations: OpenCode CLI was slower while using less memory. Real-data tasks used a 1.5 GiB process-family guard. Full extraction was correctness-checked separately; independent verification CPU is unmeasured.
Author readiness
Human owner: @mvanhorn
Before merge
type(scope): outcome.