Skip to content

Stop three installer tests from inheriting and leaking uv resolver policy - #11133

Closed
danielhanchen wants to merge 2 commits into
mainfrom
pr/installer-test-env-leak
Closed

danielhanchen wants to merge 2 commits into
mainfrom
pr/installer-test-env-leak

Conversation

@danielhanchen

@danielhanchen danielhanchen commented Sep 16, 2026 •

Copy link
Copy Markdown
Member

Summary

Six tests under tests/studio/install fail on main today. None of them indicts product code: two are wrong tests, and one of those two poisons the other five through a leaked process environment variable. This fixes both ends and makes the assertions durable.

cf335fa47 (origin/main)            6 failed, 6125 passed, 33 skipped
cf335fa47 + this change            6132 passed,  32 skipped

The interference, named

test_setup_fast_path_guard.py::test_the_installer_reads_uv_offline_the_same_way_the_shell_does assigned os.environ["UV_OFFLINE"] = value directly inside a 20-iteration loop, with no monkeypatch and no teardown. When it finished, the last loop value was still set process wide: UV_OFFLINE="2".

That file sorts before test_woa_wheelhouse_guard_behaviour.py, whose _run passed no env= to subprocess.run(["pwsh", ...]). So Test-WoaResolveReachesPyPI received UV_OFFLINE=2 and took the early return at install.ps1:765:

if ($flag -and ($flag.Trim().ToLowerInvariant() -notin @("", "0", "false"))) { return $false }

"2" is not in that set, so the function answered $false before reading anything else. That accounts for the failure set exactly, including which row survives: every True row fails except env9 (UV_OFFLINE: "0"), the only one that overwrites the leaked value. env10 sets UV_NO_INDEX instead and so cannot rescue itself.

Two files alone reproduce it in 13 seconds:

pytest tests/studio/install/test_setup_fast_path_guard.py \
       tests/studio/install/test_woa_wheelhouse_guard_behaviour.py -q -p no:randomly

uv names the value itself. A full-directory run with -rs on unfixed main shows a skip that does not exist in isolation, and it is the 33 skipped to 32 skipped delta here:

SKIPPED tests/studio/install/test_transformers_tokenizers_pair.py:277: uv pip compile failed
without a resolver verdict: error: Failed to parse environment variable `UV_OFFLINE` with
invalid value `2`: expected a boolish value

So the leak was also silently disabling a real resolver test, which is worse than the five it turned red. That file invokes uv with env = {**os.environ, "MACOSX_DEPLOYMENT_TARGET": "15.0"}, so uv received UV_OFFLINE=2 and refused to start; its startup error contains none of _RESOLVER_VERDICT_MARKERS, so the test took the branch at line 277 that exists to tolerate flaky index trouble. Five loud red tests are an annoyance; a real resolver test quietly not running is the kind of thing that stays invisible for months.

The skip lists differ by exactly that one entry, and the arithmetic closes with nothing left over: 6125 + 6 + 33 = 6164 before, 6132 + 32 = 6164 after. The six failures became passes and the seventh test went from silently skipped to running and passing.

The second failure is an unsatisfiable assertion, not a regression

test_pr10648_offline_and_status.py::test_the_pr_only_added_new_arms_to_the_setup_status_blocks ran git diff -U0 191b69c12 -- studio/setup.sh studio/setup.ps1 and asserted that no removed line contains already matches, step , grep -Fq or -match. On a PR branch that diff is the PR. On main it is every installer change since 2026-09-09, so it indicts whichever unrelated commit last touched such a line. Today that is #11007 and its if ($cap -match '^(\d+)\.(\d+)$') {.

It was never satisfiable on main and has been red since the day it merged. It escaped notice because studio-backend-ci.yml checks out at the actions/checkout default fetch-depth: 1, the merge base is absent, and requires_merge_base skips the whole thing, so CI has never executed it.

What changed

  • test_setup_fast_path_guard.py: monkeypatch.setenv instead of the raw os.environ write.
  • test_woa_wheelhouse_guard_behaviour.py: _run builds an explicit env with the uv and pip policy variables removed (UV_OFFLINE, UV_NO_INDEX, UV_DEFAULT_INDEX, UV_INDEX_URL, UV_INDEX, UV_EXTRA_INDEX_URL, UV_CONFIG_FILE, UV_NO_CONFIG, the three PIP_*, plus APPDATA and ProgramData, which Get-WoaUvConfigIndexPolicy reads). This is the idiom the sibling test_woa_torch_index_persistence.py already uses via woa_ps_harness.clear_env(UV_POLICY_ENV). A new no_uv_config_dir fixture supplies the working directory and asserts by name that no uv.toml or [tool.uv] table sits anywhere above it, since Get-WoaUvConfigIndexPolicy walks to the filesystem root. No assertion was weakened and the parametrisation is untouched.
  • test_pr10648_offline_and_status.py: the diff archaeology is replaced by live invariants on the shipped text, and @requires_merge_base is dropped because nothing historical is left in it. Renamed to test_the_keep_arm_sits_beside_the_status_arms_it_did_not_replace: exactly two keep arms in each script, each guarded by its own shell's construct (grep -Fq in sh, -match in ps1), the three pre-existing arms present verbatim, and update unavailable, existing prebuilt kept exactly twice per script. The sibling test_pre_pr_... keeps MERGE_BASE, which is legitimate: it reads a fixed historical blob with git show, not a diff against a moving branch.

Can it fail

Every changed assertion was checked against a real defect, so that none of them passes merely because the environment is now scrubbed.

