Skip to content

Run the Astro compiler and helpers on deno_core with Codex's V8 - #341

Merged
murphye merged 23 commits into
mainfrom
feat/v03-deno-core-one-v8
Nov 28, 2026
Merged

murphye merged 23 commits into
mainfrom
feat/v03-deno-core-one-v8

Conversation

@murphye

@murphye murphye commented Nov 27, 2026

Copy link
Copy Markdown
Contributor

Run the Astro compiler child and captured TypeScript helpers on deno_core again, built on the single V8 that Codex pins (openai-oss-forks/rusty_v8, v8 152.2.0), and remove Boa.

Why one V8 works now

deno_core 0.413.0 reaches V8 through deno_v8 0.5.0, which requires v8 ^150.4.0, so Codex's 152.2.0 patch did not apply and the lock held two V8 lines. Upstream denoland/deno#36665 bumps the v8 crate to 152.2.0 but is unreleased. This PR vendors deno_core 0.413.0 and deno_v8 0.5.0 under third_party/deno with that change applied (13 call sites hand-ported where upstream moved code after the PR), so deno_core resolves to Codex's V8 and the lock holds one built V8. third_party/deno/README.md records the crates.io checksums, the upstream commit and how to drop the patch once upstream releases it; scripts/deno-vendor-check.sh rebuilds the tree from the pinned .crate files plus the diff and fails on any difference.

What changes

  • Build: deps/v8.toml pins the v8 152.2.0 archive and binding for x86_64 and aarch64 Linux, aarch64 macOS and x86_64 Windows. scripts/v8-archive.sh verifies them, and atomic-core's build script refuses every rusty_v8 override except the pinned local mirror and sets RUSTY_V8_ARCHIVE_SHA256 to the pin. scripts/lock-check.sh enforces one V8 by name, version and source. deny.toml, scripts/codex-pin.sh, the SBOM, scripts/dev.sh and the CI and release workflows are updated to match.
  • Compiler child: the bundled worker and host.js are unchanged; a small bridge provides the same host operations as deno_core ops and removes Deno, __bootstrap, WebAssembly, SharedArrayBuffer and resizable ArrayBuffers. A heap limit with a terminating near-heap-limit callback and a budgeted ArrayBuffer allocator bound each compile.
  • Helpers: one fresh isolate per call, with the heap and ArrayBuffer budgets, no host operations or string code generation, a closed module graph, the step's logical clock, and UTC and en-US through rusty_v8's ICU binding (V8 15.2 bundles ICU 78). Fatal errors stay inside the child.
  • Recorded engine: the helper-runtime identity names the engine and hashes the vendored sources. A run recorded by atomic 0.2, whose helpers ran on Boa, is refused on resume with a message naming the engine change; finished steps still replay.
  • Boa and its Boa-only modules are removed. Docs describe the deno_core engine.

Checks run locally (Linux x86_64, through scripts/dev.sh)

  • cargo build --workspace --locked, cargo fmt --all --check, and cargo clippy --workspace --all-targets --locked -- -D warnings, with and without postgres-tests,sandbox-tests, all pass.
  • atomic-core lib tests: 876 passed, 5 ignored (881). Workspace tests pass except six that need the pinned bd binaries CI provides; the sandbox suites were run with the sandbox on.
  • lock-check.sh, lock-check-test.sh, v8-archive-test.sh, deno-vendor-check-test.sh, codex-pin.sh check, forks-check.sh, lock-check.sh v8-built, cargo deny (bans, licenses, sources, advisories), sbom.sh and the examples checker (no Deno on PATH) all pass.
  • Every controls row the change touches was run with its control off and on and bites; this includes 41 new rows for the archive check, helper isolation and limits, and compiler capabilities.
  • An independent review found no P0 or P1 issues; its two P2 and five P3 findings are fixed in the last eight commits.

Not run locally: macOS, Windows and aarch64 builds and tests (no such hosts here). The Windows release links V8 statically, which needs the macOS and release workflows to confirm.

