Repository navigation
Stand the margin's option proxy where the control it forwards to stands - #411
Conversation
leaf-agent
left a comment
There was a problem hiding this comment.
The ring repair is the right reading, but the attribute it writes is already spoken for. ASK_ROW is data-lf-for, and its own declaration in asks/view.js calls it "the attribute lf-suggestion writes on the row it hangs in the margin" — one element per ask. optionControlNode now writes it onto a second element for the same ask, so every selector meaning "the row for this change" resolves to two: the hoisted .lf-sug-actions span and the .lf-margin-option-proxy button. The option group is built on every margin render and merely hidden when closed (syncOptionGroup runs unconditionally from syncControls, and keepsHidden is the only thing gating it), so the second match is in the DOM whenever a suggestion has a secondary control — not only while More options is open.
Eight nightly cases fail on this branch as a result, reproduced here on the PR's merged tree with the repository's browser:
tests/test_render_widgets.py::test_suggestion_controls_stay_out_of_the_column[no-preference]
tests/test_render_widgets.py::test_suggestion_controls_stay_out_of_the_column[reduce]
tests/test_render_widgets.py::test_a_moved_change_takes_its_controls_with_it
tests/test_render_widgets.py::test_a_row_waits_for_the_change_it_decides_to_be_on_screen
tests/test_render_widgets.py::test_a_settled_boxless_suggestion_keeps_its_own_margin_identity
tests/test_render_widgets.py::test_an_optimistic_decision_stays_plain_while_delivery_waits
tests/test_render_widgets.py::test_the_rail_survives_every_script_being_removed
tests/test_render_anchors.py::test_the_comment_button_stands_on_no_control
tests/test_render_options.py::test_a_quoted_widget_exhibits_without_taking_input
Seven of them pass with the single standsWith(node, control) line removed from optionControlNode and nothing else changed. The eighth, test_suggestion_controls_stay_out_of_the_column[no-preference], then fails later at its .lf-docked wait — a separate problem in this container, not this branch's — but on the branch it never reaches that point, failing first at assert 4 == 2.
The green checks on this PR do not cover any of it. Per tests/CLAUDE.md, a pull request runs the everyday suite and then the nightly cases in the modules it touches; this branch touches only tests/test_render_projection.py, so test_render_widgets.py, test_render_anchors.py, and test_render_options.py are first run with --run-nightly after main moves — and running-tend treats a red ci on main as live.
What needs deciding is where the proxy's attribution lives, not whether it should have one. A distinct attribute that standsAt's closest() reads alongside ASK_ROW and ASK_AT would give the proxy the same standing without collapsing "which ask this decides" and "which element is the row" into one selector. The runtime's own consumers survive the collision either way — standOn's document.querySelector([data-lf-for="<id>"] ASK_CONTROL) fallback still finds the row's control, because the proxy is itself the button rather than a descendant of one — so this is entirely about the attribute no longer identifying one element.
Reproduction
On the merged tree at b408770:
uv run pytest tests/test_render_widgets.py -q --run-nightly
uv run pytest tests/test_render_anchors.py tests/test_render_options.py -q --run-nightlyThe strict-mode violations name both matches directly, e.g. from test_the_rail_survives_every_script_being_removed:
Locator.evaluate: Error: strict mode violation: locator("[data-lf-for='sug-refill']") resolved to 2 elements:
1) <span data-lf-offer="" data-lf-for="sug-refill" class="lf-sug-actions lf-ui lf-margin-contribution">
2) <button data-lf-for="sug-refill" data-lf-button-key="reject:proxy" class="lf-margin-option-proxy lf-ui lf-margin-button">
test_a_quoted_widget_exhibits_without_taking_input is the count form of the same thing — [data-lf-for='live-suggestion'] goes from 1 to 2, while the quoted widget's assertion of 0 still holds, so nothing leaks into an exhibit.
Baseline: the same selection with only that one line removed is 6 passed, 1 failed.
data-lf-for names one element per ask — the row lf-suggestion hangs in the margin — and the runtime, the theme and the suite all read it as that row. The proxy wearing it made every such selector resolve to two elements whenever a suggestion had a secondary control, since the options group is built on every margin render and only hidden while closed. standsWith now writes data-lf-stands, which standsAt reads alongside data-lf-for and data-lf-at, so the stand-in has the same standing without collapsing "which ask this decides" and "which element is the row" into one selector.
## Problem `publish-site` has gone red on `main` twice since #414 introduced the layer-matching verification — [run 34163256368](https://github.com/max-sixty/leaf/actions/runs/34163256368) (the build of #414 itself) and [run 34163695118](https://github.com/max-sixty/leaf/actions/runs/34163695118) (the build of #411). Both times the deploy succeeded and `Verify public Leaf pages` spent its whole budget without the edge shell's layer and `/api/state`'s layer ever agreeing. In the second run the state body carried `"producer": {"commit": "cb02617a7704"}` — the container was still serving the *previous* deploy's image while the edge served the new shell. The step asks the same session cookie on all twenty attempts. That cookie picks one Durable Object, and `sleepAfter = "10m"` on `LeafWebsiteSession` keeps a container Cloudflare has already started alive for ten minutes. So the first attempt seats a container on whatever image the rollout has reached at that instant, and the remaining nineteen attempts re-read that one instance. What the step then measures is the image one session began on — not the image the fleet hands a reader arriving now, which is the property it exists to prove. I measured both against the live site while run 34163695118's rollout was still in flight, polling a fresh session and one fixed session side by side against the edge shell's layer `6260affc`: ``` edge shell layer: 6260affc432de909ef10a47d5552bb36 t+7s fresh=017bc7bd fixed=017bc7bd t+45s fresh=6260affc fixed=017bc7bd t+140s fresh=017bc7bd fixed=017bc7bd t+217s fresh=6260affc fixed=017bc7bd ... t+505s fresh=6260affc fixed=017bc7bd fresh converged at: 45s ; fixed converged at: never ``` A new session reached the new image in 45 seconds. The fixed session never did, across 8.7 minutes of polling — consistent with the idle timer, and the reason the twenty attempts could not have converged however many of them ran. ## Solution Mint a session cookie per attempt, so each one asks as an arriving reader, and bound the loop by one fifteen-minute deadline shared across both pages rather than a fixed twenty attempts. The deadline is what covers the rest of what the measurement shows: a gradual rollout leaves the fleet mixed for a while, so fresh sessions still landed on the old image intermittently out to `t+198s`, well past the ~145s the old loop actually spent. Fifteen minutes is entered about 2 minutes into the job and leaves margin under `timeout-minutes: 30`. Sharing it between the two pages is right because they are waiting on the same rollout, but each page keeps five attempts past the deadline: the two pages mint separate cookies and so seat separate containers, and a rollout slow enough to run the first page to the deadline must not leave the second a single probe before it reports a healthy deploy red. The failure line now names both layers, and each attempt clears the state layer and body it is about to overwrite so the line reports what this attempt observed rather than an earlier one's reading. Diagnosing these runs meant inferring the mismatch from `producer.commit` buried in the dumped state body, because the step printed the body and not the two values it had just compared. ## What this does not address During a rollout a real reader can be served a new edge shell against an old container, and `sameLayer` in `layer-client.js` reloads the tab on that mismatch — with the session cookie sticky, into a reload loop until the container's idle timer retires it. This PR makes CI observe that window honestly rather than closing it; narrowing it (a faster container rollout, or a reader-facing answer to the mismatch) is a deployment and reader-experience decision I have left to you. ## Testing `publish-site` runs only on pushes to `main`, so this branch's CI cannot exercise the changed step. I ran the step's script as CI runs it, extracted from the workflow with the same `bash -e`: <details><summary>Extracted-step runs against the live site</summary> Against the settled site, both pages pass on their first attempt: ``` $ time bash -e /tmp/verify.sh true true real 0m7.165s exit=0 ``` The deadline path, with the deadline cut to 12s and the product predicate falsified so it can never pass — it breaks out, names both layers, dumps the body, and returns 1: ``` $ bash -e /tmp/verify-fail.sh https://leaf.page/ served layer 6260affc432de909ef10a47d5552bb36; https://leaf.page/api/state served layer 017bc7bd82e042ede192a56a1e1b41de {"layer": {"generation": "017bc7bd82e042ede192a56a1e1b41de", ... exit=1 real 0m16.200s ``` That run also caught the live failure in the act: the edge was serving #411's shell while the container still served #414's image, the same disagreement both red runs reported. Re-running the extracted step against the settled site after the review fixes still passes both pages on their first attempt (7.2s). With the deadline set to 0 so it is already spent, the first page passes and the second still probes five times instead of once. Stubbing `curl` so the shell fetch succeeds once and then fails: before the per-attempt reset the failure line reported `served layer BBB` and dumped attempt 1's body for a probe that never ran; after it, both read `none`. The convergence measurement above polled `https://leaf.page/api/state` every 15s, reading `Leaf-Layer` from the response headers, with a new `openssl rand -hex 16` cookie for the `fresh` column and one cookie held for the whole run for the `fixed` column. `pre-commit run --files .github/workflows/publish-site.yaml worker/README.md` passes, actionlint — which shellchecks the `run:` block — included. </details> --- Automated fix for [failed run 34163256368](https://github.com/max-sixty/leaf/actions/runs/34163256368). --------- Co-authored-by: leaf-agent <[email protected]>
test_the_ring_says_where_the_reader_is_standingwas the last unclaimed failure in the nightly leg of run 34149953389; #407 took four of that run's six and #408 closed the fifth. It read the suggestion's ring as['none', '3px', 'rgb(28, 27, 24)']— the outline shorthand's initial values, which is whatoutline: var(--here-ring)computes to when nothing on the element is wearingdata-lf-askat all.A control that forwards another control's press was standing nowhere. When a hoisted control spills out of the margin's visible row into its More options group,
optionControlNodebuilds a proxy button for it: same label, same tone, same owner, and anonclickthat presses the original. It copied everything about that control except where the control stands.askPlacereads the ask a node points back at off the nearest[data-lf-for]/[data-lf-at]ancestor, and the suggestion's own.lf-sug-actionsrow carriesdata-lf-for="sug-refill"for exactly this reason — but the proxy is built into.lf-margin-options, which carries neither. SostandingIn()answerednullfor it, and Tab from a suggestion's ✓ Accept to its own ✗ Reject took the "you are here" band off the change the reader was deciding, for as long as they held that control. The walk read the same nothing: stepping on from the proxy measured from the margin rather than from the suggestion.The repair is the identity the proxy already records in
lfForwardedControl, said where the readingaskPlaceperforms can find it — but said in an attribute of the stand-in's own,data-lf-stands.data-lf-fornames one element per ask, the rowlf-suggestionhangs in the margin, and the runtime's lookups, the theme and this suite all read[data-lf-for="<id>"]as that row; a proxy wearing it would be a second answer to every one of them for the same ask, whenever a suggestion has a secondary control — the options group is built on every margin render and merely hidden while closed. SostandsAtis factored out ofaskPlaceand reads the three attributes together, andstandsWith, new inasks/view.jsbeside it, writes the third. It writes only where the value changes —test_an_unchanged_heartbeat_restates_no_margin_namecatches the unguarded version, since a heartbeat re-presenting the same control must restate nothing.How that reached CI as an intermittent red. The paint is coalesced to an animation frame (
paintHere), so the drop and the restore each land a frame after the focus move that caused them. The test tabs to the proxy and back before reading, and the read landed in the gap after the clearing frame and before the restoring one — about half the time here, which is whymainreddened on this case only after the branch that added the case's margin fixture had been green for days. The test now names the defect directly: it reads the ring while the reader holds the proxy, after the frame that focus move's repaint is coalesced into, and asserts the band is the one the options row wore. It also pins the count that the collision above would have broken — the suggestion's margin row stays the one element[data-lf-for='sug-refill']names — and waits for the second ask's arrival mark the way the test already waits for the first, so the earlier read states an ordering rather than a timing.Verification
Linux, with the repository's browser, at
f9fb71cd:['none', '3px', 'rgb(28, 27, 24)']against['solid', '2px', 'rgb(47, 84, 128)']— so the case catches the behavior it is named for rather than the frame it used to catch;tests/test_render_projection.pyunder--run-nightly: 102 passed;tests/test_render_margin.pyunder--run-nightly: 82 passed;[data-lf-for]as a single element, acrosstest_render_widgets.py,test_render_anchors.pyandtest_render_options.py: 8 passed, 1 failed —test_suggestion_controls_stay_out_of_the_column[no-preference], which fails identically at its!lf-dockedwait on the merge base2cdb4048in this container and is not this branch's;uv run pytest tests: 901 passed, 6 skipped;The failure, and the frame it fell in
Reproduced 3 of 8 times on
mainbefore the change. AMutationObserverondata-lf-askover one failing run, withdocument.activeElementat each write:focusinafter theawalk#sug-refillsug-refill#sug-refillfocusinon the hoisted ✓ Accept.lf-sug-acceptfocusinon the options proxy for ✗ Reject.lf-margin-option-proxysug-refill.lf-margin-option-proxyfocusinback on ✓ Accept.lf-sug-acceptThe restoring paint would have landed around 1321. On the runs that passed, the same removal and restore happened either side of the read.