Skip to content

Let the torch tag check tell the handoff restore from a conditional report - #10524

Merged
danielhanchen merged 2 commits into
mainfrom
fix-installer-torch-tag-check
Sep 8, 2026
Merged

danielhanchen merged 2 commits into
mainfrom
fix-installer-torch-tag-check

Conversation

@danielhanchen

Copy link
Copy Markdown
Member

What

tests/studio/test_amd_venv_repair_loop.ps1 fails on main since #8066:

FAIL  the report is assigned on every run, not only when known

The check rejects any if (...) { followed by an assignment to UNSLOTH_INSTALLER_TORCH_TAG, to make sure the report is unconditional. #8066 added a finally that puts the caller's own value back:

if ($hadPreviousInstallerTorchTag) {
    $env:UNSLOTH_INSTALLER_TORCH_TAG = $previousInstallerTorchTag
}

That is a conditional assignment too, but it is the restore, not the report, so the check now trips on a correct tree.

Fix

The negative half of the check ignores an assignment from a $previous* variable. A conditional report is still rejected:

tree result
main today passes
a synthetic if ($known) { $env:UNSLOTH_INSTALLER_TORCH_TAG = $tag } rejected
the restore alone accepted

One line in one test; no product code changes.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for security reviews. Please try again later.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 8, 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-08T15:42:48.019084Z a28fae9 PR opened
ℹ️ 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
danielhanchen merged commit 8ccdc17 into main Sep 8, 2026
24 of 31 checks passed
@danielhanchen
danielhanchen deleted the fix-installer-torch-tag-check branch September 8, 2026 15:48
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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant