Repository navigation
fix(runtime-snapshot): trim dependency payload and verify runtime closure - #3096
Merged
Merged
Conversation
Replace the manifest-only assertion with a glob-exclusive file and an unshipped sibling. The fixture detects disabled glob expansion and whole-package copying. Refs #3083 (part B)
Retain the full nested and hoisted closure and snapshot-local native assets. Filter inert dependency trees and redundant sources with manifest entry exemptions, and govern the real Node/Bun CLI graph with an offline inventory regression and a fixture budget. Refs #3083 (part B)
Use the matching Bun loader while recording every JavaScript and TypeScript module extension reached by representative CLI paths. Refs #3083 (part B)
Cover the tracker requirement beyond README and changelog while preserving licenses and every manifest-declared entry root. Refs #3083 (part B)
Keep the fork tracker aligned with the full Part B payload policy. Refs #3083 (part B)
Prove a manifest-named root Markdown asset overrides the dependency pruning convention. Refs #3083 (part B)
Treat macOS /tmp and /private/tmp as the same tree when proving every observed runtime path stays inside the snapshot. Refs #3083 (part B)
code-yeongyu
force-pushed
the
fix/3083-snapshot-closure
branch
from
October 10, 2026 18:41
8221504 to
013679c
Compare
code-yeongyu
marked this pull request as ready for review
October 10, 2026 20:31
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.
Refs #3083 (part B)
Changes
Retain the complete nested/hoisted runtime dependency graph, but omit dependency development trees, root Markdown and extensionless README/changelog/history files, and redundant source TypeScript when an existing built JavaScript entry makes it redundant. Manifest entry roots override directory conventions. Source-only codemode, source assets, skills, licenses, native binaries, and wasm remain.
Extract tree planning and package-root shipping policy from layout. The package-root policy introduced in #3084 is preserved.
Add a real offline CLI inventory regression under both Node and Bun: help, an external TypeScript extension using typebox and SDK types, a faux print turn, Claude executable resolution, photon wasm, and an actual codemode JS tool call. The test asserts successful delivery and snapshot-local runtime paths rather than maintaining a sampled package allowlist. It probes the grep loader but does not assert a native binding loads; the packed-install review recorded
native-unavailableunder both runtimes.Replace the redundant manifest-only shipping assertion with a glob-exclusive file plus an unshipped sibling. Add a dependency fixture bounded to 20 files and less than 4 KiB.
SDK decision
Keep the SDK and its platform executable eagerly snapshot-local. Both runtime inventories resolve the platform executable there. Lazy copying from the original install would fail after an update removes that install; a separate content-addressed store adds ownership/GC and hashing contracts.
A five-trial macOS arm64 probe of the 235,017,328-byte SDK executable measured copy medians of 0.115709 ms under Bun 1.4.2 and 0.098 ms under Bun 1.4.3, both in clone mode. Node 26.7.0 reported clone-or-copy mode with a 135.228209 ms median. These are executable-copy measurements only, not full cold-launch or physical-storage measurements. The paired packed-install run will establish the complete user-visible delta.
Runtime inventory
The latest npm-installed-package probe recorded 260 snapshot paths under Node and 222 under Bun. Node resolved files from these 15 packages:
@anthropic-ai/claude-agent-sdk@anthropic-ai/claude-agent-sdk-darwin-arm64@babel/parser@code-yeongyu/senpi-codemode@earendil-works/chord@earendil-works/pi-pty@silvia-odwyer/photon-node@xterm/headlesscross-spawnisexejitipath-keyshebang-commandshebang-regexwhichBun resolved the same set except
jiti(14 packages). Typebox operations execute through the CLI extension loader's virtual modules, so they produce no external Typebox filesystem path. The list is evidence about the representative scenarios, not an allowlist: all packages in the dependency closure remain eligible for copying.Evidence already captured
TMPDIR=<temporary directory> SENPI_INVENTORY_PACKAGE=<npm-installed package> bun run --cwd packages/coding-agent test test/runtime-snapshot/: 8 files / 24 tests passed against the final materializer and inventory code./tmp→/private/tmpalias in the containment assertion. The check now canonicalizes both sides; the exactTMPDIR=/tmpnpm-install inventory reproduction passes.tsc --noEmit,bun run check, rebuilt runtime-snapshot suite (8 files / 24 tests), and CLI self-test (8/8) all passed.biome check --error-on-warnings;git diff --checkpassed. The preload is excluded by the repository's Biome configuration;node --checkpassed and both runtimes executed it in the inventory.node scripts/check-pr-changelog.mjs --base origin/main: passed after both commits.docs/index.jsentry disappears).Packed-install measurements
Quiet macOS arm64 box; exact baseline
0f23d4cd40and measured head8221504fd7; separate worktrees; each built and packed, then installed with npm into separate run-scoped prefixes. Bun 1.4.2 and 1.4.3 were downloaded only into that run's/tmptree and invoked by full path. Five first launches used fresh HOME, TMPDIR and agent directories. Five direct cold--helplaunches used the resulting snapshot. Values are median / minimum.After measurement, main advanced only in
packages/senpi-codemode/**; the required behind-zero rebase produced reviewed PR head013679c8f8. The measuredpackages/coding-agent/**, root manifest/lock, and build/pack scripts are byte-identical between the measured and rebased heads. The post-rebase real runtime-snapshot suite, including codemode bootstrap inventory, passes 8 files / 24 tests.node_modulesfilesnode_moduleslogical bytesdu -sk)node_modulesallocated KiBPart B reduces median real first launch by 145 ms (7.4%) on Bun 1.4.2 and 93 ms (3.4%) on Bun 1.4.3. Direct snapshot help is effectively unchanged at 42-44 ms and is far below five seconds. The dominant SDK binary remains, so byte savings are intentionally smaller than file-count savings.
The remote cleanup receipt is clean: run directory removed, self-excluding process match zero, and global Bun resolution/version unchanged (
~/.bun/bin/bun,~/.vite-plus/bin/bun; 1.4.2 before and after).No timeout was increased. No package is removed based solely on the representative inventory. The complete graph and native executable remain necessary for upgrade resilience; the dominant SDK logical bytes are not claimed as removed.
Review follow-up (M1, L1, L2, L4)
index.ts,src/helper.ts, and no built JavaScript. It asserts the helper contents copied by the real snapshot materializer.built &&makes the fixture fail with ENOENT for snapshotnode_modules/nested-dep/src/helper.ts; 1 failed / 1 passed, exit 1.bun run --cwd packages/coding-agent test test/runtime-snapshot/dependency-files.test.ts.native-unavailableunder both runtimes. No native binary requirement was added to CI.yaml/dist/doccontain real runtime code.bunx tsc --noEmitexited 0;node scripts/check-pr-changelog.mjs --base origin/mainpassed. Conflict-marker scans andgit diff --checkwere clean. Merge with refreshed origin/main was already up to date (behind 0). No timing work was run.Local evidence hashes (SHA-256):
785af961efc918ec7a46ddda08e9bf71bdfd7d9be75661d542b108fa2dab5f814e97a755ec718150945b2371566350c47da60b5705ebdbc1453384e36149b91ba7cb9b3c897f73b66480d33bf367df6b7aa6126c775663d21152a40f2e87ed8c7d1a98da4187850be6b4e787ce8ce917de43c67316c7eb5a63a5fca674a7f3caKnown gaps (not addressed in this follow-up)
importsmaps. The review found an inactivebabel-srccondition in the current closure; future runtime imports targets under pruned roots remain a known gap.