Skip to content

Compose each page's layer from the Leaf reading it, so only the log and records bump the protocol - #4551

Merged
max-sixty merged 35 commits into
mainfrom
narrow-protocol-bump
Oct 28, 2026
Merged

max-sixty merged 35 commits into
mainfrom
narrow-protocol-bump

Conversation

@max-sixty

@max-sixty max-sixty commented Oct 28, 2026 •

Copy link
Copy Markdown
Owner

The page protocol was meant to bump only when the interface between a page and the CLI changed, but it went from 17 to 33 in six days. 11 of those 16 bumps came from the layer page init copied into every page: bundled widgets and their registry entries, and widget-api.js imports, all called the serving Leaf's runtime across the version gap. (CSS was never part of the protocol.)

This PR removes the copy. A page now records only its selection in layer.json (packages, theme, generation, protocol: the layer record, since 36). Every Leaf that serves, checks or exports the page composes the layer itself (layer.selected_layer, cached by the package roots it resolves to), the same way it already supplies the runtime. So bundled widgets, registry entries, the theme and the public package API ship with Leaf and never bump the protocol. The protocol now covers only the event log and the records kept outside a page, so an update reaches new sessions without refusing pages that older sessions hold.

What changed

  • Init and the record: vendoring.py writes the record rather than copying files. A package selected by path, such as ./.leaf, is copied into the page's packages/<name>/ and recorded as ./packages/<name>. Otherwise the Codex adapter, a server started elsewhere and the website container would each resolve the path against their own working directory. Copies are never pruned, since a stored revision may still name one. Packages selected by name resolve to the reading Leaf's bundled or installed packages.
  • Readers: registry/storage.py composes the vocabulary from the record. Revisions capture only the files the page owns and name their layer in the manifest. RevisionArtifact carries its page directory, and runtime_selection.executing serves the composed layer beside the runtime. A page snapshot freezes the layers it serves when it is captured.
  • Addresses: a revision's resources are served under runtime_selection.execution_identity, which covers the runtime and the fingerprint of the layer the revision executes. A page's package copy or an installed package can change while the runtime stays the same, and an immutable address must never name other bytes.
  • Protocol check: build/browser/protocol.mjs no longer compares browser commands or x-state verbs, which the serving Leaf now supplies.
  • Retired with the copy: revision refusals, the retired-*, layer-identity, leaf-version and missing-vendored findings, and the served state's server and leaf fields.
  • Contracts: layer-registry.md ("Page protocol"), page-storage.md and AGENTS.md "Pages across Leaf updates" are rewritten. The shipped references now say "record" and "re-initialize" instead of "vendor", and page-authoring.md reads the vocabulary with the new leaf page vocabulary.
  • Preview: leaf-dev preview restarts its server when the serving code or the layer sources change, --user previews included.

The diff is +1,005/−1,156 in code, +198/−238 in prose and +1,291/−2,333 in tests, not counting generated files. A fresh page is 12 KB instead of 2.4 MB.

Trade-off

A version the user approved no longer keeps the widget code it was approved under. That code now updates with Leaf, as the runtime already did. A page's own widgets and an installed package's modules still call widget-api.js across versions. A bump wouldn't repair them, so page check --render and package check --render report a module an API change breaks.

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

Pages now record a layer selection (`layer.json`) instead of holding a copy
of the layer, so the interact contract tests declare vocabulary changes on
the page (`page/registry.json`) or through a selected package, and read the
composed vocabulary through `load_registry` / `read_page_registry`.

Behavior changes in src:
- The served state names a fingerprint and producer for the layer of the
  shown revision too (`served_state.page.read_served_page`), not only before
  a first revision; an `/api/event` answer and `/api/state` otherwise broke
  their schema once a page had a revision.
- A revision declaring nothing over its selected layer is not validated
  again when a process first reads it (`registry.storage._revision_vocabulary`),
  since the layer was validated where it was composed. This keeps a cold read
  of the active revision free of a registry validation.

Test support:
- An autouse fixture clears the per-process layer caches after each test, so
  a project-relative package such as `./.leaf` composes from the test's own
  directory rather than an earlier test's.
- `_mutated_registry_check` declares its mutation on the page.
- `model_folds` states a `$layer` in the record's shape.

Deleted tests of removed mechanisms:
- a vendored entry declaring an unknown x- key names a re-vendor;
- a malformed vendored registry.json is refused with a re-vendor;
- a bare re-vendor repairs a broken vendored registry.
Pages now record a layer selection in layer.json and every Leaf composes
the layer itself, so these tests read the composed vocabulary, the
layer's served files and `executing(artifact).resources` instead of
files copied into a page or a revision. A test that customized the
vocabulary declares on the page (`declare_on_page`) or selects a package
by path; one that stood a page file in for a package's makes that
package.

Fixes in src the migration exposed:

- Capture lets a document name a file its layer serves, such as
  `<link rel="icon" href="/icon.svg">`, which every docs page uses;
  capture refused it once layer files left the capture.
- A sample child writes the layer record its parent revision selects;
  without it the child's activation staged no artifact and crashed.
- `page check` and every activation report `no-layer` for a page with
  no layer.json, rather than crashing while staging a missing artifact.
