Skip to content

Resolve the layer of the tab's revision in one place - #3099

Merged
max-sixty merged 5 commits into
mainfrom
named-layer-lookup
Oct 16, 2026
Merged

max-sixty merged 5 commits into
mainfrom
named-layer-lookup

Conversation

@max-sixty

Copy link
Copy Markdown
Owner

The page server worked out in five places which layer an answer speaks for the revision a tab reads: the default every authorized answer takes (_named_layer), the write gate (_layer_gate), and the /api/state, /api/deferred and /api/view routes. They agreed for ordinary tabs and disagreed in rare cases: a tab naming no revision after a re-vendor whose source failed to save, and a write from a tab on a revision past a protocol bump. This follows #3098, which made every answer default to the layer of the revision the tab names.

In skills/leaf/scripts/leaf/http.py, named_revision now says which revision the tab reads: the one it names in the query or Leaf-View-Revision, or the active one. _revision_layer says which layer a tab reading that revision speaks: the revision's own, or the page's where this Leaf refuses the revision or there is none. The default, the gate and the state route call them; the deferred and view routes take the default. requested_view_revision loses its header-only mode, which only POSTs used, and they send the same header either way.

The default no longer skips the lookup for a tab on the page's own layer. The lookup costs about 22 µs, measured against 0.5–1 ms for the /api/news answer it most often rides on.

Behaviour changes:

  • A write from a tab on a revision past a protocol bump is answered with the page's layer, so the tab reloads at once, as its news already made it do, instead of reaching the event door's final refusal.
  • A tab naming no revision speaks the active revision's layer on every route. Before, reads answered in the page's vendored layer and writes in the active revision's.
  • A state answer naming no revision speaks the layer of the revision its read left active. Reading state activates the page's source, so that revision may be newer than the one resolved before the read.

Tests: test_a_tab_on_a_revision_past_a_protocol_bump_hears_the_newer_layer now also sends a write, and test_a_state_answer_speaks_the_layer_of_the_revision_it_read is new. Each fails without its part of the change.

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

max-sixty and others added 5 commits October 16, 2026 01:24
Since #2725 (2026-10-12) a tab whose page was re-vendored under it reloaded
at once, mid-keystroke, and without the revision handoff that carries the
user's place and open editor. The cause was the freshness token: /api/news
answered in the page's newer layer, which the stale tab refuses; #2725
pointed the refusal's source probe at the page-root registry, which now
says the source moved, so layer-client.js reloaded immediately. State, event
and deferred answers already spoke the layer of the revision the tab names,
so the version controller would otherwise have taken the newer layer as a
revision with a changed executable: a fresh-document install that waits
while the user composes and hands their place across.

Every authorized answer now defaults to the layer of the revision the tab
names (`_named_layer`), and the news look sends the layer headers that name
it. A tab on the page's own layer skips the lookup. Behaviour change: a
re-vendor reloads an idle tab through the revision handoff, and a tab with
an unsent comment or reply follows only once it is sent or dropped; before,
both reloaded on the next news answer.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
A revision saved at another protocol admits no input (`incompatible_revision`),
so holding a composing tab on it would strand the user's send against a
final refusal. `_named_layer` answers such a tab in the page's layer, which
it refuses and reloads at once, as before. Also corrects version.js's note
on how a re-vendored layer reaches `prepareActivation`.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
# Conflicts:
#	tests/browser/test_render_drafts.py
Five places on the page server worked out which layer an answer speaks for
the revision a tab reads: the default every authorized answer takes
(`_named_layer`), the write gate (`_layer_gate`), and the state, deferred
and view routes. They disagreed in rare cases: a tab naming no revision
after a re-vendor whose source failed to save, and a write from a tab on a
revision past a protocol bump.

`named_revision` now says which revision the tab reads: the one it names
in the query or `Leaf-View-Revision`, or the active one. `_revision_layer`
says which layer a tab reading it speaks: the revision's own, or the
page's where this Leaf refuses the revision or there is none. The default,
the gate and the state route call them; the deferred and view routes take
the default. `requested_view_revision` loses its header-only mode, which
only POSTs used and which read the same header they always send.

The default no longer skips the lookup for a tab on the page's own layer:
it costs about 22 µs against 0.5-1 ms for the news answer it rides on.

Behaviour changes:
- A write from a tab on a revision past a protocol bump is answered with
  the page's layer, so the tab reloads at once as its news already made
  it, instead of reaching the event door's final refusal.
- A tab naming no revision speaks the active revision's layer everywhere,
  rather than the page's vendored layer on reads and the active one on
  writes.
- A state answer naming no revision speaks the layer of the revision its
  read left active, which may be newer than the one resolved before the
  read activated the source.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
# Conflicts:
#	skills/leaf/scripts/leaf/http.py
#	tests/process/test_interact_server.py
@max-sixty
max-sixty merged commit 7f2e834 into main Oct 16, 2026
3 checks passed
@max-sixty
max-sixty deleted the named-layer-lookup branch October 16, 2026 20:43
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