[PR #7000] [MERGED] feat(artifacts): inventory and extract Node.js single executable application blobs #7562

Closed
opened 2026-11-03 13:38:43 +00:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/morluto/rea/pull/7000
Author: @mvanhorn
Created: 10/24/2026
Status: ✅ Merged
Merged: 10/24/2026
Merged by: @morluto

Base: main ← Head: fix/node-sea-blob


📝 Commits (3)

  • fc1d7e7 feat(artifacts): inventory and extract Node.js single executable application blobs
  • 305dddd fix(artifacts): reuse PE resource facts and bound SEA asset tables
  • b5a7256 fix(artifacts): make SEA metadata construction cancellable

📊 Changes

26 files changed (+3151 additions, -17 deletions)

View changed files

📝 docs/cli.md (+10 -0)
➕ docs/node-sea.md (+91 -0)
📝 package.json (+1 -0)
➕ scripts/verify-node-sea.mjs (+81 -0)
📝 src/artifacts/ArtifactReader.ts (+1 -0)
➕ src/artifacts/NodeSeaArtifactReader.test.ts (+585 -0)
➕ src/artifacts/NodeSeaArtifactReader.ts (+446 -0)
📝 src/artifacts/extraction/ArtifactExtraction.ts (+5 -0)
📝 src/artifacts/inventory/ArtifactGraphConstruction.ts (+3 -1)
📝 src/artifacts/inventory/classify.ts (+13 -1)
📝 src/artifacts/inventory/reader.ts (+10 -1)
📝 src/artifacts/inventory/scanReader.ts (+9 -2)
➕ src/artifacts/nodeSea/NodeSea.fixture.ts (+238 -0)
➕ src/artifacts/nodeSea/NodeSeaBlob.test.ts (+245 -0)
➕ src/artifacts/nodeSea/NodeSeaBlob.ts (+350 -0)
➕ src/artifacts/nodeSea/NodeSeaLocation.ts (+669 -0)
📝 src/contracts/artifactToolContracts.ts (+2 -2)
📝 src/domain/analysisSnapshot.ts (+1 -0)
📝 src/domain/analysisView/artifactInventoryView.ts (+2 -1)
📝 src/domain/artifactFormatMetadata.ts (+35 -0)

...and 6 more files

📄 Description

Summary

A Node.js single executable application (SEA) is the node binary with a NODE_SEA_BLOB injected: the main script, an optional snapshot or code cache, and named assets. Before this change inspect-artifact saw such a file only as a plain Mach-O, ELF or PE executable, and extract-artifact had nothing to extract. This adds a node-sea artifact reader so the blob is inventoried and its stored members can be extracted; the executable itself is never started. No related issue; this is a new static format in the existing artifact graph.

Problem and expected behavior

An analyst who wants the shipped JavaScript of a SEA today has to find the blob and decode Node's layout by hand. Expected: inspect-artifact reports root format node-sea with flags, code path and fuse observations, and lists the main script, snapshot or code cache, and each asset by name; extract-artifact writes their stored bytes through the existing safe output tree.

Change and scope

src/artifacts/nodeSea/NodeSeaLocation.ts locates the blob in Mach-O __NODE_SEA_BLOB sections, ELF notes owned by NODE_SEA_BLOB, and PE RCDATA resources named NODE_SEA_BLOB. NodeSeaBlob.ts decodes the Node v24 layout. NodeSeaArtifactReader builds members.

For ELF, PT_NOTE segments are authoritative, as at runtime; SHT_NOTE sections are read only when no program-header table is readable. The real postject-injected aarch64 binary below carries stale section entries that start mid-note. For PE, a bounded name probe runs before the shared resource parser, so a malformed resource tree in an ordinary PE stays a native-classification concern.

Truncation, unknown flags, invalid UTF-8, duplicate asset names and conflicting blobs fail closed. Limits are in docs/node-sea.md. Asset count and name-byte admission bound retained metadata independently of body sizes; decoding and inventory construction yield for cancellation, and member construction no longer retains a second full array. Not included: decoding V8 snapshots or code caches, or any execution. No new tool; the existing artifact contracts carry the new format. AI was used for assistance.

Follow the contribution scope.
Unresolved scope, authority, side effects, or required verification block
integration. Link the required maintainer scope decision for new providers or
capabilities involving target execution, injection, mutation, or protection
recovery; ordinary fixes within existing boundaries may state "not applicable".
Draft PRs may leave the scope decision pending and the readiness and merge checklists
unchecked. Maintainers can help resolve open questions.

Contract and boundary impact

  • Semantic owner and earliest changed stage: artifact inventory classification (src/artifacts/inventory/classify.ts) and the artifact reader registry.
  • Contribution scope fit and linked maintainer decision: static format inspection and extraction of a local file within existing artifact authority; separate scope decision not applicable.
  • CLI and MCP/tool-catalog contract: no new tool or flag. inspect_artifact / extract_artifact accept the new node-sea root format; the artifact format enum gains node-sea and node-sea-entry.
  • Provider, bridge, target-format, or platform compatibility: portable TypeScript, no provider. Mach-O (including universal), ELF and PE carriers.
  • Evidence, artifact, provenance, or reconstruction contract: new format_metadata kinds for the root and entries; raw flags, code path, blob location and fuse observations are retained.
  • Target selection, authority, upstream behavior, and cleanup details (if applicable): unchanged; extraction uses the existing safe output tree and never overwrites.
  • Generated metadata (docs/public/product-catalog.json), package, or installation impact (CI generates and validates ignored catalogs and skills/; edit authored instructions in .agents/skills/reverse-engineer-anything/ and never commit build outputs): adds a verify:node-sea package script. No committed build outputs.

Expected effects (check known effects; use documentation-only on its own).
Unchecked items do not establish absence; leave uncertainties visible.

  • Read existing files or captured data.
  • Launch or attach to a process.
  • Inject instrumentation or run scripts/code.
  • Change process memory, registers, files, or configuration.
  • Contact network services.
  • Recover protected code or work around protections.
  • Documentation or usability only; no target interaction.
  • Not sure yet; investigation or maintainer guidance needed.

Evidence and regression coverage

  • Tests added or updated: src/artifacts/nodeSea/NodeSeaBlob.test.ts and src/artifacts/NodeSeaArtifactReader.test.ts (Mach-O, universal, ELF and PE carriers; flags and fuses; a stale SHT_NOTE entry beside a valid PT_NOTE; a non-SEA PE with a cyclic resource tree; the large-PE admission limit; truncated, unknown and conflicting blobs), tests/acceptance/nodeSeaCli.test.ts, tests/boundary/mcp/nodeSeaMcp.test.ts. Fixtures are synthetic; no binaries are committed.
  • Base reproduction or other evidence: with the released CLI, inspect-artifact on a SEA reports a plain native executable and extract-artifact has nothing to extract. Executed against a real Node 24.22.1 linux-arm64 SEA (not committed), built with node --experimental-sea-config and postject with useCodeCache: true and two assets. Before the PT_NOTE change this binary failed with Node SEA ELF note table is truncated.
  • User-visible CLI/MCP output (if applicable): see below.
  • Remaining proof gaps: no real Mach-O or PE SEA was exercised (synthetic coverage only). Older blob layouts without the exec-argument byte are not supported.
$ rea inspect-artifact hello-sea --json | jq ...
root: node-sea
  main-script  app.js
  code-cache   __node_sea__/code-cache
  asset        config.json
  asset        greeting.txt

$ rea extract-artifact hello-sea --json   # output root contains:
app.js  config.json  greeting.txt  __node_sea__/code-cache

The extracted app.js and greeting.txt are byte-identical to the build inputs (cmp).

For evidence-bearing changes:

  • Observed, derived, and inferred claims remain distinguishable.
  • Artifact identity, source provenance, and failed attempts remain preserved.
  • Unsupported, incomplete, unavailable, or uncertain outcomes remain visible.

Validation performed

Review follow-up b5a7256b7; macOS arm64, pinned Node 24.22.1 and npm 11.16.0:

  • npm run test:focused -- src/artifacts/nodeSea/NodeSeaBlob.test.ts src/artifacts/NodeSeaArtifactReader.test.ts tests/acceptance/nodeSeaCli.test.ts tests/boundary/mcp/nodeSeaMcp.test.ts - 56 tests passed. Covers parser limits, in-flight cancellation, close during inventory construction, compiled CLI inventory/extraction, and both MCP schema profiles, including refusal of an empty-body table above the record bound.
  • npm run check - passed (typecheck, lint, module boundaries, architecture guards).
  • npm run docs:check - passed, including 9 README consistency tests.

The author's earlier real Linux arm64 SEA inventory/extraction evidence above was not rerun for this cancellation follow-up. Real Mach-O and PE producer coverage remains unverified. No resource benchmarks were run.

Compatibility, safety, and release

  • Breaking changes or migration steps: none. Files that previously classified as plain native executables now classify as node-sea only when a valid blob is found.
  • Real Hopper/Ghidra, browser, or OS coverage: macOS arm64 with a Linux arm64 carrier; no provider involved.
  • Package or release metadata impact: one new package script (verify:node-sea).
  • Security, privacy, process, or containment review: the input is never executed; parsing is bounded and extraction goes through the existing safe output tree.

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.

Demo

demo


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/morluto/rea/pull/7000 **Author:** [@mvanhorn](https://github.com/mvanhorn) **Created:** 10/24/2026 **Status:** ✅ Merged **Merged:** 10/24/2026 **Merged by:** [@morluto](https://github.com/morluto) **Base:** `main` ← **Head:** `fix/node-sea-blob` --- ### 📝 Commits (3) - [`fc1d7e7`](https://github.com/morluto/rea/commit/fc1d7e71b191a98b4445123fffeef0a88d9f3e18) feat(artifacts): inventory and extract Node.js single executable application blobs - [`305dddd`](https://github.com/morluto/rea/commit/305dddd5c13b1f982edf78db3029652e487b703d) fix(artifacts): reuse PE resource facts and bound SEA asset tables - [`b5a7256`](https://github.com/morluto/rea/commit/b5a7256b759b820ae02dfe83c3c3b2267923e8e0) fix(artifacts): make SEA metadata construction cancellable ### 📊 Changes **26 files changed** (+3151 additions, -17 deletions) <details> <summary>View changed files</summary> 📝 `docs/cli.md` (+10 -0) ➕ `docs/node-sea.md` (+91 -0) 📝 `package.json` (+1 -0) ➕ `scripts/verify-node-sea.mjs` (+81 -0) 📝 `src/artifacts/ArtifactReader.ts` (+1 -0) ➕ `src/artifacts/NodeSeaArtifactReader.test.ts` (+585 -0) ➕ `src/artifacts/NodeSeaArtifactReader.ts` (+446 -0) 📝 `src/artifacts/extraction/ArtifactExtraction.ts` (+5 -0) 📝 `src/artifacts/inventory/ArtifactGraphConstruction.ts` (+3 -1) 📝 `src/artifacts/inventory/classify.ts` (+13 -1) 📝 `src/artifacts/inventory/reader.ts` (+10 -1) 📝 `src/artifacts/inventory/scanReader.ts` (+9 -2) ➕ `src/artifacts/nodeSea/NodeSea.fixture.ts` (+238 -0) ➕ `src/artifacts/nodeSea/NodeSeaBlob.test.ts` (+245 -0) ➕ `src/artifacts/nodeSea/NodeSeaBlob.ts` (+350 -0) ➕ `src/artifacts/nodeSea/NodeSeaLocation.ts` (+669 -0) 📝 `src/contracts/artifactToolContracts.ts` (+2 -2) 📝 `src/domain/analysisSnapshot.ts` (+1 -0) 📝 `src/domain/analysisView/artifactInventoryView.ts` (+2 -1) 📝 `src/domain/artifactFormatMetadata.ts` (+35 -0) _...and 6 more files_ </details> ### 📄 Description ## Summary A Node.js single executable application (SEA) is the `node` binary with a `NODE_SEA_BLOB` injected: the main script, an optional snapshot or code cache, and named assets. Before this change `inspect-artifact` saw such a file only as a plain Mach-O, ELF or PE executable, and `extract-artifact` had nothing to extract. This adds a `node-sea` artifact reader so the blob is inventoried and its stored members can be extracted; the executable itself is never started. No related issue; this is a new static format in the existing artifact graph. ## Problem and expected behavior An analyst who wants the shipped JavaScript of a SEA today has to find the blob and decode Node's layout by hand. Expected: `inspect-artifact` reports root format `node-sea` with flags, code path and fuse observations, and lists the main script, snapshot or code cache, and each asset by name; `extract-artifact` writes their stored bytes through the existing safe output tree. ## Change and scope `src/artifacts/nodeSea/NodeSeaLocation.ts` locates the blob in Mach-O `__NODE_SEA_BLOB` sections, ELF notes owned by `NODE_SEA_BLOB`, and PE RCDATA resources named `NODE_SEA_BLOB`. `NodeSeaBlob.ts` decodes the Node v24 layout. `NodeSeaArtifactReader` builds members. For ELF, `PT_NOTE` segments are authoritative, as at runtime; `SHT_NOTE` sections are read only when no program-header table is readable. The real postject-injected aarch64 binary below carries stale section entries that start mid-note. For PE, a bounded name probe runs before the shared resource parser, so a malformed resource tree in an ordinary PE stays a native-classification concern. Truncation, unknown flags, invalid UTF-8, duplicate asset names and conflicting blobs fail closed. Limits are in `docs/node-sea.md`. Asset count and name-byte admission bound retained metadata independently of body sizes; decoding and inventory construction yield for cancellation, and member construction no longer retains a second full array. Not included: decoding V8 snapshots or code caches, or any execution. No new tool; the existing artifact contracts carry the new format. AI was used for assistance. Follow the [contribution scope](https://github.com/morluto/rea/blob/main/CONTRIBUTING.md#contribution-scope). Unresolved scope, authority, side effects, or required verification block integration. Link the required maintainer scope decision for new providers or capabilities involving target execution, injection, mutation, or protection recovery; ordinary fixes within existing boundaries may state "not applicable". Draft PRs may leave the scope decision pending and the readiness and merge checklists unchecked. Maintainers can help resolve open questions. ## Contract and boundary impact - Semantic owner and earliest changed stage: artifact inventory classification (`src/artifacts/inventory/classify.ts`) and the artifact reader registry. - Contribution scope fit and linked maintainer decision: static format inspection and extraction of a local file within existing artifact authority; separate scope decision not applicable. - CLI and MCP/tool-catalog contract: no new tool or flag. `inspect_artifact` / `extract_artifact` accept the new `node-sea` root format; the artifact format enum gains `node-sea` and `node-sea-entry`. - Provider, bridge, target-format, or platform compatibility: portable TypeScript, no provider. Mach-O (including universal), ELF and PE carriers. - Evidence, artifact, provenance, or reconstruction contract: new `format_metadata` kinds for the root and entries; raw flags, code path, blob location and fuse observations are retained. - Target selection, authority, upstream behavior, and cleanup details (if applicable): unchanged; extraction uses the existing safe output tree and never overwrites. - Generated metadata (`docs/public/product-catalog.json`), package, or installation impact (CI generates and validates ignored catalogs and `skills/`; edit authored instructions in `.agents/skills/reverse-engineer-anything/` and never commit build outputs): adds a `verify:node-sea` package script. No committed build outputs. Expected effects (check known effects; use documentation-only on its own). Unchecked items do not establish absence; leave uncertainties visible. - [x] Read existing files or captured data. - [ ] Launch or attach to a process. - [ ] Inject instrumentation or run scripts/code. - [ ] Change process memory, registers, files, or configuration. - [ ] Contact network services. - [ ] Recover protected code or work around protections. - [ ] Documentation or usability only; no target interaction. - [ ] Not sure yet; investigation or maintainer guidance needed. ## Evidence and regression coverage - Tests added or updated: `src/artifacts/nodeSea/NodeSeaBlob.test.ts` and `src/artifacts/NodeSeaArtifactReader.test.ts` (Mach-O, universal, ELF and PE carriers; flags and fuses; a stale `SHT_NOTE` entry beside a valid `PT_NOTE`; a non-SEA PE with a cyclic resource tree; the large-PE admission limit; truncated, unknown and conflicting blobs), `tests/acceptance/nodeSeaCli.test.ts`, `tests/boundary/mcp/nodeSeaMcp.test.ts`. Fixtures are synthetic; no binaries are committed. - Base reproduction or other evidence: with the released CLI, `inspect-artifact` on a SEA reports a plain native executable and `extract-artifact` has nothing to extract. Executed against a real Node 24.22.1 linux-arm64 SEA (not committed), built with `node --experimental-sea-config` and postject with `useCodeCache: true` and two assets. Before the `PT_NOTE` change this binary failed with `Node SEA ELF note table is truncated`. - User-visible CLI/MCP output (if applicable): see below. - Remaining proof gaps: no real Mach-O or PE SEA was exercised (synthetic coverage only). Older blob layouts without the exec-argument byte are not supported. ```text $ rea inspect-artifact hello-sea --json | jq ... root: node-sea main-script app.js code-cache __node_sea__/code-cache asset config.json asset greeting.txt $ rea extract-artifact hello-sea --json # output root contains: app.js config.json greeting.txt __node_sea__/code-cache ``` The extracted `app.js` and `greeting.txt` are byte-identical to the build inputs (`cmp`). For evidence-bearing changes: - [x] Observed, derived, and inferred claims remain distinguishable. - [x] Artifact identity, source provenance, and failed attempts remain preserved. - [x] Unsupported, incomplete, unavailable, or uncertain outcomes remain visible. ## Validation performed Review follow-up `b5a7256b7`; macOS arm64, pinned Node 24.22.1 and npm 11.16.0: - `npm run test:focused -- src/artifacts/nodeSea/NodeSeaBlob.test.ts src/artifacts/NodeSeaArtifactReader.test.ts tests/acceptance/nodeSeaCli.test.ts tests/boundary/mcp/nodeSeaMcp.test.ts` - 56 tests passed. Covers parser limits, in-flight cancellation, close during inventory construction, compiled CLI inventory/extraction, and both MCP schema profiles, including refusal of an empty-body table above the record bound. - `npm run check` - passed (typecheck, lint, module boundaries, architecture guards). - `npm run docs:check` - passed, including 9 README consistency tests. The author's earlier real Linux arm64 SEA inventory/extraction evidence above was not rerun for this cancellation follow-up. Real Mach-O and PE producer coverage remains unverified. No resource benchmarks were run. ## Compatibility, safety, and release - Breaking changes or migration steps: none. Files that previously classified as plain native executables now classify as `node-sea` only when a valid blob is found. - Real Hopper/Ghidra, browser, or OS coverage: macOS arm64 with a Linux arm64 carrier; no provider involved. - Package or release metadata impact: one new package script (`verify:node-sea`). - Security, privacy, process, or containment review: the input is never executed; parsing is bounded and extraction goes through the existing safe output tree. ## Author readiness Human owner: @mvanhorn - [x] 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. - [x] I checked the evidence above, confirmed it supports the current change, and recorded meaningful validation gaps. - [x] 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. ## Demo ![demo](https://raw.githubusercontent.com/mvanhorn/pr-demo-assets/main/rea/2026-10-24-011-feat-node-sea-blob/preview.gif) <video src="https://mvanhorn.github.io/pr-demo-assets/rea/2026-10-24-011-feat-node-sea-blob/out.mp4" controls width="720"></video> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-03 13:38:43 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
morluto/rea#7562
No description provided.