- The served state names the active revision's layer with its
  fingerprint and producer (`served_layer`), as its schema requires.
- `page inspect` counts the selected layer's CSS and JavaScript again.
- A package's page-overlap gate recognizes a page by events.jsonl and
  layer.json; it looked for vendored layer files no page has now.
- `layer.selected_layer` caches by the directories a selection
  resolves to, not its spelling, so a project-relative package from
  another directory is composed afresh.

interact_support: `read_page_data` reads the live vocabulary (page
declarations included); `declare_on_page` sees the page's earlier
declarations and patches a `$` map member by merge-patch.

Behaviors no longer protected, with their mechanisms gone: copying and
hard-linking layer files into pages and revisions, a revision keeping
layer bytes edited in place, pruning retired layer files, destination
and symlink collisions for layer files in a page, staged-write modes,
refusing a layer whose x- key was renamed, a page another Leaf vendored
taking writes, `page check` and the served state naming the vendoring
Leaf, re-init minting a generation for a serving-code change, a page
exporting with a theme package since uninstalled. The browser gate
opening a page away from the project its relative package was selected
in is marked xfail: composing from layer.json refuses it there.
# Conflicts:
#	src/leaf/layer.py
#	tests/interact_support.py
…layer

Tests now customize a page's vocabulary through its own declarations
(`declare_on_page`, `page/registry.json`) or a selected package, read the
vocabulary through `load_registry`/`read_page_registry`, and move a page to a
new generation by selecting another package rather than editing vendored files.

Product fixes the migration found:
- A live state answer for a page with an active revision now carries the
  layer's `fingerprint` and `producer` (`served_layer`), as the schema requires;
  it carried the bare `$layer` before.
- A sample child records the layer its parent's revision selects, so it composes
  a vocabulary and activates; every sample allocation failed without it.

Shared test support: `declare_on_page` diffs against the page's whole candidate
vocabulary, so it can change a page-declared entry; `read_page_data` reads the
candidate; the page pool recreates a lent page a test removed; the model fold's
`$layer` takes the current shape.

