Skip to content

Keep pages working across Leaf updates in the render gate and Codex delivery - #2505

Merged
max-sixty merged 5 commits into
mainfrom
fix-delivery-cursor
Oct 12, 2026
Merged

max-sixty merged 5 commits into
mainfrom
fix-delivery-cursor

Conversation

@max-sixty

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

Copy link
Copy Markdown
Owner

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

max-sixty and others added 3 commits October 11, 2026 22:23
…elivery

The render gate refused any page whose vendored runtime differed from the
running Leaf's (`layer.foreign_runtime` on `$layer.runtime`), which nearly every
plugin update changes, so the pre-handover `page check --render` failed on every
existing page until `leaf page init` restarted its server and reloaded the
user's tab; `page picture`, which loads no probe module, stayed refused forever
on revisions saved before an update. Every page snapshot now serves this Leaf's
probe modules, whichever Leaf captured the revision, so the 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 (a missing export)
refuses naming the re-vendor, with the browser's reason. `foreign_runtime`,
`payload_runtime_fingerprint` and `$layer.runtime` are deleted.

Input on a page vendored at another protocol could not be receipted, yet the
watch delivered it 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` hands a
watch or a Codex capture no input from such a page; the prompt hook still names
the page and the re-vendor.

The browser build now holds the generated event contract to the protocol:
`protocol-contract.d.ts` keeps the 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, until it
keeps taking them or the number moves. A passing build moves the baseline
forward; a bump starts it again.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>

@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 Claude Code and Pi prompt hook still offers fresh input from a page this Leaf cannot write. hook_transport.read_plans() builds plan.batch from unacknowledged(...), and carry_turn() includes it even when plan.unwritable is set. The new receive_batch() refusal then makes render() hand out a delivery pointer whose receipt cannot succeed; later prompt or Stop hooks can offer the same input again. Filter unwritable plans out of the hook's new-input batches, while keeping the re-vendor remedy in the prompt.

The Claude Code and Pi prompt hook built its new-input batch from every
unacknowledged event, so on a page vendored at another protocol it handed
over a pointer whose receipt `receive_batch` now refuses, and every later
prompt or Stop offered the same input again. `read_plans` now takes
`delivery.deliverable`, which also answers a quiet page without loading its
layer, keeping Codex's per-tool-call hook off the page model. The protocol
check's constants are no longer exported, since nothing imports them.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
leaf-agent
leaf-agent previously approved these changes Oct 12, 2026
…nter

`test_a_hook_hands_input_it_cannot_confirm_to_its_reader` asserted the old
behavior: a pointer to input on a page vendored at another protocol, which
the reader could never acknowledge. The hook now offers no such input, so
the test folds into `test_a_prompt_offers_no_new_input_from_a_page_its_leaf_cannot_write`,
which also checks the input is handed over once the page is writable again.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
@max-sixty
max-sixty merged commit e21a6dc into main Oct 12, 2026
3 checks passed
@max-sixty
max-sixty deleted the fix-delivery-cursor branch October 12, 2026 06:57
max-sixty added a commit that referenced this pull request Oct 12, 2026
The task → todo rename (#2506) and the contract snapshot (#2505) landed
together, so main's check:browser fails; this regenerates it.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
max-sixty added a commit that referenced this pull request Oct 12, 2026
#2505 and #2506 landed together: the contract still described protocol 1
with the task names, so check:browser failed on main and on every PR.
This is build:browser's output from the merged source.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
max-sixty added a commit that referenced this pull request Oct 12, 2026
#2505 and #2506 landed together with the protocol contract still at protocol 1,
so every pull request's bundle check fails before the suite runs.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
max-sixty added a commit that referenced this pull request Oct 12, 2026
Branch protection now requires `test`, the combined CI gate. Remove the
temporary `lint` dependency check used to land the rename while the old
requirement was still active.

Also regenerate the protocol baseline introduced by [PR
#2505](#2505). That change landed
a protocol-1 baseline after the registry had already moved to protocol
2, causing the cleanup PR's browser build to fail with `Stale protocol
contract`. The canonical build refreshes the baseline for protocol 2; no
other generated output changes.

Reuse the reviewed correction from [PR
#2533](#2533): export `createRef`
from the widget API so the website can bundle `lf-trace`, and check that
widget imports resolve through the API. That PR was blocked by the same
stale protocol baseline; combining the corrections lets the cleanup
clear both CI prerequisites.

Validation: `pnpm run build:browser`, all 361 runtime tests, the focused
widget API test, pinned actionlint, YAML validation and `git diff
--check` passed.

> _This was written by Codex on behalf of max-sixty_

---------

Co-authored-by: leaf-agent <[email protected]>
leaf-agent added a commit that referenced this pull request Oct 12, 2026
Export Lit's `createRef` through `widget-api.js` so `lf-trace` can be
bundled for the website. The [failed publish
run](https://github.com/max-sixty/leaf/actions/runs/38214399140) stops
because `lf-trace.js` imports `createRef` from that API, while the API
exports only `ref`. The browser runtime already exports both names.

The existing widget API test now checks that every name imported by a
behavior module is exported. It failed with `['createRef']` before the
fix and passes after it. The site build produced all 105 pages locally,
and `pnpm run test:runtime` passed.

This PR also refreshes the generated protocol contract. [PR
CI](https://github.com/max-sixty/leaf/actions/runs/38215371869) could
not reach the site gate because the earlier contract from #2505 no
longer matched #2506's event names; `node build/browser/build.mjs
--check` failed on `main` and `pnpm run check:browser` passes with the
regenerated contract. #2536 carries the same contract refresh alongside
its workflow cleanup, but its own site gate failed on the missing
`createRef`. Including both repairs here lets the required `test` check
verify and land them together.

---------

Co-authored-by: leaf-agent <[email protected]>
leaf-agent added a commit that referenced this pull request Oct 12, 2026
The failing probe test now exercises a module fault while preserving the
render gate’s re-vendor guidance. In [main run
38239628776](https://github.com/max-sixty/leaf/actions/runs/38239628776),
the test injected a missing export and expected a browser gate finding,
but the loader raised `ProbesUnlinked`. That exception is the path added
in #2505 for a page whose vendored runtime lacks an import required by
this Leaf’s probes; `preview_server` turns it into a re-vendor
instruction. Catching it as a generic finding made
`test_the_browser_gate_names_the_re_vendor_when_its_probes_cannot_link`
fail in this PR’s first CI run.

The test now injects a module execution error, which reaches the
existing generic probe failure path. Both the revised browser gate test
and the re-vendor test pass locally (`uv run pytest -q -n0
tests/test_render_gate.py::test_a_broken_probe_module_is_a_gate_finding
tests/test_interact_layer.py::test_the_browser_gate_names_the_re_vendor_when_its_probes_cannot_link`).

---------

Co-authored-by: leaf-agent <[email protected]>
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