Skip to content

Studio: record how a Windows install was launched and what it produced - #8066

Merged
danielhanchen merged 15 commits into
mainfrom
studio-windows-install-elevation-diag
Sep 8, 2026
Merged

danielhanchen merged 15 commits into
mainfrom
studio-windows-install-elevation-diag

Conversation

@shimmyshimmer

@shimmyshimmer shimmyshimmer commented Aug 7, 2026 •

Copy link
Copy Markdown
Member

Summary

Two things a support report could not answer about a failed Windows install, both from the same report.

Was the run elevated? An install started with "Run as administrator" writes %USERPROFILE%\.unsloth owned by Administrators. The same account cannot read it back from a normal shell, and the folder outlives an uninstall, so a later install, setup or update fails on a folder nobody remembers creating. Nothing recorded whether a run was elevated, and nothing warned while the user could still close the window and start over.

Did llama.cpp actually land? In Tauri mode a degraded llama.cpp is deliberately not fatal, so one transient prebuilt download failure does not throw away a first-launch install. But it was announced only through install-progress-detail, which the next install-step clears and the install screen discards on close. The install then looked clean, and the first sign of trouble was a GGUF failing to load with "the llama.cpp runtime is not installed".

What changed

install.ps1 and studio/setup.ps1 read the process token and report the result as true, false, or unknown when the token cannot be read.

  • Elevated runs get a warning that names %USERPROFILE%\.unsloth, says it outlives an uninstall, and says to re-run from a normal PowerShell. It is a warning, not a block, since elevation is not always a mistake.
  • The warning prints straight after the banner, before winget, Python, uv, the venv or PyTorch, so the user can still stop before any of that runs. install.rs creates ~/.unsloth itself before spawning the script, so stopping is not entirely free on the desktop; the wording does not claim otherwise.
  • The state goes out as [TAURI:DIAG] elevated=... on every run, not only the bad one. false is the answer that rules elevation out; absence would be ambiguous.
  • The marker is gated on the parsed --tauri flag, not UNSLOTH_TAURI_MODE. install.rs never sets that variable; install.ps1 assigns it itself, far below, right before invoking setup.ps1.
  • The warning names the resolved install root, so a custom UNSLOTH_STUDIO_HOME is not sent to the wrong directory.
  • setup.ps1 skips this when SKIP_STUDIO_BASE=1, because install.ps1 has already reported it for the install it drives. That leaves direct unsloth studio setup, unsloth studio update, and desktop repair covered without duplicating the marker.

studio/setup.ps1 and studio/setup.sh emit [TAURI:DIAG] llama_cpp=unavailable alongside the existing progress notice when the run ends without a usable server.

A second, marker-only block covers desktop repair. update.rs sets UNSLOTH_TAURI_UPDATE alone, neither SKIP_STUDIO_BASE nor UNSLOTH_TAURI_MODE, so the install-side block never ran on a repair. It parses [TAURI:DIAG] the same way, and the update exit contract is unchanged.

Both use the [TAURI:DIAG] channel install.rs already parses, so the markers reach record_diag_marker and print in the support report under installer_diag_markers. No Rust or frontend change.

Behavior boundaries

  • Nothing new blocks or fails. Elevated installs still proceed.
  • The non-desktop contract is untouched: outside Tauri mode a degraded llama.cpp still exits non-zero, so install.sh and install.ps1 still fail. tests/sh/test_llama_degraded_tauri_mode.sh pins both halves and still passes.
  • The user-facing [TAURI:PROGRESS] notice is unchanged; the marker is added beside it, not in place of it.
  • Desktop repair runs with UNSLOTH_TAURI_UPDATE rather than UNSLOTH_TAURI_MODE, so the elevation marker checks both.
  • Reading the token is wrapped, so a host where it throws reports unknown rather than failing the run or claiming false.

What this does not do