perturbation result
drop the [Oo][Nn] arm from _uv_offline_requested() in studio/setup.sh red: UV_OFFLINE='on': setup.sh says False, install_python_stack.py disagrees
delete the UV_OFFLINE / UV_NO_INDEX gate from install.ps1 red: env7, env8
make PIP_INDEX_URL decide the uv resolve red: env3, so the True rows still measure something
drop a uv.toml above the tmp dir red by name: a uv.toml above the tmp dir: ...
reword the ps1 already matches arm red
remove one sh whisper keep arm red
swap -match for .Contains() in setup.ps1 red

Not this PR

  • install.ps1:765 is the third and only disagreeing spelling of "is uv offline" in the repo. studio/setup.sh::_uv_offline_requested and studio/install_python_stack.py::_uv_is_offline both use uv's real boolish set (1 t true y yes on), and a test asserts those two agree. install.ps1 uses not in ("", "0", "false"), so it reads off and no, both meaning online to uv, as offline. Left alone here because the error is in the fail-safe direction, which the code comment states deliberately: a false "PyPI unreachable" keeps our wheelhouse copy rather than deleting it. Worth a follow-up for consistency.
  • Two concurrent full tests/studio/install runs corrupt the shared ~/.cache/powershell/StartupProfileData-NonInteractive, after which every pwsh on the box segfaults and unrelated runs report hundreds of failures. Pointing XDG_CACHE_HOME at a per-run directory fixes it. If CI ever schedules two of these jobs on one runner it will look like a mass product regression.

Note on #11112

#11112 is merged (907f19830) and origin/main still produces the identical six failures. It was fixing tests/security/test_scan_packages.py and touches studio/backend/requirements/extras.txt; neither failing test reads that file. It is a good change for the reason it states and simply is not related to these six.

…licy

Six tests in tests/studio/install fail on main and have since the commits that
introduced them. None of them indicts product code.

test_setup_fast_path_guard.py assigned os.environ["UV_OFFLINE"] directly inside
a 20-iteration loop with no teardown, so it left UV_OFFLINE=2 set process wide.
That file sorts before test_woa_wheelhouse_guard_behaviour.py, whose _run passed
no env= to pwsh, so Test-WoaResolveReachesPyPI saw UV_OFFLINE=2, took the early
return at install.ps1:765 and answered False. That accounts for the failure set
exactly, including why env9 (UV_OFFLINE=0) is the one True row that survives: it
is the only one that overwrites the leaked value. The same leak was also silently
skipping test_transformers_tokenizers_pair.py, which uv rejects outright with
"invalid value 2: expected a boolish value".

Fixed at both ends. The writer uses monkeypatch.setenv. The reader builds an
explicit env with the uv and pip policy variables removed, matching the idiom
test_woa_torch_index_persistence.py already uses, and runs under a fixture that
asserts no uv.toml or [tool.uv] table sits anywhere above its working directory,
since Get-WoaUvConfigIndexPolicy walks to the filesystem root.

test_the_pr_only_added_new_arms_to_the_setup_status_blocks diffed the installers
against a fixed 2026-09-09 SHA and asserted no removed line matched "step " or
"-match". On a PR branch that diff is the PR; on main it is every installer
change since, so it indicts whichever unrelated commit last touched such a line.
It was never satisfiable on main and has been red since it merged, unnoticed
because actions/checkout defaults to fetch-depth 1 and requires_merge_base skips
it in CI. Restated as live invariants on the shipped text: exactly two keep arms
per script, each guarded by its own shell's construct, the three pre-existing
arms present verbatim.

tests/studio/install: 6 failed, 6125 passed, 33 skipped on cf335fa before;
6132 passed, 32 skipped after. Each assertion was checked against a real defect
in both directions, so none of them passes merely because the environment is
now scrubbed.
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Sep 16, 2026
@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 16, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-09-17T00:23:15.728008Z ecd367f Manual request
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@danielhanchen

Copy link
Copy Markdown
Member Author

@codex security review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 0cb16d8961

ℹ️ 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".

"PIP_EXTRA_INDEX_URL",
# Get-WoaUvConfigIndexPolicy reads %APPDATA%\uv\uv.toml and the ProgramData copy.
"APPDATA",
"ProgramData",

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Normalize ProgramData before filtering the child environment

On Windows, Python normalizes os.environ keys to uppercase, so the inherited entry is exposed as PROGRAMDATA and does not match this mixed-case tuple member. Consequently _run still passes the system-wide ProgramData directory to PowerShell, where $env:ProgramData\uv\uv.toml can override the supposedly isolated environment-policy cases and make them fail based on machine configuration. Compare keys case-insensitively or list PROGRAMDATA here.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Confirmed, and it fails on exactly the platform the scrub is for. CPython upper-cases every environment key on nt: os.py's _createenviron defines encodekey as encode(key).upper() under the comment "Where Env Var Names Must Be UPPERCASE", and builds the mapping with data[encodekey(key)] = value. So Windows hands the comprehension PROGRAMDATA, the literal not-in test against ProgramData passes it through, and the child keeps reading %PROGRAMDATA%\uv\uv.toml. install.ps1:737 joins that file in Get-WoaUvConfigIndexPolicy, and a NoIndex or non-PyPI DefaultIndex there flips Test-WoaResolveReachesPyPI, so a row asserting True goes machine-dependent.

Fixed in ecd367f by folding the comparison. The new test deliberately runs everywhere rather than under requires_pwsh: a Linux session has no ProgramData to leak, so a literal-match scrub passes this suite green on CI and only stops working on Windows, which is how this got in.

The scrub list carries one mixed-case name, ProgramData, and it is the one that
would survive a literal match on the only platform it matters on. CPython
upper-cases every environment key on nt (os.py, _createenviron: encodekey does
encode(key).upper(), under the comment Where Env Var Names Must Be UPPERCASE),
so on Windows os.environ hands the comprehension PROGRAMDATA, it compares
unequal to ProgramData, and the child pwsh keeps reading
%PROGRAMDATA%\uv\uv.toml.

That file is uv's system-level config and install.ps1 reads it:
Get-WoaUvConfigIndexPolicy joins it at install.ps1:737, and a NoIndex or a
non-PyPI DefaultIndex there flips Test-WoaResolveReachesPyPI to False. So a row
asserting True becomes machine-dependent on exactly the boxes the installer
ships to, which is the failure this scrub exists to remove.

Fold the comparison, and state the requirement in a test that runs everywhere:
a Linux session has no ProgramData to leak, so a scrub that only matches
literally passes this suite green on CI and quietly stops working on Windows.
The parametrisation feeds the three spellings an environment block can carry.
@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. More of your lovely PRs please.

Reviewed commit: ecd367f931

ℹ️ 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".

@danielhanchen

Copy link
Copy Markdown
Member Author

Recording the one overlap with #11139 so that whichever of these merges second does not have to guess.

The two PRs are independent (both base=main, merging in either order), but they share three files. Two of them are not a problem: tests/studio/install/test_pr10648_offline_and_status.py and tests/studio/install/test_setup_fast_path_guard.py are byte-identical on the two heads, because both branches carry the same commit 0cb16d896. They auto-merge with nothing to resolve, so this PR's rewrite of the offline/status test cannot be lost there.

The third does conflict, in either order, and I confirmed it by simulating the merge: tests/studio/install/test_woa_wheelhouse_guard_behaviour.py, in the body of _run. This PR's ecd367f93 replaces the env line with _scrubbed_environ(); #11139 replaces the spawn on the next line with run_pwsh. Adjacent lines, one hunk.

Neither side should drop its hunk. _scrubbed_environ() is what survives CPython upper-casing ProgramData on nt, and run_pwsh is what gives the child its own pwsh startup-profile cache, which the guard #11139 adds will indict this file for missing. The resolution is the union:

