Skip to content

fix: strip the bootstrap's marks from failed requests' frames and order the missed stage after the page's reports - #6861

Merged
leaf-agent merged 4 commits into
mainfrom
fix/issue-6767-request-frame
Nov 23, 2026
Merged

leaf-agent merged 4 commits into
mainfrom
fix/issue-6767-request-frame

Conversation

@leaf-agent

@leaf-agent leaf-agent commented Nov 23, 2026 •

Copy link
Copy Markdown
Collaborator

The page-code reading (src/leaf/render_gate/page_code.py) reported two facts in a form that depended on timing. On macOS runners both came out wrong often enough to fail test_plain_check_reports_page_request_failures_but_ignores_optional_assets, the recovered-frame failure in #6767:

  • A failed request's frame kept the bootstrap's marks. A failure can reach the checker before the bootstrap's address rewrite does. When it did, the image 404 named its frame …/v1.html?t=test-page-key&_leaf-recovered, with the host key the bootstrap strips from the address bar, and the render check's reading disagreed with run_page_code's. Each failure still takes its frame's address when it arrives, as it did before, and frame_address now removes the marks bootstrap.js removes and spells the query left as the bootstrap's URLSearchParams does, so a marked and a rewritten address read the same. Those marks are ADDRESS_MARKS in render_checks.py, and a test holds them to the bootstrap's list. Model tests cover a marked address, its rewritten spelling, and a navigation between two failures.
  • The missed stage could come before the runtime's report. findings appended not-ready before waiting for the runtime's report, and the report can reach the console during that wait, so the report sometimes followed the stage. The stage now joins the reports after the wait, which is the order the findings' docstring states. A wait that raises still leaves the stage in reports for run_page_code's error path.

Verified with ci dispatches of 54 copies of the test on the test-macos runner:

The PR's test job fails only test_every_skill_file_reads_in_one_command, on skills/leaf/references/module-input.md at 30002 bytes; this diff doesn't touch that file, main's own push run fails the same way (run 45133210016), and #6826 fixes it. Locally, the test, its Firefox sibling, tests/model/test_render_gate.py, and the other run_page_code and render-check page-code consumers pass.

#6767 also tracks a Firefox wheel defect in keepFoot and the smooth-revision-above Firefox case, which this leaves open.

Refs #6767 — automated triage

… answered

The page-code reading had two orderings that macOS runners lose:

- It took each failed request's frame address in the response handler. A
  failure can reach the checker before the bootstrap's address rewrite
  does, so the image 404 in
  test_plain_check_reports_page_request_failures_but_ignores_optional_assets
  sometimes named its frame with the _leaf-recovered mark and the host
  key, and the render check's reading disagreed with run_page_code's. The
  frame's address is now read when the findings are stated.
- It appended the page's missed stage before waiting for the runtime's
  report, which can reach the console during that wait, so the report
  sometimes followed the stage. The stage now joins the reports once the
  wait ends, as the findings' order says.

Refs #6767
@max-sixty

Copy link
Copy Markdown
Owner

The report/stage ordering fix looks good. FailedRequests.findings() now reads request.frame.url after waiting for the page answer, but that Frame is mutable: if a frame at /a has a failed request and navigates to /b before collection, the failure will be attributed to /b. Please retain the failed document's URL when the event arrives, then normalize the captured URL using the bootstrap's address rules (or associate it with that navigation). Add a focused case where navigation occurs between the failed request and collection, while keeping the report/stage ordering fix.

This was written by Codex on behalf of max

…e bootstrap's marks

A Frame follows its navigations, so reading its url at collection named the
document the frame had gone on to. Each failure now captures the frame's
address on arrival and strips the marks bootstrap.js takes off the address
bar (ADDRESS_MARKS), which a failure can reach the check ahead of. A model
test covers both, and another holds ADDRESS_MARKS to bootstrap.js's list.

Co-Authored-By: Claude <[email protected]>
@leaf-agent

Copy link
Copy Markdown
Collaborator Author

Done in 8949848. Each failure now takes its frame's address when the event arrives, and frame_address removes the marks bootstrap.js removes (_leaf-revision, _leaf-recovered, t). Those marks are now ADDRESS_MARKS in render_checks.py, and a test reads the bootstrap's marks list and checks the two match. The new model test test_a_failed_request_names_the_document_that_made_it_without_its_marks sends a failure from …/v1.html?view=a&t=key&_leaf-recovered, navigates the frame to /b.html, then sends a second failure. It checks that they name …/v1.html?view=a and /b.html. The report/stage ordering fix is unchanged.

Locally, tests/model/test_render_gate.py and the journey test test_plain_check_reports_page_request_failures_but_ignores_optional_assets pass. I haven't rerun the 54-copy macOS dispatch on this head.

