Repository navigation
feat(runtime): add a Web global surface that hides the Node names - #502
Merged
Merged
Conversation
eval takes a trailing `surface: Global_Surface = .Node`. `.Node` is what every context got before and stays the default; `run_file` and the CLI never select anything else. `.Web` exposes the web-platform subset only: no `process`, `require`, `module`, `exports`, `__filename`, `__dirname`, `Buffer`, `global`, `setImmediate`/`clearImmediate`, and no `__lava*` hook. How `.Web` gets there: - the CommonJS entry bindings are never injected; - install_stdio does not run, so internal/stdio and the node-streams stack are never compiled (console writes through its own native writer); - `process`, `Buffer`, `setImmediate`, `clearImmediate` and `global` are installed for the bootstrap and removed as the last step before user code; - an `.mjs` source name is Invalid_Input, and no top-level nextTick drain is appended. The one change on the default path: `__lavaDrainNextTicks` and `__lava_tl_drain` are now defined from install_microtasks instead of microtasks.js, with the same attributes. They are non-configurable, so a `.Web` context could not have deleted them. `.Web` promises that the names are gone, nothing more: web APIs still hand out Buffer-backed bytes and `ERR_*` codes (x-ror/larva#5). Pinned by cmd/lava/global_surface_test.odin; seven mutations recorded in tests/mutation-manifest.json. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This was referenced Nov 18, 2026
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 changed
evaltakes a trailingsurface: Global_Surface = .Node..Nodeis what every context got before. It stays the default, andrun_fileand the CLI never select anything else..Webexposes the web-platform subset only. Not reachable:process,require,module,exports,__filename,__dirname,Buffer,global,setImmediate/clearImmediate, and every__lava*hook.This is the seam Larva needs for page contexts (x-ror/larva#5). It lands here so that
globals.odinandruntime.odindo not diverge downstream; Larva will only select the surface.How
.Webgets there (the contract comment onGlobal_Surfaceinruntime.odinhas the full version):setup_module_environment).install_stdio.internal/stdioand the node-streams stack are never compiled; console writes through its own native writer.process,Buffer,setImmediate,clearImmediate,global..mjssource name isInvalid_Input(exit 2), and no top-level nextTick drain is appended.The one change on the default path
__lavaDrainNextTicksand__lava_tl_drainare now defined frominstall_microtasksinstead ofmicrotasks.js, on.Nodeonly. They are non-configurable, so a.Webcontext could not have deleted them. The attributes are the same as before. Top-levelnextTick→ promise →queueMicrotaskorder is unchanged against node 26 (nt,p,qmon both), and event-loop oracle cases 09 and 10 pass.What
.Webdoes not promiseThe names are gone, nothing more. Web APIs still hand out Buffer-backed bytes and
ERR_*codes, soBufferstays reachable through a value's.constructor. That is the "browser-shaped errors and bytes" part of x-ror/larva#5. No CLI flag selects the surface.Reuse verdict (§2)
No new low-level code: a parameter, a five-name loop over
JSObjectDeleteProperty, and twoJSObjectSetPropertycalls that replace twoObject.definePropertycalls.Node parity
.Node: unchanged. Every oracle suite passes unedited..Web: a Lava-only surface (node has one global surface), a declared §1 deviation. Pinned bycmd/lava/global_surface_test.odin: every hidden name bytypeofandin, every kept API exercised rather than merely present,.mjsrefused, stdio never compiled, and Node/Web/Node alternating on one thread.Tests and mutations
Four tests in
cmd/lava/global_surface_test.odin. Seven mutations recorded intests/mutation-manifest.json:Bufferdropped from the removal list.Webfalls through to the CommonJS entry bindingsinstall_stdioruns on.Webevalstops refusing.mjson.Webinstall_microtasksdefines the drain hooks on.Webevalappends the top-level drain on.Webeval's default surface is not.Nodemake test-mutation CHANGED=1: 53/53 died as recorded (the seven above plus the 46 existing entries this diff can affect).Gates
Run locally on this commit's tree, Node 26.13.1, 16 cores. All passed:
make check(incl. windows and darwin front-ends),make check-js,make check-md,make check-actions,make buildmake test: 140 Odin tests; node-compat (91 cases), sqlite, fs and event-loop oraclesmake test-odin-serial,make test-eventloop-odin,make test-lava-nohostfn,make test-stdio,make test-propertymake bench-gatemake test-mutation CHANGED=1Not done:
/pr-gatehas not been run on this branch. CI has 4 cores, so the concurrency-sensitive gates above are not proof of a pass there.No perf claim.
make bench-gatepasses withstartupat 1.37x against its 3x cap.Open for review
.Webcontexts. Not measured here; it will be measured on Larva'sbench/pagesonce pages select.Web.__lava_precacheis an enumerable global on.Nodetoday (Object.keys(globalThis)shows it; node shows nothing of the kind).🤖 Generated with Claude Code