Repository navigation
Measure whether a hardening change alters what the installer does, instead of arguing that it does not - #10992
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. |
659d1d5 to
699412a
Compare
| - name: Prove the comparer can still fail, then compare | ||
| run: | | ||
| set -euo pipefail | ||
| # Again, immediately before the verdict. The run above was 10 minutes and two installs | ||
| # ago, and this is the assertion the whole lane rests on. | ||
| python .github/scripts/compare_installer_evidence.py --self-test | ||
| echo | ||
| set +e | ||
| python .github/scripts/compare_installer_evidence.py \ | ||
| --base evidence/base --head evidence/head \ | ||
| --base-sha '${{ needs.resolve.outputs.base_sha }}' \ | ||
| --head-sha '${{ needs.resolve.outputs.head_sha }}' | ||
| code=$? | ||
| set -e | ||
| case "$code" in | ||
| 0) echo "VERDICT: no behaviour difference." ;; | ||
| 2) echo "::error::VERDICT: the installer's behaviour changed. See the differences above." | ||
| echo "::error::If the change is intended, say so in the PR and update whichever test pins the old behaviour. Do not widen the comparer's normalisation to make this green." ;; | ||
| 3) echo "::error::VERDICT: VOID. Nothing was compared, so nothing was shown to be unchanged." ;; | ||
| *) echo "::error::VERDICT: the comparer itself failed (exit $code); no verdict." ;; | ||
| esac | ||
| exit "$code" |
Validation: can this lane lie?This PR ships no user-facing file, so it cannot break an install. The only risk it carries is that the lane reports "same" when something differed, which launders a regression into a green check. So I went at it from that direction only. Theorised failure modes first, then 95 adversarial fixture pairs asserting the exact 3/2/0 verdict for each. 12 came back wrong, all of them false greens. Fixed in c9b40ce and 4804b16. What I theorised could produce a false verdict
3, 4 and 6 were already closed, and correctly. 1, 2, 5 and 7 were open. The adversarial matrix95 cases, synthetic base/head evidence pairs, each asserting an exact exit code.
Every one of the 12 was a run that exited 0 and printed Defects found and fixedThe installer's exit status never reached the comparer. An The A manifest of the wrong shape was coerced, not rejected. A BOM made valid evidence unreadable. Windows PowerShell 5.1 writes one for The tools-extraction guard passed on a zero-byte file. A failed The label gate matched as a bare substring, so a future A transcript difference suppressed the shortcut note, so a run reporting a changed line also stopped saying whether the launch contract had been looked at. Version drift was reported from the transcript only. Every new guard is in Normaliser audit
Everything else I checked
What a Linux host cannot tell you about a windows-latest laneEverything above is about the comparer and the collector's portable half. It is not a run of the lane.
|
|
@codex security review |
|
From a CI sweep: your
--- a/tests/python/test_installer_differential_comparer.py
+++ b/tests/python/test_installer_differential_comparer.py
@@ -781,6 +781,7 @@ def test_a_contract_that_moved_without_changing_its_bytes_is_a_difference() -> N
was added to make observable.
"""
+
def side(found_at: str) -> dict:Reproduced against your head Two things that make the log misleading:
Not touching the branch, since you have it in flight. |
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 90550ab37f
ℹ️ 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".
| } | ||
|
|
||
| # Always zero. A collection failure is data for the comparer, not a red step. | ||
| exit 0 |
There was a problem hiding this comment.
Return instead of exiting the collector host
When the collector is invoked after the second install in windows-installer-differential-ci.yml, this exit 0 terminates the entire hosting pwsh step rather than merely returning from the script. Consequently, the commands after that invocation never merge secondInstallExit into run.json, and compare_run_status treats every otherwise-successful run as VOID because that required status is missing. Remove the explicit exit or use return so the caller can finish recording the evidence.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Not correct, and this one is settled by running it rather than by reading it.
exit inside a script invoked with the call operator terminates that script's scope and returns to the caller with $LASTEXITCODE set. It only takes the host down when the script is dot-sourced, and the workflow uses & at both call sites (windows-installer-differential-ci.yml:328 and :354).
Executed here, with the real collector and the same invocation shape as the step:
pwsh -NoProfile -Command "$ErrorActionPreference='Continue'; & './.github/scripts/Collect-InstallerEvidence.ps1' -StudioHome ... -OutDir ... | Out-Null; Write-Host 'STEP CONTINUED...'; 'second_install_exit=0' | Out-File ...; Write-Host ('proof written: ' + (Test-Path ...))"
collected 2 artifact entr(ies)
STEP CONTINUED AFTER THE COLLECTOR, LASTEXITCODE=0
proof written: True
step exit=0
And under the shape GitHub actually uses for a shell: pwsh step, which dot-sources the step script into the host (pwsh -command ". '<step>.ps1'") and then calls the collector with & from inside it:
pwsh -NoProfile -Command ". './step.ps1'"
inner start
STEP CONTINUED (dot-sourced host), LASTEXITCODE=0
host exit=0
So the commands after the second collector invocation do run, and secondInstallExit is merged into run.json. The exit 0 is deliberate and documented where it sits: a collection failure is data for the comparer, not a red step, and the comparer is what decides VOID.
Worth adding one thing in your favour, because it came out of checking this: I had been treating a green run of this lane on a staging repo as evidence it works end to end, and it was not. That run only executed the gate job and skipped the two installs, because the staging PR carries no installer-differential label. I have now labelled it, the real two-install differential is running, and I will report what the comparer actually says rather than what a skipped job implies.
90550ab to
8f42c42
Compare
8f42c42 to
c7631a9
Compare
ee74fdb to
963c3e9
Compare
… has to prove it changed nothing The claim every antivirus-shape change in this series rests on is that the installer still does exactly what it did. Nothing measured that. This lane runs install.ps1 to completion twice on windows-latest, once from the merge base and once from the candidate, and compares four contracts: - the transcript, first run and reinstall, so a change to what a user sees fails - the shortcut manifest, every field of the launch contract including the description install.ps1 reads back when it decides whether a shortcut is already correct - the generated launch-studio.ps1 and unsloth.cmd, by content, encoding and location - idempotency, by running the installer a second time and requiring it to write nothing The design rule throughout is that unmeasured is not passed. Both legs are produced by the same collector, so malformed evidence is symmetric and compares equal to itself, and every check is written for that: an empty shortcut object, a content contract with no captured content, a manifest of the wrong shape, an installer that exited non-zero, an unmeasured idempotency run and an unknown expected set are all VOID rather than agreement. The comparer carries a positive control it must call different and a pair it must call equal, because a differ that reports no differences looks the same whether it is working or broken. Normalisation is deliberately narrow. Console output and generated files get different rules: a port, a size or an elapsed time is noise in a transcript and content in a launcher. Only values that genuinely vary between two installs of two commits are erased, and the one rule that can reach a deliberate change, the version normaliser, prints what it erased. Two full installs per run, so a pull request opts in with the installer-differential label, the label event is scoped so an unrelated label cannot cancel a measurement in flight, and a weekly run keeps the lane known to work before it is relied on to judge anything. No shipped file is touched: two CI scripts, one workflow and its tests.
963c3e9 to
1e491b4
Compare
|
Codex Review: Didn't find any major issues. Nice work! 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". |
…stead of arguing that it does not (unslothai#10992) * Windows: a base vs head installer differential, so a hardening change has to prove it changed nothing The claim every antivirus-shape change in this series rests on is that the installer still does exactly what it did. Nothing measured that. This lane runs install.ps1 to completion twice on windows-latest, once from the merge base and once from the candidate, and compares four contracts: - the transcript, first run and reinstall, so a change to what a user sees fails - the shortcut manifest, every field of the launch contract including the description install.ps1 reads back when it decides whether a shortcut is already correct - the generated launch-studio.ps1 and unsloth.cmd, by content, encoding and location - idempotency, by running the installer a second time and requiring it to write nothing The design rule throughout is that unmeasured is not passed. Both legs are produced by the same collector, so malformed evidence is symmetric and compares equal to itself, and every check is written for that: an empty shortcut object, a content contract with no captured content, a manifest of the wrong shape, an installer that exited non-zero, an unmeasured idempotency run and an unknown expected set are all VOID rather than agreement. The comparer carries a positive control it must call different and a pair it must call equal, because a differ that reports no differences looks the same whether it is working or broken. Normalisation is deliberately narrow. Console output and generated files get different rules: a port, a size or an elapsed time is noise in a transcript and content in a launcher. Only values that genuinely vary between two installs of two commits are erased, and the one rule that can reach a deliberate change, the version normaliser, prints what it erased. Two full installs per run, so a pull request opts in with the installer-differential label, the label event is scoped so an unrelated label cannot cancel a measurement in flight, and a weekly run keeps the lane known to work before it is relied on to judge anything. No shipped file is touched: two CI scripts, one workflow and its tests. * [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>
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.
steppads its label to exactly 15 columns and the output lock pins the indent, so leading whitespace is compared and only trailing whitespace is stripped..lnklaunch contract, read back through the shell rather than taken from the installer's own log: target, arguments, working directory, window style, icon.argumentscarries-WindowStyleand-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.launch-studio.ps1,unsloth.cmd,share/studio.conf, plus the shape of the install tree.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:
erroris now VOID.ConvertTo-Jsonunwraps a one-element collection into a bare object, and-AsArraydoes not exist on Windows PowerShell 5.1. With exactly one shortcut found,shortcuts.jsonwas 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
measurejob also asserts thatgit rev-parse HEADequals 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,RemoteSignedbecomingBypassin a shortcut, a shortcut that stopped being created, a changed generated launcher, a second run that rewrote something: each must be reported. One test 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
uvpatch 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-differentiallabel, a dispatch, or the weekly schedule.synchronizeis 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, which is
windows-vt-preflight.yml(#10984).Verification
tests/security/, the new comparer tests, the workflow-trigger lint and the installer shape suite.pwshon Linux, feeding the real comparer. That is what exposed both JSON defects above and a third:Join-Paththrows on a null path, and composing%APPDATA%unconditionally made a parse-clean script print a binding error before doing any work.Parser::ParseFileclean on the collector; the workflow parses as YAML with the three expected jobs.