Skip to content

Skip the Leaves tray paint when its element has left the document - #850

Merged
max-sixty merged 2 commits into
mainfrom
fix/ci-35430767109
Sep 19, 2026
Merged

max-sixty merged 2 commits into
mainfrom
fix/ci-35430767109

Conversation

@leaf-agent

@leaf-agent leaf-agent commented Sep 19, 2026 •

Copy link
Copy Markdown
Collaborator

nightly on main failed at 767e36c2 with seven failures and one error. #847 has since landed the seven; this is the error, which #847 does not reach. The Leaves tray throws when a state read finds it gone from the document, and the throw comes back out of the whole state application, so a page reports State presentation failed for chrome it no longer has.

What happens

bake() takes the copy by removing .lf-chrome from the live page (standalone.js), and that page's state stream goes on running until export_page closes the tab. A read that lands in the gap reaches renderOthers → presentLeaves → LiveLeavesList.present, which throws Leaves presentation needs its connected tray for the handle its own disconnectedCallback has already dropped. state-application.js catches it, reports State presentation failed: …, and rethrows, so the read reports again as read failed: … — the pair, twice over, that the run recorded:

ERROR tests/test_render_export.py::test_a_copy_carries_a_workers_standing_report
  'leaf: State presentation failed: Leaves presentation needs its connected tray'
  'leaf: read failed: Leaves presentation needs its connected tray'
  … the same pair again

Whether a read lands in that gap is a matter of the machine's load, which is why this arrives as an occasional error on a copy that is itself correct: alone it passes, and it reproduced once on a6c73f3d in a seven-case selection and not in two repeats of the same selection.

What changes

A tray that has left the document has no region to present into, so presentLeaves returns without presenting. That is the rule the runtime already states for clock-driven paints — tickClock culls an entry whose owner.isConnected is false — applied to the one caller that paints directly. renderOthers is clocked on the list rather than on document.body for the same reason: the body never leaves, so a clock owned by it would go on repainting a tray that has.

The rule is stated in Standalone copies and print in skills/leaf/assets/CLAUDE.md, beside what else baking takes off the live page, because the next chrome paint added here faces the same gap.

Verification

test_a_state_read_outlives_the_chrome_the_copy_takes_out takes .lf-chrome out directly and provokes a read, so the gap is the arrangement rather than the weather. Against the unchanged runtime it fails with exactly the production text; with the change it passes. It sits in tests/test_chrome_contracts.py rather than beside the copy tests: it arranges the gap without any export machinery, so it is one of the shared chrome contracts the everyday gate holds, and a later change dropping the guard is caught on the pull request rather than on main's nightly.

Suite run

uv run pytest tests --run-nightly -n 3 is green apart from failures this sandbox owns and that reproduce on the unmodified tree: four test_render_commands cases and two test_render_export cases where the installed Chrome will not launch here, test_staged_writes_honor_umask_without_copying_a_replaced_symlink_mode, and the demo recorder. tests/test_interact_session.py, tests/test_website_server.py and tests/test_live_shell_artifact.py are deselected: the first two need a writable /tmp, which the agent sandbox mounts read-only, and the third needs worker/node_modules.

Baking a copy removes `.lf-chrome` from the live page while that page's
state stream is still running, so a read landing before the tab closes
reached a detached `LiveLeavesList`. `present` threw for the handle its
own `disconnectedCallback` had dropped, and the throw came back out of
the whole state application: the page reported `State presentation
failed` and `read failed`, both naming a tray it no longer had.

`presentLeaves` now returns without presenting when the list is not
connected — the rule `tickClock` already states for clock-driven paints,
applied to the one caller that paints directly — and `renderOthers` is
clocked on the list rather than on `document.body`, which never leaves.

`test_a_state_read_outlives_the_chrome_the_copy_takes_out` takes the
chrome out directly and provokes a read, so the gap is the arrangement
rather than the machine's load.

@leaf-agent leaf-agent left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The runtime change reproduces and the guard holds: against the unchanged live-leaves.js the new test fails with exactly the production pair — State presentation failed: Leaves presentation needs its connected tray / read failed: …, repeated per read — and passes with it. presentation.ts's disconnect retires the region's barrier member, so skipping the present leaves nothing claimed and whenDocumentPresented still settles.

