Skip to content

Keep the quota fixture's placement render idempotent - #695

Merged
max-sixty merged 1 commit into
mainfrom
fix/ci-34787351258
Sep 14, 2026
Merged

max-sixty merged 1 commit into
mainfrom
fix/ci-34787351258

Conversation

@leaf-agent

Copy link
Copy Markdown
Collaborator

The nightly ci run on main was cancelled at the job's 135-minute timeout, not by
anyone: tests/test_render_controls.py::test_a_stale_package_widget_uses_recursive_parent_eligibility
wedged its browser at 22:59, held its xdist worker for the remaining 114 minutes, and
the run ended with no summary and no nightly.xml artifact. This makes that test
finish in seconds again.

The fixture's lf-quota.renderState moved its owner on every render:

const rest = [...parent.children].filter(child => child.id && child !== this);
parent.insertBefore(this, rest[index] ?? null);

insertBefore on an element the platform already has in place still removes and
re-inserts it, which fires disconnectedCallback and connectedCallback. The module
drops its subscription in the first and renews it in the second, and the renewed
subscription renders — which moves the element again. Each turn is a fresh microtask, so
the page never yields: the renderer sits at ~110% CPU, and Playwright cannot get a reply
even to report its own 30-second timeout. That is why the suite hung rather than failing.

The guard belongs in the fixture because the contract is already stated against it.
skills/leaf/references/packages.md asks a module for "a total, idempotent
renderState(state)" and names "a renderState that changes the page when handed the
same state again" as a render-gate fault. Every shipped widget that rewrites the
document keeps to it — lf-board returns early when the columns already hold the
ordered cards, lf-task when the status attribute already reads the value — and the
sibling placement fixture in tests/test_render_projection.py guards the same move with
if (parent.children[index] !== this). This fixture was the one that did not, so it now
checks its position before moving. The move it exercises, and every assertion about
where #quota ends up, is unchanged.

Bisected to 859c6cc (#666, "Make Leaf pages complete reactive applications"): the test
passed in 1.5s in the 2026-09-13 10:50 nightly on e2ebdcb, and hangs on every commit
from 859c6cc onward, including current main.

One thing that change leaves open, which this PR does not decide: before #666 a
non-idempotent renderState was wasteful, and now it locks up the reader's tab. The
render gate is documented to catch exactly this fault and did not catch this widget.
Whether the runtime should bound a render that keeps re-entering itself is a question for
the reactive runtime rather than for a test fixture.

Reproduction and verification

Before, on main at 7acc84b — no output, killed by the outer timeout:

$ timeout 600 uv run pytest -q -n0 --run-nightly \
    "tests/test_render_controls.py::test_a_stale_package_widget_uses_recursive_parent_eligibility"
Terminated
EXIT=124

After: 1 passed in 5.26s.

The loop, captured by counting presentRender calls per widget id and breaking after
400, then reading the stacks off the page:

renders: 404  invalidations: 396
  at connect (runtime/widget-controller.js:402)
  at Object.subscribe (runtime/widget-controller.js:441)
  at HTMLElement.connectedCallback (widgets/lf-quota.js:34)
  at HTMLElement.renderState (widgets/lf-quota.js:55)
  at presentRender (runtime/widget-controller.js:284)

uv run pytest -q --run-nightly tests/test_render_controls.py — 90 passed, 4 failed in
5:00. The four are on main already, all named in the cancelled run's own log
(test_the_composed_corpus_declares_every_control_row_archetype,
test_a_runtime_cannot_adopt_a_new_registry_while_it_is_loading,
test_an_open_tab_reloads_before_posting_through_a_revendored_layer,
test_a_covering_auxiliary_surface_keeps_a_replacement_document_inert). That run
reported 22 failures and 4 errors before it hung; this PR addresses the hang only.

The everyday gate does not reach this file — tests/test_render_controls.py is
pytest.mark.nightly throughout — so the proof for this change is the local run above
and the next nightly.

Failed run: https://github.com/max-sixty/leaf/actions/runs/34787351258

@max-sixty
max-sixty merged commit 90b60cc into main Sep 14, 2026
4 checks passed
@max-sixty
max-sixty deleted the fix/ci-34787351258 branch September 14, 2026 02:24
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