The published crates with the libs/core and libs/deno_v8 changes of
denoland/deno pull request 36665, which move deno_v8 to v8 152.2.0, the
V8 Codex pins. third_party/deno/README.md records the crates.io
checksums, the upstream commit, the one hand-port into
modules/map/dynamic.rs and how to drop the copy. Nothing builds them yet.
Patch the vendored deno_core and deno_v8 in after Codex's entries
(scripts/codex-pin.sh writes the lines), and depend on deno_core from
atomic-core, so Cargo.lock builds one V8: v8 152.2.0 from Codex's
rusty_v8 fork. Restore what the move to Boa removed, for 152.2.0 and the
four release targets: deps/v8.toml archive pins, scripts/v8-archive.sh
and its test, the build script's archive check, the RUSTY_V8_MIRROR
config, the dev.sh prefetch, CI and release archive steps, the SBOM's
V8 archive component and lock-check's one-V8 rule in place of the V8
exclusion. List the rusty_v8 fork in deps/forks.toml and deny.toml, and
pin the new V8 build dependencies to Codex's locked versions.
The compiler worker runs on V8 through deno_core with the host surface it
had on Boa: host.js is unchanged and receives the same op_compiler_*
operations (stdin and stdout, stderr console, exit, native Astro parse
and TSX, TypeScript services, random bytes, SHA-256, timers), and the
bridge removes deno_core's __bootstrap and V8's WebAssembly, which Boa
never offered. The module loader serves only the worker and its four Node
modules and refuses dynamic imports. A V8 heap limit with a terminating
near-heap-limit callback and a budgeted ArrayBuffer allocator bound the
compile; the child exits with child_exit::HEAP or BUFFERS so its parent
names the limit. The cleared environment, rlimits, deadline and macOS
supervision are unchanged, and the bundled worker needs no rebuild.