This makes a degraded install visible in the support report and in the log stream. It does not yet put a proactive notice in the app itself, so a desktop user whose prebuilt download failed still finds out at model-load time. That needs a completed-with-warnings state in install.rs and a surface in the frontend, which is worth doing separately rather than folding into a scripts-only change.

Testing

tests/test_installer_elevation_report.py (8 tests) pins:

  • the [TAURI:DIAG] channel is still parsed by install.rs and still printed by report.rs, so the markers cannot go silently unread
  • elevation comes from the process token, and true, false and unknown are all reachable
  • the marker is written before the warning's early return, so it is recorded on non-elevated runs too
  • the notice is printed before winget, the venv and setup
  • the warning names the folder and says it survives an uninstall
  • setup.ps1 covers repair via UNSLOTH_TAURI_UPDATE and skips the duplicate under SKIP_STUDIO_BASE=1
  • both setup scripts record the degraded verdict and keep the non-Tauri failure

tests/sh/test_llama_degraded_tauri_mode.sh gains two assertions: Tauri mode emits the marker, and setup.ps1 mirrors it.

Also run:

  • python -m pytest tests/test_installer_elevation_report.py -q (8 passed)
  • bash tests/sh/test_llama_degraded_tauri_mode.sh (10 passed)
  • every tests/sh/*.sh suite (4 pre-existing macOS-host failures, identical on main)
  • python -m pytest tests/studio tests/python/test_cross_platform_parity.py tests/test_installer_system32_guard.py -q (2521 passed, up 8 from main; the 113 failures are cases needing a working local pwsh and are identical on main)
  • bash -n studio/setup.sh

chatgpt-codex-connector[bot]

This comment was marked as resolved.

@shimmyshimmer

Copy link
Copy Markdown
Member Author

Note on the red checks. None of them are from this PR, which touches only install.ps1, studio/setup.ps1, studio/setup.sh and two test files, and no Python or frontend source.

Repo tests (CPU) fails on tests/studio/test_desktop_reliability_frontend_contract.py::test_desktop_titlebar_separates_navigation_from_sidebar_brand. Pre-existing on main, reproduces on a clean checkout, and #8067 is already fixing it.

(Python 3.10/3.11/3.12/3.13) fail in studio/backend/tests/test_inference_status_loaded_gguf.py with:

TypeError: models.inference.InferenceStatusResponse() got multiple values for keyword argument 'chat_template_override'

That is a separate pre-existing bug on main. In studio/backend/routes/inference.py the GGUF branch of get_status unpacks **_llama_runtime_fields(llama_backend) and then also passes chat_template_override explicitly on the next line. _llama_runtime_fields builds its dict dynamically from _InferenceRuntimeFields.model_fields, so that key is already in it. get_status catches the TypeError and returns a 500, so the chat UI cannot read inference status for a loaded GGUF. Introduced in a70146d (#6245). Worth its own PR rather than folding in here.

Chat UI Tests failed once on the Playwright typeahead assertion and passed on re-run.

chatgpt-codex-connector[bot]

This comment was marked as resolved.

chatgpt-codex-connector[bot]

This comment was marked as resolved.

@shimmyshimmer

Copy link
Copy Markdown
Member Author

Worked through all four review points. Three were right and are fixed in 5eb3f46; the fourth is real but I have not taken the suggested remedy. Details below.

Gate the elevation marker on the parsed Tauri flag. Correct, and it was the important one. Verified in install.rs: spawn_script passes --tauri as an argument and never sets UNSLOTH_TAURI_MODE, and install.ps1 only assigns that variable itself at the setup invocation far below. So the marker was gated on an unset variable, setup.ps1 then skipped its own under SKIP_STUDIO_BASE=1, and the desktop first-launch install, the flow this PR exists for, recorded no elevated= line at all. Write-ElevationNotice now takes a -Tauri switch fed from the parsed flag. The test pins the ordering in both directions: the flag is parsed before the call, and the env var is still unassigned at that point, so the test cannot silently stop proving anything.

Name the active custom install root. Correct. $StudioHome and $StudioRedirectMode are resolved well before the banner in install.ps1, so the notice now names the resolved root: a custom root when one is set, otherwise %USERPROFILE%\.unsloth, which is the parent that also holds llama.cpp on a default install. setup.ps1 does not resolve $StudioHome until much later, so it mirrors the documented override precedence for the message only, and the test asserts that ordering so the two cannot drift apart unnoticed.

Record degraded llama.cpp during desktop updates. Correct. update.rs sets UNSLOTH_TAURI_UPDATE=1 and neither SKIP_STUDIO_BASE nor UNSLOTH_TAURI_MODE, so the install-side block never ran on a repair. It does parse [TAURI:DIAG] and call record_diag_marker, so the marker lands. Added a marker-only block to both setup.sh and setup.ps1, deliberately separate from the existing block so its sed range and pinned contract are untouched. tests/sh/test_llama_degraded_tauri_mode.sh now executes the new block: a Tauri repair records, a plain unsloth studio update stays silent, a healthy repair says nothing, the install path is left to the block above, and the block contains no setup_fail or exit, so the update exit contract is unchanged.

Warn before the desktop process creates the install root. The premise is right, the remedy is not one I can justify. spawn_script does create_dir_all(home/.unsloth) before spawning PowerShell, so by the time the notice prints the directory exists. I have fixed what I can verify: the message no longer says to close a window and re-run from a normal PowerShell, since install.rs spawns this from the desktop app where there is neither. I have not made install.rs delete a directory on abort. Whether an empty elevated-created .unsloth is actually unreadable afterwards depends on inherited ACLs, I cannot test Windows ACL behaviour from here, and having the installer remove a directory during an abort path is a worse failure mode than the one it would prevent. Worth its own change with a Windows box in the loop.

Verification: tests/test_installer_elevation_report.py is 13 tests, tests/sh/test_llama_degraded_tauri_mode.sh is 17 assertions, both green. I mutation-tested the new assertions rather than trusting them: restoring the env-var gate fails 2, removing the repair block fails 2 more.

pwsh is unusable on my machine, so the PowerShell here is statically reviewed and leans on the windows-latest runners.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Bravo.

Reviewed commit: 34c831fb19

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

@shimmyshimmer

Copy link
Copy Markdown
Member Author

The follow-up point about the custom install root is correct too, and unlike the desktop one it is fixable entirely inside install.ps1, so it is fixed in 2de11e9.

Verified the ordering: the resolver calls [System.IO.Directory]::CreateDirectory($envOverride) and then writes a .unsloth-write-probe-* file into the result, both before the notice ran. So an elevated shell install with UNSLOTH_STUDIO_HOME pointing somewhere new had already created the admin-owned folder by the time it was told to stop. Also checked that nothing else is created earlier in the function, so moving the notice above the resolver genuinely makes stopping free on that path.

The notice now runs immediately after flag parsing. $StudioHome is not assigned that early, so the root shown is derived from the override precedence directly, which is what setup.ps1 already had to do for the same reason. A new test asserts both scripts resolve it from the same five fragments, so the two cannot drift and send half the flows to the wrong directory. The trade is that the warning prints above the banner; that only happens on an elevated run and seemed the right way round.

Mutation-checked again: moving the call back below the resolver fails 2 of the 14 tests.

Still not touching the install.rs create_dir_all case from the earlier round, for the reasons in my previous comment. That one needs a Windows box to settle what an elevated-created empty .unsloth actually does to a later normal install.

@shimmyshimmer
shimmyshimmer force-pushed the studio-windows-install-elevation-diag branch from 81c0944 to 7e17d5f Compare August 7, 2026 04:48
@shimmyshimmer

Copy link
Copy Markdown
Member Author

Rebased onto current main. The Python matrix reds I put down to a pre-existing main bug were real but stale: e99651b (#8074) fixed the duplicate chat_template_override keyword and bb21c0a (#8072) fixed the contract tests, both after this branch was cut. Retained the pre-commit formatting commit from the pre-rebase branch rather than dropping it.

No code change in this push beyond the rebase; the four review fixes are unchanged and still green locally (14 Python tests, 17 shell assertions).

@shimmyshimmer

Copy link
Copy Markdown
Member Author

On the red (Python 3.x) / Backend tests check: it is a fresh regression on main, not from this branch.

studio/backend/tests/test_native_context_length.py::TestRouteCompleteness::test_status_path fails on a clean main at 0ebc912. I reproduced it by running the test's own parser against main's studio/backend/routes/inference.py with nothing else in the tree.

Cause: e99651b (#8074) fixed the duplicate chat_template_override keyword by hoisting the runtime fields into a local before unpacking them:

_runtime_fields = _llama_runtime_fields(llama_backend)
_runtime_fields["chat_template_override"] = _reported_chat_template_override
return InferenceStatusResponse(..., **_runtime_fields)

The runtime fix is right. But test_status_path scans the InferenceStatusResponse( construction block for the literal _llama_runtime_fields(llama_backend), which now sits above the call rather than inside it, so the contract assertion fires. It is the test that needs updating, not the route, and it will stay red on every PR until it is.

Happy to send that one-line change as a separate PR if it is wanted here rather than left to whoever owns #8074.

@shimmyshimmer

Copy link
Copy Markdown
Member Author

Breakdown of the current reds, neither from this branch.

Repo tests (CPU) fails on tests/studio/load_freeze/test_load_orchestrator.py::test_100_concurrent_healths_during_slow_probe_all_responsive with 100-burst max latency 0.518s exceeds 350 ms. That is a wall-clock assertion about concurrent health probes on a loaded runner, and this branch touches no backend or orchestrator code. Re-running.

(Python 3.10 - 3.13) are the test_status_path regression on main described in my previous comment: #8074 hoisted _llama_runtime_fields(llama_backend) out of the InferenceStatusResponse(...) call while fixing a real duplicate-keyword bug, and the contract test still greps for that literal inside the call. It fails on a clean main checkout with nothing else in the tree.

shimmyshimmer and others added 6 commits August 7, 2026 01:19
Two things a support report could not answer about a failed Windows install.

Elevation. An install started with "Run as administrator" writes
%USERPROFILE%\.unsloth as Administrators, the normal account cannot read it
back, and the folder outlives an uninstall, so the next install fails on a
folder nobody remembers creating. Nothing recorded whether a run was
elevated, and nothing warned while the user could still close the window.
install.ps1 and setup.ps1 now read the process token, warn when it will
create admin-owned files, and emit the state as [TAURI:DIAG] elevated=... on
every run, since "false" is what rules elevation out.

llama.cpp availability. In Tauri mode a degraded llama.cpp is deliberately
not fatal, but it was announced only through install-progress-detail, which
the next install-step clears and the install screen discards on close. The
install then looked clean and the first sign of trouble was a GGUF failing
to load. setup.ps1 and setup.sh now also emit [TAURI:DIAG]
llama_cpp=unavailable beside the existing notice.

Both use the [TAURI:DIAG] channel install.rs already parses, so the markers
land in the support report under installer_diag_markers with no Rust change.
The non-desktop contract is unchanged: setup still exits non-zero there.
… repairs

install.rs launches install.ps1 with --tauri and never sets
UNSLOTH_TAURI_MODE; install.ps1 assigns that variable itself much later,
right before invoking setup.ps1. Gating the marker on the env var emitted
nothing for the desktop install, and setup.ps1 then skipped its own marker
under SKIP_STUDIO_BASE=1, so the flow this exists for recorded no elevated=
line at all. Gate on the parsed flag instead.

A custom UNSLOTH_STUDIO_HOME holds every artefact, so a hardcoded
%USERPROFILE%\.unsloth named the wrong directory. install.ps1 uses the
resolved root; setup.ps1 resolves $StudioHome much later, so it mirrors the
override precedence for the message only.

update.rs sets UNSLOTH_TAURI_UPDATE alone, neither SKIP_STUDIO_BASE nor
UNSLOTH_TAURI_MODE, so a degraded desktop repair recorded nothing. It parses
[TAURI:DIAG] the same way, so add a marker-only block for it. The update
exit contract is unchanged.

The warning no longer says to close a window and re-run from PowerShell:
install.rs spawns the script from the desktop app, where there is neither.
The override resolver calls CreateDirectory on a custom UNSLOTH_STUDIO_HOME
and writes a probe into it, both before the notice ran. An elevated run that
followed the advice to stop had therefore already created the admin-owned
folder the warning is about.

Move the notice ahead of the resolver. $StudioHome does not exist that early,
so the root shown is derived from the override precedence directly, the same
way setup.ps1 already does it, and a test pins the two resolutions together.
The notice now prints before the banner, which is the cost of warning while
stopping still leaves nothing behind.
@shimmyshimmer
shimmyshimmer force-pushed the studio-windows-install-elevation-diag branch from 7e17d5f to 1aaa576 Compare August 7, 2026 08:22
chatgpt-codex-connector[bot]

This comment was marked as resolved.

An override that resolves to %USERPROFILE%\.unsloth\studio is not a custom
root downstream: the canonical comparison treats it as a default install and
keeps llama.cpp and node as siblings under ~/.unsloth. The warning named only
the studio directory, so following it left the admin-owned assets behind.
Both scripts now map a legacy-equal override to that parent.

install.ps1 set SKIP_STUDIO_BASE=1 for the child setup and never restored it.
'irm ... | iex' runs in the caller's shell, so the next direct setup or update
in that session inherited the flag, and setup.ps1's guard then took the run for
an installer child and suppressed the elevation notice, the elevated= marker
and the degraded-repair marker. Save and restore it alongside
UNSLOTH_TAURI_MODE, which the same block already does.
chatgpt-codex-connector[bot]

This comment was marked as resolved.

pre-commit-ci Bot and others added 2 commits August 7, 2026 09:15
…he finally

The legacy-root comparison was a raw string compare with a TrimEnd. The env
override reaches it unresolved, so the spellings a user actually types miss:
'~/.unsloth/studio', forward slashes, and a '..' segment all name the legacy
root but compared unequal, and the notice then named the studio directory and
sent the user past the admin-owned llama.cpp beside it. Both scripts now
expand a leading ~ and run GetFullPath before comparing, matching the
canonical resolver already used for the hipInfo filter.

Separately, --with-llama-cpp-dir with a missing path returns before
'& $UnslothExe', and that return sat between the env mutations and the try,
so the bail still leaked SKIP_STUDIO_BASE, UNSLOTH_STUDIO_HOME and
UNSLOTH_TAURI_MODE into the caller's shell. The saves stay outside the try
because they read the previous value; the try now opens before the first
mutation.
@shimmyshimmer

Copy link
Copy Markdown
Member Author

Both remaining points addressed in 89b1518.

The legacy-root comparison was not canonical. It was a raw string compare with a TrimEnd, and the env override reaches it unresolved, so the spellings a user actually types missed it: ~/.unsloth/studio, forward slashes, and a .. segment all name the legacy root but compared unequal. When the compare missed, the notice named the studio directory rather than its parent, which sends the user past the admin-owned llama.cpp sitting beside it. That is the folder the original report got stuck on.

Both scripts now expand a leading ~ and run GetFullPath before comparing, matching the canonical resolver already used for the hipInfo filter in the same files. A bare ~ is handled separately because Join-Path rejects an empty child path on PS 5.1, and GetFullPath is wrapped because an unresolvable override must cost the comparison, not the install.

I checked the resolution table against a faithful port of the helper: exact, trailing separator, forward slashes, ~, ~ with forward slashes, a .. segment and a case variant all resolve equal; the parent itself, a real custom root on another drive, and the prefix-sharing sibling .unsloth\studio2 all stay unequal.

SKIP_STUDIO_BASE still leaked on one path. --with-llama-cpp-dir with a path that does not exist returns before & $UnslothExe, and that return sat between the env mutations and the try, so the bail leaked SKIP_STUDIO_BASE, UNSLOTH_STUDIO_HOME and UNSLOTH_TAURI_MODE into the caller's shell. The try now opens before the first mutation. The saves stay outside it, because they read the previous value and the finally would otherwise see them unset if anything threw in between.

Two tests, both mutation-checked. Reverting the try placement fails the early-bail test; reverting either script's comparison, or dropping the tilde expansion or the GetFullPath, fails the canonicalization test.

One caveat worth stating plainly: pwsh is broken on the machine I verified this on (7.6.3 against .NET 10 only, which it cannot load), so the PowerShell here is verified statically rather than executed. The pre-existing test_installer_system32_guard.py cases that shell out to pwsh fail locally for that reason, on the branch point too. The Windows job is what actually executes this.

install.ps1 conflicted: main took the same save-and-restore approach for its
own handoff variables while this branch was open. Kept every one of main's
env vars and restores, and re-applied this branch's two changes on top --
SKIP_STUDIO_BASE is saved and restored too, and the try opens before the
first mutation so the --with-llama-cpp-dir bail restores as well. Every
capture now sits above the try, so a finally reached early cannot read an
unset flag as "there was nothing here".

Two things the merge broke rather than conflicted on. main moved setup.ps1's
override resolver ahead of where this branch printed the elevation warning,
and that resolver creates and write-probes the custom root -- the exact
folder the warning tells you not to create. The block moves back above it.
And the warnings still called Write-Host, which main routed through the UTF-8
sink in #8148: under CREATE_NO_WINDOW the desktop app renders those as
U+FFFD, which is the flow this branch exists for.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Aug 30, 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-08T14:20:40.650084Z bcd5bbb 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.

@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Sep 8, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Sep 8, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Sep 8, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Sep 8, 2026
@unslothai unslothai deleted a comment from shimmyshimmer Sep 8, 2026
@unslothai unslothai deleted a comment from shimmyshimmer Sep 8, 2026
@unslothai unslothai deleted a comment from shimmyshimmer Sep 8, 2026
@danielhanchen

Copy link
Copy Markdown
Member

@codex security review

chatgpt-codex-connector[bot]

This comment was marked as resolved.

Codex review item on install.ps1:6632, and it is correct.

The finally ended with three bare Remove-Items for UNSLOTH_LOCAL_LLAMA_CPP_DIR,
UNSLOTH_INSTALL_ROLLBACK_MANAGED and UNSLOTH_SETUP_PYTHON. That was survivable only while
the finally could not be reached without having set them. This branch moved the try above
the first mutation so the --with-llama-cpp-dir bail restores, and the same move means that
bail now reaches the finally having assigned none of the three, and clears whatever the
caller had.

UNSLOTH_LOCAL_LLAMA_CPP_DIR is not an internal handoff. install.ps1 reads it itself as a
user-facing input, so a caller having it set is the ordinary case rather than a contrived
one, and a mistyped --with-llama-cpp-dir silently destroyed it in the caller's session
under `irm | iex`. A successful install cleared it too, which predates this branch.

Measured in-process under pwsh over the same matrix as the rest of the table, every
variable x {unset, empty, populated} x {succeeds, bail, throws}: 18 failures before, 136
of 136 after. The unset case still ends unset rather than empty.

The regression test now covers all fifteen managed variables, and was mutation-checked:
turning any one restore back into a bare Remove-Item fails it.

Parity 659 passed 8 skipped, elevation report 19 passed, shell suite 17 passed,
install.ps1 parses with 0 errors.
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Sep 8, 2026
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. You're on a roll.

Reviewed commit: 3487e01bba

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

Post-convergence comment pass. Comments only, no behaviour change.

The comment lines this branch adds go from 140 to 62, 55 percent fewer. Two sweeps:
the first shortened, the second deleted. Section banners went, as did headers that
restated the function immediately under them (Get-CanonicalRootPath had three lines
saying it canonicalizes a root path). Multi-line rationales collapse to one or two
lines that keep the fact and drop the retelling: the fourteen lines on
GetUnresolvedProviderPathFromPSPath are now three, keeping what a reader cannot
recover from the code, that GetFullPath uses a working directory Set-Location does
not move, and the citation.

Two comments are deliberately left long. Get-ElevationState still says why elevation
is worth recording at all, and the handoff save block still explains why the captures
sit above the try, because that is the bug class the ordering exists to prevent.

Excluded from the count: 35 comment lines that show as added only because the
try/finally restructure re-indented pre-existing text from main. Rewriting those
would enlarge the diff a reviewer has to read for no gain.

studio/setup.sh is left alone. Its three comment lines could be cut the same way, but
comment_tools.py's shell lexer reports the result as CODE CHANGED: unlike the
PowerShell lexer it does not strip these comments from the code-only signature, so
the gate cannot pass any comment edit in that file. It fails closed by design, so the
edit is reverted rather than pushed past it. The change was independently comment-only
(non-comment lines byte-identical, every changed line a comment), which is why this
is a tooling limit and not a finding.

Gate is 4 of 4 code unchanged. 105 pytest passed 17 skipped, shell suite 17 passed,
ruff clean, and the four simulation harnesses are 214 of 214.
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Sep 8, 2026
@danielhanchen

Copy link
Copy Markdown
Member

@codex review

1 similar comment
@danielhanchen

Copy link
Copy Markdown
Member

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Keep them coming!

Reviewed commit: bcd5bbb286

ℹ️ 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
danielhanchen merged commit 42e7ff0 into main Sep 8, 2026
17 of 145 checks passed
@danielhanchen
danielhanchen deleted the studio-windows-install-elevation-diag branch September 8, 2026 15:09
danielhanchen added a commit that referenced this pull request Sep 8, 2026
…t cannot

tests/test_windows_amd_gpu_scan_fallback.py lifts install.ps1's save/set/try/finally block out
of the shipped script by string markers and runs it under pwsh. #8066 grew that block from 61
lines to 197 and added calls to Get-ExpectedTorchFlavorTag, Get-InstalledTorchVersionRaw,
Write-StudioLine, Write-ApplicationControlBlocked and Exit-InstallFailure, plus reads of
$VenvDir and $script:ManagedUnslothCliExit. None of those exist in the synthesized script, so
the block threw on its first helper call.

The production change is correct: the handoff is still set, cleared and restored, and the
--with-llama-cpp-dir bail moved INSIDE the try, so the finally now covers a path that
previously sat outside it. Only the test was wrong.

Two failure modes, and the second was the worse one:

- Four tests failed with "assert '<never ran>' == 'gfx1151'", which names neither the missing
  helper nor the fact that the block never ran, because the catch swallowed the error. It is
  recorded as block_error now and asserted directly, so the next helper added to install.ps1
  says "The term 'X' is not recognized" instead. Verified by deleting a stub: the failure
  names it.
- Eight more tests were PASSING while the block threw, asserting over an environment it never
  touched. Surfacing block_error turned those into honest failures, which is why this fixes 4
  visible failures by first exposing 12.

test_installer_restores_the_private_handoff_after_setup asserted "the save sits after the last
early return", a proxy for "no path skips the restore" that only held for the old shape and
that #8066 inverted. It now asserts the structure the guarantee needs: save, then try, with the
early return between the try and the finally that restores.

82 passed.
danielhanchen added a commit that referenced this pull request Sep 8, 2026
…t cannot

tests/test_windows_amd_gpu_scan_fallback.py lifts install.ps1's save/set/try/finally block out
of the shipped script by string markers and runs it under pwsh. #8066 grew that block from 61
lines to 197 and added calls to Get-ExpectedTorchFlavorTag, Get-InstalledTorchVersionRaw,
Write-StudioLine, Write-ApplicationControlBlocked and Exit-InstallFailure, plus reads of
$VenvDir and $script:ManagedUnslothCliExit. None of those exist in the synthesized script, so
the block threw on its first helper call.

The production change is correct: the handoff is still set, cleared and restored, and the
--with-llama-cpp-dir bail moved INSIDE the try, so the finally now covers a path that
previously sat outside it. Only the test was wrong.

Two failure modes, and the second was the worse one:

- Four tests failed with "assert '<never ran>' == 'gfx1151'", which names neither the missing
  helper nor the fact that the block never ran, because the catch swallowed the error. It is
  recorded as block_error now and asserted directly, so the next helper added to install.ps1
  says "The term 'X' is not recognized" instead. Verified by deleting a stub: the failure
  names it.
- Eight more tests were PASSING while the block threw, asserting over an environment it never
  touched. Surfacing block_error turned those into honest failures, which is why this fixes 4
  visible failures by first exposing 12.

test_installer_restores_the_private_handoff_after_setup asserted "the save sits after the last
early return", a proxy for "no path skips the restore" that only held for the old shape and
that #8066 inverted. It now asserts the structure the guarantee needs: save, then try, with the
early return between the try and the finally that restores.

82 passed.
danielhanchen added a commit that referenced this pull request Sep 9, 2026
… it drives (#10538)

* Catch the handoff harness up with the block it drives, and make it say why when it cannot

main fails four cases in tests/test_windows_amd_gpu_scan_fallback.py.

The lifecycle harness lifts install.ps1's save / set / try / finally block and runs
it with the setup call replaced by a probe. That block has since grown a dependency
on the installer's own inputs and helpers (Get-ExpectedTorchFlavorTag and the torch
pin check from #10524, Write-ApplicationControlBlocked from #8066), and it reads
$script:ManagedUnslothCliExit on the line right after the call it replaces, then
returns early when that exit code is null. None of those were bound, so under
ErrorActionPreference Stop the block threw, the harness's own catch swallowed it,
and every assertion read "never ran" -- which looks like a handoff defect and is not
one.

Bound them, and made the harness loud rather than silent: the replacement is
asserted to have matched, the swallowed error is reported back and fails the test
with its message, and the report is read as the last JSON line so a stub's own
output cannot be mistaken for it.

The fourth failure was an ordering assertion, that the save appears after the
--with-llama-cpp-dir bail in file order. That bail now sits inside the try whose
finally restores, which is a stronger arrangement than the ordering stood for, so
the check is now the arrangement itself: save, then the bail, then the restore.

Still a real test: dropping the inherited-handoff clear from install.ps1 fails
stale_only, and restoring it passes. 82 tests in the file.

* Run the bail rather than reading its offsets, and require the injected throw

Two review points, both about this harness accepting less than it claims.

The setup_throws cases skipped the error assertion entirely, so any exception
passed: a helper failing before the setup call would leave the shipped finally to
restore the environment, and every assertion would hold without the failure path
ever running. They now require the injected "setup exploded" and fail on anything
else. Checked by calling an undefined function before the setup call: all four
cases fail, and pass again once it is removed.

The restore invariant was three string offsets, which establish order and not
structure. The block now runs inside a function, so its own return leaves the
block rather than the script, and a new case takes the --with-llama-cpp-dir bail
with a directory that does not exist and reads the environment afterwards. It
asserts on the two variables the block sets at the top of its try, above the bail,
since those are what say the finally ran rather than that nothing happened.
Checked by moving the assignments and the bail out of the try, which the textual
ordering still accepts and this rejects.

83 tests in the file.

* Tighten the comments in the handoff lifecycle harness

Collapse the multi-line explanations added with the bail test down to one or
two lines each, and drop the parts the code already says. No behaviour change:
comments and whitespace only.

---------

Co-authored-by: danielhanchen <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants