Repository navigation
Read two lines of one label as one label - #58
leaf-agent wants to merge 5 commits into
Conversation
leaf-agent
left a comment
There was a problem hiding this comment.
The gate change reads right and I couldn't fault it: label is read once per run rather than per pair, the null guard keeps HTML pages on the containment skip alone, and neither of the two existing COVERED_WORDS exemption tests replaces a string this new line collides with — both still pass. I ran the new test, the chart cases, and the gate's heat-loss cases here; all green, and reverting render_checks.py to the base makes the new test fail on held, so it isn't vacuous.
One note on the new test's second leg, inline.
|
Still red on main, and now on its own. Run 33016679240 (8a08f53, "Split widget measurement runtime") failed 14 tests, and the three this PR answers are among them — the same The other eleven were the The hold this adds is not on main — The nine findings, unchanged from the run |
A dated axis names the month where one begins, on a line under the day: the tick for the first week of December reads 1 over Dec. Those are two tspans of one SVG <text>, offset by the dy the drawing asked for, and each reports a line box carrying the font's own leading — a couple of pixels taller than the step between them. COVERED_WORDS compared them as two elements and called every such tick a collision, so examples/heat-loss.html failed the render gate and its export for drawing an ordinary axis, in both schemes and in print. A wrapped paragraph is the identical shape and was never reported, because its lines are boxes of one text node and the same-element skip takes them. Two lines of one label are two nodes only because SVG spells a line break as an element, so the pass reads the <text> that draws them and holds a pair inside one of them out, next to the paragraph-and-<em> skip it belongs with. The new test takes the reading twice, as the float and collapse exemptions do: once as the gate runs it, and once with the hold defeated, where it has to report the lines it just passed.
The test's unheld reading borrowed its collision from whatever leading lf-chart's date axis settles on, so an ordinary change to that drawing would empty it and fail the test for a reason that has nothing to do with the exemption it names. Pull a label's second line onto the first before either reading instead: the hold does not care how far apart a label's lines are, so held stays empty, and reported has to report whatever the axis is drawn with.
4c8adf8 to
a759ef6
Compare
|
One more run under the same three findings, and the branch is verified green against today's main. Run 33017981619 (4af9466, "Publish factory-owned widget APIs directly") is the same fourteen the comment above describes: eleven What is new is the other side of that split. Main is now at dbc0065, two commits past a5e062d, and I re-ran the sweep there rather than at a5e062d: Then this branch at its current head, |
|
Confirming the comment above from the whole suite rather than three cases: I was dispatched for run 33017141598 (b1b23c4), which was the same fourteen: these three and the eleven |
|
Main has moved two commits past what the comments above measured, and one of them rewrites the file this PR changes — so the question is no longer whether these three findings are still red, but whether this is still the fix for them. It is, on both halves. Run 33018883535 (0736905, "Add table of contents widget and move render helper") is the same three and nothing else: 3 failed, 1281 passed, 6 skipped. I was dispatched for it and am not opening a PR. Then the part that is new. What was runOn On this branch at 705b923 (which contains I had run the same three modules on a hand-merge of 419747b onto 268e925 before the sibling push landed — also 141 passed — so the result is the merge's, not the assertion 705b923 adds to the new test. |
|
Landed directly on main as 999f933, preserving the fix and regression test per the repository landing workflow. |
## Problem This came out of reviewing #58, which landed as [999f933](999f933) while the review was running. The fix itself is right and this does not touch it — what it leaves behind is an exemption with one leg. `999f933c` holds a label's own lines out of `COVERED_WORDS`: an SVG `<text>` spells a line break as an element, so two lines of one tick are two nodes where a wrapped paragraph's are one, and the pair overlapped by construction on a drawing where no glyph comes near another. `test_the_gate_passes_a_chart_whose_tick_names_its_month_on_a_second_line` proves the hold fires. Nothing proves it is narrow. Widen `el.closest('text')` to `closest('g')` or `closest('svg')` — every tick of an axis sits inside both — and every word of a chart stops being read against every other word of that chart. The whole suite stays green. I ran it rather than reasoning about it: with the predicate widened, `tests/test_render_gate.py`, `tests/test_render_widgets.py` and `tests/test_render_export.py` give 18 passed over every case naming this pass, the new exemption test among them. Nothing else in the suite can see it, for four separate reasons: - The corpus sweeps and the copy assert this pass returns nothing, which a wider hold only makes more true. - `test_no_two_of_a_chart_s_words_land_in_the_same_place` reads `CHART_COLLISIONS`, which compares whole `<text>` boxes and never reaches this pass. - The exemption test defeats the predicate wholesale (`.replace("a.label && a.label === b.label", "false")`), so its `reported` leg is identical however `label` was computed. - The only standing bug-back on `COVERED_WORDS` *reporting* is `test_the_covered_words_gate_still_reads_a_control_in_the_flow`, and that is an HTML page whose runs never get an SVG label at all. That test's docstring is the precedent this is written from: "a gate that has only ever passed has been tested for nothing, and this one is one predicate away from exempting every control there is." The same sentence is true of the new predicate one element up. `tests/CLAUDE.md` states the general shape under **Make a green test non-vacuous** — "A reading blind to one mechanism does not report that it is blind — it returns the same clean result it returns when nothing is wrong." ## Solution The other half, put back as a bug, the way the float's two halves are already written. One whole `<text>` stood on another by copying its `transform`, so the labels stay whole and what lands is two of them rather than two lines of one. Arranged that way rather than by spreading a label's lines, because the hold asks which `<text>` drew a line and not how far a line was moved — and because it depends on neither the axis's leading nor a neighbouring chart's layout. Test-only. `render_checks.py` is untouched. ## Testing Every run below at `-n0` on this branch, based on `999f933c`. - `uv run pytest tests/test_render_widgets.py` — 58 passed. - Bug-back, `closest('text')` → `closest('svg')`: the new test fails on `two of a chart's labels stood on each other unreported: []`; the exemption test still passes. - Bug-back, `closest('text')` → `closest('g')`: same failure, same complement. - The complement, with `if (a.label && a.label === b.label) continue;` removed entirely: the exemption test fails on `held` with `<lf-chart id=c-line> draws "1" in the same place as <lf-chart id=c-line>'s "Jun"`, and the new test still passes. The two are about different halves and neither stands in for the other. - Repeated 5× at `-n0`: passed each time. - `pre-commit run --files tests/test_render_widgets.py` — passed. <details><summary>What the arrangement produces</summary> The two ticks and the finding, printed from the reading during development: ``` MOVED: ['20', '22'] FOUND: ['<lf-chart id=c-line> draws "20" in the same place as <lf-chart id=c-line>\'s "22"'] ``` The assertion matches on both labels in their quoted form rather than on the chart id, so a finding about some other pair in the same chart cannot satisfy it. </details> --------- Co-authored-by: leaf-agent <[email protected]> Co-authored-by: Maximilian Roos <[email protected]>
## Problem This came out of reviewing #58, which landed as [999f933](999f933) while the review was running. The fix itself is right and this does not touch it — what it leaves behind is an exemption with one leg. `999f933c` holds a label's own lines out of `COVERED_WORDS`: an SVG `<text>` spells a line break as an element, so two lines of one tick are two nodes where a wrapped paragraph's are one, and the pair overlapped by construction on a drawing where no glyph comes near another. `test_the_gate_passes_a_chart_whose_tick_names_its_month_on_a_second_line` proves the hold fires. Nothing proves it is narrow. Widen `el.closest('text')` to `closest('g')` or `closest('svg')` — every tick of an axis sits inside both — and every word of a chart stops being read against every other word of that chart. The whole suite stays green. I ran it rather than reasoning about it: with the predicate widened, `tests/test_render_gate.py`, `tests/test_render_widgets.py` and `tests/test_render_export.py` give 18 passed over every case naming this pass, the new exemption test among them. Nothing else in the suite can see it, for four separate reasons: - The corpus sweeps and the copy assert this pass returns nothing, which a wider hold only makes more true. - `test_no_two_of_a_chart_s_words_land_in_the_same_place` reads `CHART_COLLISIONS`, which compares whole `<text>` boxes and never reaches this pass. - The exemption test defeats the predicate wholesale (`.replace("a.label && a.label === b.label", "false")`), so its `reported` leg is identical however `label` was computed. - The only standing bug-back on `COVERED_WORDS` *reporting* is `test_the_covered_words_gate_still_reads_a_control_in_the_flow`, and that is an HTML page whose runs never get an SVG label at all. That test's docstring is the precedent this is written from: "a gate that has only ever passed has been tested for nothing, and this one is one predicate away from exempting every control there is." The same sentence is true of the new predicate one element up. `tests/CLAUDE.md` states the general shape under **Make a green test non-vacuous** — "A reading blind to one mechanism does not report that it is blind — it returns the same clean result it returns when nothing is wrong." ## Solution The other half, put back as a bug, the way the float's two halves are already written. One whole `<text>` stood on another by copying its `transform`, so the labels stay whole and what lands is two of them rather than two lines of one. Arranged that way rather than by spreading a label's lines, because the hold asks which `<text>` drew a line and not how far a line was moved — and because it depends on neither the axis's leading nor a neighbouring chart's layout. Test-only. `render_checks.py` is untouched. ## Testing Every run below at `-n0` on this branch, based on `999f933c`. - `uv run pytest tests/test_render_widgets.py` — 58 passed. - Bug-back, `closest('text')` → `closest('svg')`: the new test fails on `two of a chart's labels stood on each other unreported: []`; the exemption test still passes. - Bug-back, `closest('text')` → `closest('g')`: same failure, same complement. - The complement, with `if (a.label && a.label === b.label) continue;` removed entirely: the exemption test fails on `held` with `<lf-chart id=c-line> draws "1" in the same place as <lf-chart id=c-line>'s "Jun"`, and the new test still passes. The two are about different halves and neither stands in for the other. - Repeated 5× at `-n0`: passed each time. - `pre-commit run --files tests/test_render_widgets.py` — passed. <details><summary>What the arrangement produces</summary> The two ticks and the finding, printed from the reading during development: ``` MOVED: ['20', '22'] FOUND: ['<lf-chart id=c-line> draws "20" in the same place as <lf-chart id=c-line>\'s "22"'] ``` The assertion matches on both labels in their quoted form rather than on the chart id, so a finding about some other pair in the same chart cannot satisfy it. </details> --------- Co-authored-by: leaf-agent <[email protected]> Co-authored-by: Maximilian Roos <[email protected]>
Writing the attribute from Marked's authored text made the checked string and the emitted string one string, and took away the decode Marked's own renderer was relying on: every character reference in a link or image destination started resolving literally, so `?a=1&b=2` reached the query as one parameter named `a` with `1&b=2` in it, and an image with that shape 404ed. Take the decode here instead, in the one place a destination is read, so that reading is what `safeUrl` checks and what `escapeAttribute` puts back unchanged. Every legitimate destination resolves where it did before the guard changed, and `javascript:` is refused outright rather than resolving to a relative path carrying a literal `:`. The contract test carries both halves now. Its earlier assertion held vacuously over an empty list of anchors, so it stayed green whether or not a link was rendered; it now names the one href the document is allowed to resolve, beside a live destination whose `&` has to survive.
…#929) Markdown destinations such as `[press me](javascript:alert(1))` passed the scheme guard as relative paths, then became executable links when the document decoded the attribute. Links and images now use Marked’s standard renderer, parse that output in an inert template, and validate the destination the document actually reads before publishing it. Keeping Marked responsible for element rendering preserves flattened image alt text, titles, entity handling, autolinks, and URL normalization. Page-media inspection wraps the same rendered image and derives its accessible button name from that image’s alt. The browser regression covers encoded executable links and images, ordinary URL entities, autolink entities, formatted alt text, titles, and keyboard inspection of page media. Reintroducing raw token alt text makes it fail. An additional adversarial check refused 18 encoded executable link/image variants. Validation: 121 chrome/conversation browser tests; 1,273 everyday cases (two rerun after local setup); 33 runtime tests; and pre-commit checks. > _This was written by Codex on behalf of max-sixty_ --------- Co-authored-by: leaf-agent <[email protected]> Co-authored-by: Maximilian Roos <[email protected]>
Problem
ceb4214("Draw a page's numbers with lf-chart") reddenedcion main:test_example_renders[heat-loss], and the exported copies ofheat-lossandgallery, all failed with the same three findings in every scheme and in print.The three pairs are the three ticks where a month begins. A dated axis names the month there, on a line under the day, and Plot draws that as two tspans of one
<text>:<text transform="translate(561.8,299)"><tspan x="0" y="0.71em">5</tspan><tspan x="0" dy="1em">Jan</tspan></text>. Measured in the browser, the two lines step 11.5px apart and each reports a 14px line box, because the box carries the font's own leading and the drawing asked for adyof exactly 1em. So the boxes overlap by 2.5px, pastCOVERED_WORDS's 2px of slack, on a drawing where no glyph comes near another. The chart is drawn correctly —overhangalready measures the second line and grows the bottom margin for it.Solution
COVERED_WORDSalready skips a pair where one element contains the other, because a paragraph and the<em>inside it are one run of words the flow lays out together. A wrapped paragraph's own lines are the identical shape and never reported either: they are boxes of one text node, which the same-element skip takes. Two lines of one label are two nodes only because SVG spells a line break as an element, so the pass now reads the<text>that draws them and holds out a pair inside one of them, next to the skip it belongs with. Nothing else moves: two separate<text>elements landing on each other is still a finding, which is whatCHART_COLLISIONSand the corpus sweeps ask about.The alternative was to give the axis a
tickFormatso no label takes two lines, and it is the worse drawing: one line per tick means the month repeats on every tick or goes missing, and the labels get wider at exactly the width — a phone's column — where they are already close.Testing
tests/test_render_widgets.py::test_the_gate_passes_a_chart_whose_tick_names_its_month_on_a_second_line— new. It asserts the page is carrying a two-line tick at all, pulls a label's second line onto its first so the overlap belongs to the test rather than to whatever leading the axis settles on, runs the gate's own reading (empty), then runs the same reading with the hold defeated by its own predicate, where it has to report; the two existingCOVERED_WORDSexemption tests (the float and the collapse) are written this way.uv run pytest tests/test_render_gate.py tests/test_render_export.py tests/test_render_widgets.py— the three failures above are gone.uv run pytest testson the rebased branch — 587 passed, 6 skipped, nothing red.pre-commit run --files …on both changed files.The unrelated red this branch was rebased past
Main was also red for a second, later cause while this was in review:
cae9ea5("Split widget element runtime") movedquotedout ofleaf.js, whilerender_checks.pystill calledleaf.quoted(el)afterimport('/leaf.js'), which failedtest_smoke.pyand fivetest_example_renderscases withTypeError: leaf.quoted is not a function. Main answered that itself in a5e062d, routing the gate's probes through/runtime/widget-api.js. This branch is rebased ontodbc0065, so its owncino longer carries that failure anduv run pytest testsis 587 passed, 6 skipped here.Automated fix for failed run