Repository navigation
feat: persistent REPL kernel behind FUSION_CODE_REPL_PERSIST=1 - #470
Merged
Merged
Conversation
Round-2 Code Mode direction (code-mode-design §7, Scroll 2608.21690): REPL code can keep user variables across calls in a per-process vm context. Off by default — the stateless AsyncFunction path stays the default until the bench gate shows a measured delta on the 27B. - kernel.ts: per-process vm context, sloppy mode so implicit globals persist (var/let/const are IIFE-call-scoped), __last holds the previous returned value, bindings refreshed per run, 1MB retained- state budget dropping oldest-first via in-vm delete (Bun quirk: deleting through the context proxy does not reach the vm global) - REPLTool.ts: flag-gated kernel path; prompt documents persistence semantics when on - clear/caches.ts: resetReplKernel on /clear, --resume, compaction Bun vm notes captured in tests: lazy Script parsing (SyntaxError surfaces at runInContext, cross-realm so instanceof fails — match on name); proxy delete bypass. REPLTool tests pin FUSION_CODE_REPL_PERSIST=0 — bun interleaves test files in one worker, the kernel test's flag window otherwise redirects them into the shared context. Gates: 1925 tests / typecheck / lint (no new findings) / build. Co-Authored-By: Claude Code <[email protected]>
This was referenced Dec 2, 2026
Merged
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.
What
Implements the round-2 Code Mode direction from
code-mode-design.md§7 (#468): REPL user variables survive across calls in a per-processvmcontext. Flag-gated (FUSION_CODE_REPL_PERSIST=1), default off — the stateless AsyncFunction path is unchanged until the bench gate shows a measured delta on the 27B.Design
kernel.ts: per-process context; sloppy mode so implicit globals persist (var/let/conststay IIFE-call-scoped — documented in prompt and tests);__lastholds the previous returned value; bindings refreshed per run; 1 MB retained-state budget, oldest-first eviction.clearSessionCachesdrops the kernel on /clear, --resume, and compaction (dynamic import, matches file style).replmarking via existing logCall).Bun vm findings (captured in tests)
vm.Scriptparses lazily: bad implicit-return transforms surface atrunInContext, and the error is cross-realm (instanceof SyntaxErrorfails — match on.name).delete contextProxy[name]does not reach the vm's real global object — eviction runsdelete globalThis[...]inside the vm.FUSION_CODE_REPL_PERSIST=0so the kernel test's env window cannot redirect them into the shared context.Gates
1925 tests 0 fail / typecheck clean / lint no new findings / build green.
Refs #468, #449
🤖 Generated with Claude Code