Skip to content

Space the kernel manifest's entries so neighbouring modules merge - #5060

Merged
max-sixty merged 4 commits into
mainfrom
thread-card-grows-over-media
Nov 2, 2026
Merged

max-sixty merged 4 commits into
mainfrom
thread-card-grows-over-media

Conversation

@max-sixty

Copy link
Copy Markdown
Owner

dist/kernel/kernel.json lists one module hash per line, sorted by path. Git treats changes to two touching lines as one conflict, so a runtime PR conflicted with main whenever main changed a module whose path sorts next to one the PR changed, even though each line was right for its own module. The kernel build now writes a blank line between the entries, a layout prettier leaves alone, and those merges are clean. The record's content is unchanged.

How much it helps

I replayed the 455 merges of main into PRs #4500 to #5045 with git merge-tree, rendering each side's kernel.json in both layouts:

  • kernel.json conflicted in 257 of them.
  • In 216, both sides had changed the same module. Those still conflict, and should: the merged module is source no build has read. In 127 of them the source merged cleanly, so the kernel conflict is what makes the PR build and test the merged code before it lands.
  • The other 41 were conflicts between neighbouring modules, and all merge cleanly in the new layout. In 30 of them kernel.json was the only conflict, so those merges become clean outright.
  • For each of those 30, rebuilding the merged tree's kernel with that tree's own build script reproduced the textual merge byte for byte. A control rebuild of the PR side reproduced its committed kernel each time.

Clean merges of main go from 145 to 175 of the 455.

Cost

kernel.json gains a blank line per entry. When this lands, each open runtime PR conflicts once on the new layout, resolved as any kernel conflict is (build/AGENTS.md).

Checks

check:browser passes, as does build/runtime-bundle.test.mjs. read_runtime parses the new file and serves the kernel.

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

kernel.json lists one module hash a line, sorted by path. Git conflicts when
two branches change adjacent lines, so a runtime PR conflicted with main
whenever main changed a module whose path sorts next to one the PR changed,
though each line was right for its own module. A blank line now separates the
entries, which prettier keeps, and those merges are clean.

Replaying the 455 merges of main into PRs #4500 to #5045: kernel.json
conflicted in 257. In 216 of those both sides changed the same module, and
those still conflict, since the merged module is source no build has read. The
other 41 merge cleanly with the spacing, and 30 of those would have been clean
merges outright. For each of the 30, the textual merge equals a rebuild of the
merged tree, byte for byte.

The record's content is unchanged; only its layout.
…r-media

# Conflicts:
#	dist/kernel/kernel.json
leaf-agent
leaf-agent previously approved these changes Nov 2, 2026
…r-media

# Conflicts:
#	dist/kernel/kernel.json
…r-media

# Conflicts:
#	dist/kernel/kernel.json
@max-sixty
max-sixty merged commit a300990 into main Nov 2, 2026
4 checks passed
@max-sixty
max-sixty deleted the thread-card-grows-over-media branch November 2, 2026 06:57
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