Repository navigation
Phase 3c: a progress bar, measured wheel caching, and an adopter guide - #451
Merged
neuromechanist merged 18 commits intoSep 23, 2026
Conversation
Compute the whole boot's step count once, before it starts: one for the interpreter, one per preload name, one for micropip plus one per allow_install entry when there is one, and one for the prelude when there is one. Every progress message now carries step/steps instead of the per-phase index/total that reset mid-boot. The widget renders a determinate progressbar from them, and runtime_loaded gets its own reassuring label instead of rendering nothing.
serve.js sent no-store everywhere, so the browser cache was never measured. Wheel routes now send the same "public, max-age=31536000, immutable" the API and worker send. Named as a module constant on the Python side (RUNTIME_WHEEL_CACHE_CONTROL) with a drift test that keeps it equal to the worker's IMMUTABLE and the harness server's own copy. Also adds an in-memory lock-change overlay variant (one wheel renamed with a build tag, same bytes) for the upcoming warm-cache measurement.
Auto-attach to the blob worker Pyodide runs in (Target.setAutoAttach on the page session, Network.enable and runIfWaitingForDebugger per worker session) and record its network traffic. After the nemarlike run, a new cache-boot.html page reboots NEMAR's overlay on the same server, port and browser: every overlay wheel request must now be served from cache, cross-checked against encodedDataLength. A third boot serves eegprep-lean under a renamed (same-bytes) file name, and only that wheel should reach the network. jsDelivr's own assets are reported, not gated. Numbers recorded in README.md.
docs/community-browser-runtime.md covers the client_tools and runtime.python config keys, fetch_allow as the egress control, the lock overlay and its refresh procedure (linked, not copied, since nemar's runtime/README.md is being rewritten elsewhere), the prelude, the Pyodide version pin CI enforces, the embedding page's CSP and why a refused runtime hangs, the measured first-load cost and what the cache gate found for a warm load, and the pybids blocker. Linked from the README's Adding a New Community section. Also updates the design note's stale scipy-era size figures to match.
progress.step and progress.steps are only ever null or a positive integer (guarded in onRuntimeProgress), so they cannot carry a quote character; the drift test already whitelists other numeric interpolations for the same reason.
28,502 B, not 28,475 B: verified against a clean (non-mutated) run rather than the earlier mutation-check run, which measured the same wheel while every route was reverted to no-store.
Rebased onto the dev2 re-vendor; chrome.js passes its warm and lock-change checks there, and the table now shows dev2's 28,852 bytes.
The panel kept the boot's last label and a full bar while the reader's code ran. The widget now takes the runtime's state changes and goes back to 'Running Python' on ready. runtime_loaded no longer says Python is ready while its packages are still to load. Mutation-checked.
The warm and lock-change checks passed when a wheel went unobserved, for example from a worker the recorder missed. Both now compare against the overlay's own file names, and a failed worker attach is logged. Mutation-checked: hiding zarr fails both.
Failed, terminated and idle now clear the bar as ready does. A step count that is not a positive integer, or a step past it, draws no bar. Widget tests: 127 of 127; both guards mutation-checked.
The plain boot, allow_install without preload, and a failing boot, plus the runtime forwarding step and steps unchanged. Worker core 135 of 135, lifecycle 166 of 166; each new case mutation-checked.
Rebuilds the runtime bundle and its integrity pin.
The drift test now fails when a route sends another literal or a file spells the value twice. Mutation-checked on all three files.
A worker whose network could not be watched fails its run, an empty overlay list stops the harness, and page listeners are removed after each run. chrome.js: all checks pass; both guards mutation-checked.
Four limits are server-capped (stdout, stderr, images, image_px); memory_mb and exec_seconds are the browser's own. jsDelivr's header has no immutable. MCP dropped from the example; CORS, CI and API spelled out. Reflowed to semantic line breaks.
Semantic line breaks, and the two guarantees this round added: an unwatched worker fails its run, and the checks need the exact set.
image_px is capped by the server but defaults below the cap.
Member
Author
Local review, and what was done with each findingThe lead's pass over the implementer's commits came first, then six Sonnet reviewers: code, tests, error handling, docs accuracy, simplification, and the seams with the rest of the epic. Every finding is addressed; the two items not changed are explained at the end. The lead's pass
Error handling
Tests
Docs
Simplification and code
Not changed
|
Contributor
Preview Deployment
This preview will be updated automatically when you push new commits. |
neuromechanist
merged commit Sep 23, 2026
dfd1606
into
feature/issue-429-epic-browser-execution
14 checks passed
This was referenced Sep 23, 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.
Summary
The last of three OSA pull requests for phase 3. It gives the browser runtime a progress bar that counts the whole boot, measures in Chrome that the wheels a reader downloads once stay in the browser's cache, and writes down for any community how to adopt the runtime.
What ships
A progress bar that does not jump. Each boot phase used to restart its own count, so a reader saw "1 of 4", then "1 of 1", then "1 of 2", and
runtime_loadedshowed nothing. The worker core now fixes the boot's step count before it starts (one for the interpreter, one perpreloadname, one for micropip plus one perallow_installentry, one for the prelude) and every progress message carriesstepandsteps;indexandtotalare gone, and nothing read them. The widget draws a determinaterole="progressbar"witharia-valuenow,aria-valuemaxand an accessible name beside the label.runtime_loadedsays Python downloads once and the browser keeps it, with no size figure. Once the runtime leavesbooting(ready, failed, terminated or idle) the bar clears and the panel says the code is running. A step that is not a positive integer, or one past the count, draws no bar. The runtime bundle and its integrity pin are rebuilt.Cache behavior, measured and gated. The API route and the worker already served wheels as
public, max-age=31536000, immutable, but every harness run used a fresh profile andserve.jssentno-store, so the cache was never measured.serve.jsnow sends the same header on the wheel routes, and a drift test keeps the three copies equal and checks each file sends its own constant.chrome.jsattaches to the Pyodide worker paused at its start and records its network, then boots NEMAR's runtime twice more on the same origin: a warm boot, where both overlay wheels must come from the browser cache with 0 bytes over the network, and a lock change, where one wheel renamed with a build tag (same bytes and sha256) must be the only one fetched. Both require the exact set of wheels the overlay lists, and a worker the harness could not watch fails the run. Measured on Chrome 153: zarr 377,491 B cold and 0 B warm, eegprep-lean dev2 28,852 B cold and 0 B warm. jsDelivr's interpreter and stock wheels were also cache hits; they are reported, not gated.A guide for a community adopting the runtime.
docs/community-browser-runtime.md, linked from the README's "Adding a New Community": theclient_toolsandruntime.pythonkeys and what the server enforces oflimits,fetch_allowas the egress control, the lock overlay and immutable wheel names, the prelude and the privileges it runs with, the Pyodide pin CI requires, the embedding page's Content-Security-Policy and why a refused runtime hangs, the measured first-load cost (18.9 MB for NEMAR on 0.29.5, 35.2 MB with scipy), and the pybids blocker. Every claim cites the file that owns it, and each citation was checked against the code. The design note's size figures now agree with nemar-cli ADR 0049's 2026-09-22 amendment.For the release
The widget's own bytes changed, so its integrity hash changed too. Nothing in this repository pins it, but nemar.org does: the re-pin after the phase 4 release covers it.
Test plan
uv run pytest -m "not network": 2709 passed, 50 skipped. Two failures, neither from this branch: the known test_version_shows_version fails locally and passes in CI, because rich colorizes on a TTY #434, andtest_fetch_real_document, which timed out reaching GitHub and passes on its own; it is an unmarked network test, which test: unmarked live-network tests can hang the local suite indefinitely #397 tracks.ruff checkandruff format --checkare clean.test-worker-core.js135 of 135,test-widget-tools.js127 of 127,test-runtime-lifecycle.js166 of 166,test-data-lane.js57 of 57,test-controller.js77 of 77,test-egress.js80 of 80,test-output.js66 of 66,test-runtime-bundle.js25 of 25,test-citation-markers.js,test-streaming.js,test-endpoint-resolution.js, and the worker'stest-routing.jsandtest-mounted-hosts.js, all green.build-runtime-bundle.js --checkis current.chrome.jsin headless Chrome 153:nemarlike40 of 40,controlfails to boot as it must, warm and lock change pass.step/stepssequence for every boot shape: nothing to load, preload only, preload withallow_install,allow_installalone, a prelude, and a boot that fails partway.no-storeon the wheel routes (warm and lock change fail); one overlay wheel hidden from the recorder (warm fails); a worker attach that fails (every recorded run fails, naming the worker); an empty overlay list (the harness stops); a route sending another literal, or a second copy of the header (drift test); dropping micropip's step when nothing is preloaded (only the newallow_install-alone case catches it); the widget clearing only on ready, and a missingstep <= stepsbound (widget tests); the runtime forwarding progress withoutstep/steps(lifecycle test).Reviewed locally by Sonnet agents; how each finding was addressed is in a comment below.
Closes #432.
Part of epic #429.