Skip to content

Commit a readable compiled kernel and serve it to installs while it matches the tree - #2889

Merged
max-sixty merged 13 commits into
mainfrom
commit-readable-kernel
Oct 14, 2026
Merged

max-sixty merged 13 commits into
mainfrom
commit-readable-kernel

Conversation

@max-sixty

Copy link
Copy Markdown
Owner

Installs follow main and loaded the browser runtime as about 270 source modules, while the website, the suite's browser tiers and developer previews compiled it into one kernel, so tests ran something installs did not. This commits that kernel, readable, in skills/leaf/kernel/ and serves it to installs whenever it was built from the tree's own modules, as decided on the "How should installs get the compiled kernel?" page.

What changes

  • The build. pnpm run build:browser now also writes the kernel (build/runtime-bundle.mjs, kernelOutputs), last, from the layer the other outputs leave. pnpm run check:browser compares it with a rebuild like every other committed bundle, so the check runs on each PR, in wt merge and on main. A stale kernel fails with Stale browser output; rebuild it with \pnpm install --frozen-lockfile && pnpm run build:browser``, followed by the stale files.
  • Stable form. The kernel is unminified, and each split chunk is renamed after the first module in it (runtime/bundle-<path, / as ~>.js), with references rewritten. esbuild's own chunkNames can't do this: [name] is chunk for every split chunk, so only [hash] distinguishes them. Replaying the last 52 runtime PRs, this form conflicted in 2, against 30 for minified chunks and 26 for unminified hashed chunks, with no clean-but-wrong merges.
  • The guard. kernel.json records the SHA-256 of every module the build read (leaf.js and each .js under the layer's runtime/, vendor/, widgets/), one line each, and replaces, the modules compiled in. leaf.layer.current_kernel is the one place that chooses: page composition swaps in the kernel only while those digests equal the tree's, and vendors the source modules otherwise, as it also does for a page whose package replaces a vendor module the kernel compiled in. It costs about 10 ms warm per composition (page init or re-vendor), never per request.
  • Prepared installations (website container, browser tiers, previews, comparison arms) copy the payload and rebuild its kernel with the same build into the same place, instead of replacing assets/runtime/ in place. leaf-distribution.json now carries only the producer, and the prepared tree no longer strips package.json. arms.build_source's compiled=False source baseline, which nothing passed, is removed. A comparison arm from before this change can't read a tree prepared this way, which only matters for an explicit old --base ref. The website's minified rebundle of vendored layers (worker/bundle-runtime.mjs) is unchanged and consumes the kernel's output.
  • Suite. In-process model and process tests vendor source modules whatever the checkout kernel's freshness (compiled_pages), so their readings don't depend on when it was last rebuilt; browser tiers use the prepared installation as before.
  • Exclusions. The kernel joins the generated paths in pre-commit (including check-added-large-files; leaf.js is about 490 KB), typos, prettier and ESLint, and the Dependabot bundle publisher accepts it as generated output.

For other open runtime PRs

After this lands, a PR that changes a runtime module fails check:browser until its kernel is rebuilt: merge main, then run pnpm install --frozen-lockfile && pnpm run build:browser and commit skills/leaf/kernel/. A conflict in a kernel file resolves the same way, never by hand.

Measured

On pr-walkthrough, served from a checkout's payload on a loaded Mac: the kernel loads 58 JS requests (8.53 MB) before presentation, source modules 272 (9.99 MB). Presentation came about 818 ms after document receipt against 897 ms (5 runs each; diagnostic only). The kernel is 43 files and 2.0 MB on disk, plus kernel.json; pnpm run build:browser rebuilds it twice to identical bytes.

This was written by Claude Code on behalf of max-sixty

max-sixty and others added 4 commits October 14, 2026 12:14
…atches the tree

Installs follow main and loaded the runtime as about 270 source modules, while the
website, suite and previews compiled it into one kernel, so tests ran something
installs did not. The kernel is now committed in skills/leaf/kernel/ and built by
`pnpm run build:browser` with every other committed bundle, so `pnpm run check`
compares it with a rebuild on each pull request, in `wt merge` and on main. A stale
kernel fails the check with the rebuild command:
`pnpm install --frozen-lockfile && pnpm run build:browser`.

The kernel is unminified and each split chunk is renamed after the first module in
it, since esbuild names chunks only by hash. Replayed over the last 52 runtime pull
requests, this form conflicted in 2, against 30 for minified chunks. kernel.json
records the SHA-256 of every module the build read; leaf.layer.current_kernel
vendors the kernel only while those match the tree, and the source modules
otherwise, so a stale kernel never ships. The guard costs about 10 ms per page
composition.

Prepared installations (website container, browser tiers, previews) now copy the
payload and rebuild its kernel with the same build, rather than replacing the
runtime in place, and no longer strip package.json. Model and process tests vendor
source modules regardless of the kernel's freshness.

On pr-walkthrough, a page from the committed kernel loads 58 JS requests (8.5 MB)
before presentation, against 272 (10.0 MB) from source modules.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…entry paths from chunk names, and drop the unused source-baseline option

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
leaf-agent
leaf-agent previously approved these changes Oct 14, 2026
…etween revisions, and leave the kernel's exports to its source's check

Revisions share unchanged runtime files as hard links, so writing the first
revision's bundled leaf.js in place rewrote every other revision's too.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
leaf-agent
leaf-agent previously approved these changes Oct 14, 2026
leaf-agent
leaf-agent previously approved these changes Oct 14, 2026
leaf-agent
leaf-agent previously approved these changes Oct 14, 2026
@max-sixty
max-sixty merged commit c47370e into main Oct 14, 2026
3 of 4 checks passed
@max-sixty
max-sixty deleted the commit-readable-kernel branch October 14, 2026 21:23
max-sixty added a commit that referenced this pull request Oct 14, 2026
#2889 merged after #2892 and its neighbors changed runtime modules, so
main's committed kernel no longer matches its modules: `pnpm run
check:browser` fails on main and installs fall back to source modules
until this lands. This is `pnpm run build:browser` on main, kernel files
only.

> _This was written by Claude Code on behalf of max-sixty_

---------

Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
max-sixty added a commit that referenced this pull request Oct 14, 2026
… floating panel (#2902)

In the floating panel, the line over the field (`.lf-fp-context`, #2885)
and New reply (#2892) both stood over an open view's foot with no room
of their own. The line reached 12px into the view, 6px past its padding,
so at a long thread's end its last line ran into "Claude replied". New
reply stuck over whatever the view ended with, so in a thread whose
answer waited below the fold it sat on the user's own last turn ("And
the weekend?").

- **One room at the view's foot.** The view's bottom padding is now the
room the line lies in (`--lf-fp-foot-room`: the line's 18px less the
row's 6px), kept whether or not the line shows. The line's coming still
moves nothing at the view's head, and the view's last words always
scroll clear of it. A view now keeps 12px rather than 6px under its last
words, well short of the blank line #2885 removed.
- **New reply on the panel's ground.** The press stands on a sticky
strip (`.lf-fp-foot`) that fades in above it and runs down through that
room, so the press and the line read as one foot, and text passing under
reads as under a layer. At the view's end the strip stands where it
stuck, in flow below the answer.
- **The user's last turn stays in sight.** Where the user stood at the
view's end when an answer arrives that doesn't fit, the view scrolls by
the room the strip takes (`fitAnswer`). That scroll is the panel's own,
so `sawAnswer` doesn't count it as the user reaching the answer, and New
reply stays.

Tests: `test_nothing_in_a_view_stands_under_the_line_or_new_reply` (new)
holds that the last words' text box clears the line's and the press's
boxes at the end of a long Threads list and a long thread the user types
in, and that the user's own turn clears both while an answer waits. It
fails without the change at the long thread's end, and at the held reply
without the scroll. The Threads and one-message height checks now
measure against a row's height and the foot room instead of fixed pixel
bounds the extra 6px crossed.

The kernel (#2889) is rebuilt for the runtime change.

> _This was written by Claude Code on behalf of max-sixty_

---------

Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
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