The heap test returns to the array-growth probe: V8 builds 'x'.repeat()
as a rope, so it no longer reaches the heap. Rows that named Boa code now
name the deno_core binding, and new rows cover the bridge's removals,
the buffer budget and its report.
With the buffer report switched off, the heap callback still ends the
compile, so the test only passed through the shared memory message; it
now asserts the child named the budget it reached.
Each helper call runs in a fresh V8 isolate in its own child process, from
the pre-Boa template: no ops, a closed module graph that refuses dynamic
imports and modules outside the capture, no string compilation, a
budgeted ArrayBuffer allocator, a terminating near-heap-limit callback,
and the logical clock with ICU's default zone and locale set to UTC and
en-US (read back through v8::icu on V8 15.2's ICU 78). The prelude also
removes queueMicrotask, which Boa never offered, and a captured graph
keyed outside atomic-helper:/// is refused as before. The call's wrapper
exports its result for Rust to read, so no host global is left for the
helper. The deadline stays the child's (process::supervised) and V8's
fatal aborts stay contained by the process boundary.

js_budget's counting allocator and js_modules were Boa's and go. Tests
whose expectations were Boa's (frozen-input wording, ICU date and time
formats, the heap probes V8 builds as ropes, the heap-callback abort and
the fresh-isolate heap measure) return to their V8 forms; a test for the
module-URL refusal is new. Each restored guard has a controls row.
A run records its helper runtime when it starts and refuses to run a
helper step on any other; a finished step replays from its checkpoint
whatever the runtime. The recorded identity now starts with the engine
("v8 <version>:<digest>"), and the refusal describes both sides: a bare
digest, which atomic 0.2 and earlier recorded, is named as such, with
0.2's engine, Boa. A pipeline test resumes a run recorded with a 0.2
identity and checks the refusal names the change and runs nothing.
Nothing runs on Boa any more, so boa_engine leaves the workspace and the
lockfile. The crates it had pulled past Codex's locked versions return
to them, and their lock exceptions go; the notices credit V8 instead.
The compiler worker and captured helpers run on V8 through deno_core
again: the architecture rule, development guide (Astro compiler and its
limits, the prebuilt V8, the CI build row), authoring notes, user guides
and references now say so, the dependency table names deno_core, and the
atom reference says what a run atomic 0.2 started sees when 0.3 resumes
it. The vendored crates' README records the one deno_core test that
fails outside the Deno repository.
scripts/sbom.sh reads Cargo.lock to find the V8 archive the binary
links; the fixture repository now has an empty one, so its SBOM lists
no V8 archive instead of failing.
scripts/cache-trim.py keeps target/v8-mirror, as it did before Boa, so
CI's build cache carries the verified archive; its test says so.
V8 builds 'x'.repeat() as a rope that stays small, so the probe no longer
reached the 8 MiB heap; growing an array of arrays does, as the helper
runtime's own heap tests do.
atomic-core's build script checked only RUSTY_V8_ARCHIVE, V8_FROM_SOURCE
and a :// mirror, and hashed only the archive of whatever version it
found, so rusty_v8 settings it did not know (a mirror tag, a fallback, a
skipped download, another bindings file, a docs or trybuild build, a URL
template, an https: mirror without //, a copy at the mirror's top level)
could link something else. The check, now in build/v8_archive.rs and
tested in atomic-core's lib tests, refuses each of those, takes the V8
version from Cargo.lock, hashes the bindings as well as the archive, and
requires RUSTY_V8_ARCHIVE_SHA256 to be the pinned hash, so rusty_v8
checks the copy it takes and any library an earlier build left.
scripts/v8-archive.sh prints that hash with --sha256 and sets it in a
GitHub Actions job; scripts/dev.sh passes it into the container.

Both the compiler and helper runtime identities now also hash every file
of the vendored deno_core and deno_v8, which Cargo.lock does not
checksum, so a run does not resume its helpers on an edited copy.
The development guide claimed no environment could link another V8; it
now lists what the build refuses and that rusty_v8's own output
directory is outside the check. It also names shared memory and
resizable ArrayBuffers among what the compiler worker is not given.
scripts/deno-vendor-check.sh unpacks the deno_core and deno_v8 .crate
files whose SHA-256 third_party/deno/README.md pins, applies
pr-36665.diff, adds the LICENSE.md files and fails on any difference
from third_party/deno. Its test, which CI runs, refuses an edited, added
or removed file and an unpinned .crate, and shows the comparison is what
refuses them.
lock-check's one-V8 rule keyed on name and version, so the same v8
version from two sources collapsed into one build and passed. The key
now includes the source, and lock-check-test has the case.
RLIMIT_CPU's hard bound equalled its soft one, so Linux killed the child
with SIGKILL and the host's SIGXCPU-means-deadline mapping never ran; the
hard bound is now a second later, as the compiler's is. The child's
watchdog ends the process with _exit rather than exit, so no exit handler
or static destructor runs while V8 is still running the call on another
thread. Tests cover the limits the child sets and a child the kernel
stops at a soft CPU limit; each change has a controls row.
The uncaptured-module row bites only on resolve's refusal and its
message; the loader's own refusal now has a test and a row, and the
resolve test says which half it covers.
Their memory is reserved outside the compiler's ArrayBuffer budget. The
bridge now removes SharedArrayBuffer and replaces ArrayBuffer with one
that takes a length only, unreachable around through the prototype, as
the helper prelude does; the buffer test checks each and a row switches
each off.
Only the build script reruns on the settings it lists; the lib's test
build compiles the check without using it, which clippy refused.
The fatal-error row switched off the 'invalid size' marker and expected
the end-to-end probe to fail, but on some hosts that probe's stderr also
holds another marker, so it still read as the call exhausting its memory.
The host's reading of a finished child's status and output is now
outcome(), and a unit test feeds it V8's fatal invalid-size report and
nothing else; the row points at that test. The end-to-end test stays.
The cold controls proof and the full-repository trial check run Cargo on
atomic's own repository, offline, in the exec sandbox. With V8 back,
two things stopped them. The repository's .cargo/config.toml, which set
RUSTY_V8_MIRROR, is a Cargo config a controls proof refuses (bound Cargo
config can change host build inputs), so the run failed before the proof
began; and the sandboxed build had no V8 mirror, no archive hash and a
read-only rusty_v8 checkout to copy its bindings into.

The config goes: scripts/dev.sh and CI already give the build its
variables, and scripts/v8-archive.sh now sets RUSTY_V8_MIRROR,
RUSTY_V8_ARCHIVE_SHA256 and RUSTY_V8_SRC_BINDING_PATH (the pinned
bindings, which rusty_v8 then reads in place) for a CI job, or prints
them with --env-for. The archive check accepts RUSTY_V8_SRC_BINDING_PATH
only when it names the pinned bindings in the mirror. When the operator
process has all three, atomic hands them to a controls proof's and a
trial check's Cargo with read-only access to the mirror (V8Mirror); some
without the others, a mirror that is not a directory, a value that is
not a SHA-256 or bindings outside the mirror are refused at startup, and
a controls atom cannot declare them. The nested build keeps the full
archive check.
…ronment

In CI, scripts/v8-archive.sh appends the mirror, archive pin and bindings
path to $GITHUB_ENV. scripts/v8-archive-test.sh ran it against temporary
copies of the mirror, so the last case's temporary directory became the
job's RUSTY_V8_MIRROR, and the build that followed looked for the archive
in a directory the test had already removed.

The test now clears GITHUB_ENV for its cases, and one new case points it at
a file of its own and checks the three lines name the verified mirror, the
pinned SHA-256 and the bindings path.
The check returned the mirror's top-level archive and bindings paths,
which it requires to be absent, as rerun-if-changed inputs. Cargo takes
a missing rerun-if-changed path as changed, so every cargo invocation
reran atomic-core's build script and rebuilt atomic-core, atomic-graph,
atomic-atoms and atomic, relinking every test binary; CI's acceptance
job, which runs cargo many times over one build, ran out of time. The
build now reruns on the mirror directory instead, which Cargo scans, so
a copy appearing there still reruns the check; a test asserts every path
the check returns exists.
@murphye
murphye added this pull request to the merge queue Nov 28, 2026
Merged via the queue into main with commit 5812894 Nov 28, 2026
29 checks passed
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