def _run(script: str, *, cwd: str | pathlib.Path | None = None) -> str:
    env = _scrubbed_environ()          # this PR
    proc = run_pwsh(                   # #11139

import subprocess goes away with the routing and nothing else in the file uses it. With that resolution the merged tree runs 186 passed over the three installer tests plus the pwsh guard.

danielhanchen added a commit that referenced this pull request Sep 17, 2026
CPython puts every os.environ key through .upper() on nt ("Where Env Var
Names Must Be UPPERCASE", os.py), so Windows hands the comprehension
PROGRAMDATA, the literal "ProgramData" in the tuple compares unequal, and
the child keeps reading %PROGRAMDATA%\uv\uv.toml. That is uv's system-level
config and the one file that can turn a row asserting True into a
machine-dependent False, on the only platform install.ps1 ships to.

Matched on the upper-cased name at both ends. The row that states it feeds
_scrubbed_environ the three spellings a real environment block can carry,
and runs everywhere: a Linux session has no ProgramData to leak, so a
literal-match scrub passes this suite green on CI and quietly stops working
where it matters.

Same fix as #11133 carries for its copy of this file; both are open against
main and this branch has since converted the spawn to run_pwsh, so the two
are landed independently rather than one waiting on the other.
Lyxot pushed a commit to NilayYadav/unsloth that referenced this pull request Sep 17, 2026
* Stop three installer tests from inheriting and leaking uv resolver policy

Six tests in tests/studio/install fail on main and have since the commits that
introduced them. None of them indicts product code.

test_setup_fast_path_guard.py assigned os.environ["UV_OFFLINE"] directly inside
a 20-iteration loop with no teardown, so it left UV_OFFLINE=2 set process wide.
That file sorts before test_woa_wheelhouse_guard_behaviour.py, whose _run passed
no env= to pwsh, so Test-WoaResolveReachesPyPI saw UV_OFFLINE=2, took the early
return at install.ps1:765 and answered False. That accounts for the failure set
exactly, including why env9 (UV_OFFLINE=0) is the one True row that survives: it
is the only one that overwrites the leaked value. The same leak was also silently
skipping test_transformers_tokenizers_pair.py, which uv rejects outright with
"invalid value 2: expected a boolish value".

Fixed at both ends. The writer uses monkeypatch.setenv. The reader builds an
explicit env with the uv and pip policy variables removed, matching the idiom
test_woa_torch_index_persistence.py already uses, and runs under a fixture that
asserts no uv.toml or [tool.uv] table sits anywhere above its working directory,
since Get-WoaUvConfigIndexPolicy walks to the filesystem root.

test_the_pr_only_added_new_arms_to_the_setup_status_blocks diffed the installers
against a fixed 2026-09-09 SHA and asserted no removed line matched "step " or
"-match". On a PR branch that diff is the PR; on main it is every installer
change since, so it indicts whichever unrelated commit last touched such a line.
It was never satisfiable on main and has been red since it merged, unnoticed
because actions/checkout defaults to fetch-depth 1 and requires_merge_base skips
it in CI. Restated as live invariants on the shipped text: exactly two keep arms
per script, each guarded by its own shell's construct, the three pre-existing
arms present verbatim.

tests/studio/install: 6 failed, 6125 passed, 33 skipped on cf335fa before;
6132 passed, 32 skipped after. Each assertion was checked against a real defect
in both directions, so none of them passes merely because the environment is
now scrubbed.

* Repair the six CI checks that are red on main itself

Every one of these reproduces on origin/main with no pull request involved, so
they were failing on every open PR at once and reading like each PR's own fault.
Grouped by root cause rather than by check name: three commits between unslothai#11118 and
unslothai#10282 account for all six.

b535eca (unslothai#10282, Windows on ARM native CUDA) -- four failures

  tests/test_windows_amd_gpu_scan_fallback.py, two tests. install.ps1's handoff
  block grew four UNSLOTH_WOA_* saves and restores them from a TABLE walked with
  Set-Item "Env:$(...)", not from four written-out `$env:NAME = $previousX` arms.
  The installer is right; this file's reader knew only the written-out spelling,
  so it read four correct restores as absent. Worse than the noise: a table that
  really HAD gone missing would have been reported identically, so the check could
  not tell a correct block from a broken one. The reader now understands both
  spellings, and a table only counts when something walks it. The four names join
  _CALLER_ENV, so the runtime cases below actually exercise their restore instead
  of the file merely claiming to cover them -- dropping one row from the table, or
  restoring every row from row 0's save, now fails at runtime rather than passing.

  tests/studio/test_cache_budget_discipline.py. The guard flagged woa-wheelhouse's
  vcpkg cache as saving on a pull request ref. It cannot: that workflow is
  workflow_dispatch only, holds signing credentials and is deliberately unreachable
  from a pull request. The guard was reading `if:` without ever reading `on:`, so
  it applied a PR-ref rule to a workflow no PR can reach. It now reads the trigger
  block, the exemption is named with its reason rather than silently skipped, and a
  second test re-derives that claim from `on:` -- so the day woa-wheelhouse gains a
  pull_request trigger it comes straight back under the rule. An ungated cache save
  in a workflow a PR can reach still fails exactly as before.

  tests/studio/test_pwsh_calls_use_the_shared_runner.py. unslothai#10282 added four files
  under tests/studio/install that start PowerShell through subprocess directly,
  which opts them back into the shared $XDG_CACHE_HOME/powershell startup-cache
  race (~1 startup in 500 dies before it reaches the script). Routed through
  run_pwsh, which is the one-word change the runner was written for.

9b1f931 (unslothai#11117, localize the prompt queue) -- two failures

  tests/studio/studiobench/.../test_studiobench_queued_idle_live.py. The selftest
  pinned the composer's label as the English literal
  `followUpBehavior === "queue" ? "Queue message" : "Steer response"`, and unslothai#11117
  correctly replaced it with the two translation keys. A second assertion, on the
  queue surface's hardcoded English aria-label, was stale for the same reason and
  was hidden behind the first. Both now read the branch and the shipped en catalog,
  which is strictly stronger than the literals were: it also checks that dom.js's
  hardcoded `[aria-label^="Prompt queue,"]` selector still agrees with the catalog,
  which is the coupling a localization pass could have broken in silence.

  tests/studio/test_playwright_suites_run_in_ci.py. unslothai#11117 added
  playwright_queue_localization.py and wired it into nothing. It is a gate, not a
  measurement harness, so it is wired into the composer-compatibility engine loop
  beside the sibling suite that drives the same fixture -- not added to NOT_IN_CI.
  Verified green first on chromium 153, firefox 155 and webkit 26.6, so this adds
  coverage rather than a new red.

cf335fa (unslothai#11118) and 9b1f931 (unslothai#11117) -- one failure

  tests/test_formatter_fixed_point.py named three files that are not a fixed point
  of the ruff-format-with-kwargs hook, which fails pre-commit.ci on the next PR to
  edit any of them. Formatted with the pinned ruff 0.6.9.

None of this changes shipped behaviour. studio/backend/main.py is in the diff for
formatting only, and install.ps1 is untouched -- it was correct throughout.

Before / after, measured the same way both times:

  workflow guard suites   2 failed, 1961 passed, 44 skipped
                       -> 0 failed, 1976 passed, 44 skipped
  studiobench selftests   1 failed, 1423 passed, 145 skipped
                       -> 0 failed, 1424 passed, 145 skipped

* Scope the cache-save guard by trigger, not by an excused filename

Follow-up on review of the previous commit. The first version skipped
woa-wheelhouse.yml by name, from a dict carrying the reason. That works and it
rots: skipping a whole FILE blinds the guard to every other step in it, so a
`setup-python` implicit cache added to that workflow later would have been
invisible, and the excuse would keep applying after the reason for it had gone.
It is the same shape as a PINNED_BY_DESIGN keyed on filename.

The predicate was already there. Now it is the only thing doing the work: a
workflow is scanned if and only if `_pull_request_reachable` says a pull request
can run it, and there is no list. The day a workflow gains a `pull_request` or
`pull_request_target` trigger, every cache save in it is indicted on that same
commit with nobody having to remember an entry exists.

Composite actions stay indicted unconditionally. An action has no triggers of its
own, and one `uses:`d from a pull_request job saves on the PR's ref exactly as an
inline step would.

Mutation-proved, each applied then restored from a file copy:

  ungated actions/cache save injected into lint-ci.yml            RED
  ... into consolidated-tests-ci.yml                              RED
  ... into studio-frontend-ci.yml                                 RED
  woa-wheelhouse.yml given pull_request_target, save unchanged    RED
  woa-wheelhouse.yml given pull_request, save unchanged           RED
  woa-wheelhouse.yml given pull_request AND a second offender     RED, naming BOTH

The last is the one the filename exemption could not do. It reports

    woa-wheelhouse.yml:build-pyarrow: setup-python implicit post-step save
    woa-wheelhouse.yml:build-pyarrow: Cache vcpkg packages

where the excused-filename version would have named neither.

Workflow guard suites: 1975 passed, 44 skipped, 0 failed.

* Read the locale entry, not the line it starts on

studio/frontend/tests/pasted-text-attachment.test.ts "every locale keeps the
shortcut in the threshold description" fails on origin/main, which takes down
"Frontend build + bundle sanity" and "Frontend unit tests (Windows)" on every PR
whose merge picks up main. Reported by the lane that hit it on unslothai#11070; it is
main's test rather than that PR's, so it belongs here.

The test did source.indexOf("pastedTextThresholdDescription:"), sliced to the
next newline, and asserted "{shortcut}" was on that slice. That asserts about the
formatter as much as about the translation: a value Prettier wraps onto the
FOLLOWING line leaves the slice holding only the key, and the placeholder is
invisible while being right there.

Product is correct. All twelve locales carry {shortcut} -- checked by parsing the
value out of each file rather than by reading the assertion's own slice.

It is also worse than one locale. ELEVEN of the twelve are wrapped that way on
main today; only en.ts is not. The test was passing on readdir order alone, and
fixing ar.ts by hand would have handed the same failure to de.ts, then es.ts, and
so on down the directory.

So it now imports the locale module and asserts on the resolved string, which is
what the app reads and cannot be moved by layout. The key is found by walking the
tree rather than by a fixed path, so reorganising the message tree does not
silently drop the check either, and `values.length == 1` keeps it from passing
vacuously if the key disappears.

Checked the other indexOf-based source assertions in studio/frontend/tests while
here: they bound their slices with an explicit end marker ("];", the next symbol
name), not with the next newline, so none share this failure mode.

Mutation-proved:

  a locale drops {shortcut}          RED "ar.ts keeps {shortcut}"
  a locale loses the key entirely    RED "ja.ts carries the description
                                      exactly once"
  a value wrapped onto the next line GREEN here, and the old line-scoped
                                      assertion on the same tree sees only
                                      'pastedTextThresholdDescription:' and fails

The third is the regression itself, and it needs no synthetic edit: eleven
locales on main are already in that state.

studio/frontend: 34 pass, 0 fail (was 33 pass, 1 fail).

* Run the queue localization suite for the files it actually reads

Wiring the driver into the composer job left it unreachable by the change it
guards. The workflow filters on tests/studio/*composer* and
tests/studio/*prompt_queue*, and playwright_queue_localization.py carries
neither substring, so a pull request that edits only the driver never runs it.
Nor does one that edits only a catalog: the driver calls setLocale through
src/i18n/index.ts and asserts five hard-coded Japanese strings, and no pattern
reached src/i18n at all. A translation-only edit to ja.ts is the exact change
this suite exists to catch.

tests/studio/test_playwright_suites_run_in_ci.py cannot see this by design; its
own docstring says trigger paths say when CI runs, not what it runs.

Add the two patterns. Checked against GitHub's filter semantics with the
controls in both directions: the driver, each locale catalog and the i18n
loader now trigger the job, thread.tsx and playwright_prompt_queue_actions.py
still do, and README.md and unsloth/models/llama.py still do not.

Also close a hole in _pull_request_reachable, whose docstring promises that
anything unrecognised counts as reachable while the code fell through to
exempt. merge_group runs on its own refs/heads/gh-readonly-queue ref, so a
cache saved there is exactly the pull-request-scoped entry this rule forbids,
and the guard would have said nothing. Name the three events that really are
default-branch-only and indict the rest. No current workflow changes verdict.

* Close the three gaps the repaired CI run then hit

The previous commit got the Backend-CI and Windows jobs far enough to reach
three failures that were sitting behind them.

tests/studio/test_pwsh_calls_use_the_shared_runner.py scanned tests/ and
nothing else, so studio/backend/tests was never checked, and
studio/backend/tests/test_setup_llama_cpp_backend.py had two parametrised
probes (17 pwsh startups in one xdist job) calling subprocess.run(["pwsh",
...]) directly. That is exactly the shared startup-cache race run_pwsh
exists to end, and it showed up as SIGABRT in the "rest" shard. Both call
sites now go through run_pwsh, the guard scans both test trees, its
allowlist is keyed on the repo-relative path, and a new row asserts a file
from the backend tree is really in the scanned set. Checked for
non-vacuity: the widened guard flags both call sites as they stood before.

test_account_tool_confinement.py::test_install_under_a_granted_root_stays_hidden
packed three claims into one command line. Once the credential pre-flight in
tools.py learned to refuse a command that names the auth database, that line
was refused whole, so the two reach probes passed without anything running
and the "the rest of the granted root is still usable" probe could not run
at all. Split into three commands, each answered by the layer that owns it.
Fails on origin/main at f6cf06d too, so it is not this branch's.

playwright_composer_icons.py and playwright_queue_localization.py navigated
with a bare page.goto: playwright's 30s default, waiting for "load", which
on a vite dev server means every module in the graph. On a cold Windows
runner that overran twice, taking the Frontend unit tests (Windows) job down
after the node tests reported "# fail 0". Both now navigate with
domcontentloaded and an explicit budget, as every other driver in that
directory already does. Ran both locally end to end: 1296 icons centered,
all five localization checks pass.

* Give the Windows frontend job time for its own steps

Frontend unit tests (Windows) carries more than its name: node tests, the
composer icon alignment smoke, and data settings in both Chromium and
Firefox. Under a 15 minute cap it cannot finish them, and the overrun is
deterministic rather than flaky, so every run that reaches the last step
dies there and reports itself as "cancelled" -- the failure mode the
comment on the alignment job already describes.

Measured on run 35166979977: setup and npm ci 1m10s, unit tests 4m12s,
browser install 32s, composer icons 39s, data settings in Chromium 4m21s,
then Firefox cut off at 4m13s having needed about what Chromium needed.
That is roughly 15m30s of work under a 15m cap.

Raised to 30. The Linux sibling of this job allows 40.

* Scrub the resolver policy variables case-folded

CPython puts every os.environ key through .upper() on nt ("Where Env Var
Names Must Be UPPERCASE", os.py), so Windows hands the comprehension
PROGRAMDATA, the literal "ProgramData" in the tuple compares unequal, and
the child keeps reading %PROGRAMDATA%\uv\uv.toml. That is uv's system-level
config and the one file that can turn a row asserting True into a
machine-dependent False, on the only platform install.ps1 ships to.

Matched on the upper-cased name at both ends. The row that states it feeds
_scrubbed_environ the three spellings a real environment block can carry,
and runs everywhere: a Linux session has no ProgramData to leak, so a
literal-match scrub passes this suite green on CI and quietly stops working
where it matters.

Same fix as unslothai#11133 carries for its copy of this file; both are open against
main and this branch has since converted the spawn to run_pwsh, so the two
are landed independently rather than one waiting on the other.
@danielhanchen

Copy link
Copy Markdown
Member Author

Closing: every line of this is now on main, so merging it would be a no-op.

The case-folded ProgramData scrub went in through #11139, which touched the same file and had to carry the fix rather than wait, since the two branches had diverged on it (this one spawns pwsh through subprocess.run, #11139 had already converted that call site to run_pwsh). The rest landed through #11139 and #11145.

Checked rather than assumed: merging origin/main into this branch and resolving the one conflict in tests/studio/install/test_woa_wheelhouse_guard_behaviour.py leaves git diff --name-only origin/main..HEAD empty.

shaojun pushed a commit to shaojun/unsloth that referenced this pull request Sep 29, 2026
* Stop three installer tests from inheriting and leaking uv resolver policy

Six tests in tests/studio/install fail on main and have since the commits that
introduced them. None of them indicts product code.

test_setup_fast_path_guard.py assigned os.environ["UV_OFFLINE"] directly inside
a 20-iteration loop with no teardown, so it left UV_OFFLINE=2 set process wide.
That file sorts before test_woa_wheelhouse_guard_behaviour.py, whose _run passed
no env= to pwsh, so Test-WoaResolveReachesPyPI saw UV_OFFLINE=2, took the early
return at install.ps1:765 and answered False. That accounts for the failure set
exactly, including why env9 (UV_OFFLINE=0) is the one True row that survives: it
is the only one that overwrites the leaked value. The same leak was also silently
skipping test_transformers_tokenizers_pair.py, which uv rejects outright with
"invalid value 2: expected a boolish value".

Fixed at both ends. The writer uses monkeypatch.setenv. The reader builds an
explicit env with the uv and pip policy variables removed, matching the idiom
test_woa_torch_index_persistence.py already uses, and runs under a fixture that
asserts no uv.toml or [tool.uv] table sits anywhere above its working directory,
since Get-WoaUvConfigIndexPolicy walks to the filesystem root.

test_the_pr_only_added_new_arms_to_the_setup_status_blocks diffed the installers
against a fixed 2026-09-09 SHA and asserted no removed line matched "step " or
"-match". On a PR branch that diff is the PR; on main it is every installer
change since, so it indicts whichever unrelated commit last touched such a line.
It was never satisfiable on main and has been red since it merged, unnoticed
because actions/checkout defaults to fetch-depth 1 and requires_merge_base skips
it in CI. Restated as live invariants on the shipped text: exactly two keep arms
per script, each guarded by its own shell's construct, the three pre-existing
arms present verbatim.

tests/studio/install: 6 failed, 6125 passed, 33 skipped on cf335fa before;
6132 passed, 32 skipped after. Each assertion was checked against a real defect
in both directions, so none of them passes merely because the environment is
now scrubbed.

* Repair the six CI checks that are red on main itself

Every one of these reproduces on origin/main with no pull request involved, so
they were failing on every open PR at once and reading like each PR's own fault.
Grouped by root cause rather than by check name: three commits between unslothai#11118 and
unslothai#10282 account for all six.

b535eca (unslothai#10282, Windows on ARM native CUDA) -- four failures

  tests/test_windows_amd_gpu_scan_fallback.py, two tests. install.ps1's handoff
  block grew four UNSLOTH_WOA_* saves and restores them from a TABLE walked with
  Set-Item "Env:$(...)", not from four written-out `$env:NAME = $previousX` arms.
  The installer is right; this file's reader knew only the written-out spelling,
  so it read four correct restores as absent. Worse than the noise: a table that
  really HAD gone missing would have been reported identically, so the check could
  not tell a correct block from a broken one. The reader now understands both
  spellings, and a table only counts when something walks it. The four names join
  _CALLER_ENV, so the runtime cases below actually exercise their restore instead
  of the file merely claiming to cover them -- dropping one row from the table, or
  restoring every row from row 0's save, now fails at runtime rather than passing.

  tests/studio/test_cache_budget_discipline.py. The guard flagged woa-wheelhouse's
  vcpkg cache as saving on a pull request ref. It cannot: that workflow is
  workflow_dispatch only, holds signing credentials and is deliberately unreachable
  from a pull request. The guard was reading `if:` without ever reading `on:`, so
  it applied a PR-ref rule to a workflow no PR can reach. It now reads the trigger
  block, the exemption is named with its reason rather than silently skipped, and a
  second test re-derives that claim from `on:` -- so the day woa-wheelhouse gains a
  pull_request trigger it comes straight back under the rule. An ungated cache save
  in a workflow a PR can reach still fails exactly as before.

  tests/studio/test_pwsh_calls_use_the_shared_runner.py. unslothai#10282 added four files
  under tests/studio/install that start PowerShell through subprocess directly,
  which opts them back into the shared $XDG_CACHE_HOME/powershell startup-cache
  race (~1 startup in 500 dies before it reaches the script). Routed through
  run_pwsh, which is the one-word change the runner was written for.

9b1f931 (unslothai#11117, localize the prompt queue) -- two failures

  tests/studio/studiobench/.../test_studiobench_queued_idle_live.py. The selftest
  pinned the composer's label as the English literal
  `followUpBehavior === "queue" ? "Queue message" : "Steer response"`, and unslothai#11117
  correctly replaced it with the two translation keys. A second assertion, on the
  queue surface's hardcoded English aria-label, was stale for the same reason and
  was hidden behind the first. Both now read the branch and the shipped en catalog,
  which is strictly stronger than the literals were: it also checks that dom.js's
  hardcoded `[aria-label^="Prompt queue,"]` selector still agrees with the catalog,
  which is the coupling a localization pass could have broken in silence.

  tests/studio/test_playwright_suites_run_in_ci.py. unslothai#11117 added
  playwright_queue_localization.py and wired it into nothing. It is a gate, not a
  measurement harness, so it is wired into the composer-compatibility engine loop
  beside the sibling suite that drives the same fixture -- not added to NOT_IN_CI.
  Verified green first on chromium 153, firefox 155 and webkit 26.6, so this adds
  coverage rather than a new red.

cf335fa (unslothai#11118) and 9b1f931 (unslothai#11117) -- one failure

  tests/test_formatter_fixed_point.py named three files that are not a fixed point
  of the ruff-format-with-kwargs hook, which fails pre-commit.ci on the next PR to
  edit any of them. Formatted with the pinned ruff 0.6.9.

None of this changes shipped behaviour. studio/backend/main.py is in the diff for
formatting only, and install.ps1 is untouched -- it was correct throughout.

Before / after, measured the same way both times:

  workflow guard suites   2 failed, 1961 passed, 44 skipped
                       -> 0 failed, 1976 passed, 44 skipped
  studiobench selftests   1 failed, 1423 passed, 145 skipped
                       -> 0 failed, 1424 passed, 145 skipped

* Scope the cache-save guard by trigger, not by an excused filename

Follow-up on review of the previous commit. The first version skipped
woa-wheelhouse.yml by name, from a dict carrying the reason. That works and it
rots: skipping a whole FILE blinds the guard to every other step in it, so a
`setup-python` implicit cache added to that workflow later would have been
invisible, and the excuse would keep applying after the reason for it had gone.
It is the same shape as a PINNED_BY_DESIGN keyed on filename.

The predicate was already there. Now it is the only thing doing the work: a
workflow is scanned if and only if `_pull_request_reachable` says a pull request
can run it, and there is no list. The day a workflow gains a `pull_request` or
`pull_request_target` trigger, every cache save in it is indicted on that same
commit with nobody having to remember an entry exists.

Composite actions stay indicted unconditionally. An action has no triggers of its
own, and one `uses:`d from a pull_request job saves on the PR's ref exactly as an
inline step would.

Mutation-proved, each applied then restored from a file copy:

  ungated actions/cache save injected into lint-ci.yml            RED
  ... into consolidated-tests-ci.yml                              RED
  ... into studio-frontend-ci.yml                                 RED
  woa-wheelhouse.yml given pull_request_target, save unchanged    RED
  woa-wheelhouse.yml given pull_request, save unchanged           RED
  woa-wheelhouse.yml given pull_request AND a second offender     RED, naming BOTH

The last is the one the filename exemption could not do. It reports

    woa-wheelhouse.yml:build-pyarrow: setup-python implicit post-step save
    woa-wheelhouse.yml:build-pyarrow: Cache vcpkg packages

where the excused-filename version would have named neither.

Workflow guard suites: 1975 passed, 44 skipped, 0 failed.

* Read the locale entry, not the line it starts on

studio/frontend/tests/pasted-text-attachment.test.ts "every locale keeps the
shortcut in the threshold description" fails on origin/main, which takes down
"Frontend build + bundle sanity" and "Frontend unit tests (Windows)" on every PR
whose merge picks up main. Reported by the lane that hit it on unslothai#11070; it is
main's test rather than that PR's, so it belongs here.

The test did source.indexOf("pastedTextThresholdDescription:"), sliced to the
next newline, and asserted "{shortcut}" was on that slice. That asserts about the
formatter as much as about the translation: a value Prettier wraps onto the
FOLLOWING line leaves the slice holding only the key, and the placeholder is
invisible while being right there.

Product is correct. All twelve locales carry {shortcut} -- checked by parsing the
value out of each file rather than by reading the assertion's own slice.

It is also worse than one locale. ELEVEN of the twelve are wrapped that way on
main today; only en.ts is not. The test was passing on readdir order alone, and
fixing ar.ts by hand would have handed the same failure to de.ts, then es.ts, and
so on down the directory.

So it now imports the locale module and asserts on the resolved string, which is
what the app reads and cannot be moved by layout. The key is found by walking the
tree rather than by a fixed path, so reorganising the message tree does not
silently drop the check either, and `values.length == 1` keeps it from passing
vacuously if the key disappears.

Checked the other indexOf-based source assertions in studio/frontend/tests while
here: they bound their slices with an explicit end marker ("];", the next symbol
name), not with the next newline, so none share this failure mode.

Mutation-proved:

  a locale drops {shortcut}          RED "ar.ts keeps {shortcut}"
  a locale loses the key entirely    RED "ja.ts carries the description
                                      exactly once"
  a value wrapped onto the next line GREEN here, and the old line-scoped
                                      assertion on the same tree sees only
                                      'pastedTextThresholdDescription:' and fails

The third is the regression itself, and it needs no synthetic edit: eleven
locales on main are already in that state.

studio/frontend: 34 pass, 0 fail (was 33 pass, 1 fail).

* Run the queue localization suite for the files it actually reads

Wiring the driver into the composer job left it unreachable by the change it
guards. The workflow filters on tests/studio/*composer* and
tests/studio/*prompt_queue*, and playwright_queue_localization.py carries
neither substring, so a pull request that edits only the driver never runs it.
Nor does one that edits only a catalog: the driver calls setLocale through
src/i18n/index.ts and asserts five hard-coded Japanese strings, and no pattern
reached src/i18n at all. A translation-only edit to ja.ts is the exact change
this suite exists to catch.

tests/studio/test_playwright_suites_run_in_ci.py cannot see this by design; its
own docstring says trigger paths say when CI runs, not what it runs.

Add the two patterns. Checked against GitHub's filter semantics with the
controls in both directions: the driver, each locale catalog and the i18n
loader now trigger the job, thread.tsx and playwright_prompt_queue_actions.py
still do, and README.md and unsloth/models/llama.py still do not.

Also close a hole in _pull_request_reachable, whose docstring promises that
anything unrecognised counts as reachable while the code fell through to
exempt. merge_group runs on its own refs/heads/gh-readonly-queue ref, so a
cache saved there is exactly the pull-request-scoped entry this rule forbids,
and the guard would have said nothing. Name the three events that really are
default-branch-only and indict the rest. No current workflow changes verdict.

* Close the three gaps the repaired CI run then hit

The previous commit got the Backend-CI and Windows jobs far enough to reach
three failures that were sitting behind them.

tests/studio/test_pwsh_calls_use_the_shared_runner.py scanned tests/ and
nothing else, so studio/backend/tests was never checked, and
studio/backend/tests/test_setup_llama_cpp_backend.py had two parametrised
probes (17 pwsh startups in one xdist job) calling subprocess.run(["pwsh",
...]) directly. That is exactly the shared startup-cache race run_pwsh
exists to end, and it showed up as SIGABRT in the "rest" shard. Both call
sites now go through run_pwsh, the guard scans both test trees, its
allowlist is keyed on the repo-relative path, and a new row asserts a file
from the backend tree is really in the scanned set. Checked for
non-vacuity: the widened guard flags both call sites as they stood before.

test_account_tool_confinement.py::test_install_under_a_granted_root_stays_hidden
packed three claims into one command line. Once the credential pre-flight in
tools.py learned to refuse a command that names the auth database, that line
was refused whole, so the two reach probes passed without anything running
and the "the rest of the granted root is still usable" probe could not run
at all. Split into three commands, each answered by the layer that owns it.
Fails on origin/main at f6cf06d too, so it is not this branch's.

playwright_composer_icons.py and playwright_queue_localization.py navigated
with a bare page.goto: playwright's 30s default, waiting for "load", which
on a vite dev server means every module in the graph. On a cold Windows
runner that overran twice, taking the Frontend unit tests (Windows) job down
after the node tests reported "# fail 0". Both now navigate with
domcontentloaded and an explicit budget, as every other driver in that
directory already does. Ran both locally end to end: 1296 icons centered,
all five localization checks pass.

* Give the Windows frontend job time for its own steps

Frontend unit tests (Windows) carries more than its name: node tests, the
composer icon alignment smoke, and data settings in both Chromium and
Firefox. Under a 15 minute cap it cannot finish them, and the overrun is
deterministic rather than flaky, so every run that reaches the last step
dies there and reports itself as "cancelled" -- the failure mode the
comment on the alignment job already describes.

Measured on run 35166979977: setup and npm ci 1m10s, unit tests 4m12s,
browser install 32s, composer icons 39s, data settings in Chromium 4m21s,
then Firefox cut off at 4m13s having needed about what Chromium needed.
That is roughly 15m30s of work under a 15m cap.

Raised to 30. The Linux sibling of this job allows 40.

* Scrub the resolver policy variables case-folded

CPython puts every os.environ key through .upper() on nt ("Where Env Var
Names Must Be UPPERCASE", os.py), so Windows hands the comprehension
PROGRAMDATA, the literal "ProgramData" in the tuple compares unequal, and
the child keeps reading %PROGRAMDATA%\uv\uv.toml. That is uv's system-level
config and the one file that can turn a row asserting True into a
machine-dependent False, on the only platform install.ps1 ships to.

Matched on the upper-cased name at both ends. The row that states it feeds
_scrubbed_environ the three spellings a real environment block can carry,
and runs everywhere: a Linux session has no ProgramData to leak, so a
literal-match scrub passes this suite green on CI and quietly stops working
where it matters.

Same fix as unslothai#11133 carries for its copy of this file; both are open against
main and this branch has since converted the spawn to run_pwsh, so the two
are landed independently rather than one waiting on the other.
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.

1 participant