Repository navigation
Point the release-desktop ordering tests at the job graph the workflow now has - #8239
danielhanchen wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: d5a35f55fe
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| for index, step in enumerate(publish["steps"]) | ||
| if step.get("uses", "").startswith("actions/download-artifact@") | ||
| ) | ||
| assert publish_names.index("Wait for the build matrix") < download_index |
There was a problem hiding this comment.
Assert the waiter actually gates on successful builds
Because publish-release now needs only prepare-version, this assertion replaces the only test that guaranteed completion of the build job, but it checks only that a display name occurs before the download. If the named step is skipped or its run body is replaced with a no-op, the test still passes while the publisher races the matrix and can attempt to download before artifacts exist, causing desktop releases to fail. Inspect the waiter’s API/status/conclusion checks rather than relying solely on its label.
Useful? React with 👍 / 👎.
| # The scan job holds no build of its own, so it has to pull the same | ||
| # artifacts publish-release released rather than rebuild them. | ||
| names = self._scan_steps() | ||
| assert names.index("Download published assets") < names.index("VirusTotal scan") |
There was a problem hiding this comment.
Verify the scan step downloads the expected artifacts
This only verifies ordering between two display names, so a Download published assets step using the wrong action, pattern, or destination—or merely run: true—would still pass. The scan reads the fixed $RUNNER_TEMP/desktop-release-assets path, and scripts/virustotal_scan.py treats finding no scannable bundles as a successful skip, so such a regression would silently disable the advisory scan. Assert the step’s actions/download-artifact usage, desktop-release-* pattern, and destination in addition to its position.
Useful? React with 👍 / 👎.
| assert names.index("Download signed release assets") < names.index( | ||
| "Create versioned release" | ||
| ) |
There was a problem hiding this comment.
Gate creation on asset-set validation
Ordering the download before release creation does not establish that the assets are actually ready: actions/download-artifact can complete after retrieving only the artifacts that matched, while the separate Validate release asset set step is what enforces the complete expected bundle set. If that validation is accidentally moved after Create versioned release, this test still passes, and a missing bundle can make the workflow fail only after it has created a public empty release. Include the validation step in the asserted ordering before creation.
Useful? React with 👍 / 👎.
| assert "publish-release" in self._jobs()["virustotal-scan"]["needs"] | ||
| assert "Validate versioned release state" in self._publish_steps() |
There was a problem hiding this comment.
Preserve success gating on the scan job
A needs: publish-release edge prevents the scan after a failed publish only while the scan job retains GitHub Actions’ default success condition. Adding if: always() to virustotal-scan—a pattern already used elsewhere in this repository—would make it run after a failed validation or publish, yet both assertions here would continue to pass because the dependency and validation step still exist. Assert that the scan job has no overriding condition, or that its condition explicitly requires needs.publish-release.result == 'success', so invalid bundles are not disclosed.
Useful? React with 👍 / 👎.
|
Superseded by #8240, which is merged. Both point the same two test files at the current job graph; #8240 additionally pins that the scan job cannot be silently lost (exists, needs publish-release, not conditioned away, sparse-checkout mechanism, artifact pattern matches what the build uploads) and carries a 17-case sabotage matrix. This branch is now conflicting against main and adds no test main lacks. |
…caped code stays in its code block (unslothai#17200) Fixes unslothai#17199. ## Problem When the model fetches a page, Studio's HTML-to-Markdown converter: - appends a `;` to a bare `&` followed by a letter, and decodes names that are references only with their `;`. For example, `AT&T.` becomes `AT&T.;` and `?key=abc&format=json&lang=en` becomes `?key=abc&format;=json⟨=en`. - moves escaped characters out of a `<pre>` in a table cell. That is the layout of line-numbered code from Pygments' table formatter, Rouge and Chroma, so `if a < b and c > 0:` reads `if a b and c 0:` inside the fence. Inside a link in a `<pre>`, it moves the escaped characters into the link text and drops a ` `. - can pass the rest of the page through as raw HTML: - on Python 3.13 and 3.14, after a decimal reference that has no `;` and runs into a letter a–f (`©Copyright`); - on 3.11 and 3.12, after a `&#` with no digits when no `;` follows it. The issue lists live pages where this happens, such as Alpha Vantage's API samples, Google's Maps URLs docs and RFC 6749. ## Root cause The renderer ran `HTMLParser` with `convert_charrefs=False` and decoded references itself in `handle_entityref` and `handle_charref`: - `HTMLParser` reports `&name` whether or not a `;` follows, and the handler always decoded `&name;`. - The decoded text went through `_emit()`, which picks an open link or table cell before an open `<pre>`, while the text around it went to the `<pre>`. - With `convert_charrefs=False`, `HTMLParser`'s handling of a malformed `&#` depends on the Python version, and on each version some form of it ends the parse early. ## Changes - **`HTMLParser(convert_charrefs=True)`**, the stdlib default. - References decode inside their text run with `html.unescape`, as a browser decodes text, and the decoded run reaches `handle_data`, so it is routed with the text around it. - `HTMLParser` then never calls `handle_entityref` or `handle_charref`. They, their two replay branches and the `html` import are removed. - The `_TokenLog` docstring now names the three handlers its replay contract covers. - **U+00A0 is not collapsed.** - ` ` used to bypass the whitespace collapse in `handle_data`. Decoded inside the text run, it would be collapsed, and code indented with ` ` (W3Schools writes its examples that way) would lose its indentation. - Emitted text now collapses whitespace other than U+00A0 (`_COLLAPSIBLE_RUN`), as a browser does. - The header link-density tally still counts the text with U+00A0 collapsed, so a link header padded with ` ` is stripped as before. - **Decimal references longer than 640 digits are shortened before parsing.** - `html.unescape` raises `ValueError` once a decimal reference has more digits than `int()`'s limit. Python never sets that limit below 640, and leading zeros count toward it. - `html_to_markdown` drops the leading zeros of such a reference. If 8 or more digits remain, it writes `�`, which is the U+FFFD that `html.unescape` gives past U+10FFFF. - On every version, main raised for such a reference ended by `;` or a space, or inside an attribute. On 3.13 and 3.14 it also raised for one followed by a hex letter or cut off at the end of the page. With `convert_charrefs=True` alone, 3.11 and 3.12 would raise for those two as well. ## Other behavior changes - **Literal U+00A0:** a literal U+00A0 in flowing text is now kept, as ` ` already was, instead of becoming a space. - **Other whitespace references:** ` `, ` `, ` `, `&unslothai#8239;`, `	`, ` ` and ` ` in flowing text now collapse like the characters they decode to, as those literal characters already did. Main emitted them as is, including a raw tab and carriage return. - **U+00A0-only text between table elements:** this is now dropped like other whitespace there. - Main put it in front of the next Markdown row (`\xa0| c | d |`). - It also drops Javadoc 8's method-summary tab separators, which sit inside a `<caption>`: `All Methods\xa0Static Methods` becomes `All MethodsStatic Methods`. - **List markers:** a list item whose first text is a reference after source indentation now gets the two spaces after its marker that literal text already gets (`* "Quoted" title`). - **Legacy reference names in query parameters:** a parameter that starts with a legacy reference name still decodes, as in a browser, but without the stray `;`. `¶m=x` was `¶m;=x` and is now `¶m=x`. ## Testing All runs were on macOS 26 (arm64). - **New tests:** 12 cases in `test_web_fetch_extraction.py`, which make 28 tests with the `main_content` variants. - Against `origin/main`'s converter, 22 fail on Python 3.11.16 and 3.12.7, and 18 fail on 3.13.11 and 3.14.7, where CPython already parses a `&#` without digits as text. - The 6 that pass on main are guards: references still decode, ` `-indented text keeps its indentation, and a ` `-padded link header is still stripped. - All 28 pass on this branch on 3.11.16, 3.12.7, 3.13.11 and 3.14.7. - **Converter test files** (`test_html_to_md_*.py` and `test_web_fetch_extraction.py`): 1567 passed on main and 1595 (1567 + 28) on this branch, on each of 3.11.16, 3.12.7, 3.13.11 and 3.14.7. - **Related backend tests:** 47 backend test files around web fetch and the tool loop, on Python 3.12.7 with the backend CI dependencies. - This branch: 8232 passed, 9 failed, 3 skipped. `origin/main`: 8204 passed, 9 failed, 3 skipped. The 28 extra passes are the new tests. - The same 9 deferred workspace-deletion tests in `test_sandbox_files_and_storage_roots.py` fail on both on this machine. - The same 3 tests skip on both, because `unsloth_zoo` is not installed and a tokenizer file was not fetched. - **Live pages:** 155 saved responses (153 distinct URLs) from documentation, code-heavy, prose and data sites. They are 133 pages (7 of which give empty Markdown with both converters), 17 Cloudflare challenge pages, 4 "Access Denied" pages and 1 empty file. Converted with `main_content=True`: - **112 are identical**, including all 29 non-pages and empty conversions. - **25 differ only in whitespace.** 24 come from a literal U+00A0 that is now kept. The other is legislation.gov.uk, where `
` no longer emits a raw carriage return. - **18 differ in content.** A script sorted the differing hunks on those pages: - 619 drop a stray `;` or keep a bare `&` that main decoded. - 53 put characters back in their `<pre>`. - 12 keep a U+00A0 from ` ` inside a link in a `<pre>`, which main dropped (RFC section links, Cloudflare-protected email addresses in code samples). - 1 is the Javadoc caption change above. - Across these outputs, U+00A0 goes from 2,822 to 12,253 characters, 0.15% of the branch's 8.26M. - **Robustness and speed:** - 3,000 generated documents in both modes, on each of 3.11.16, 3.12.7, 3.13.11 and 3.14.7: 0 exceptions on this branch, 18 on main. - CPU time over the 155 responses (49 MB) on 3.13.11, as the sum of per-page minimums over 5 interleaved runs: 4.52 s on main and 4.44 s on this branch. The pre-pass costs 14 ms over the whole 49 MB. - **Lint:** `python scripts/run_ruff_format.py` (ruff-unsloth 0.6.9.post1), `ruff check` (0.17.3) and `git diff --check` pass. ## Not covered - **`<caption>` rendering:** `<caption>` has no rendering rule. On both main and this branch, a caption runs into its table's header row. - **`_HTMLBodyLocator` in `tools.py`:** it also runs `HTMLParser` with `convert_charrefs=False`. It only finds where `<body>` starts, so the download can stop a window after it, and it produces no text, so it is left as is. This contribution is part of Stanford's CS146S: The Modern Software Developer. --------- Co-authored-by: Nilay Yadav <[email protected]> Co-authored-by: Daniel Han <[email protected]>
Repo tests (CPU)andpytest tests/securityare red onmainand on every open PR branched from it. Five assertions still describe the release-desktop workflow as it was before #8193 and #8194 restructured it.What changed under them:
publish-releasealongside the build matrix, so it needsprepare-versionand waits on an explicitWait for the build matrixstep instead ofneeds: build.publish-releaseinto its ownvirustotal-scanjob that needspublish-release, and renamed its steps (VirusTotal pre-flight scan->VirusTotal scan, plus aDownload published assetsstep).The workflow is untouched here. The tests now assert the same properties against the current graph:
Wait for the build matrixstep, and it precedes thedownload-artifactstep;virustotal-scanneedspublish-release, so everythingpublish-releasevalidates is settled before the scan starts;virustotal-scan, the script checkout and the asset download both precedeVirusTotal scan.Verified by sabotage, each against the restored workflow:
Wait for the build matrixtest_build_matrix_hands_off_assets_without_release_credentialsfailsvirustotal-scanneedsbuildinstead ofpublish-releasetest_scan_runs_after_the_release_is_validatedfailsCheck out the scan scriptafter the scantest_the_scan_script_is_checked_out_firstfails