Removed tests of mechanisms that no longer exist: repairing vendored layer
files, a layer vendored by an earlier Leaf (old kernel vocabulary, renamed x-
keys, another Leaf's producer), refusing a revision saved at an older protocol,
stale links in a page's vendor/widgets, restoring an installed package's
vendored layer in a website record, a server start naming the page's vendored
layer, and a preview pausing mid re-vendor on a runtime edit.
# Conflicts:
#	src/leaf/samples.py
#	tests/interact_support.py
# Conflicts:
#	dev/leaf_dev/commands/preview.py
# Conflicts:
#	skills/leaf/references/page-authoring.md
#	src/leaf/revision_artifact.py
#	src/leaf/runtime_selection.py
A page records its selection and every Leaf reading it composes the layer, so a
package selected by a project-relative or ~ path was resolved against each
reader's working directory: the Codex adapter, a server started elsewhere and
the website's container could not find it. page init now copies such a package's
layer files into the page's packages/ and records it as ./packages/<name>;
readers resolve a record's paths against the page directory, which revisions
and served-state readers now carry. Names still resolve to the reading Leaf's
bundled or installed packages. Edits reach the page at the next
page init --package, as before this branch.
A page no longer holds a copy of its layer: it records its selection in
layer.json and every Leaf that serves, checks or exports it composes the
layer. The prose and names still described the vendored design. This
rewrites them to the current one; the only behavior changes are the
renamed finding codes and messages, and the removed `served_by` path.

Renamed:
- finding `unready-revendor` -> `unready-reinit` ("re-initialized PAGE, but
  index.html will not activate ...")
- finding `revendor-refused` -> `renewal-refused` ("PAGE is at an older page
  protocol, and this Leaf could not take it to its own: ...")
- finding `stopped-while-revendored` -> `stopped-during-init`
- `vendoring._revendor` -> `vendoring._reinit`
- `schema.VENDORED_FILES` -> `schema.LAYER_TOP_FILES`, beside
  `LayerComposition.top_files`
- the `vendored` value of `foreign-layer`/`newer-layer` -> `recorded`
- `unknown-widget` now says "not in the page's registry", and
  `message-stylesheet` "the one theme its layer composes"

Removed as dead:
- `_declared`'s `revendor` suffix ("run `leaf page init` to re-vendor it"),
  which nothing produced
- the served state's top-level `leaf` field, which nothing produced since
  every Leaf composes the layer it serves: its schema entry, the generated
  type, `server.leaf` and the website's `leaf=` attribute, and the
  browser's `served_by` identity with the "served by" lines the leaf's
  menu could no longer show

Claims that no longer hold were rewritten or dropped: the served layer
cannot change under a server because the server composes it once and
`page init` restarts it (not because a copy is fixed); `renew_layer` no
longer guards an x- key a re-vendor would strip, since nothing is copied
to strip; validation.md no longer says the render gate declines to
re-vendor. The design-comment handling clause in the kernel registry now
says to take a package change into the page as packages.md says, with
the event-clause snapshot regenerated; the kernel is rebuilt for the
runtime comment edits.

Third-party bundles under vendor/ keep the word.
…hot's served layers

A page now records its layer selection (layer.json, the layer record since 35)
instead of holding a copy of the layer, which a Leaf at 34 cannot read.

A page snapshot serves what it froze after the page directory moves or goes, so
it composes the layer each of its readings is served under at capture, since
that layer may name the page's own package copies.
…ces change

A server composes its layer once, as it starts, so an edit to a bundled package
needs a restart even when the page's record is unchanged; page init restarts a
--user service only when the record changes.
# Conflicts:
#	AGENTS.md
#	dist/kernel/kernel.json
#	skills/leaf/references/packages.md
#	src/leaf/layer-registry.md
#	src/leaf/revision_artifact.py
…to protocol 36

Main bumped to 35 for its own record change, so the layer record cuts over at 36.

@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.

Removing a page-local package breaks historical revision reads, and refreshing one can reuse an immutable asset URL for different module bytes. These two reproduced regressions withhold approval.

Comment thread src/leaf/vendoring.py Resolved
Comment thread src/leaf/runtime_selection.py Resolved
page init no longer writes the layer into the page, so the worker's bundle test
writes the layer the installation composes for the page beside its runtime, and
ServingRuntime.resources takes the layer and captured files separately.
…rces by their layer too

A re-init that drops a package left revisions naming its copy unreadable, so
copies stay. A page's package copy, or an installed package, can change with
the runtime unchanged, so a revision's resources are addressed by the runtime
and the fingerprint of the layer it executes (runtime_selection.execution_identity),
and an immutable address never names other bytes.
A served revision's resources now answer under the runtime and its layer
(runtime_selection.execution_identity), so the tests that fetch them and the
website's private-record paths name that address (interact_support.revision_root).
…server answers

The head commit moved revision resources from the runtime's identity to the
runtime and layer's (`runtime_selection.execution_identity`), but the website
container's publisher still captured them under the runtime's alone, so every
private revision's publication failed on a 404 (src bug, found by
test_saved_website_record_restores_comments_choices_and_private_revision).

Tests that built a revision's resource root by hand from the runtime identity
now read it from `interact_support.revision_root`, which asks the same
`execution_identity` the server does.
An open document reloads on a new generation (runtime/bootstrap.js), so an edit
to a package selected by path reaches it as a reload rather than only as new
asset addresses.
# Conflicts:
#	src/leaf/findings.py
#	src/leaf/layer-registry.md
#	src/leaf/layer.py
#	src/leaf/vendoring.py
#	tests/model/test_hooks.py
#	tests/model/test_interact_layer.py
leaf-agent
leaf-agent previously approved these changes Oct 28, 2026
@max-sixty
max-sixty merged commit a76f7fd into main Oct 28, 2026
4 checks passed
@max-sixty
max-sixty deleted the narrow-protocol-bump branch October 28, 2026 07:21
max-sixty added a commit that referenced this pull request Oct 28, 2026
#4563 gave every runtime press whose face its surface draws its symbol
and name from `ACTIONS` through `nameAction`. Package presses still
paired `showAction` or `actionTemplate` with a hand-written name, so the
two could drift there.

The public package API (`widget-api.js`) now offers `nameAction` and
`namedAction`, and these presses use them, keeping their own labels
where they say more:

- `lf-sample`'s Full view / Return to page
- `lf-diff`'s Expand/Collapse all files and `lf-call-diff`'s
Expand/Collapse all call-tree roots
- `lf-deck`'s forward press (Start / Next)
- `lf-file-editor`'s Retry

`showAction` and `actionElement` leave the public package API: no
package uses them, and `nameAction` already swaps the symbol for a press
whose action follows its state. `actionTemplate` stays for a symbol that
isn't a press's whole face, such as `lf-trace`'s play/pause pair.
`module-reading.md`'s Icons section says which to use. No protocol bump,
since the public package API doesn't bump it (#4551).

No behavior change: each press keeps its symbol, label and tooltip, and
each keeps its own face.

Checks: `pnpm run check` (runtime tests 693/693) and 9 focused browser
tests covering each of these presses (live samples' full view, diff
fold-all, call-diff rows, deck, file-editor status controls on a phone).

> _This was written by Claude Code on behalf of max-sixty_
max-sixty added a commit that referenced this pull request Oct 28, 2026
…a Leaf reads (#4574)

`lf-code` now loads and draws on a plain HTML page that maps `/runtime/`
and
`/vendor/` with its own import map, as `lf-chart` does since #4542. On a
Leaf
page it behaves as before. Its import graph is 14 runtime modules and 80
KB of
source, down from 182 and 2,271 KB. `lf-chart` draws to its own box's
height,
so a plain host no longer has to write `data-lf-height`.

Off Leaf a widget binds no keys, shows no Copy control and writes no
quiet
word. Leaf adds each of those by reading what the widget declares on its
elements, rather than the widget calling into Leaf.

**Keys are data on the element.** A widget sets an element's
`lfCommands` to the
scope (`{title, rows, when, ready, escape, claims}`, the rows unchanged,
or a
`commandScope()` value) and calls `commandsChanged(element)`, a portable
helper
that dispatches a bubbling, composed `lf-commands` event. Leaf's
register
(`keyboard/scopes.js`) reads the declaration from a window listener: a
new one
stands in place of the last, `null` withdraws it, and the same one
standing
means something its rows read changed, so the register repaints, as
`paintKeys()` did. Leaf stays the only writer of `aria-keyshortcuts`,
and a
plain page, which hears nothing, advertises no key.
- One public route. `commands` and `paintKeys` leave `widget-api.js`,
and
every caller moves to the declaration: all 16 package widgets,
`lf-suggestion`,
the feature gallery's page script, the docs and the tests.
`commandScope` stays,
as the value form a margin entry and several elements share, and so does
the
template directive `commandsOn`. The internal `keys` remains core's own
entry
to the register, which the declaration's reader calls.
- A malformed declaration still throws where the widget made it. A
listener's
exception never reaches the dispatcher, so the reader hands the refusal
back on
the event and `commandsChanged` throws it.
- An element out of the document dispatches on the window, carrying
itself, as
`reportFailure` does, so a control declared before it is placed keeps
its keys.
- Rejected: reading `lfCommands` at upgrade or connection without a
signal. It
would need a second way in, an arrival watch over every widget tag plus
a sweep
after each module import, and would still miss elements a render creates
and
declarations made after asynchronous drawing, such as lf-code's. Also
rejected:
keeping `commands` public as a portable writer of the declaration, which
leaves
two public routes to one capability.

**Copy.** A widget block declares its Copy control with `data-lf-copy`,
naming
what it holds, and an `lfCopy()` method returning the text to copy.
Leaf's code
block watch (`code-copy.js`) stands the control right after the block
while
both are in the page. `copyBlock` stays for a widget that seats the
control
among its own, as `lf-draft` does in its toolbar; declaring that
placement would
add an option for one caller.

**Quiet words.** A module declares a part's quiet word with
`data-lf-quiet`, and
Leaf writes it there (`watchQuietWords`, `declared-words.js`). Off Leaf
no
stylesheet would clip the word, so it would show in the code line.
`quietWord`
leaves `widget-api.js`; `lf-suggestion` declares its slots' words the
same way,
so `data-lf-quiet` joins `PAGE_PAINT_ATTRIBUTE`, the paint an authored
element's reading looks past.

**Portable homes.**
- `tab-store.js` holds `tabStore`: Leaf's tab store where the prepaint
opened
one, and off Leaf a store that keeps nothing (reads answer null, writes
are
refused). Off Leaf the wrap can't be toggled anyway, since the key is
Leaf's.
- `syntax-tokens.js` holds `syntax`, `synNodes`, `tokenLines` and
`ensureSyntaxLanguage`. `syntax.js` keeps the page's code blocks and
`langForPath`, which read Leaf's registry. A tokenizer failure reaches
Leaf
through `failSoft`'s error event.
- `layoutChanged` and `LAYOUT` move to `widget-upgrade.js`.
- lf-code announces its drawing with `PendingTaskEvent` instead of
`widgetController(this).present`.

**lf-chart height.** It reads `clientHeight` instead of
`data-lf-height`, once,
at its first drawing, while the theme (on a Leaf page) or the host (off
Leaf)
still holds the box, and keeps that height through redraws (`#height`).
Reading
it on every redraw would let a chart that a grid or flex row stretches,
such as
a short chart beside a taller one in `.layout-tiles`, grow to the row's
height
after a width change. The legend subtraction is unchanged.

**No protocol bump.** Since #4551 each page's layer is composed by the
Leaf
that reads it, so a change to the package API leaves the protocol at 36.

**Tests.**
- `tests/smoke/test_plain_page.py` adds lf-code, drawing coloured lines
with the
highlighted one among them, and asserts the page holds no
`aria-keyshortcuts`,
Copy control or quiet word. The chart's drawing now fills its host's
height,
with no `data-lf-height`. Each assertion failed when undone: lf-code
importing
`widget-api.js` (fails at load), lf-code writing its own quiet word,
lf-code
setting `aria-keyshortcuts`, and lf-chart reading `data-lf-height`
again.
- `test_code_wrapping_keeps_source_copy_and_reader_choice` asserts that
on a
Leaf page lf-code advertises `w`, its Copy control stands after its
block and
its highlighted line says "highlighted". Each failed with its
declaration
withheld.
- A runtime test covers a declaration made out of the document, its
withdrawal
and its refusal; it failed with the window dispatch or the withdrawal
removed.
- `test_a_chart_keeps_its_stated_height_beside_a_taller_one` puts charts
of
data-height 200 and 420 in one tiles row and resizes it 640 then 1280
wide;
reading the height on each redraw, the short chart ends at 420.
- `module-input.md` lists every declaration field and says that a new
`lfCommands` object replaces the scope and is checked, while
`commandsChanged`
on the same object only repaints. `module-authoring.md` states the
limit: Leaf
finds `data-lf-copy` and `data-lf-quiet` in the page and its own shadow
stages,
not in a shadow root a page script attaches. The
`widget-list-keeps-focus` eval
rubric asks for the declaration.
- Also run: `pnpm run test:runtime` (694 after merging main), `pnpm run
check:browser`,
`pnpm run test:browser`, and 66 focused browser tests: every converted
register
test, a keyboard test for each converted widget, the chart tests, code
copy,
export quiet words, composition and the pending-task test.

> _This was written by Claude Code on behalf of max-sixty_
max-sixty added a commit that referenced this pull request Oct 28, 2026
…s answer held (#4608)

#4516 and #4561 made the playground's submit, Done, reaction chips and
the suggestion's controls stay live while their gesture travels. This
finishes the job for Resolve and Reopen, and adds a suite test that
presses every bundled control with the server's answer held, so the next
widget that keeps its own "sending" state fails before review.

**Resolve and Reopen stay live.** A resolve or reopen marked its thread
as settling until the server answered. While it was set, the card's and
panel's settle button wore a busy or disabled face for one round trip, a
second press was dropped, and replies and edits on the thread were
refused. The settling mark goes, with the thread's `offers` (which only
combined `resolved` with it), the busy and disabled faces, the drop in
`settleThread` and `pendingForParent`. A press while one is in flight
sends the opposite settlement after it, as the pending ledger orders
them; a reply or edit sends as usual, and a reply reopens the thread as
the server already does. `settleThread` now waits on its own attempt
rather than any settlement of the thread.

**Every bundled control is pressed with its answer held.**
`tests/browser/widgets/test_pressed_controls.py` presses each control in
each bundled package's worked examples, and the margin entries Leaf
draws for them, with the event POST held. A control whose press sends a
gesture must keep the cursor and the available, idle face it had before
the press, and where the same control stays under the pointer, a second
press must send again. A small states page adds a `multiple` group,
since no worked example shows Done. Restoring `aria-busy` or an
in-flight guard on the playground's submit, or the pre-#4561
`lf-suggestion` or `lf-options`, fails it. It runs only in the suite, so
`page check` and `package check` pay nothing for it; each package takes
at most about 3.5 s.

**`package check --render` works again.** Since #4551,
`start_throwaway_page` was handed the composed layer where it expected
the selection, so the check raised `TypeError` for every package. It now
selects the package as `page init` would, by its installed or bundled
name or else by path, with no theme, so the reading is the same on every
machine. The sweep serves examples through
`widget_quality.served_examples`, split out of `_page_findings`.

Behavior changes, with their tests:

- Pressing Reopen while the resolve travels sends `unresolve` after
`resolve`, instead of nothing
(`test_a_settlement_in_flight_leaves_its_opposite_live`, replacing the
test that the control stopped being busy once a poll accounted it).
- Packages read `thread.resolved` rather than `thread.offers`
(`module-annotations.md`).

With the render check working, the nightly
`test_bundled_widgets_meet_the_widget_quality_checks` reports first-box
findings for `lf-worktree` (#4475), `lf-timeline` (#4476) and `lf-dial`;
`test_a_widget_first_paints_the_box_it_presents[diff-*]` already fails
on main (#4349).

> _This was written by Claude Code on behalf of max-sixty_
max-sixty added a commit that referenced this pull request Oct 28, 2026
…le (#4611)

`lf-diagram` now loads and draws on a plain HTML page that maps
`/runtime/`
and `/vendor/` with its own import map, as `lf-chart` and `lf-code` do.
On a
Leaf page it behaves as before. Its import graph is 14 runtime modules
and
76 KB of source, down from 183 and 2,252 KB (static imports through
`/runtime/` and relative paths; Pele stays a lazy `/vendor/` import).

**Visual parts are a declaration Leaf reads.** `registerVisualParts`
records
an inventory in a WeakMap keyed by the element, and Leaf reads it only
when a
Comment, an aim or the render gate asks, so the call already is a
declaration; it was off the portable surface only because
`visual-parts.js`
imported `under` and `upFrom` through `shadow.js`, whose `registry.js`
import
doesn't load off Leaf. It now imports them from `shadow-tree.js`, which
has no
dependencies, and `portable-api.js` re-exports `registerVisualParts`;
`widget-api.js` drops its own export line and keeps the name through
`export *`. Off Leaf the inventory is recorded and nobody reads it, so a
diagram there offers no Comment target. The Leaf readers stay in the
module
and now ship in the kernel's portable chunk.
- Rejected: an `lfVisualParts` property on the element, as keys are
`lfCommands`. Keys need a signal because Leaf binds them on arrival;
parts
are read on demand, so the WeakMap needs none, and the property would
have
moved six widgets, three test fixtures and the docs to a second spelling
of
  the same declaration for no change in behaviour.

**Drawing.** `lf-diagram` announces its drawing with `PendingTaskEvent`
instead of `widgetController(this).present`; the document listener in
`widget-controller.js` holds the same presentation on it.

**Fonts off Leaf.** The drawing reads `--sans` and `--mono`, which a
plain
page doesn't set, so Pele measures with no family and draws in
`var(--pele-font, sans-serif)`: the browser's sans-serif unless the host
sets
those properties. Left as is: reading the inherited `font-family`
instead
would add an off-Leaf branch for a page that can already name its fonts.

No protocol bump: the public package API doesn't move the protocol
(#4551),
and every name `widget-api.js` exported is still exported.

**Tests.**
- `tests/smoke/test_plain_page.py` adds lf-diagram, drawing an svg
holding its
two named boxes inside the room the host reserves.
`Portable.fills_height`
becomes `sized` (`box`, `width` or `natural`), since a diagram keeps its
natural size rather than filling the host's width as a chart and a code
block do. The host reserves the diagram's height, as Leaf's stylesheet
does
from `data-height`; without it the drawing's arrival shifted the refused
  chart below by 98px and the shift watch failed the test.
- Each failed when undone, at load, on prepaint's `lfInputs` read in
  `bundle-dom-move.js`: lf-diagram importing `widget-api.js` again, and
  `visual-parts.js` importing `shadow.js` again.
- Also run: `pnpm run test:runtime` (694), `pnpm run check:browser`, and
24
focused browser tests: every diagram test (renderer loading, render gate
identities, late labels, scrollbar clearance, scheme, fonts, injection,
room, failed-soft room, rounded part aims, pane aims, revision
restoration),
the visual-part fixtures (picture target, shadow visual clipping, shadow
  scroller aim) and the pending-task test.

`lf-motion` and `lf-timeline` follow in the next two PRs, which make
Leaf's Lit, first drawing and base class load anywhere.

> _This was written by Claude Code on behalf of max-sixty_
max-sixty added a commit that referenced this pull request Oct 28, 2026
…ere (#4616)

`lf-motion` now loads, draws and plays by its own controls on a plain
HTML
page that maps `/runtime/` and `/vendor/` with its own import map, as
`lf-chart`, `lf-code` and `lf-diagram` do. On a Leaf page it looks and
behaves
as before, except that a playback failure now also says so in the
transport.
Its import graph is 17 runtime modules and 101 KB of source plus
`/vendor/lit.js` (33 KB), down from 183 modules and 2,252 KB.
`lf-diagram`'s
grows from 14 modules and 76 KB to 17 and 101 KB, since the portable
surface
now carries Lit's names, the motion preference and the first-drawing
reader.

**Leaf's Lit loads in any document.** `/vendor/lit.js` imported
`/runtime/dom-move.js`, whose `focus.js` reads prepaint's `lfInputs` at
import, and Lit's insertion seam and namespace assignment both
dereferenced
`document.documentElement.lfInitial`. Now the seam asks the root for its
mover
at each insertion and inserts natively where there is none, the
namespace is
assigned only where a coordinator exists, and the runtime installs the
focus-preserving mover from outside: `framework.js` imports
`dom-move.js`, and
neither `lit.js` nor `lit-shared.js` does. The kernel no longer serves
`dom-move.js` as an entry of its own, which existed only because Lit
imported
it by URL.

**Words for a listener are an event.** `announce(message)` keeps its
form and
moves to the portable surface: it dispatches `lf-announce` on the window
with
the words as `detail`, which `notifications.js` says in the live region
and a
page without Leaf leaves unsaid. Every caller is unchanged.
`runtime-globals.d.ts` declares the event.

**A first drawing off Leaf.** `initialRender(host, draw)` adopts
prepaint's
drawing where a coordinator ran, and otherwise calls `draw` with plain
tools
and renders it. The plain tools give both of prepaint's role
constructors
(`offerAction`, `offerActionElement`) in its shapes, and set only the
widget's own classes, button type
and name, not Leaf's marks (`lf-ui`, a role's face, `data-lf-gen`,
`data-lf-offer`), which nothing reads there. Motion's producer moves
beside
its widget (`widgets/motion-view.js`) and imports the portable helpers
by
served path; the initial bundle imports it, and `build/initial.mjs`
resolves
`/runtime/` to sources with `sideEffects: false`, so the bundle holds
only what
the producer uses. Where `drawsFirst()` says a coordinator drew, the
module
defines the element at once and fetches nothing more; elsewhere it
imports the
producer and defines the element once it arrives (a module-level
`.then`), so
every study upgrades with its producer in hand and draws in the task
that
upgrades it.
- Rejected: a static import, which had every Leaf page fetch the 3.4 KB
  producer it never runs, one more request on upgrade. Also rejected: a
top-level `await import()` before `customElements.define`, which the
lint
  rule `architecture/top-level-await` refuses because it turns off the
bundler's chunk merging; and defining at once and waiting for the
producer in
  each instance's connection, a second route through setup.
- Off Leaf a widget that draws at upgrade still grows when it is
defined, so a
host that doesn't reserve its room sees what follows it move: deferring
the
definition keeps the widget from showing undrawn but can't move its
drawing
before the first paint. (The Layout Instability API scores the old and
new
shapes alike here: the authored nodes the drawing moves are reinserted,
which
  it doesn't count, and what follows moves the same either way.)
- Rejected: off Leaf the widget renders its own template with no
adoption. The
template is the producer's and calls the producer's tools, so that path
needs
the same module and tools, with the branch in each widget instead of in
  `initialRender`, which seven other `x-initial` widgets can share.
- On the motion playground the page reaches its first presented state
with 3
fewer requests (2 of them script) and 5 KB more, and on lost-update with
3
  fewer and 1.5 KB more, against main.

**The widget.** It extends `HTMLElement` and draws its transport with
Lit's
`render` in the task that changes it, as it already did for every frame,
so it
claims no presentation. `onUserInput` becomes window capture listeners
for the
inputs prepaint counts, `signal` a private field, and `reducedMotion`
and
`onMotionPreferenceChange` portable exports.
- Rejected: `LitElement` with a `PendingTaskEvent` on its first update,
which
adds Lit's asynchronous scheduler beside the per-frame `render` and a
public
`LitElement` export. Also rejected: splitting `LeafElement` so Leaf
attaches
presentation from outside, a change to all 30 `LeafElement` widgets for
  state this one doesn't read.
- What `LeafElement` gave it that no longer applies: a region claim per
update
and no drawing while detached; motion's setters drew directly before
too.
- **Play** is the widget's own button. Its row names the press its
control
makes, with no `run`, so the register runs nothing for it; one click
listener
plays when there is something to play; and the transport draws the
button
`aria-disabled` from a `playable` input, the availability the register
reads.
  The producer reads the study's videos before the coordinator moves the
authored nodes into the body box, so a video study is available from
first
  paint.
- **A playback failure** reaches the agent through `reportFailure`, and
the
clock's place says "Failed" until the next press or seek, on any page.
It
replaces `raiseError`, whose notice exists only in Leaf's panel. The
word
  fits the clock's 9ch box, where "Playback failed" moved the transport.
- **A drawing failure** shows the fail-soft box beside the transport,
placed
by the widget (`placesFailure`): the default replaced the Lit part,
whose
template holds the author's study, so a throwing frame deleted the study
and a
frame that kept throwing swapped box and transport every frame. One
failure
keeps one box and stops the clock, and a frame that draws takes it away.
Play
draws the first frame before saying Pause, so a throwing frame doesn't
write
  Pause and back in one task.

No protocol bump: the public package API doesn't move it (#4551).

**Tests.**
- The smoke test adds lf-motion (transport, icon, scrubber), sets
`renderFrame`, clicks Play, and sees the clock and the last frame reach
the
end. The host hides each widget until defined, serves the producer late
so
the page paints first, lays its widgets two to a row with the one that
draws
at upgrade last, so its growth moves nothing under the shift watch, and
holds
  the clock to one width as the package's stylesheet does.
- New
`test_a_motion_failure_shows_beside_the_study_and_reaches_the_agent` and

`test_play_is_available_from_first_paint_only_where_there_is_something_to_play`.
`test_timeline_steps_by_every_route_and_keeps_the_step` asserts a key's
step
  is said in the live region.
- Each failed when undone: Lit's seam without its native fallback
(`reading
'move'` in `lit.js`); `notifications.js` not hearing `lf-announce` (live
region
empty); the "Failed" word removed; the widget's failure placer removed
(the
study is deleted); the videos read after the body box takes them (Play
drawn
  `aria-disabled` at first paint on a video study).
- Also run: `pnpm run test:runtime` (695), `pnpm run check:browser`,
pre-commit, `test_motion.py`, `test_timeline.py`, `test_key_surfaces.py`
(its announce test included), a board's keyboard move, a diff's hunk
step,
  retained moves, the initial-delivery tests, initial settlement, the
pending-task hold, the public API before boot, and a reply's widget
module.

> _This was written by Claude Code on behalf of max-sixty_
leaf-agent added a commit that referenced this pull request Oct 29, 2026
Correct the package guide’s introduction: `page init` records the
package selection, and the Leaf serving, checking or exporting the page
composes its layer. The introduction still described copying the
composed layer into the page, despite #4551 moving ownership to the
reading Leaf; the existing “Package reach” section already explains
where named and path selections come from.

This is a factual correction to existing guidance, with no new policy or
runtime change. The existing selected-layer and public-provider
replacement tests pass (2 tests). No new regression test or instruction
eval is needed for this correction.

Co-authored-by: leaf-agent <[email protected]>
leaf-agent added a commit that referenced this pull request Nov 5, 2026
…ler's old-runtime file check (#5419)

Two pieces of build code handle cases no caller produces any more. This
PR removes them. Nothing any current caller sees changes.

- **Protocol check** (`build/browser/protocol.mjs`): `diff` kept a
branch for `side.overlay`, a mode for schemas that narrow a record
declared elsewhere. #4551 removed its last caller (the `...SENT,
overlay: kinds[kind].record` side), and `protocolBreaks` now passes only
`SENT`, `OLDER_READS` and `READ`, none of which has an overlay. The
branch, its doc sentence and `nested`'s fourth parameter are removed.
`baselineSchemas`' doc now also names the widget declaration schema,
which it drops along with the served state and the x-state verb.
- **Kernel bundler** (`build/runtime-bundle.mjs`): before compiling
`runtime/annotation-overlay/check-api.js`, `kernelOutputs` checked that
the file exists, so that comparison arms whose runtime predates it would
still build. Its only caller, `leaf-dev`'s distribution `prepare`,
compiles this checkout's own payload, which always has the file.
AGENTS.md ("Stage") rules out code kept for earlier runtimes. The kernel
now compiles its diagnostic entries unconditionally. I also removed the
test case that built a kernel from a layer missing the file, since no
caller builds one. A site's layer is still bundled from `runtimeEntries`
alone (`worker/bundle-runtime.mjs`, `bundleLayer`), as before.

`node --test build/runtime-bundle.test.mjs
build/browser/protocol.test.mjs` passes (7 tests). ESLint and Prettier
aren't installed in this sandbox, so I'm leaving the lint check to CI.

---------

Co-authored-by: leaf-agent <[email protected]>
max-sixty added a commit that referenced this pull request Nov 10, 2026
…5798)

An open page now keeps its document when the page server and the agent's
`leaf` commands run different Leaf versions. Before, each version took
the other's capture of the same `index.html` for a change, published it
again as a new revision, and the tab reloaded at every one.

## What was happening

A page server keeps the Leaf it started with, while the agent's commands
run the session's current Leaf: a plugin update since the server
started, or a worktree's `bin/leaf`. Since #4551 each Leaf composes the
page's vocabulary from its own bundled packages, so two versions compose
different vocabularies whenever any bundled registry changed between
them, which most commits do.

A revision's `executable` digest decides whether an open tab patches in
place or loads a fresh document, and it included a digest of that
composed vocabulary. The revision's identity (its manifest digest)
includes `executable`. So on every state read the server captured the
source as revision N with its vocabulary, the agent's next `leaf thread
reply` captured the identical source as N+1 with its own, the server's
next read captured N+2, and so on. Every revision had a different
executable from the last, and each one reloaded the tab.

Evidence from the pages on this machine, read from each page's
`observations.jsonl` and revision manifests:

- On the 68 pages where a Firefox tab was replaced since October, 678 of
the 805 executable changes between consecutive revisions from 2026-10-28
on, the day #4551 landed, had identical scripts, page modules and layer
generation; 417 revision pairs differed in nothing but `executable`.
Before that day there were none.
- In the week of Nov 2-8, 56 of the 79 same-tab reloads in Firefox were
this. One page's executable alternated between two values for an hour,
with revisions minted in pairs a second apart, server then CLI.
- Reproduced with two copies of the tree, one with a bundled registry
description reworded, alternating `leaf page state` on one page: 6 reads
made 6 revisions with alternating executables on `main`, and 1 revision
with this change.

## The change

The executable digest now covers only what the page owns: the layer
generation, the annotation mode, the page's own declarations
(`page/registry.json`), its modules and its script elements. What an
open document runs under comes from the serving Leaf, and each part
already reaches the tab by another route: a runtime or bundled-package
change as a server that refuses the tab (`runtime_selection`), and a new
selection or changed package copy as a new generation (`vendoring`).

The manifest also drops `public_modules`, the capturing Leaf's list of
public runtime modules, which nothing read and which minted duplicate
revisions the same way whenever that list changed between versions.

Behavior change in tests:
`test_two_leaf_versions_capture_one_source_as_the_same_revision` holds
that two vocabularies capture the same revision and that a change to the
page's declarations still loads a fresh document;
`test_authored_lazy_positioning_import_uses_the_runtimes_public_provider`
no longer asserts the dropped `public_modules` field.

## What's left

- A package installed by name (`leaf package install`) and updated while
a server runs changes what the next revision runs under without changing
the generation or the runtime identity, so the tab now patches in place
and keeps the old widget code until it reloads. The vocabulary digest
caught this only when the update changed the package's registry; an
update to its modules alone already escaped it. No page on this machine
selects an installed package. The fix is to judge the reload against
what the server serves the revision with, the execution identity
`runtime_selection.executing` already computes for resource addresses,
or to have an install move the generation of the pages that select it.
- The manifest's `declarations` and `implementations` still list the
capturing Leaf's layer-owned tags, so two versions that differ in which
bundled widgets exist still mint a duplicate revision, which patches in
place rather than reloading. Making them page-owned changes what an
older Leaf at the same protocol reads, so it belongs with the next
protocol bump.
- The other reloads observed were a server restarted under a newer Leaf:
the tab's runtime code no longer matches the server's, so it has to load
a fresh document.

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

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>
max-sixty added a commit that referenced this pull request Nov 20, 2026
… copy installed since

A session's hooks, watch and bare `leaf` commands now run the plugin copy the
session loaded, as Claude Code intends: it puts that copy's `bin/` on the Bash
tool's PATH and names it in each hook. They still hand themselves to a checkout
the session selected. This reverses #4557, which handed every session to the
copy `installed_plugins.json` records, and deletes that hop from the launcher
(`bin/leaf`) and `session_runtime`, with the pages follower's restart on it.

The hop stopped buying what it was added for a day after it landed. #4557 fixed
idle sessions refusing pages a newer Leaf had re-vendored (94% of pickup wait,
20-27 Oct). #4551 then stopped copying the layer into pages, so the protocol
covers only the log and records, and only the session holding a page renews it
(`vendoring.renew_layer`), so a session's pages stay at its own copy's protocol.
Of 36 live sessions on 2026-11-19, 34 ran a replaced copy, and 33 were at the
installed copy's protocol (51) anyway; the protocol moved 15 times in the last
1,318 commits.

The hop also ran code the session's instructions didn't describe: two live
sessions loaded a copy at protocol 44 whose references tell the agent to pass
`--markup` to a thread message, a flag the installed Leaf dropped (#6208). With
it gone, a session's instructions, hooks module and Python are one copy, except
under a selected checkout, and Leaf no longer reads Claude Code's undocumented
install record or cache marks. An update now reaches a running session when it
runs /reload-plugins or starts anew. A copy that has lost its project still
refuses, naming /reload-plugins, rather than leave uv to run the caller's
`python`.
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