Repository navigation
Reduce comment volume across the installers, CLI, unsloth package and backend utilities - #10504
Conversation
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
…end utilities Deletes restatements, section narration and duplicated prose, and collapses multi-line comment and docstring paragraphs to one line where every fact is kept. Comments, docstrings and whitespace only: no code, no test files. Functional directives (noqa, type: ignore, shellcheck, novermin, #Requires, coverage pragmas, shebangs, SPDX headers), installer section banners that the installer tests locate by literal, and user-visible --help text are preserved.
ab5b0e2 to
db4bff4
Compare
|
@codex security review |
|
Codex Review: Didn't find any major issues. Delightful! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
Resolve conflicts in install.ps1, install.sh, studio/install_python_stack.py and studio/setup.ps1 by taking upstream's code and comments verbatim.
The trees read install.sh, install.ps1, studio/setup.ps1, unsloth/models/vision.py and the kaggle leg registry and cut them on exact comment text, so a reworded or moved marker changes behaviour. Restore those markers verbatim at their original positions.
Same anchor restorations from both sides; keep the copy that matches upstream's wording and line breaks verbatim.
Take upstream's download-liveness hunk in unsloth_cli/commands/start.py verbatim.
Take upstream's native_tls.py hunks verbatim, including the desktop-owner clause and the UV_SYSTEM_CERTS default it adds.
|
Codex Review: Didn't find any major issues. What shall we delve into next? Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
scripts/lint_exec_literals.py and scripts/profile_startup.py pass __doc__ as the argparse description, so those module docstrings are CLI output rather than comments. profile_startup.py uses RawDescriptionHelpFormatter, so its layout is rendered verbatim and collapsing it destroyed an intentional indented table. Both --help outputs are byte-identical to base again. The executable AST is unchanged either way. Left as-is: .github/scripts/interrupted_install_probe.py, whose help also changed but for the better. Base ran the verdict names into the surrounding prose once argparse re-wrapped it, and the parenthesised form reads correctly.
Resolves the two conflicts in studio/backend/utils/hardware/hardware.py. Both keep main's code verbatim and apply this branch's single-line comment form, so the branch stays comment-only against main. _torch_get_device_inventory: takes main's `mod, backend = _torch_get_device_module()`, which feeds the new `_cuda_props_are_integrated(props, backend)` call, together with this branch's one-line docstring. Main's pointers to _torch_get_per_device_info and _rocm_props_total_is_carve_out are folded back into that line rather than dropped. get_backend_visible_gpu_info device dict: takes main's `_cuda_integrated` handling for shared_memory, shared_memory_host_backed_gb and unified_memory unchanged. Main's new note that an integrated part's total is host memory is kept and condensed onto one line; the _rocm_known_unified note, which main did not change, takes this branch's one-line form.
… trainer (unslothai#10854) * Stop a comment in unsloth_zoo from silently disabling the patched SFT trainer `import unsloth` against current unsloth_zoo prints: Could not build the patched trl.trainer.sft_trainer, so training will use trl's own trainer instead: Unsloth: source anchor not found (sft_prepare_dataset pack_dataset call) and every SFT run then falls back to TRL's own trainer, losing the packing and truncation fixes rl_replacements exists to apply. Nothing in the Zoo's code moved. unsloth-zoo unslothai#1192 put a `# noqa: F821` on the `pack_dataset(` call while building an undefined-name lint gate, and the literal anchor here stopped matching a line that had only grown a comment: repo's literal anchor present in zoo source? -> False anchor + the zoo's trailing comment present? -> True The `# noqa` is correct on its own terms: `pack_dataset` really is an undefined name at that point, reached only past a bare-name probe, and the Zoo has no way to know this file string-matches its source. The brittleness is ours, and it is not a one-off risk: this repo edits comments in bulk (unslothai#10504, unslothai#10116), so an anchored line growing or losing a comment is routine drift. _require_replace now tries the literal anchor first and a form of the same anchor that allows an optional trailing comment per line second, so the only drift that still raises is drift in the code itself. The literal branch is untouched, so any Zoo that matched before takes the identical path and produces identical output. Checked against the 12 most recent unsloth_zoo revisions of dataset_utils.py (2026-07-01 through 2026-09-12): the literal anchor still matches on the 11 older ones, only unslothai#1192 needs the tolerant form, and the patch applies on all 12. Fixing the shared helper covers all five _require_replace call sites, not just the pack_dataset one. Test covers the exact shape that broke, a comment on an inner anchored line, a `#` inside a string literal (not a comment, must still match), and asserts the tolerance does NOT reach across a real code change. Without this, of 30 failures in `pytest tests/ -n 64`, 16 trace back here: tests/utils/test_packing.py 5 -> 0, version_compat/test_trl_padding_free 9 -> 1, plus test_trl_grpo_fake_run, test_trl_fake_train_cpu and test_rl_config_pickling. * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
…stead of arguing that it does not Six antivirus-hardening passes have shipped (#7822, #8586, #6326, #10540, #10560, #10504). Each was argued safe in prose, because there was no way to show it. The worry that hardening breaks functionality is the right worry, and the answer to it is a measurement, not a more careful argument. This lane installs from the merge base and from the candidate on two identical Windows runners and compares four things. Zero differences is the pass condition. - **The transcript.** Every line the installer printed, normalised. `step` pads its label to exactly 15 columns and the output lock pins the indent, so leading whitespace is compared and only trailing whitespace is stripped. - **The `.lnk` launch contract**, read back through the shell rather than taken from the installer's own log: target, arguments, working directory, window style, icon. `arguments` carries `-WindowStyle` and `-ExecutionPolicy`, which is the pair this whole effort is about, and a change there is completely invisible in the transcript -- which is what a prose review looks at. - **The generated files** whose text is a contract: `launch-studio.ps1`, `unsloth.cmd`, `share/studio.conf`, plus the shape of the install tree. - **Idempotency**, by installing twice. Several of the changes this lane judges touch content-comparison paths -- the code deciding whether a launcher needs rewriting at all -- so "a reinstall writes nothing" is a contract that can break silently. ## VOID is not a pass Same commit on both sides, missing evidence, an installer that did not finish, a checkout that resolved to the wrong tree: each is reported as "nothing was measured" and exits **3**, distinct from **2** for "it changed", because those need different reactions from whoever reads the run. Two of those guards exist because the failure actually happened while building this: - A collection error on both sides compared equal to itself. Two runs that both failed to read any shortcut reported "1 compared, every field equal" and exited zero. Failures are symmetric far more often than behaviour changes are, since they come from the host and both sides share it, so the symmetry is no comfort at all. Any entry carrying an `error` is now VOID. - `ConvertTo-Json` unwraps a one-element collection into a bare object, and `-AsArray` does not exist on Windows PowerShell 5.1. With exactly one shortcut found, `shortcuts.json` was an object; iterating that yields dictionary *keys*, so two different launch contracts would have compared as agreement. Forced to an array on the producing side and tolerated on the consuming side. The `measure` job also asserts that `git rev-parse HEAD` equals the SHA it asked for. A checkout that silently resolved to the default branch would make both sides the same tree, the comparison trivially pass, and the lane report that a change broke nothing while never having seen the change. Both sides are measured with the tools from the candidate, never each side's own copy: a base commit that predates them has neither, and measuring two sides with two different rulers is not a measurement. ## The comparer can fail, and that is tested A differ reporting no differences looks identical whether it is working or broken, so the comparer carries positive controls and refuses to produce a verdict if they fail. They run twice: once before either install starts, so a drifted normaliser costs seconds rather than ninety minutes of runner time ending in a meaningless green check, and once immediately before the verdict. 20 unit tests in `tests/python/test_installer_differential_comparer.py`, weighted toward the failure direction. A changed output line, a lost indent, `RemoteSigned` becoming `Bypass` in a shortcut, a shortcut that stopped being created, a changed generated launcher, a second run that rewrote something -- each must be reported. One of them widens the normaliser until it erases every line and requires the self-test to notice, because a control that cannot fail is decoration. The other direction is tested too, since a lane that fails on every run gets disabled, which costs the same coverage by a slower route: a `uv` patch release and a 30-second timing difference must not fail it. Version drift is normalised away **and printed anyway** -- silently normalising something and never mentioning it is how a lane stops being able to tell you anything. Every normalisation rule carries a written cause, enforced by a test, because that list is exactly where a future "just make it green" change would land. ## Cost Two full clean-machine installs, so it opts in: the `installer-differential` label, a dispatch, or the weekly schedule. `synchronize` is in the trigger list so a labelled PR keeps being re-measured as it is pushed to, rather than the verdict being about whichever commit was there when the label went on. Not a required check. ## What it cannot answer Nothing about a third-party antivirus: hosted runners have none, and installing an endpoint agent per run is neither fast nor faithful. Nothing about Windows PowerShell 5.1 at a real console either -- that is `windows-vt-preflight.yml`. ## Verification - 887 passed, 9 skipped across `tests/security/`, the new comparer tests, the workflow-trigger lint and the installer shape suite. - The collector was run end to end under `pwsh` on Linux, feeding the real comparer. That is what exposed both JSON defects above and a third: `Join-Path` throws on a null path, and composing `%APPDATA%` unconditionally made a parse-clean script print a binding error before doing any work. - `Parser::ParseFile` clean on the collector; the workflow parses as YAML with the three expected jobs.
…already worked Six hardening passes shipped with no measurement (#7822, #8586, #6326, #10540, #10560, #10504). There was no baseline to measure against. There is one now: install.ps1 at commit 1ad4467 is the revision reported in #10805, it hashes to ec29980b..., and VirusTotal holds its verdict. ## The result, run live against the real key | | baseline (1ad4467) | main (2c70592a) | | engines flagging | 1 / 60 | 1 / 61 | | which | Skyhigh BehavesLike.PS.Suspicious.gr | the same | | Sigma | 17 (high 1, medium 11, low 5) | 14 (medium 10, low 4) | | YARA | 2 | 0 | The **high**-severity Sigma rule is gone. So are both crowdsourced YARA hits, `INDICATOR_SUSPICIOUS_PWSH_B64Encoded_Concatenated_FileEXEC` and `Windows_API_Function`. Three fewer Sigma rules overall. The Skyhigh verdict has not moved, and that is reported as unchanged rather than dressed up: a cloud behavioural verdict is not recomputed because we deleted some code. So the static indicators, which are what drives the alarming scores third-party analysis sites report, already improved measurably. That was not knowable before. Two corrections to what I wrote in the plan, both from running this rather than reasoning about it: - I recorded current main's install.ps1 as **not on VirusTotal**. It is. It has been scanned since, so the delta above is real and not a projection. - I treated the prior passes as unverifiable. They are verifiable, retroactively, and they worked on the axis they could affect. ## Three axes, separately Reporting only the engine count makes every shape win look like it achieved nothing. Reporting only Sigma overclaims. Both, or the number is not worth having. Engines are compared **by name**, not by count. A count-only comparison calls the single most consequential possible change -- Skyhigh's detection being replaced by Microsoft's, one engine before and one after -- "no difference". Defender is on every Windows machine; Skyhigh is enterprise-deployed. There is a test for exactly that case. Sigma is compared **per severity**, not in total. Trading one high for three lows is an improvement a total calls a regression, and the reverse is a regression a total calls an improvement. ## GET only, and VOID is not clean There is no upload path, and that is a deliberate omission rather than an oversight. A freshly uploaded file is a prevalence-zero, first-seen sample, which is exactly what `CloudBlockLevel HighPlus` and ASR rule `01443614` punish -- so uploading a candidate can *create* the detection it was meant to measure, under a hash no user will ever have. Released artefacts are uploaded by `virustotal_scan.py` at release time; branches are not. A test parses the module and asserts no non-GET method appears, having first been written as a grep and caught matching the module's own explanation of why there is no upload. So an unknown hash is VOID, exit 3, never clean. Also VOID: a missing `VT_API_KEY`, and a file VirusTotal knows but has never analysed -- that last one being the subtle case, because zero engine verdicts is not sixty engines clearing the file. Exit codes are distinct: 3 could-not-measure, 2 worse, 0 not worse. ## The baseline is checked, not trusted A baseline hash copied out of an issue is a number nobody can verify, and if it ever pointed at the wrong file every delta reported against it would be wrong while the lane looked perfectly healthy. So both a test and a workflow step recompute it from this repository's history -- `git show 1ad4467:install.ps1` -- and assert the 427,113 bytes the sample is recorded as. A shallow clone skips rather than fails. ## Verification - 613 passed, 6 skipped across `tests/security/`, including 25 new tests. - Run live against the real key; the table above is its actual output. - Weighted toward the failure direction: a new high-severity rule, a new YARA hit, an engine swap at an unchanged count, and a medium promoted to high must each be reported as worse. One test replaces the comparison with one that reports nothing and requires the self-test to notice, because a control that cannot fail is decoration. - Both parsers are fuzzed against schema drift. VirusTotal has renamed and added buckets over time, and a crash would break the measurement on precisely the day the schema moved.
…already worked (#10996) * Give this work a before-and-after number, and find out the hardening already worked Six hardening passes shipped with no measurement (#7822, #8586, #6326, #10540, #10560, #10504). There was no baseline to measure against. There is one now: install.ps1 at commit 1ad4467 is the revision reported in #10805, it hashes to ec29980b..., and VirusTotal holds its verdict. ## The result, run live against the real key | | baseline (1ad4467) | main (2c70592a) | | engines flagging | 1 / 60 | 1 / 61 | | which | Skyhigh BehavesLike.PS.Suspicious.gr | the same | | Sigma | 17 (high 1, medium 11, low 5) | 14 (medium 10, low 4) | | YARA | 2 | 0 | The **high**-severity Sigma rule is gone. So are both crowdsourced YARA hits, `INDICATOR_SUSPICIOUS_PWSH_B64Encoded_Concatenated_FileEXEC` and `Windows_API_Function`. Three fewer Sigma rules overall. The Skyhigh verdict has not moved, and that is reported as unchanged rather than dressed up: a cloud behavioural verdict is not recomputed because we deleted some code. So the static indicators, which are what drives the alarming scores third-party analysis sites report, already improved measurably. That was not knowable before. Two corrections to what I wrote in the plan, both from running this rather than reasoning about it: - I recorded current main's install.ps1 as **not on VirusTotal**. It is. It has been scanned since, so the delta above is real and not a projection. - I treated the prior passes as unverifiable. They are verifiable, retroactively, and they worked on the axis they could affect. ## Three axes, separately Reporting only the engine count makes every shape win look like it achieved nothing. Reporting only Sigma overclaims. Both, or the number is not worth having. Engines are compared **by name**, not by count. A count-only comparison calls the single most consequential possible change -- Skyhigh's detection being replaced by Microsoft's, one engine before and one after -- "no difference". Defender is on every Windows machine; Skyhigh is enterprise-deployed. There is a test for exactly that case. Sigma is compared **per severity**, not in total. Trading one high for three lows is an improvement a total calls a regression, and the reverse is a regression a total calls an improvement. ## GET only, and VOID is not clean There is no upload path, and that is a deliberate omission rather than an oversight. A freshly uploaded file is a prevalence-zero, first-seen sample, which is exactly what `CloudBlockLevel HighPlus` and ASR rule `01443614` punish -- so uploading a candidate can *create* the detection it was meant to measure, under a hash no user will ever have. Released artefacts are uploaded by `virustotal_scan.py` at release time; branches are not. A test parses the module and asserts no non-GET method appears, having first been written as a grep and caught matching the module's own explanation of why there is no upload. So an unknown hash is VOID, exit 3, never clean. Also VOID: a missing `VT_API_KEY`, and a file VirusTotal knows but has never analysed -- that last one being the subtle case, because zero engine verdicts is not sixty engines clearing the file. Exit codes are distinct: 3 could-not-measure, 2 worse, 0 not worse. ## The baseline is checked, not trusted A baseline hash copied out of an issue is a number nobody can verify, and if it ever pointed at the wrong file every delta reported against it would be wrong while the lane looked perfectly healthy. So both a test and a workflow step recompute it from this repository's history -- `git show 1ad4467:install.ps1` -- and assert the 427,113 bytes the sample is recorded as. A shallow clone skips rather than fails. ## Verification - 613 passed, 6 skipped across `tests/security/`, including 25 new tests. - Run live against the real key; the table above is its actual output. - Weighted toward the failure direction: a new high-severity rule, a new YARA hit, an engine swap at an unchanged count, and a medium promoted to high must each be reported as worse. One test replaces the comparison with one that reports nothing and requires the self-test to notice, because a control that cannot fail is decoration. - Both parsers are fuzzed against schema drift. VirusTotal has renamed and added buckets over time, and a crash would break the measurement on precisely the day the schema moved. * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Read the VirusTotal secret this repository actually has, so the lane can measure something `secrets.VT_API_KEY` does not exist. `VT_API_KEY` is the ENV VAR name the Python reads (`scripts/virustotal_scan.py:37`); the repository secret is `VIRUS_TOTAL_API_TOKEN`, which is the only VirusTotal secret in all 51 workflows, and `release-desktop.yml:2193` maps it the same way. As written the expression expanded to empty and the lane exited 3 / VOID on every dispatch. That is the right failure shape -- it refuses to report a clean it did not measure -- but a lane that can never measure anything is not worth having, and the failure only surfaces after someone dispatches it and waits. Two guards added, because both halves of this were invisible: - `test_the_workflow_reads_the_secret_this_repository_actually_has` pins the secret name in both directions and also asserts the checkout keeps `fetch-depth: 0`, since the step that reverifies the baseline against commit 1ad4467 reverifies nothing on a shallow clone. - `test_the_baseline_hash_is_the_file_the_reporter_ran` now checks the constant's shape unconditionally before the git half. That git half skips on a shallow clone, which is every CI lane that collects `tests/security` -- so the one assertion tying the baseline to real history was green locally and silently absent everywhere it mattered. * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Compare Sigma severities in order, and void an unanalysed baseline too The per-severity comparison reported each bucket independently, which cannot express a trade: swapping the single high rule for three extra low ones moves two buckets in opposite directions, so it landed in worse and in better at once and exit_code answered worse. The comment beside that loop calls exactly that swap an improvement. SEVERITIES is ordered most severe first, so the most severe bucket that moved now decides and the rest are reported alongside it without flipping the verdict. The zero-engine guard was on the candidate only. A baseline hash VirusTotal knows but has never analysed carries no engines, no Sigma and no YARA, so every finding on the candidate read as newly introduced and the run exited 2 having compared against nothing. * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Bound the lookups, keep ruleset identity, and escape third-party text Neither lookup carried a deadline, and request can spend four 300-second socket attempts plus 20, 40 and 80 seconds of backoff. The workflow gives the whole job 20 minutes, so the baseline lookup alone could exhaust it and the runner would kill the step before it fetched the candidate or wrote its summary, which is a lost run rather than a reported one. Both lookups now share a 420 second budget and an expired budget is reported as VOID, since we did not find out. YARA hits were keyed on the rule name alone, so the same rule identifier appearing in two crowdsourced rulesets collapsed to one entry: a candidate could gain a hit from a second ruleset, parse to the same list as the baseline, and exit 0 on a real regression. Keyed on ruleset and rule now. Engine names and detection labels are third-party text and the report is appended to GITHUB_STEP_SUMMARY, where a newline ends the row, a pipe opens a cell and an angle bracket starts HTML that GitHub renders. virustotal_scan._md_text exists for exactly this and the report was bypassing it; reused rather than duplicated. * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Stop labelling an overridden baseline as the recorded install.ps1 A dispatch can supply baseline_sha256, and the lookup and the comparison then use that hash while the header still announced the recorded identity and printed install.ps1's historical scores beside the override's live table. That is an artifact built to be misattributed: the numbers belong to one file and the name to another. The note is now printed only when the baseline hash really is the recorded one, and an override says so and disclaims the historical comparison. * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Catch a spent deadline in the VirusTotal delta lookup VirusTotalClient.request signals an expired deadline with TimeoutError, which inherits from OSError rather than RuntimeError, so the handler in fetch never ran and the workflow died with a traceback before render wrote its summary. That is the lost run the deadline was meant to prevent. Catch both and keep returning a VOID row. * Keep Sigma buckets this tool cannot rank The parser warned in its own docstring that VirusTotal renames and adds severity buckets, then read a fixed key list, so a candidate that gained rules only in a new bucket produced a dictionary identical to the baseline's and the run exited 0 on a regression. Keep every reported bucket. Unrankable ones stay out of the ordered trade-off, which depends on knowing which of two buckets is more severe, and a rise in one is reported as worse rather than assumed minor. * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Count every engine verdict bucket, not the five the dataclass carries parse_stats names type-unsupported and failure as categories VirusTotal has added, but ScanStats has fields only for five buckets, so the engine count this report prints was short by however many engines answered that way, and a response made up entirely of those buckets summed to zero and voided the run as unanalysed. Sum every numeric bucket from the raw stats, which leaves the shared dataclass alone for the release scanner. * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Require an explicit verdict before calling an engine cleared An engine that flagged the baseline and is absent from the candidate's results has not cleared it, it did not evaluate it, and a set difference cannot tell those apart. Since Skyhigh is the one engine that actually flags this file, a sparse candidate analysis could print the single most consequential sentence in the report and exit 0. Track which engines returned a verdict of any kind, call only an answering non-flagging engine cleared, and report the silent ones as an unanswered question. * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Only a conclusive verdict clears a prior detection The responder set was built on the truthiness of the category, so timeout, confirmed-timeout, failure and type-unsupported counted as answers while parse_detections correctly left them out of the flagging list. An engine returning one of those appeared in neither set and was reported as having stopped flagging the candidate, which is the same mistake as treating absence as a clean verdict. * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
…already worked (unslothai#10996) * Give this work a before-and-after number, and find out the hardening already worked Six hardening passes shipped with no measurement (unslothai#7822, unslothai#8586, unslothai#6326, unslothai#10540, unslothai#10560, unslothai#10504). There was no baseline to measure against. There is one now: install.ps1 at commit 1ad4467 is the revision reported in unslothai#10805, it hashes to ec29980b..., and VirusTotal holds its verdict. ## The result, run live against the real key | | baseline (1ad4467) | main (2c70592a) | | engines flagging | 1 / 60 | 1 / 61 | | which | Skyhigh BehavesLike.PS.Suspicious.gr | the same | | Sigma | 17 (high 1, medium 11, low 5) | 14 (medium 10, low 4) | | YARA | 2 | 0 | The **high**-severity Sigma rule is gone. So are both crowdsourced YARA hits, `INDICATOR_SUSPICIOUS_PWSH_B64Encoded_Concatenated_FileEXEC` and `Windows_API_Function`. Three fewer Sigma rules overall. The Skyhigh verdict has not moved, and that is reported as unchanged rather than dressed up: a cloud behavioural verdict is not recomputed because we deleted some code. So the static indicators, which are what drives the alarming scores third-party analysis sites report, already improved measurably. That was not knowable before. Two corrections to what I wrote in the plan, both from running this rather than reasoning about it: - I recorded current main's install.ps1 as **not on VirusTotal**. It is. It has been scanned since, so the delta above is real and not a projection. - I treated the prior passes as unverifiable. They are verifiable, retroactively, and they worked on the axis they could affect. ## Three axes, separately Reporting only the engine count makes every shape win look like it achieved nothing. Reporting only Sigma overclaims. Both, or the number is not worth having. Engines are compared **by name**, not by count. A count-only comparison calls the single most consequential possible change -- Skyhigh's detection being replaced by Microsoft's, one engine before and one after -- "no difference". Defender is on every Windows machine; Skyhigh is enterprise-deployed. There is a test for exactly that case. Sigma is compared **per severity**, not in total. Trading one high for three lows is an improvement a total calls a regression, and the reverse is a regression a total calls an improvement. ## GET only, and VOID is not clean There is no upload path, and that is a deliberate omission rather than an oversight. A freshly uploaded file is a prevalence-zero, first-seen sample, which is exactly what `CloudBlockLevel HighPlus` and ASR rule `01443614` punish -- so uploading a candidate can *create* the detection it was meant to measure, under a hash no user will ever have. Released artefacts are uploaded by `virustotal_scan.py` at release time; branches are not. A test parses the module and asserts no non-GET method appears, having first been written as a grep and caught matching the module's own explanation of why there is no upload. So an unknown hash is VOID, exit 3, never clean. Also VOID: a missing `VT_API_KEY`, and a file VirusTotal knows but has never analysed -- that last one being the subtle case, because zero engine verdicts is not sixty engines clearing the file. Exit codes are distinct: 3 could-not-measure, 2 worse, 0 not worse. ## The baseline is checked, not trusted A baseline hash copied out of an issue is a number nobody can verify, and if it ever pointed at the wrong file every delta reported against it would be wrong while the lane looked perfectly healthy. So both a test and a workflow step recompute it from this repository's history -- `git show 1ad4467:install.ps1` -- and assert the 427,113 bytes the sample is recorded as. A shallow clone skips rather than fails. ## Verification - 613 passed, 6 skipped across `tests/security/`, including 25 new tests. - Run live against the real key; the table above is its actual output. - Weighted toward the failure direction: a new high-severity rule, a new YARA hit, an engine swap at an unchanged count, and a medium promoted to high must each be reported as worse. One test replaces the comparison with one that reports nothing and requires the self-test to notice, because a control that cannot fail is decoration. - Both parsers are fuzzed against schema drift. VirusTotal has renamed and added buckets over time, and a crash would break the measurement on precisely the day the schema moved. * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Read the VirusTotal secret this repository actually has, so the lane can measure something `secrets.VT_API_KEY` does not exist. `VT_API_KEY` is the ENV VAR name the Python reads (`scripts/virustotal_scan.py:37`); the repository secret is `VIRUS_TOTAL_API_TOKEN`, which is the only VirusTotal secret in all 51 workflows, and `release-desktop.yml:2193` maps it the same way. As written the expression expanded to empty and the lane exited 3 / VOID on every dispatch. That is the right failure shape -- it refuses to report a clean it did not measure -- but a lane that can never measure anything is not worth having, and the failure only surfaces after someone dispatches it and waits. Two guards added, because both halves of this were invisible: - `test_the_workflow_reads_the_secret_this_repository_actually_has` pins the secret name in both directions and also asserts the checkout keeps `fetch-depth: 0`, since the step that reverifies the baseline against commit 1ad4467 reverifies nothing on a shallow clone. - `test_the_baseline_hash_is_the_file_the_reporter_ran` now checks the constant's shape unconditionally before the git half. That git half skips on a shallow clone, which is every CI lane that collects `tests/security` -- so the one assertion tying the baseline to real history was green locally and silently absent everywhere it mattered. * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Compare Sigma severities in order, and void an unanalysed baseline too The per-severity comparison reported each bucket independently, which cannot express a trade: swapping the single high rule for three extra low ones moves two buckets in opposite directions, so it landed in worse and in better at once and exit_code answered worse. The comment beside that loop calls exactly that swap an improvement. SEVERITIES is ordered most severe first, so the most severe bucket that moved now decides and the rest are reported alongside it without flipping the verdict. The zero-engine guard was on the candidate only. A baseline hash VirusTotal knows but has never analysed carries no engines, no Sigma and no YARA, so every finding on the candidate read as newly introduced and the run exited 2 having compared against nothing. * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Bound the lookups, keep ruleset identity, and escape third-party text Neither lookup carried a deadline, and request can spend four 300-second socket attempts plus 20, 40 and 80 seconds of backoff. The workflow gives the whole job 20 minutes, so the baseline lookup alone could exhaust it and the runner would kill the step before it fetched the candidate or wrote its summary, which is a lost run rather than a reported one. Both lookups now share a 420 second budget and an expired budget is reported as VOID, since we did not find out. YARA hits were keyed on the rule name alone, so the same rule identifier appearing in two crowdsourced rulesets collapsed to one entry: a candidate could gain a hit from a second ruleset, parse to the same list as the baseline, and exit 0 on a real regression. Keyed on ruleset and rule now. Engine names and detection labels are third-party text and the report is appended to GITHUB_STEP_SUMMARY, where a newline ends the row, a pipe opens a cell and an angle bracket starts HTML that GitHub renders. virustotal_scan._md_text exists for exactly this and the report was bypassing it; reused rather than duplicated. * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Stop labelling an overridden baseline as the recorded install.ps1 A dispatch can supply baseline_sha256, and the lookup and the comparison then use that hash while the header still announced the recorded identity and printed install.ps1's historical scores beside the override's live table. That is an artifact built to be misattributed: the numbers belong to one file and the name to another. The note is now printed only when the baseline hash really is the recorded one, and an override says so and disclaims the historical comparison. * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Catch a spent deadline in the VirusTotal delta lookup VirusTotalClient.request signals an expired deadline with TimeoutError, which inherits from OSError rather than RuntimeError, so the handler in fetch never ran and the workflow died with a traceback before render wrote its summary. That is the lost run the deadline was meant to prevent. Catch both and keep returning a VOID row. * Keep Sigma buckets this tool cannot rank The parser warned in its own docstring that VirusTotal renames and adds severity buckets, then read a fixed key list, so a candidate that gained rules only in a new bucket produced a dictionary identical to the baseline's and the run exited 0 on a regression. Keep every reported bucket. Unrankable ones stay out of the ordered trade-off, which depends on knowing which of two buckets is more severe, and a rise in one is reported as worse rather than assumed minor. * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Count every engine verdict bucket, not the five the dataclass carries parse_stats names type-unsupported and failure as categories VirusTotal has added, but ScanStats has fields only for five buckets, so the engine count this report prints was short by however many engines answered that way, and a response made up entirely of those buckets summed to zero and voided the run as unanalysed. Sum every numeric bucket from the raw stats, which leaves the shared dataclass alone for the release scanner. * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Require an explicit verdict before calling an engine cleared An engine that flagged the baseline and is absent from the candidate's results has not cleared it, it did not evaluate it, and a set difference cannot tell those apart. Since Skyhigh is the one engine that actually flags this file, a sparse candidate analysis could print the single most consequential sentence in the report and exit 0. Track which engines returned a verdict of any kind, call only an answering non-flagging engine cleared, and report the silent ones as an unanswered question. * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Only a conclusive verdict clears a prior detection The responder set was built on the truthiness of the category, so timeout, confirmed-timeout, failure and type-unsupported counted as answers while parse_detections correctly left them out of the flagging list. An engine returning one of those appeared in neither set and was reported as having stopped flagging the candidate, which is the same mistake as treating absence as a clean verdict. * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
What this does
Cuts 23,636 comment lines from the installers, the CLI, the
unslothpackage,.github/scriptsand the studio backend utilities. Comments, docstrings and whitespace only; no code changes.219 files changed, 6,445 insertions, 30,120 deletions.
The comment counts above are
comment_tools.py collecttotals over the 219 files this branch changes, and they and the diffstat are measured against the current merge base, which has moved withpre-commit.cireformatting and merges ofmain.This is the part of the tree the earlier comment passes never reached. #10112 through #10118 covered studio backend, studio frontend and the test suites; the installers,
.github/scriptsat 32.6% comments and theunslothpackage itself were untouched, which is why the reduction here is roughly triple what the already-swept areas yield.The standard applied
Delete first, shorten second. A comment survives only if it states an invariant the code does not, cites a non-obvious choice, says why an alternative is wrong, or names a real defect.
Deletion rather than rewriting,
.github/scripts/kaggle_t4_ci/legs.pyat 768 lines to 84: the control and canary essay went, because the leg table already states the pairing and the code names the pins file.Typical shortening,
studio/backend/hub/utils/gguf.py:Why this is 53.9% and not 70%
The remaining 20,232 lines are dominated by one-line survivors carrying hardware quirks, driver version constraints and issue citations: gfx architecture routing, ROCm wheel families, PowerShell profile behaviour, Windows anti-virus and Application Control cases. Cutting further means deleting facts rather than prose.
Verification
The merge base for this branch is
mainitself, socomment_tools.py check --changed --strict-ext --strip-docstringsis a direct per-file comparison against upstream for all 219 files, not a spot check. It reports219/219 checked OKwith zero files reported as not checked. Extensions changed: 187 py, 26 sh, 6 ps1, all with a lexer.Per-file code identity against
main, for the files where a rebase conflict had to be resolved by hand:ast.dumpwith docstring nodes blanked is identical for all five Python files, and all 187 Python files in the diff match. Forsetup.ps1, stripped of own-line comments, upstream and this branch are 5,453 lines each and byte identical. That last check has a hole, since a#-leading line inside a here-string would be stripped on both sides, so the authoritative proof is the gate itself, whose PowerShell signature compares here-string bodies byte for byte.Both suites, comparing sorted FAILED and ERROR node ids rather than summary counts:
Functional directives were compared as full match sets, path plus text, between base and head:
type: ignore,noqa,shellcheck,#Requires, coverage pragmas,novermin, SPDX and copyright headers are identical, and shebang counts match at 178. That check caught one real defect: collapsing the_column_namesdocstring inunsloth/models/rl.pydropped the trailing# noqa: D208sitting on the closing quotes. Restored.Comments that are load bearing for tests
Installer tests locate sections by literal banner text, so all 237
# ── ... ──banner lines in the installers are kept despite banners being the most confidently deletable category in a comment pass.tests/python/test_tokenizers_and_torch_constraint.pyslices the installer source assource.split("# ── 6b.", 1)[1].split("# ── GPU detection", 1)[0]; both anchors are intact. The other installer tests that read installer sources match on code text or use a_code_only()helper, so they are comment-insensitive.Kept because it is an API, not a comment
<# .SYNOPSIS ... #>blocks insetup.ps1andinstall.ps1, which areGet-Helpoutput.studio run,verify-installandreset-password, which are--helpoutput.scripts/lint_duplicate_definitions.py, whichargparse(description = __doc__)prints.Local test state
The backend suite aborts during collection on both trees in this environment, 21 collection errors,
No module named 'loggers.handlers'andstructlog.__spec__ is not set, reproduced on a pristine checkout of both the old base and currentmain.--continue-on-collection-errorsis what makes the 40,000 test comparison above possible. There is no clean local run to claim; the claim is that both trees behave identically.