Repository navigation
Declare the page protocol in the kernel's $events, beside what it numbers - #2486
Merged
Merged
Conversation
A hook records pickups in two places: receipt of a delivery, and the entry of already-acknowledged, unanswered updates into a new turn (`pick_up_acknowledged`). The previous change made a refused receipt hand its delivery over as a pointer, but the second writer still raised on a page another Leaf vendored: a prompt hook whose session owed an answer there exited 1 before printing, so the turn got no delivery, no reminder and no reason. The hook plan now reads `event_contracts.write_refusal` once per page, the same check the append door raises on. The hook records no pickup on a page it cannot write and names the refusal (with its `leaf page init` remedy) in the turn's attention, beside the pointer or debt reminder. Behavior change: on such a page the prompt hook reminds the turn of its debt instead of failing, and an undeliverable batch's pointer arrives with the reason. Test: a prompt on a foreign page with acknowledged debt. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…col bump Every page server refused a page whose vendored runtime fingerprint (a hash of all of assets/runtime/) differed from the running Leaf's, and since #2416 the append door also refused any write when the hash of all Leaf's Python differed. Over the last 30 days those hashes changed in 751 and 494 of 1828 commits, so nearly every plugin update made every open page unservable and unwritable by the newly installed Leaf, hooks included, until `leaf page init`. That is what stopped a live session's hooks from confirming receipt. Compatibility is now a declared number. `layer.PROTOCOL` is recorded by `page init` under `$layer.protocol`, and every page server and the append door refuse only a page vendored at another number (`layer.incompatible_layer`). The comment on PROTOCOL says when to bump it. The render gate keeps the exact runtime check, now in `render_gate.preview`, because its probe modules import the page's runtime modules by name. Additive kernel changes stay compatible at one number because the running Leaf owns the kernel's event records: admission, the browser door and sample histories validate against `registry.kernel.kernel_event_kinds()` instead of the page's captured `$events` copy, and reading a vendored layer no longer requires that copy to equal the running kernel (`validate_event_contracts` is gone; `merge_layer_declarations` still stops a layer changing `$events`). This fixes #2415 part 1 (a newer CLI's reply refused by an older page's schema) without a re-vendor. Behavior changes: a page another Leaf vendored at the same protocol is served, written and checked; one vendored at another protocol, including every page vendored before this change, is refused once with the `leaf page init` command. Tests: the reply and page-check case on an older vocabulary, and the protocol refusals (server start, wait revival, website, reply, hooks). Three tests that relied on a mismatched kernel copy being refused now expect it to be read: an old plugin missing `attempt`, a page an earlier Leaf left behind, and the Stop-guard test, which now breaks a required declaration instead. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
# Conflicts: # skills/leaf/scripts/leaf/event_contracts.py
# Conflicts: # worker/leaf_website/__init__.py
…bers The protocol number was a Python constant, `layer.PROTOCOL`, that `page init` stamped under `$layer.protocol`, apart from every schema it versions. It now lives in the kernel registry as `$events.protocol`, beside the kinds and ownership it numbers, where Leaf's other format versions already sit (`leaf-drawing/3` is a `const` in the same object). A page carries the number in the `$events` it was vendored with, so the `$layer` stamp, its storage check and its place in the re-vendor comparison are gone: the fingerprint covers it. `incompatible_layer` now reads the registry a server would serve the page under, a snapshot's captured one or else the vendored layer, rather than a layer identity. Snapshot previews copied the raw `$layer` and lost the number, so they refused fresh pages. A layer may restate only `$events.handling` and `answering`; every other member is the kernel's, compared as JSON so `true` or `1.0` is not taken for 1, and the kernel's copy is kept. The bump rule moves from the constant's comment to layer-registry.md, "Page protocol". The stale `$events` claim that `page init` checks the existing log, removed in #2020, gives way to the protocol sentence. Behaviour change: a page vendored under #2476 records the number only under `$layer`, so it is refused once until `leaf page init`. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
leaf-agent
approved these changes
Oct 12, 2026
max-sixty
added a commit
that referenced
this pull request
Oct 12, 2026
…elivery (#2505) Follows #2476 and #2486, which let any Leaf at the same page protocol serve and write a page another Leaf vendored. Three places still broke on an ordinary plugin update, or would break silently when a contract change slipped past the bump. **The render gate refused nearly every existing page after an update.** `layer.foreign_runtime` refused any page whose vendored runtime bytes differed from the running Leaf's, which most commits change, so the pre-handover `page check --render` failed until `leaf page init` restarted the page's server and reloaded the user's tab. `page picture`, which loads no probe module, was refused forever on revisions saved before an update. Now every page snapshot serves this Leaf's probe modules (`page_snapshot.py`), whichever Leaf captured the revision, so the gate's Python readers and the probes they call always agree, and the probes link against the page's runtime by name. A probe load that fails with a `SyntaxError` answers `{unlinked}` from the driver, and the gate refuses with the browser's reason and the re-vendor (`render_gate/preview.py`). `foreign_runtime`, `payload_runtime_fingerprint` and `$layer.runtime` are deleted. **Input on a page this Leaf cannot write looped.** On a page vendored at another protocol no receipt can be recorded, yet the watch delivered its input on every pass, and Codex's receipt paths, which catch only `ReceiptRefused`, failed every retry with `EventRefused`. `receive_batch` now refuses such a receipt as `ReceiptRefused`, and `delivery.deliverable` gives a watch, its nudge, both Codex capture sites and the Claude Code and Pi hooks no input from such a page. The input waits for a Leaf that can write it; the prompt hook still names the page and the re-vendor. **Nothing caught a breaking event-contract change shipped without a bump.** The browser build now keeps `build/browser/protocol-contract.d.ts`, the generated event contract as it last stood at the current `$events.protocol`, and `protocol.test.ts` fails a change that drops a kind or a field at any depth, requires a new one, or narrows a type or constant. A passing build moves the baseline forward; a bump starts it again. Patterns, bounds and conditional clauses are not in the generated types, so they stay unchecked, as `layer-registry.md` says. Tests: `test_the_browser_gate_reads_a_page_another_leaf_vendored` and `test_the_browser_gate_names_the_re_vendor_when_its_probes_cannot_link` replace the refusal test, and fail on the old gate; `test_codex_retires_a_receipt_on_a_page_its_leaf_cannot_write` and `test_a_watch_delivers_nothing_from_a_page_its_leaf_cannot_write` and `test_a_prompt_offers_no_new_input_from_a_page_its_leaf_cannot_write` reproduce the loop. The protocol check was exercised by dropping a nested drawing field, a field inside a list, a kind, adding a required field and changing the drawing format (each fails), and adding an optional field (passes). > _This was written by Claude Code on behalf of max-sixty_ --------- Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
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.
Follow-up to #2476. The page protocol number was a Python constant,
layer.PROTOCOL, thatpage initstamped under$layer.protocol, apart from every schema it versions. It now lives in the kernel registry as$events.protocol, beside the kinds and ownership it numbers, where Leaf's other format versions already sit (leaf-drawing/3is aconstin the same object). A page carries the number in the$eventsit was vendored with, so the$layerstamp, its storage check and its place in the re-vendor comparison are gone; the layer fingerprint covers it.layer.incompatible_layerreads the registry a server would serve the page under: a snapshot's captured one, or else the vendored layer. Snapshot previews copied the raw$layerand lost the number, so they refused freshly initialized pages.$events.handlingandanswering; every other member is the kernel's, compared as JSON sotrueor1.0is not taken for 1, and the kernel's copy is kept (registry/layer.merge_layer_declarations).layer-registry.md, "Page protocol". The stale$eventsdescription claim thatpage initchecks the existing log (removed in Clarify navigation and keep decided pages editable #2020) gives way to the protocol sentence.Behaviour change: a page vendored under #2476 records the number only under
$layer, so it is refused once untilleaf page init.The other version marks stay separate:
Leaf-Layerchecks a tab against the page's current layer, andleaf-delivery-v5,leaf-codex-delivery-v4andleaf-user-views-v1version state-home records that change independently of the page contract.