Skip to content

Publish CI-prepared installations with a shared browser kernel - #1963

Merged
max-sixty merged 3 commits into
mainfrom
codex/prepared-distribution
Oct 7, 2026
Merged

max-sixty merged 3 commits into
mainfrom
codex/prepared-distribution

Conversation

@max-sixty

Copy link
Copy Markdown
Owner

Leaf's installed native module graph adds avoidable startup requests. Publish a CI-built prepared installation branch so Claude Code, Codex and Pi copy a bundled kernel while development branches keep source modules and avoid generated kernel merge conflicts.

One compiler serves website and installation delivery. Native package widgets and helpers share the existing public widget API without a build; package checks now refuse private kernel imports and replacements. Installation, package creation/checks, page initialization and offline export require no consumer browser build or npm command. Native installer refs are documented, and the post-merge refresh waits for source ancestry before migrating default Codex installs while preserving custom refs and local marketplaces.

Validation includes real prepared installation with Node/npm/npx blocked, custom-package authoring, render checks, an acknowledged live choice preserved read-only in offline export, shared module identity/lazy-loading tests, and real Git publication ancestry/stale-build checks. Canonical local startup comparisons cover cold/warm triage and PR pages; raw samples are retained in the research report. Focused Python/browser/runtime checks and pre-commit pass.

This was written by Codex on behalf of max-sixty

leaf-agent
leaf-agent previously approved these changes Oct 7, 2026

@leaf-agent leaf-agent left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The full test job fails in test_the_resources_a_fixture_owns_are_taken_from_that_fixture: the new distribution test closes tab in a finally block, but the browser fixture owns that page's cleanup. Remove the try/finally and run the assertions directly in the loop so the fixture can close both tabs. The focused distribution test passes; the cross-suite ownership check catches this at the full gate.

@leaf-agent
leaf-agent dismissed their stale review October 7, 2026 04:33

CI test failed: distribution test closes a browser-fixture-owned tab.

leaf-agent
leaf-agent previously approved these changes Oct 7, 2026
@max-sixty
max-sixty merged commit 67307c6 into main Oct 7, 2026
6 checks passed
@max-sixty
max-sixty deleted the codex/prepared-distribution branch October 7, 2026 05:38
max-sixty added a commit that referenced this pull request Nov 4, 2026
…kernel (#5287)

Every branch that touched `browser/` carried a rebuilt kernel in
`dist/kernel/`, so any two such branches conflicted there, whatever
their sources did. Each merge of `main` then took a `checkout --theirs`,
a `pnpm run build:browser` and a commit. This PR stops committing the
kernel. Every install, checkout, preview and test serves the runtime's
source modules, which installs already did wherever a merge left the
kernel stale. Only a prepared installation, the website's build and
container, compiles one.

## Why this design

I replayed with `git merge-tree` the 102 merges of `main` into a PR
branch since #5060 spaced `kernel.json`'s entries. 51 conflicted, 35 of
them only in `dist/kernel/`. With no kernel committed, 16 would
conflict, all in hand-written files. In 26 of the 35, both sides edited
one runtime module, which git merged cleanly in the source. Its hash
line in `kernel.json` conflicted anyway, since no build had read the
merged module, so no layout of a committed kernel avoids those.

The goal was no merge conflicts in generated files, with no build on the
consumer's side, no build machinery of Leaf's own, no commit after a
merge and no second branch. Each alternative breaks one of those:

- A CI job that commits the kernel after each merge adds a commit per
merge.
- Installs following a build branch is a second branch. #1963 tried one,
and #2889 replaced it with the committed kernel.
- Compiling at install, or downloading a CI-built kernel, needs Node or
a release pipeline and cache on the consumer's side.
- A `.gitattributes` merge driver has to be configured in every clone,
and GitHub's mergeability check ignores it, so PRs still show the
conflicts.
- A kernel whose output merges like its source needs a module format of
Leaf's own in place of Rolldown's.

## What changes

- **A resource request is answered from the execution its address
names.** `runtime_selection.named_execution` serves a revision's
resources from the execution the process already holds under the
identity in their URL. Before, each request re-resolved the page's layer
selection, a stat walk of its package copies, three times. A source
module now costs the server about 0.3 ms rather than 1.3 ms. After a
page's package copy is replaced, a request at the old address gets the
old bytes that address names, where it used to get a 404; the next
document load picks up the new copy.
- **No committed kernel.** `dist/kernel/` leaves the tree, and `pnpm run
build:browser` and `check:browser` no longer write or compare one.
`current_kernel`, the in-place compile under `.tmp/kernel.lock`, and the
`compiled_checkout` and `compiled_pages` fixtures are gone, so the
suite's browser tiers test the source modules installs run. `prepare`
always compiles a kernel into its own tree with
`build/runtime-bundle.mjs`, and `read_runtime` serves it while it
matches that tree's modules, as before.
- **Exclusions.** The lint, typos, prettier, pre-commit and Dependabot
publisher exclusions for `dist/kernel/` go, as does the site workflow's
trigger on it.
- **Preview.** `LEAF_PREVIEW_COMPILER_ROOT` is now
`LEAF_PREVIEW_LAUNCHER_ROOT`, read by `preview.launching_checkout`. All
a selected-runtime preview still takes from the checkout that launched
it is the launcher that owns the session's hooks.

## Costs

A page opens from about 250 more module requests. Median time to first
showing the server's state, over 6 interleaved rounds with a cold
browser cache on a loaded Mac:

| | `main`: kernel | `main`: source modules | Kernel + server fix | This
PR |
|---|---|---|---|---|
| `pr-walkthrough` | 583 ms | 1233 ms | 479 ms | 615 ms |
| `triage-board` | 199 ms | 920 ms | 140 ms | 273 ms |

A reload from the browser cache costs 15–35 ms more than the kernel.

Before merge, only a pull request's website gate (the site build and
`leaf-dev verify-site website-worker`) compiles the kernel and opens
pages under it. `wt merge` skips that gate, as it does every site
delivery check.

`kernel_runtime_paths` reads the kernel only where one exists, so a
package that ships a `runtime/bundle-*.js` passes `package check` on a
git install and is refused on a prepared one.

## Tests

`tests/smoke/test_smoke.py` no longer asserts that the page loads kernel
chunks, and `test_native_document_layout.py` imports
`/runtime/content-layout.js` rather than its kernel chunk.
`dev/tests/model/test_distribution.py`, which held the committed kernel
current, is deleted.

Checks run: `pnpm run check:tools` and `check:framework`, the Dependabot
publisher's tests, the model tests for revision delivery, layers and
distribution, the server and website-route process tests, `tests/smoke`,
`tests/journeys/test_distribution.py` (a prepared install compiles and
serves its kernel) and the edited native-layout browser test.

> _This was written by Claude Code on behalf of max-sixty_
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.

2 participants