Repository navigation
Let a comparison reach a version stamped before a re-vendor - #776
Conversation
A revision keeps the layer it captured, and both `/api/view` and the immutable document answer for that generation rather than the page's. Version comparison ran both through the delivery gate, which reads a foreign generation as the page being re-vendored underneath the reader. After any re-vendor the base of a comparison is foreign by definition, so the page refused its own comparison, abandoned it silently, and told the reader the server was updating. Measured: a page stamped at v1, re-vendored, then stamped at v2 keeps `e258ffa7…` in r1's captured registry while the live page answers for `37c87ab9…`. The new case drives that page's chooser and requires the comparison to paint. An artifact fetch is not a delivery answer, so neither goes through the gate. A layer that really did move under the reader still reaches them through the state feed, which is the live channel and refuses on its own. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
leaf-agent
left a comment
There was a problem hiding this comment.
authoredDocument has a second caller that is not a comparison: revisionDocument feeds
prepareActivation, which hands the fetched document to activateRevision and patches it into
the reader's live document. So the gate comes off that path too, and the refusal it fed is now
unreachable — the function either returns a document or throws, so prepareActivation's
if (doc === null) return { stale: true, activates: () => false } can never fire, nor can its
consumer in state-application.js (if (activation?.stale)), nor the stale: false the two
other returns carry. The comment above prepareActivation still states that contract —
"stale where the document came from a re-vendored layer, so the page is reloading" — so a
later reader has to re-derive that it is dead, which is the guard CLAUDE.md's Stage
asks not to keep ("Add a guard only for a reachable condition with a useful response").
Deleting looks right to me rather than re-gating that call site, because the activation path is
already covered twice over: a revision stamped after a re-vendor carries different
layer-client.js bytes, so its executable digest differs from the served one and
prepareActivation returns reloadInto before it ever fetches a document, and receiveState
refuses a foreign state layer before preparing an activation at all. But that is the reasoning
this thread would be the only record of — with stale gone, the new comment on
authoredDocument can say plainly that both of its callers read a document stamped for the
revision it names. Happy to push that cleanup if you'd rather not carry it.
One smaller thing, since it is the sentence this change invalidates:
test_a_page_asks_its_source_before_reloading_onto_the_same_document in
tests/test_render_startup.py gives "a version comparison refused against the captured layer of
the revision it names" as one of the two reasons each refusal reads the source afresh. After
this PR no comparison refuses; the re-vendor-during-the-hold reason still carries the test.
What I ran
tests/test_render_projection.py (143 passed) and tests/test_render_startup.py (95 passed) at
this head, and the new case alone against
skills/leaf/assets/runtime/version.js from the merge base, where it fails on
#new-copy never taking lf-ins-block — so the case does pin the fix.
`authoredDocument` also feeds `revisionDocument`, so taking its null return away left `prepareActivation`'s refusal unreachable and the `stale` flag on its answer dead: the branch, the two `stale: false` returns, and the reading in `state-application.js` that consumed them. Delete rather than re-gate. A re-vendored layer changes the revision's executable identity, which takes the fresh-document install above this path, and a state belonging to another layer is refused by `receiveState` before it arrives. The comment claiming this answer's own reason goes with it. The new comparison case now asserts that its second `page init` succeeded. Its whole premise is that the re-vendor happened, and `CliRunner` returns a non-zero exit rather than raising, so a refusal would have left the comparison base unforeign and the case passing against the runtime it exists to pin. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
leaf-agent
left a comment
There was a problem hiding this comment.
Both points are settled in e924511, and I checked the deletion is complete rather than partial. authoredDocument now either returns a document or throws, revisionDocument only re-throws, and both callers of prepareActivation already read it null-safely — state-feed.js through activation?.activates() and state-application.js the same — so a document that fails to load still lands on the catch's null, the path that already meant "nothing to follow". The notifyChangedData() the deleted branch shared is still reached by the three refusals below it. Nothing under skills/leaf/assets/ names stale on an activation any more, and the new comparison case now asserts the re-vendor its premise rests on.
Ran at that head: tests/test_render_startup.py whole file, 95 passed — that is the file covering the activation path the deletion touches — plus the new case in test_render_projection.py. lint and test are green on the same commit.
One mechanical leftover of the comment rewrite: version.js:1466 leaves // Whether the move alone on its line where the new sentence ended above it. Prettier doesn't rewrap comments, so nothing downstream reflows it.
Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
The nightly leg of `ci` on `main` went red on [run 35295861023](https://github.com/max-sixty/leaf/actions/runs/35295861023): `test_tab_extends_the_comment_with_individual_emoji_buttons` opened the command reference expecting its `z` row to read `Take back: shorten on “The store is capped…`, and read a register of 81 commands with no such row. The case now opens the reference from the moment the page says the press is live, which is the fact the row states. That row is dead until the page has taken in a log reading that accounts the reader's own send. `history.undo`'s `when` clause asks `!unaccountedGesture() && Boolean(undoable())` ([`keyboard/page.js:1178`](https://github.com/max-sixty/leaf/blob/8d8bec8005c970234abd5f33415c25463a09aa01/skills/leaf/assets/runtime/keyboard/page.js#L1178)), and `undoable()` reads the server projection `runtime.view.undo` and answers null while a state is still being applied ([`projection/commands.js:19`](https://github.com/max-sixty/leaf/blob/8d8bec8005c970234abd5f33415c25463a09aa01/skills/leaf/assets/runtime/projection/commands.js#L19)). The case pressed `?` straight off `painted()` — the forward paint the reaction makes in the turn it sends, a turn before that reading arrives — and the register is built at the press, so the sentence it asserts could not be in it. `render_harness.undo` already carries this exact hazard for the `z` press itself, and waits on the line offering the chip: the line and the dispatcher ask one predicate, so the chip standing on the line is the page saying the press will be taken. This case waits on the same fact one step earlier, before opening the reference that names it. Not caused by `8d8bec80`, the commit this run reports on. The ordering was never stated; #774 (`145da07d`, serving each page through starlette and uvicorn) moved the timing into the window it left open. CI says the same on its own: the nightly leg of `145da07d`'s [run 35289151800](https://github.com/max-sixty/leaf/actions/runs/35289151800) failed this case with this message, and the last green `main` nightly before it is `f292b4d2` ([run 35282456731](https://github.com/max-sixty/leaf/actions/runs/35282456731)). `dc694cd8` and `80c26f0f` sit between them and were replaced before their nightly ran, so CI has no reading on either; the local repeats below cover that gap. <details><summary>Measurements</summary> All on this runner, `-n0 --run-nightly`, one node id. At the old press point the press was dead in 6 of 6 runs, and the new wait returned 3–117 ms later — so the case was green only when the reading happened to land inside the poll of the `to_be_hidden()` above it. Reopening the reference 1.5 s after a failing read showed 82 commands, so the row was merely late rather than absent. Where the window opened, by repeat runs of the case alone: | commit | result | per run | | --- | --- | --- | | `43d92073` (#767) | 4 passed | 3.8 s | | `80c26f0f` (#773) | 4 passed | 3.8 s | | `145da07d` (#774) | 3 failed, 1 passed | 4.8 s | | `8d8bec80` (#776) | 1 failed | 4.8 s | | `e382d828` (`main`) | 2 failed, 1 passed | 4.8 s | </details> Checked: the case 6/6 green with the change, `tests/test_render_reactions.py` under `--run-nightly` (50 passed), and `pre-commit run --files tests/test_render_reactions.py`. The everyday suite ran 1130 passed / 5 failed here, and all five are this sandbox rather than the change — three `test_interact_session.py` cases that need a writable `/tmp` for their private unix socket, `test_staged_writes_honor_umask`, and `test_live_shell_artifact.py::test_a_browser_executes_the_published_capture_with_live_api_routes[True]` on its node bundle step. The `test` job of the run above is the Linux control and was green on this commit; this change touches only a nightly-only file. Co-authored-by: leaf-agent <[email protected]>
A revision keeps the layer it captured, and comparing to it is not a re-vendor.
/api/viewand the immutable document both answer for that captured generation rather than the live page's (http.py's_send_documentand its/api/viewbranch), andversion.jsran both throughsameDelivery, which reads a foreign generation as the page being re-vendored underneath the reader. After any re-vendor the base of a comparison is foreign by definition, so the page refused its own comparison, abandoned it without a word, and told the reader the server was updating.Measured on a real page: stamped at v1, re-vendored, stamped at v2, r1's captured registry still holds
e258ffa7…while the live page answers for37c87ab9…. The new case intest_render_projection.pybuilds that page, drives its chooser to compare against v1, and requires the comparison to paint. It asserts its secondpage initsucceeded, since a refused re-vendor would leave the base unforeign and the case green against the runtime it exists to pin.An artifact fetch is not a delivery answer, so neither goes through the gate, and
sameDeliveryleavesversion.jsentirely. A layer that really did move under the reader still reaches the page through the state feed, which is the live channel and refuses on its own.authoredDocumentalso feedsrevisionDocument, so taking its null return away leftprepareActivation's refusal unreachable and thestaleflag on its answer dead. That axis is deleted rather than re-gated — the branch, bothstale: falsereturns, and the reading instate-application.jsthat consumed them — because a re-vendored layer changes the revision's executable identity, which takes the fresh-document install above that path, and a state belonging to another layer is refused byreceiveStatebefore it arrives.Found while verifying leaf-agent's reachability argument on #775, and left out of that PR as separate scope.
Checked: everyday suite (1138),
test_render_projection.pyandtest_render_startup.pyunder--run-nightly(238), andpre-commit run --all-files.