One thing to change: tests/test_render_export.py carries pytestmark = pytest.mark.nightly, so the regression this fix exists for is pinned only in the nightly selection. The test arranges the gap itself — it removes .lf-chrome and appends a command, with no export machinery in it — which makes it a shared-chrome contract rather than an export one, and tests/CLAUDE.md puts those in the everyday gate: "the shared chrome contracts whose regressions must block a pull request". Left where it is, a later change to presentLeaves that drops the guard lands on main and comes back as an occasional nightly error — the loop this PR closes.

tests/test_chrome_contracts.py is that gate's home and already has everything the case needs: open_page, told and serve from render_harness, and render_cases_interaction, where REPORT_PAGE lives. I'll push the move.

test_a_state_read_outlives_the_chrome_the_copy_takes_out arranges the gap
itself — it removes `.lf-chrome` and appends a command, with no export
machinery in it — so it is a shared chrome contract rather than an export one.
`tests/test_render_export.py` carries `pytestmark = pytest.mark.nightly`, which
left the guard this branch adds pinned only in the nightly selection: a later
change dropping it would reach main and come back as the same occasional error.
`tests/test_chrome_contracts.py` is where tests/CLAUDE.md puts the chrome
contracts whose regressions must block a pull request.
@leaf-agent

Copy link
Copy Markdown
Collaborator Author

nightly on main hit this again one commit later, at ffa9b9f8 — a second, independent occurrence, and it records the failure that the owner change in this diff answers.

That run's seven failures are the same node ids as run 35430767109's, and nightly on a6c73f3d (#847) is green, so nothing in it is outstanding but the tray — twice over, on two different routes:

ERROR tests/test_render_export.py::test_a_copy_carries_a_workers_standing_report
  'leaf: State presentation failed: Leaves presentation needs its connected tray'
  'leaf: read failed: Leaves presentation needs its connected tray'

ERROR tests/test_render_export.py::test_the_exported_corpus_stands_on_its_own
  'leaf: clock paint failed: Leaves presentation needs its connected tray'

clock paint failed is new — run 35430767109 carried only the State presentation failed / read failed pair — and it is the clock route rather than the read route. tickClock culls an entry by entry.owner.isConnected, so an entry owned by document.body is never culled: the tick goes on calling renderOthersNow → presentLeaves → present on a tray whose disconnectedCallback has dropped its handle, and reportError names the rejection clock paint failed.

Both routes end at the same present, so the isConnected guard alone would silence both readings. The owner change is what stops the page painting chrome it no longer has on every tick — and it now has a recorded failure of its own rather than only the argument beside it. The description reads it as the smaller half; on this evidence it is the one that ends the repaint.

@leaf-agent

Copy link
Copy Markdown
Collaborator Author

nightly on main hit this a third time, at d6aa29b2 — and this run isolates it: #848 landed, the seven failures are gone, and the tally is 2800 passed, 3 skipped, 1 error. The error is this one, with the same pair of problems on the same test, so the guard in this diff is now the only thing between main's nightly and green.

ERROR tests/test_render_export.py::test_a_copy_carries_a_workers_standing_report
  'http://127.0.0.1:35243/versions/v1.html?t=test-page-key: leaf: State presentation failed: Leaves presentation needs its connected tray'
  'http://127.0.0.1:35243/versions/v1.html?t=test-page-key: leaf: read failed: Leaves presentation needs its connected tray'

The three occurrences span three separate commits, and the number of reads that land in the gap varies with them — the pair twice over on 767e36c2; two export tests, test_the_exported_corpus_stands_on_its_own and this one, on ffa9b9f8; one pair here — which is the load-dependent window this PR describes rather than a second cause: the read that lands after bake() has removed .lf-chrome reaches presentLeaves for a tray whose disconnectedCallback already dropped the handle, and state-application.js reports and rethrows. Nothing in #848 touches that path: its eight files are shadow.css, registry.json, event_contracts.py, assets/CLAUDE.md and four test files.

This branch's own checks are green at its head (lint, test, review), and it is mergeable.

@max-sixty
max-sixty merged commit a15fafc into main Sep 19, 2026
4 checks passed
@max-sixty
max-sixty deleted the fix/ci-35430767109 branch September 19, 2026 14:04
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