Skip to content

fix(sandbox): reduce stream work and protect replacement sessions - #4200

Merged
yannickmonney merged 5 commits into
mainfrom
fix/sandbox-hot-path-efficiency
Oct 4, 2026
Merged

yannickmonney merged 5 commits into
mainfrom
fix/sandbox-hot-path-efficiency

Conversation

@yannickmonney

@yannickmonney yannickmonney commented Oct 4, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Tiny agent-output deltas repeatedly copied and serialized retained text, and sandbox execs kept unused output copies beside their replay journals. This change makes display updates incremental and snapshots lazy, preserves the complete terminal answer under its existing cap, and removes the redundant output histories while keeping exact journal replay. Session recovery now keeps endpoint and metadata tied to the same incarnation and rejects stale adoption, cleanup, legacy-acquire, Docker-readiness and admission results before they can affect replacement sessions or start an exec.

Checklist

  • bun run check passes (format, lint, typecheck, all tests) — corresponding final-head CI gates pass. All six applicable workflows completed successfully on attempt 1; actual execution, expected skips and cache replays are recorded below.
  • bun run lint:sast passes (Opengrep) — final-head CI scanned 4,510 files with 476 rules and no unsuppressed findings. All 14 SARIF records have accepted suppressions; unchanged-file parsing/timeouts and exclusions limit coverage. Local full-rule scanning of all 21 changed TypeScript files also reported zero findings and no production-file errors.
  • Translations updated in the affected messages/{en,de,fr}.yml catalogs, including shared UI strings and relevant de-CH overrides — N/A: no localized UI or product-copy changes in this PR.
  • Docs updated in docs/{en,de,fr}/ for any user-visible change — N/A: internal runtime changes; session reference and automated coverage register updated.
  • README.md / README.de.md / README.fr.md updated — runtime storage ownership and reproducible performance workloads documented; no translated README is affected.

Test plan

  • Observed local validation: full sandbox suite 1,056/1,056, platform interaction 226/226 across 17 files, and Linux runtime 128/128, including freshly compiled native process-cleanup tests; no runtime skips. Workspace types and type-aware lint pass. Root formatting passes all 10 tasks without cache; manual coverage, conflict and link guards pass.
  • Recovery and integration: five readiness/admission/reclaim races were demonstrated failing before their fixes. Fresh tests preserve upstream Docker deadlines, attempt-specific cleanup, namespace admission, attach capacity, replay cursor refusals, staging cancellation and fair recovery alongside replacement-session fences. Unresolved adoption retains upstream's retryable 503 response and succeeds on a fresh lookup without mutating replacement state. Independent reviews found no additional interaction defect. Inherited migration 0150 is byte-identical to main; fresh strict CI integration passed all 1,545 checks across 227 lanes, including recovery fairness and the four real-transaction write-race cases skipped by the unit environment.
  • Deterministic improvement: projecting 262,144 single-unit ASCII deltas removes 262,144 whole-text JSON serializations totaling 1,047,131,600 serialized units. Removing duplicate histories eliminates 2,799,392 bytes of retained output strings across 16 completed execs. Exact replay, Unicode tails, immutable snapshots and complete terminal answers remain asserted. Active typed backing is capped at 139,072 bytes and finalized text blocks release it; rendered strings and the separately retained terminal answer remain additional storage. These measurements are not production latency or RSS claims.
  • Verified source: head cbd4ee74abd3bdbd4079beebd45ef6869e70a85e; executed merge 8132049aff683c826c53e7669ae91133be23c6e1 combines that head with base 9e8f87f6832cf352eb70a0ad666bbec6fd9d1a57. Checks, E2E, Build, CLI, SAST and Commitlint all passed.
Final-head validation Status
Code checks, server/UI/browser suites and SAST PASS: changed workspace tests, types and lint ran fresh. Sandbox 1,056 passed; runtime 346 passed / 2 Pillow-only skips; platform server 81,827 passed / 6 explained skips (SOPS, live YouTube and 4 DB-only cases covered by integration); UI 5,363 passed; platform browser 327 fresh / shared UI 212 cached. Format 10/10 fresh; build 10/10 fresh. SAST has no unsuppressed findings, with coverage limits above.
Strict backend integration PASS: fresh direct execution with ITEST_REQUIRE_ALL_LANES=1 and strict error codes; 1,545/1,545 checks, 227/227 lanes, zero skips/failures, exit 0. Candidate DB image, CLI-pinned object store and exact source verified independently.
Performance workloads PASS: all 24 workloads, 20 measured samples plus 2 warmups each, no failures. Artifact source, assertions and all summary statistics independently verified. Current synthetic projection p50/p95: fragmented 47.51/57.42 ms; bursts 17.01/18.56 ms. These are current-run measurements, not a baseline comparison.
Platform, docs and web end-to-end tests PASS: all 16 platform shards: 66 passed / 1 existing chat-search fixture skip; docs 55 passed; web 90 passed. Every first-attempt diagnostic notice is clean, with no retries.
CLI and image builds, validation and smoke PASS: all five CLI targets, Storybook and all eight image builds; 29/29 smoke checks, 40/40 general image checks and 83/83 runtime assertions. Receipt-pinned digests and source independently verified, including native process cleanup, readiness, browser/harness startup and tool execution. All three advisory scans completed; limitations below.

Image scans retain existing vulnerabilities: sandbox 401 occurrences, runtime 1,743, platform 1,148. No occurrences were added against the contemporary upstream baselines. Runtime and platform each omit one previously reported medium zlib finding; that reporting difference is not evidence of remediation. Existing critical/high findings remain, and scan policy is unchanged and advisory. Scanner limits include vendor severity selection, one large source-map secret-scan warning and two runtime SBOM license-expression warnings.

The aggregate Trivy check is neutral because eight main-branch scan configurations are outside this PR's applicable scans. GitHub therefore cannot calculate whole-PR introduced alerts; the three image comparisons above were inspected independently.

@yannickmonney
yannickmonney force-pushed the fix/sandbox-hot-path-efficiency branch 4 times, most recently from 64e112b to 851f350 Compare October 4, 2026 08:14
@yannickmonney
yannickmonney force-pushed the fix/sandbox-hot-path-efficiency branch from 2cb81c0 to cbd4ee7 Compare October 4, 2026 11:29
@yannickmonney
yannickmonney merged commit cc7b5d3 into main Oct 4, 2026
@yannickmonney
yannickmonney deleted the fix/sandbox-hot-path-efficiency branch October 4, 2026 17:12
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