@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 title and the first bullet describe a change this diff doesn't make. On main, frame_of already reads request.frame.url inside the requestfailed and response handlers, so frames were already captured when each failure arrived. The net change for frames is only frame_address removing the bootstrap's marks. As written, the squashed commit says frames are now read "after the page has answered" (they aren't) and "as it arrives" (that was already true). The 54-of-54 run also tested the intermediate version that read frames at collection, not this head. I'll rewrite the title and body around the net change and say which version each dispatch ran. The code and tests need no change.

@leaf-agent leaf-agent changed the title fix: read the page-code check's request frames and missed stage after the page has answered fix: strip the bootstrap's marks from failed requests' frames and order the missed stage after the page's reports Nov 23, 2026
@max-sixty

Copy link
Copy Markdown
Owner

The mutable-frame attribution is fixed, but frame_address still produces different addresses before and after the bootstrap rewrite for valid query values. For /v1.html?q=~*&t=key, the bootstrap's URLSearchParams.delete() serializes the retained value as q=%7E*; Python urlencode in frame_address produces q=~%2A. After the rewrite, the no-marks branch keeps the browser spelling, so an identical failed request remains timing-dependent. Please match WHATWG form serialization and add a focused equality case for the marked and already-rewritten addresses. The report/stage ordering fix can stay.

This was written by Codex on behalf of max

frame_address reserialized the kept query with urlencode, which writes
~ literally and * as %2A, where the bootstrap's URLSearchParams writes
%7E and *. A failure that reached the checker before the bootstrap's
rewrite then named a different address than one after it for queries
with those characters. The kept pairs now go through the WHATWG form
serializer's character set, and a model test checks that a marked and
an already-rewritten address read the same.
@leaf-agent

Copy link
Copy Markdown
Collaborator Author

Done in f4c5d83. frame_address now writes the kept pairs with the WHATWG form serializer's character set (ASCII alphanumerics and *-._ kept, space as +, everything else percent-encoded in UTF-8), so ~ becomes %7E and * stays literal, as URLSearchParams writes them. The new model test test_a_marked_address_reads_as_the_address_the_bootstrap_leaves checks that …/v1.html?q=~*%20+a!%27()%C3%A9&t=key&_leaf-recovered#f and its rewritten form …/v1.html?q=%7E*++a%21%27%28%29%C3%A9#f both read as the rewritten form. I took that expected string from Node's URL.searchParams.delete() on the same address. The report/stage ordering fix is unchanged.

tests/model/test_render_gate.py passes locally.

@max-sixty

Copy link
Copy Markdown
Owner

The revised form encoder matches the ~* case. One address form still differs by timing: an explicitly empty fragment. For http://leaf.test/v1.html?q=~*&t=key#, frame_address on this head yields http://leaf.test/v1.html?q=%7E*, while the browser's URL.searchParams.delete() yields http://leaf.test/v1.html?q=%7E*#. The no-marks branch preserves the trailing #, so the same failure can have two reported addresses. Please preserve the original fragment delimiter when rewriting only the query, and add marked-versus-rewritten equality coverage for a trailing #.

This was written by Codex on behalf of max

urlsplit drops an empty fragment's delimiter, while URL.searchParams.delete()
keeps it, so a failure arriving before the bootstrap's rewrite read as
.../v1.html?q=%7E* and one after as .../v1.html?q=%7E*#.
@leaf-agent

Copy link
Copy Markdown
Collaborator Author

Done in 7123ce1. frame_address now splits the fragment off with partition("#") before urlsplit, rewrites only the query, and appends the original # and fragment, so an empty fragment's delimiter survives. The new model test test_a_marked_address_keeps_an_empty_fragment checks that …/v1.html?q=~*&t=key# and its rewritten form …/v1.html?q=%7E*# both read as the rewritten form, and that …/v1.html?t=key# reads as …/v1.html#. Node's URL.searchParams.delete("t") gives those same two strings. The report/stage ordering fix is unchanged.

tests/model/test_render_gate.py passes locally.

@leaf-agent
leaf-agent merged commit c8ab9ec into main Nov 23, 2026
11 of 12 checks passed
@leaf-agent
leaf-agent deleted the fix/issue-6767-request-frame branch November 23, 2026 10:09
leaf-agent added a commit that referenced this pull request Nov 23, 2026
`ruff format` wraps an assertion that #6861 added to
`tests/model/test_render_gate.py` in a form ruff doesn't accept, so the
pre-commit step of `ci` on `main` failed ([run
45177782950](https://github.com/max-sixty/leaf/actions/runs/45177782950)).
The Python tests in that run passed. This commit applies ruff's own
formatting to that one line and changes nothing else. `pre-commit run
ruff-format` on the file fails on `main` and passes here.

Closes #6865 — automated triage

Co-authored-by: leaf-agent <[email protected]>
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