Skip to content

Make the layer record's format number the page protocol, at protocol 55 - #6954

Merged
max-sixty merged 2 commits into
mainfrom
agent-ac298f7d8f7a8750e
Nov 24, 2026
Merged

max-sixty merged 2 commits into
mainfrom
agent-ac298f7d8f7a8750e

Conversation

@max-sixty

Copy link
Copy Markdown
Owner

Makes the format number of a page's layer.json its page protocol, so one comparison decides whether a Leaf serves, renews or refuses a page, and bumps the protocol to 55 to do it.

Before this, layer.json carried two versions: the shape number in its format and a separate protocol field. A Leaf read a record at another shape as no record at all. After #6900 changed the shape, every page an older Leaf had initialized read as uninitialized: the hooks never renewed it, leaf page state said "has no layer.json", and leaf page init re-initialized it with no packages. Only the newer direction had a guard, a shape check of its own (Record.newer). This recurs at every change to the layer record's shape.

Now the record has one number. LAYER.since is the kernel's page protocol, so the build's existing since rule refuses a layer shape change until the protocol moves. registry.storage.layer_record refuses any other format by its number: newer-layer above this Leaf's, foreign-layer below. No reader composes from another Leaf's record, and layer.incompatible_layer and its four call sites go. Renewal reads only the packages key from an older record (layer_packages), under a rule stated in layer-registry.md that every shape keeps it. How it works also gains a paragraph saying what the page protocol is.

Worth weighing:

Requested by max-sixty; independently reviewed twice. Tests: tests/model/test_interact_layer.py covers an older shape (renewed, keeping its packages) and a newer shape with packages moved (refused by check, init, state and vocabulary, with the file left unchanged). The focused model and process suites and pnpm run check pass.

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

A Leaf read a `layer.json` at another record shape as no record at all. After
#6900 moved the layer record from `leaf-layer/36` to `leaf-layer/53`, every page
an older Leaf had initialized read as uninitialized: the hooks never renewed it,
`leaf page state` said it had no layer.json, and `leaf page init` with no
`--package` selected no packages. Only a newer shape had a guard
(`Record.newer`), and the failure would come back at each change to the
record's shape.

The layer record's format number is now the page protocol: `page init` writes
`leaf-layer/<protocol>`, and the record's `protocol` field is gone.
`registry.storage.layer_record` returns only a record at this Leaf's format. A
record at another number refuses the page, as `newer-layer` where the number
is higher and as `foreign-layer`, naming the number, where it is lower; any
other file reads as absent, as before. Every reader of a page's layer goes
through that one reading, so none composes another Leaf's record or crashes on
a field a newer shape moved. `layer.incompatible_layer` and its comparison of
the `protocol` field are deleted, and the page endpoint, server reuse,
`page check`, the hooks' `write_refusal` and the website's page binding refuse
through the one reading.

The build's existing rule for a record's `since` now holds the layer record to
the protocol: its `since` is the current protocol, so its shape changes only
with a bump. Dropping the field is itself such a change, so the page protocol
moves from 54 to 55.

Renewal is the one read across versions left. It reads only `packages` from an
older Leaf's record (`registry.storage.layer_packages`), under a rule
`layer-registry.md` now states: a change to the layer record's shape keeps
`packages` as the page's selection, with the same meaning. The leaf-dev code
that reads a page another Leaf initialized uses the same reader: the fixtures
that read a page another arm prepared, so a comparison across a protocol bump
still finds the page's media, the eval report, and the usage survey, which
would otherwise count only pages initialized since the latest bump.
`Record.read` decides by the same parse of `format` as `layer_record`.

`leaf page state` now refuses a page at another protocol and names its repair,
where it printed a reading with the refusal as `source.error`. Its `layer`
field comes from the layer record, which this Leaf no longer reads at another
format, and a reading of a log at another protocol may be wrong. The
`agent_state` header and `serving-pages.md` say so. The turn-end clerk leaves
such a page out of its check, since it could write nothing there.

A page written before #6900 (`leaf-layer/36`, where a default page was
`packages: []` with `theme: {"name": "reading", ...}`) renews keeping its
`packages` but loses its theme, because #6900 changed what `packages` means,
and its refusal names 36, its shape's number, as its protocol. A page
initialized at protocol 54 is likewise refused as protocol 53 until it renews.
Those pages are a one-time population, and AGENTS.md "Stage" rules out code
for them.

How it works now says what the page protocol is: the protocol number of the
Leaf that last initialized a page, covering the page's log and the records
Leaf keeps, and moved by the build's schema checks.

Tests: an older shape's page is refused as `foreign-layer` by the hooks' check
and renewed by `page init` with its packages; a newer shape's page, with
`packages` moved, is refused as `newer-layer` by `page check`, `page init`,
`page state` and `page vocabulary`, which leave the file alone. The newer-Leaf
command test folds into the second. The page-state test now expects the
refusal, and the tests that set another protocol write the format instead of
the field.
@max-sixty
max-sixty merged commit c076ce9 into main Nov 24, 2026
6 checks passed
@max-sixty
max-sixty deleted the agent-ac298f7d8f7a8750e branch November 24, 2026 16:01
max-sixty added a commit that referenced this pull request Nov 24, 2026
Main took protocol 55 for the layer record's format (#6954), so the plan
event's schema change here moves the page protocol to 56.
leaf-agent added a commit that referenced this pull request Nov 25, 2026
#6954 made the layer record's format number the page protocol. Its
description says `leaf page state` now refuses a page at another
protocol in both directions, where before it printed a reading with the
refusal under `source.error`.
`test_a_command_re_vendors_its_sessions_page_an_older_leaf_vendored`
still expected that reading. It also read the layer's `generation`
through `layer_record`, which now refuses the older record as well.
Since #6954 the test fails in the scheduled run on Linux and macOS.

The journey now expects `page state` to exit non-zero and name the page
protocol, as
`tests/model/test_interact_layer.py::test_page_state_refuses_a_layer_this_leaf_cannot_serve`
already does. Its check that reads don't renew the layer now compares
`layer.json` byte for byte before and after `page state` and `page
export`. The rest is unchanged: the reply refused with the re-vendor
named, then the next write re-vendoring and the reply going through.
This repair keeps #6954's intent, and no product code changes.

The test fails on `main` at `32dc564a8` with `assert 1 == 0` at the
`page state` read, and passes with this change (`uv run pytest
tests/journeys/test_interact_layer.py::test_a_command_re_vendors_its_sessions_page_an_older_leaf_vendored
--run-nightly`).

Closes #7177 — automated triage

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