Skip to content

feat(artifacts): inspect and extract Bun standalone module graphs - #6998

Merged
gensokyo-dev merged 7 commits into
morluto:mainfrom
mvanhorn:fix/bun-standalone-module-graph
Oct 29, 2026
Merged

gensokyo-dev merged 7 commits into
morluto:mainfrom
mvanhorn:fix/bun-standalone-module-graph

Conversation

@mvanhorn

@mvanhorn mvanhorn commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

Outcome

CLI/MCP artifact inspection and extraction now recover Bun standalone module graphs from Mach-O __BUN,__bun, PE/ELF .bun sections 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. ArtifactFileSource owns 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_path enables 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

  • Final 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.
  • Both P1 review regressions fail at 9bdcf5612 and 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.
  • The original reader on current contracts fails four earlier boundary regressions: full-payload metadata reads, repeated probes, buffered-producer cleanup and selected-parent replacement. The integrated reader passes them, plus deep-name preservation and pre-allocation count admission.
  • Six real inputs passed CLI inspection/extraction and SDK stdio MCP checks again after the P1 fixes. Independent LLVM section inventories and Python struct/range hashes verified all 1,373 stored regions, source SHA and extracted bytes. Owned outputs were removed; no guard stops or surviving children occurred.
  • Inputs: digest-verified Bun 1.3.3/1.4.4 trusted compilers produced legacy appended ELF and current PE/ELF/Mach-O fixtures, bytecode/maps and a 64 MiB asset. Public OpenCode 1.19.5 (214 MB, release digest verified) supplies 1,356 modules. Targets were never executed; Windows/macOS inputs were parsed on Linux. Other Bun releases and REA running on those hosts are unverified.
  • Earlier broad related checks: 329 passed / 1 Node SEA assertion failed; pure main a108a1b81 independently reproduces both variants (39 passed / 2 failed). No Node SEA behavior was changed. Final 099c511ab passed 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 the artifact,session,application MCP tool families. This includes initialization/instructions, compact input/output schemas and catalog, client validation, open, inspect, retained views and close.

Workflow Calls / occurrence pages Whole-frame token estimate Elapsed / CPU Peak family RSS
Original reader + ID scan 20 / 16 719,910 6.04–6.05 s / 9.47–9.49 s 586–615 MB
Shared reader + exact path 5 / 1 60,678 5.92–6.01 s / 8.86–9.39 s 549–552 MB

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

  • I reviewed the final diff and relevant existing code, understand the change and its edge cases, and take responsibility for the complete PR, including AI-assisted work.
  • I checked the evidence above, confirmed it supports the current change, and recorded meaningful validation gaps.
  • I declare this PR ready for initial maintainer review.

Before merge

  • This PR addresses a concrete problem or an agreed enhancement.
  • Material scope and authority questions are resolved, and any required maintainer scope decision covers the final diff.
  • The PR has one focused outcome and the title follows type(scope): outcome.
  • Related issue is linked, or the reason for not linking one is stated above.
  • Tests cover changed observable behavior and meaningful failure paths.
  • Owning docs, contracts, and generated metadata are updated where needed.
  • User-visible CLI/MCP changes include representative output.
  • I checked the final diff for secrets, unrelated cleanup, and unsupported claims.

…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
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 24, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ⚠️ Failed 2026-10-24T11:49:25.159364Z
We couldn’t complete this review. Comment @codex review to try again.
a4daa97 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@greptile-apps

greptile-apps Bot commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5 Tier: apex

[Medium impact] The PR appears safe to merge; both numbered findings are fixed and no new actionable issues were found.

Summary

Adds static inspection and extraction of Bun standalone module graphs through the existing CLI/MCP artifact tools.

  • The existing artifact tools can now inspect and extract supported Bun module graphs without running the executable.
  • Unsafe and very deep module names use indexed paths while keeping their original names.

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"]
Loading

Reviews (4) · Last reviewed commit: "fix(artifacts): bound Bun metadata reads..." · Reviewed by Greptile

Comment thread scripts/verify-bun-standalone.mjs Resolved
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
@gensokyo-dev gensokyo-dev changed the title feat(artifacts): inventory and extract Bun standalone executable module graphs feat(artifacts): inspect and extract Bun standalone module graphs Oct 29, 2026
@gensokyo-dev
gensokyo-dev merged commit 8188497 into morluto:main Oct 29, 2026
50 checks passed
@morluto morluto mentioned this pull request Nov 11, 2026
3 tasks done
@morluto morluto added area: evidence Evidence, artifacts, and reconstruction enhancement New feature or request labels Nov 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: evidence Evidence, artifacts, and reconstruction enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants