Skip to content

perf: agent SDK snapshot wiring + bench harness + preview secure-exec dep - #1527

Merged
NathanFlurry merged 3 commits into
mainfrom
stack/perf-agent-sdk-snapshot-wiring-bench-harness-preview-secure-exec-dep-uusymyzz
Jun 25, 2026
Merged

NathanFlurry merged 3 commits into
mainfrom
stack/perf-agent-sdk-snapshot-wiring-bench-harness-preview-secure-exec-dep-uusymyzz

Conversation

@NathanFlurry

@NathanFlurry NathanFlurry commented Jun 25, 2026 •

Copy link
Copy Markdown
Member
  • Pin @secure-exec/* to the secure-exec preview (npm); @agentos-software/* preserved.
  • Clone-at-pinned-version cargo build mechanism (prepare-build) — crates.io has no
    preview track; clone secure-exec at the pinned sha and build cargo local for
    previews. Wired into publish.yaml + darwin.Dockerfile; documented in CLAUDE.md.
  • Rust client: add snapshot_userland_code: None to JsRuntimeConfig initializer.
  • Bundle transform hardening: env-api-keys transform asserts exactly 3 eager
    imports (loud fail on drift); pin @mariozechner/* exactly (direct + overrides).
  • JS-layer session benchmark + baseline gate + vm-vs-node phase traces.
  • Agent SDK snapshot opt-in (pi), MinimalResourceLoader fast path, architecture doc.

@NathanFlurry

Copy link
Copy Markdown
Member Author

Stack for rivet-dev/agentos

Get stack: forklift get 1527
Push local edits: forklift submit
Merge when ready: forklift merge 1527

@NathanFlurry
NathanFlurry force-pushed the stack/perf-agent-sdk-snapshot-wiring-bench-harness-preview-secure-exec-dep-uusymyzz branch from cb6b5d8 to 390511a Compare June 25, 2026 01:51
NathanFlurry and others added 3 commits June 25, 2026 01:10
esbuild bundles the lean pi-SDK graph (the 13 exports loadPiSdkRuntime needs) into a
single IIFE, dist/pi-sdk-snapshot.js, that publishes globalThis.__PI_SDK_RUNTIME__.
- src/snapshot-entry.ts: imports the SDK exports, assigns the runtime global.
- scripts/build-snapshot-bundle.mjs: format:iife, platform:node (node builtins external),
  deep-import plugin to bypass the package exports map (avoids the ~100MB TUI graph the
  adapter skips), provider SDKs kept lazy/external, sha256 sidecar for dep-keying.
  C0 mitigations baked in: import.meta.url pinned to projected guest path; clipboard
  native-addon require made unreachable (DISPLAY=''). 
- package.json build chains build:snapshot; tsconfig excludes the esbuild-only entry.

Validated (host, CJS harness): 13/13 exports populate, ~201ms eval, 880 modules inlined,
7.6MB. Traced top-level fs footprint = 2 deterministic package.json reads only (no net/
sockets/timers/native addons/per-session config). Artifact (dist) is gitignored.

Step 2a of the agent-SDK snapshot goal.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…flag + docs

Foreign fix (the last 2d blocker): build-snapshot-bundle.mjs snapshotSafePlugin now also
lazy-inits pi-tui/dist/utils.js's module-level `new Intl.Segmenter` (an ICU-backed native
External that V8 SnapshotCreator can't serialize) behind a Proxy — created on first use
post-restore, not at module-init. With this, the real full pi SDK bundle snapshots cleanly
and restores with createAgentSession/createAllTools intact (secure-exec Part 22 = ok).
Also adds: config.js package.json inline, env-api-keys sync-require, and the
PI_SNAPSHOT_ENTRY/OUTFILE/STUB_MODULES bisection overrides used to find it.

Flag: agent.snapshot?: boolean on AgentSoftwareDescriptor (default false, opt-in, automatic
fallback to per-session dynamic-import for SDKs that aren't snapshot-safe or fail to snapshot).

Docs: agent.snapshot field + 'SDK snapshotting & snapshot-safety' rules in
custom-software/definition.mdx.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
… dep

- Pin @secure-exec/* to the secure-exec preview (npm); @agentos-software/* preserved.
- Clone-at-pinned-version cargo build mechanism (prepare-build) — crates.io has no
  preview track; clone secure-exec at the pinned sha and build cargo local for
  previews. Wired into publish.yaml + darwin.Dockerfile; documented in CLAUDE.md.
- Rust client: add snapshot_userland_code: None to JsRuntimeConfig initializer.
- Bundle transform hardening: env-api-keys transform asserts exactly 3 eager
  imports (loud fail on drift); pin @mariozechner/* exactly (direct + overrides).
- JS-layer session benchmark + baseline gate + vm-vs-node phase traces.
- Agent SDK snapshot opt-in (pi), MinimalResourceLoader fast path, architecture doc.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@NathanFlurry
NathanFlurry force-pushed the stack/perf-2c-safety-pi-tui-intl-segmenter-foreign-fix-snapshot-opt-in-flag-docs-lzvqqnps branch from 6592029 to c72bf59 Compare June 25, 2026 08:11
@NathanFlurry
NathanFlurry force-pushed the stack/perf-agent-sdk-snapshot-wiring-bench-harness-preview-secure-exec-dep-uusymyzz branch from 390511a to 8e92a53 Compare June 25, 2026 08:11
@NathanFlurry
NathanFlurry changed the base branch from stack/perf-2c-safety-pi-tui-intl-segmenter-foreign-fix-snapshot-opt-in-flag-docs-lzvqqnps to main June 25, 2026 08:12
@NathanFlurry
NathanFlurry merged commit 8e92a53 into main Jun 25, 2026
1 check passed
@NathanFlurry
NathanFlurry deleted the stack/perf-agent-sdk-snapshot-wiring-bench-harness-preview-secure-exec-dep-uusymyzz branch June 25, 2026 08:12
@railway-app
railway-app Bot temporarily deployed to rivet-frontend / preview June 25, 2026 08:12 Inactive
@railway-app
railway-app Bot temporarily deployed to agentos / production June 25, 2026 08:12 Inactive
@railway-app
railway-app Bot temporarily deployed to agentos / preview June 25, 2026 08:12 Inactive

This branch is being deployed

12 in progress and 3 inactive deployments
rivet-frontend / secure-exec-pr-121 — 8e92a53a Deployed Jun 25, 2026 by railway-app[bot]
rivet-frontend / secure-exec-pr-126 — 8e92a53a Deployed Jun 25, 2026 by railway-app[bot]
rivet-frontend / secure-exec-pr-111 — 8e92a53a Deployed Jun 25, 2026 by railway-app[bot]
rivet-frontend / secure-exec-pr-119 — 8e92a53a Deployed Jun 25, 2026 by railway-app[bot]
rivet-frontend / rivet-pr-5320 — 8e92a53a Deployed Jun 25, 2026 by railway-app[bot]
rivet-frontend / rivet-pr-5314 — 8e92a53a Deployed Jun 25, 2026 by railway-app[bot]
rivet-frontend / rivet-pr-5324 — 8e92a53a Deployed Jun 25, 2026 by railway-app[bot]
agentos / production — 8e92a53a Deployed Jun 25, 2026 by railway-app[bot]
rivet-frontend / secure-exec-pr-112 — 8e92a53a Deployed Jun 25, 2026 by railway-app[bot]
agentos / preview — 8e92a53a Deployed Jun 25, 2026 by railway-app[bot]
rivet-frontend / secure-exec-pr-122 — 8e92a53a Deployed Jun 25, 2026 by railway-app[bot]
rivet-frontend / preview — 8e92a53a Deployed Jun 25, 2026 by railway-app[bot]
rivet-frontend / secure-exec-pr-124 — 8e92a53a Deployed Jun 25, 2026 by railway-app[bot]
rivet-frontend / rivet-pr-5328 — 8e92a53a Deployed Jun 25, 2026 by railway-app[bot]
rivet-frontend / secure-exec-pr-123 — 8e92a53a Deployed Jun 25, 2026 by railway-app[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant