Repository navigation
Repair a quarantined llama.cpp runtime at launch instead of failing at model load - #10494
Conversation
…t model load Smart App Control and antivirus quarantine individual files out of the managed llama.cpp tree while leaving the marker and the rest of the tree in place. The desktop's preflight decided staleness on the managed Python alone, so it reported Ready, launched, and the missing DLL only surfaced later at model load as an error that looked like a bad GGUF or an out of memory. Repairing it meant running `unsloth studio update` by hand, which nothing told the user to do. install_llama_prebuilt gains installed_runtime_health(), which reuses the same payload tables the keep-install path already uses rather than duplicating the required file list. The CLI reports it in the desktop capability payload and the Tauri preflight treats an explicit false as stale, so the existing repair path picks it up. Only an explicit false is stale. None covers both "no runtime installed yet" and "this CLI predates the field", and neither is a broken runtime: treating them as stale would send every existing install through repair on its first launch after an upgrade. For the same reason desktop_manageability_version is not bumped. The capability cache had to move too. Its fingerprint covered the managed venv only, so a file quarantined out of the runtime left it identical and preflight answered Ready from cache without ever asking the CLI. The runtime's file count and total size now join the fingerprint, and the cache schema goes to 4.
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 17fd5cbed7
ℹ️ 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".
| if cfg!(windows) { | ||
| bin = bin.join("Release"); | ||
| } | ||
| let entries = fs::read_dir(&bin).ok()?; |
There was a problem hiding this comment.
Rejecting this one on the body rather than the title: the text after the heading reads If a healthy tokenibele capability was cachedelbe Genius melt? noennials, so there is no claim here I can reproduce or act on. Please re-post it if it was truncated on the way out.
On what the title points at, the two states are already distinct and covered. llama_runtime_fingerprint_at returns None when the binary directory cannot be read and "0:0" when it is present and empty, so a tree whose files were all quarantined does not collide with a machine that never installed a runtime. a_quarantined_runtime_file_changes_the_fingerprint asserts both, including the transition between them.
The neighbouring case that is real, the relative override falling back to the legacy tree, came in separately as 3957928980 and is being fixed there.
The launch probe has to be no stricter than the setup scripts' own keep-or-reinstall decision. A tree the probe rejects but _existing_install_runs keeps would be repaired, kept unchanged by the repair and rejected again on the next launch, which is a loop with no way out. That property is now stated where the code is and tested as a property over the whole matrix. Three real gaps closed: The payload groups are libraries, and on Linux and macOS they name no executable at all, so a quarantined llama-server passed as a complete install. Both entrypoints are now looked for, which is what _existing_install_runs already requires, so the check stays on the safe side of the rule above. platform_only_host() left macos_version unset while detect_host() derives it from platform.mac_ver(), which reads no hardware. The parity test would have failed on a macOS runner. A relative UNSLOTH_LLAMA_CPP_PATH resolved against the desktop's working directory, which is not the one the CLI child runs under. Fingerprinting whatever sits beside the desktop is worse than not fingerprinting, so it now degrades to no coverage. A leading ~ is expanded, since the Python reader calls expanduser. Deliberately not changed, and pinned by a test so it is not "fixed" later: a marker that exists but does not parse still reads as nothing installed. Reporting it broken looks right, but confirm_install_tree only checks that the marker file exists, so the offline keep path keeps such a tree, and broken plus kept is exactly the loop above. Tests. 1361 cases over [Windows, Linux, macOS] x [cpu, cuda, rocm, vulkan, metal] x thirteen shipped marker shapes x damage modes, asserting both the verdict and the invariant, with the invariant's sensitivity checked by mutation rather than assumed. Healthy installs of every shipped shape stay healthy on every platform, which is the backwards-compatibility half. The verdict is unchanged across NVIDIA, AMD, Intel and no GPU at all. Rust gains JSON round trips proving a pre-PR payload still parses and reads Ready, that an old cache file is ignored rather than fatal, and that a newer CLI's unknown keys are inert. The frontend no longer tells a user with a quarantined runtime that their install is too old.
|
Pushed The property that mattersThe launch probe has to be no stricter than the setup scripts' own keep-or-reinstall decision. A tree the probe rejects but Matrix: The assertion is not vacuous. Healthy trees of every cell assert the keep path returns true, and the invariant was mutation checked: loosening Four defects the simulations found, now fixed
One thing deliberately not fixedA marker that exists but does not parse still reads as nothing installed. Reporting it broken looks obviously right, and it is what an interrupted write leaves behind, but Backwards compatibility
GPU independenceThe verdict is driven by the marker's backend and the platform booleans, never a probed GPU field, so the same tree gets the same answer with NVIDIA, AMD/ROCm, Intel or nothing at all. Asserted over 25 cases, and a separate test fails if the probe spawns a subprocess at all. Cost on the launch pathAbout 27 ms, essentially all of it the import; Green543 of 543 Rust, 7046 of 7046 frontend, 1387 across the three new Python files, 13 of 13 end to end in an isolated venv driving the real console script. What this still cannot answerNo reproduction of a Smart App Control block on real hardware. What is established is the code path (preflight was blind to the runtime) and the tree shape (Microsoft documents quarantine as removing the detected file from its directory and leaving the rest), not a live capture of SAC taking a file out of a shipped bundle. The fingerprint is file count and total size, not a hash. It catches removal and quarantine, which is the reported failure. A same-size in-place substitution is a different threat and is what signing covers. |
scripts/run_ruff_format.py runs whatever ruff is on the path; the hook pins 0.6.9, and these four files were written under a newer one. The two disagree about assert-message wrapping and about when a def signature goes one parameter per line, which is what pre-commit.ci reported as "files were modified by this hook".
The pre-commit failure, and why it is only half this PR'sFixed this branch's share in Reproduced locally against the pinned The other half is not this PR. Running the same hook over a clean Same cause, from 055470f, 5ca7bb3 and #10495. #10512 fixes those and stops the class recurring: This PR should go green once #10512 lands. |
…he four files that drifted (#10512) main is currently red under its own formatting hook. `pre-commit run --all-files` reformats four files nobody is touching, so every open PR fails `ruff-format-with-kwargs` with "files were modified by this hook" and a diff that has nothing to do with it. #10494 is one; there will be more. ## Why the drift happens `scripts/run_ruff_format.py` runs `sys.executable -m ruff`, which under pre-commit is the pinned `ruff==0.6.9` and on a contributor's machine is whatever they have. ruff's formatting is not stable across releases -- 0.9 moved the wrapping in `assert cond, "msg"` from the condition to the message -- so a file written under a newer ruff is committed in a style the hook reformats back, and the hook then fails on it forever. The linter hook beside it is on v0.15.18 and autoupdates, which makes a modern ruff the natural thing to have installed. Nothing catches it locally: the file looks formatted, `ruff format --check` agrees (with the newer ruff), and the failure only appears on pre-commit.ci. ## The change `run_ruff_format.py` reads the pin out of `.pre-commit-config.yaml` and refuses, before rewriting anything, when the ruff it would run is a different version. The message names both versions and how to fix it, since "files were modified by this hook" sends people looking for a defect in their own diff. `UNSLOTH_RUFF_FORMAT_ANY_VERSION=1` overrides it, which a pin bump needs. The pin is read rather than copied, so there is no second thing to forget; an unreadable pin or an unreadable ruff is not a mismatch, because the format step below already fails loudly on its own. ## The four files Re-formatted with the pinned 0.6.9, no other change: the assert wrapping in `test_docker_studio_keep_cuda_prebuilt.py`, `test_password_prompt_backstop.py` and `test_studio_password_prompt.py`, and the blank line after a short local import in `unsloth_cli/commands/studio.py`, which is the repo's own rule from #6079. Not a pin bump: moving to 0.16 reformats 1062 files and would conflict with every open PR. That is worth doing deliberately, on a quiet branch, not as a side effect of unblocking CI. 15 new tests, and the existing kwarg-spacing suite still passes (77 total).
Seven review items were genuine and are fixed here. Two of them contradicted calls I had made earlier and the review was right both times. A marker that exists but does not parse is now graded rather than reported as nothing installed. I had argued the opposite, on the grounds that the offline keep path keeps such a tree and broken plus kept is a loop. The narrower split is the correct one: an absent marker file is a runtime nobody installed, a present one that will not parse is a real tree, and when it has lost a library as well, answering None left preflight Ready with no repair offered. The keep path already reads such a marker as an unknown backend and grades the same payload, so nothing here asks for more than it does. A relative UNSLOTH_LLAMA_CPP_PATH was falling through to the legacy tree, which is a regression I introduced in the commit that was meant to prevent exactly that. Dropping it to None is not the fix either: None matches None, so the cache keeps hitting while the real runtime rots. It is anchored to this process's working directory now, which is where relative_override_pins joins the child's copy from. On Windows the tilde resolves through USERPROFILE rather than dirs::home_dir(), because that is what the child uses and a portable profile moves the second one; process.rs carries the same note at its own read. A quarantined llama-server was already covered. Managed runtime health is now reported only when the managed runtime is the one that would actually load, since _find_llama_server_binary prefers LLAMA_SERVER_PATH and the folder chosen in settings ahead of it, and grading the managed tree regardless sent a user running their own build into a repair that offline cannot even succeed. Two further defects came out of the simulations rather than the review. A dead Linux runtime was reported healthy. A release ships libllama.so.0 beside libllama.so.0.0.10360 and the group pattern matches both, so quarantining the SONAME, which is the name the loader asks for, left the group satisfied by the twin. Measured against a real install: llama-server exits 127 with a loader error while the probe said healthy. No fixture could show it, because a fixture writes one file per library and a release writes two. Dangling symlinks in a versioned chain were passing for the same reason and are covered by the same check. The repair could not terminate. setup.sh skipped the source rebuild whenever the two entrypoints were executable, which is true of every tree that lost only a library, so offline the repair returned the tree byte for byte identical and reported success while the next launch rejected it again. It asks reusable_existing_install first now. That branch only runs once the prebuilt path has failed, where keeping a tree that cannot load is never right, and a tree with no marker is a real source build and keeps the old test. Tests: 5965 in tests/studio/install, 561 in the Tauri crate. The convergence census that pinned the loop as a fact now pins its absence, and the strict xfail holding the SONAME defect is an ordinary assertion.
read_dir(build/bin).ok()? answered None for two different states: no llama.cpp runtime at all, and a runtime tree whose binary directory is gone. The capability verdict is not the same in both. With no marker, installed_runtime_health answers None, llama_runtime_ok stays null, and desktop_capability_stale_reason deliberately does not call that stale, so a Ready gets cached. Once a marker sits over a missing build/bin the CLI would answer llama_runtime_dir_missing, but the fingerprint had not moved, the cache still matched, and preflight served the old Ready without ever asking. The root's own entries now stand in when build/bin cannot be read, so the marker arriving moves the key. None still means the tree is not there, which is the NotInstalled case.
The previous commit gave a runtime tree with no build/bin its own fingerprint and prefixed the walk, which left five assertions on the old shape and the crate red at 557 of 562. Three are the format: bin: now leads the count. Two are the semantics the change introduced, and they are worth stating rather than patching. "No runtime at all" is the absence of the tree, so its test points at a path that does not exist instead of an empty directory, which is now the broken-install state. A root that is present but whose binary directory cannot be read is broken too, not absent: sharing None with a machine that never installed a runtime is exactly what let a cache written before an install keep matching after it broke.
Shorten every comment and docstring this branch added, keeping the reasoning that is load bearing and dropping the restatements of the code beside them. No code, only comments and whitespace.
|
@codex security review |
…runtime override - installed_runtime_health now checks each macOS library on its own instead of three broad globs, so a bundle missing libllama-common, libggml-base or libggml-cpu is graded incomplete rather than healthy. Verified against the real macos-arm64 bundle: complete is healthy, removing any one library is not, and dropping the metal, blas and rpc backends stays healthy. - llama_runtime_override_from resolves ~user/... through getpwnam on unix rather than treating it as a relative path. - A blank UNSLOTH_LLAMA_CPP_PATH no longer counts as an override. - The CLI capability payload only reports the managed runtime when the managed runtime is the one that would actually run. Fixtures that built macOS trees from the old broad names now write the names a real bundle ships.
…e is graded - A dylib chain now follows the same rule as an .so: losing the middle libggml.0.dylib left the group satisfied by the terminal libggml.0.23.0.dylib while dyld could not launch, since the LC_LOAD_DYLIB entry names the link. - llama-server and llama-quantize must still carry the execute bit on POSIX. _existing_install_runs already asks that way, so an install with the bit cleared was rejected there and reported healthy here. - The CLI capability helper follows the finder's own file status rather than the directory entry, so a pinned symlink whose target was quarantined falls through to the managed tree the backend really loads instead of suppressing its verdict. - UNSLOTH_LLAMA_CPP_PATH outranks the stored custom folder in the finder and default_managed_llama_dir points at exactly that tree, so it is graded even when an older selection is still in the settings database. - ~name on Windows resolves to the sibling profile the same way process.rs and ntpath.expanduser resolve it, instead of being fingerprinted under the cwd. - A runtime verdict the CLI skipped is no longer cached, since nothing in the fingerprint watches which runtime is selected and clearing a custom selection would otherwise keep serving a Ready nobody had graded.
A Windows bundle unpacked on a POSIX filesystem carries no execute bit, and the host is a parameter here, so os.access X_OK graded every real windows-x64 bundle in the history suite as missing its binaries. Windows has no execute bit for os.access to read anyway, so presence is the whole question there.
|
Codex Review: Didn't find any major issues. More of your lovely PRs please. Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
|
CI triage on the red legs. None of them are this PR, and I checked rather than assumed.
The exe would not start on the runner image, so it never reached Repo tests (CPU, python / rest / studio): pre-existing. Run on a clean
Locally this branch is green where it counts: |
|
Cross-platform staging run, off the org queue, so the platforms this PR does NOT touch are exercised too.
Two legs were red and neither is this PR:
The branch is now merged up to main and I could not answer one thing here, so I am saying so rather than implying otherwise: there is no real macOS host in this loop, so the split-dylib requirement is proven against the shipped bundles and the health matrix, not against a live dyld load. |
|
Two more legs, both checked rather than waved off.
The rest of the red set ( |
|
Codex Review: Didn't find any major issues. Can't wait for the next one! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
Comment-only; the AST gate reports install_llama_prebuilt.py code-unchanged.
|
Final state. Codex is at no open items and the review has converged. Red CI legs, all checked against a clean Local on this head: |
…ng one machine's path Merging main up brought in test_macos_loader_probe_record.py from #11237, whose install fixture writes three dylibs. This branch replaced main's three loose macOS globs with one group per library, so the fixture is now thinner than any install the code grades and 18 of its 26 tests failed on the merge. The tightening is the right side of that: on the shipped llama-b11030-mix-5ff778e-bin-macos-arm64 bundle, quarantining libggml-base leaves main answering healthy, because libggml-blas, libggml-metal and libggml-rpc still satisfy libggml*.dylib, and answers llama_runtime_payload_incomplete here. The fixture now writes the libraries that bundle actually carries, including the two impl dylibs the unparseable release tag requires under the same gate Windows has always used. test_llama_runtime_install_history.py defaulted its asset directory to one machine's workspace path. The default is now under the user's own cache, and the presence check no longer lets a PermissionError through: the file promises to skip when an artifact is not available, and an unreadable directory failed 24 tests instead. tests/studio/install: 8796 passed, 76 skipped.
|
Merged main up, and the merge exposed a real break rather than only conflicts. Pushed The branch was conflictingTwo frontend files, both against main's new What the merge broke, and which side was wrong
Cause: this branch replaces main's three loose macOS globs with one group per library, and that file's The tightening is the right side of that, checked against the artifact rather than a fixture.
Main keeps answering healthy because This is the first time the macOS requirements in this PR have been put against a real macOS bundle instead of a hand-built tree. It is still not a live dyld load, and I am not claiming one. A test carrying one machine's path
The default is now under the user's own cache, Green
CI is running on the merged head; I will triage whatever comes back red against a clean main worktree rather than assume. |
|
CI on the merged head Every leg that was red before the merge is green now, which is the point worth recording: One leg needed a second look rather than a rerun on faith. Not proven, still: no live dyld load on a real macOS host, and no reproduction of a code integrity block on real Windows hardware. The macOS claim rests on the shipped bundle's file tree, not on a loader that refused to start. |
|
Field evidence for the tree shape this grades, which I had left as inferred. The description says the quarantine shape comes from Microsoft documenting quarantine as removing the detected file and leaving the rest, rather than from a report. There are reports, upstream, against the binaries we redistribute:
That is this failure exactly. One file taken out of an otherwise intact tree, a marker that still says installed, and a directory that still looks right. A per-file machine learning detection on one DLL is also why the damage is partial rather than the whole tree: nothing else in the bundle is touched. It does not widen the scope. These are removals, which a payload check can see. A Smart App Control block leaves the file healthy on disk and is refused at load, which nothing here can detect, and signing is what addresses it. One cross check worth recording while I was looking. janhq/jan#8816 is the same mechanism against the same binaries in another llama.cpp consumer: they sign |
|
Better evidence than the upstream one I posted above, and it is in this tracker. #8184, "llama-server failing to start", closed 2026-08-08. The reporter found the cause themselves:
That is this PR's premise, reported by a user, against our own managed install: security software takes the runtime out, nothing says so, and the symptom the user sees is a llama-server that will not start. It is also the shape the launch probe is built for rather than the code integrity shape, since the files are gone rather than refused. What that user had to do was work out that an antivirus they did not know they had installed was the cause, then reinstall. With this change preflight sees the gutted tree at launch, marks it stale, and the repair reinstalls it, and the message names security software as the likely cause instead of telling them their install is too old. The neighbouring reports are the same mechanism against the other things we ship, which this PR deliberately does not cover: #9758 (the console script launcher missing), #10805 (install.ps1 flagged, blocking updates), #8523 and #9076 (Bitdefender and other EDR blocking the desktop installer). Those are installer-path problems and belong with #10986's work, not here. |
The message told the user to allow "the folder" without saying which one, and finding it is the whole work of acting on that sentence. It now names the default root, spelled the way the platform spells it, off the same navigator test the roaming-profile hint beside it already uses. Hedged with "usually" rather than asserted: UNSLOTH_LLAMA_CPP_PATH can move the root and preflight does not carry the path, so a definite statement would be wrong for anyone who set it. No navigator at all keeps the POSIX spelling rather than dropping the advice. Three tests: every reason names a folder, Windows gets the Windows spelling and no POSIX one (a path a user cannot paste into an exclusion list is not advice), and a missing navigator still answers. 15 of 15 in the file.
|
Pushed The antivirus line told the user to allow "the folder" without saying which one, and finding that folder is the whole work of acting on the sentence. It names the default root now, spelled the way the platform spells it, off the same
"Usually" rather than a flat statement, since Three tests: every reason names a folder, Windows gets the Windows spelling and no POSIX one, since a path a user cannot paste into an exclusion list is not advice, and a missing While checking where this message actually renders I found something worth recording rather than fixing here. It only shows when |
The root check was stricter than the resolver it was modelling. It rejected any root copy that existed and was not runnable, but resolve_llama_server_binary returns the first USABLE candidate, and _usable_binary is is_file() plus os.access(X_OK) off Windows. A root wrapper whose execute bit is gone is walked past, build/bin runs, and the tree is fine; grading it damaged sent a working runtime through a repair, and where repair is unavailable it blocked the launch. Reproduced against the real resolver on a Linux tree before changing anything: root wrapper executable backend picks <root>/llama-server health (True, '') root wrapper chmod 0644 backend picks <root>/build/bin/llama-server health (False, binaries_missing) root wrapper executable but empty backend picks <root>/llama-server health (False, binaries_missing) The middle row is the false positive. The third is the one that matters and is kept: an empty wrapper keeps is_file() and its execute bit, so discovery does select it and the exec dies on ENOEXEC. _discovery_would_select mirrors _usable_binary, so the root copy is graded only when the resolver would stop there. Windows keeps the current behaviour, since _usable_binary does not consult the execute bit there and an empty .exe is still what gets selected. test_a_rotten_root_entrypoint_is_not_saved_by_a_healthy_build_bin asserted the old behaviour on the strength of "the finder reaches the root first", which is true but incomplete: it reaches it and skips it. Replaced with the empty-wrapper case, plus a test that a 0644 wrapper and a directory of that name are both walked past, the Windows empty-exe case, and a parity test against the backend's own _usable_binary so the two cannot drift. tests/studio/install/test_installed_runtime_health.py: 53 passed.
The first cut changed _damaged_entrypoint for all three callers, which also relaxed the installer's keep decision and the release-reuse check. Those ask a different question: whether this tree can be reused as it stands, and a rotten root wrapper is worth replacing, which is what a reinstall is for. selected_root_only is the launch probe's rule alone. The launch verdict follows the resolver, so it walks past a wrapper with no execute bit and does not mark a working runtime stale; the keep decision stays as it was. The direction is the safe one: the launch verdict is never stricter than the repair that answers it, which is the property that stops a tree being repaired by changing nothing and rejected again on the next launch. test_a_damaged_root_entrypoint_stops_the_release_being_reused keeps its point, that the keep decision must reject where the shortcut once kept, and gains the empty-wrapper row, which is the damage the resolver does select and run. tests/studio/install: 8970 passed, 76 skipped, 1 failed, and that one (test_an_unserved_preferred_arch_source_builds_rather_than_using_the_igpus_bundle) fails identically on a clean origin/main worktree.
Under UNSLOTH_HOME the runtimes sit beside studio/, and the CLI exports <master>/llama.cpp while UNSLOTH_STUDIO_HOME stays <master>/studio. The comparison path dropped the override and called default_managed_llama_dir(), which reads only the studio home, so it answered <master>/studio/llama.cpp: the installer's own export did not match, the tree in use graded as a user pin, and master root installs never reached the health check. The rule now lives in _master_root_llama_dir() and both the export and the grading read it, so there is one answer rather than two that can drift.
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: b1f7727ce6
ℹ️ 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".
| if !looks_like_installer_managed_studio_home(root) { | ||
| return None; | ||
| } | ||
| Some(root.join("llama.cpp")) |
There was a problem hiding this comment.
Honor recorded master roots in the runtime fingerprint
On a bare desktop launch of an install recorded under UNSLOTH_HOME (for example, a venv under <master>/studio with share/.unsloth-master-root), the CLI's _ensure_studio_env_exported() restores the note and grades <master>/llama.cpp, but this return value makes Rust fingerprint <master>/studio/llama.cpp. After one healthy result is cached, quarantining a file from the active runtime therefore does not change the fingerprint, so preflight keeps returning Ready and the later model load fails without offering repair. This inference needs to honor the recorded master-root note and fingerprint its sibling runtime.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Correct, and it is the Rust half of the split the CLI side just fixed: the note is recovered there and graded as /llama.cpp, while this inference answered /studio/llama.cpp, so the fingerprint watched a tree nothing loads and a cached Ready outlived quarantine in the one that does.
inferred_studio_llama_root now reads share/.unsloth-master-root under the same containment rule _recorded_master_root applies, the recorded root must exist and must contain this Studio tree, and fingerprints the sibling runtime. The legacy and non-installer shapes are still declined before that runs. Tests cover the note, a note naming somebody else's root (the tree under studio/ stands), an empty note and one naming a directory that is not there. No Rust toolchain on the machine I am on, so these run in CI rather than locally. 9c488e1
The Rust half of the same split: inferred_studio_llama_root() answered <master>/studio/llama.cpp for an install recorded under UNSLOTH_HOME, while the CLI grades and the backend loads <master>/llama.cpp. One healthy cached result then survived quarantine in the runtime in use, so preflight kept returning Ready and the failure only appeared at model load, with no repair offered. It now reads share/.unsloth-master-root under the same containment rule the CLI applies (the recorded root must exist and contain this Studio tree) and fingerprints the sibling runtime. Tests cover the note, a note naming somebody else's root, an empty one and one naming a directory that is not there.
|
@codex review |
|
Codex Review: Didn't find any major issues. What shall we delve into next? Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
Follow-up to #10404. That PR made a blocked binary explain itself; this one makes the desktop repair the install instead of launching into it.
The gap
Antivirus quarantines individual files out of
~/.unsloth/llama.cppand leaves everything else alone. The marker still says installed, the directory is still there, and one DLL is gone.Scope, corrected against the field evidence in #10408: this is about files that are removed, truncated or stripped of their execute bit. It is not a Smart App Control fix. A code integrity block leaves the file present and healthy on disk and refuses it only at load, so no payload check can see it, and none of this helps there. Signing (unslothai/llama.cpp#204) is what addresses that.
Preflight never noticed.
probe_managed_bindecidesManagedStalefrom the managed Python only: the CLI answers-h, the managed context builds, the desktop capability payload reports a complete install, so preflight returnsReadyand the app launches. The missing file surfaces much later, at model load, as an error that reads like a bad GGUF or an out of memory. The fix was to rununsloth studio updateby hand, and nothing told anyone to do that.existing_install_matches_choicealready knew how to answer this. It just was not asked at launch.The change
studio/install_llama_prebuilt.pygainsinstalled_runtime_health(), returning(ok, reason)orNonewhen no runtime is installed. It delegates the verdict to_kept_install_payload_is_healthy, the same payload tables the keep-install path uses, so the two cannot drift apart. It runs onplatform_only_host()rather thandetect_host(), which shells out tonvidia-smiand costs over a second for facts this check does not read (measured here at 0.0000s against 1.29s).unsloth_cli/commands/studio.pyreports it in the desktop capability payload asllama_runtime_ok/llama_runtime_reason, best effort: a probe that raises leaves both null rather than turning a working install into a stale one.studio/src-tauri/src/preflight/managed.rstreats an explicitfalseas stale, so the repair path that already exists picks it up and the user gets a repaired runtime instead of a confusing failure two screens later.Backwards compatibility
Only an explicit
falseis stale.Nonemeans either nothing is installed yet or the CLI predates the field, and neither is a broken runtime. Calling either one stale would send every existing install through repair on its first launch after an upgrade.For the same reason
desktop_manageability_versionis unchanged. Bumping it would reject every older CLI on the manageability check before this one is ever reached.The cache half
The stale check alone would not have worked. The capability cache short-circuits preflight to
Ready, and its fingerprint covered the managed venv only: bin path, size, mtime, marker, installed distributions. A file quarantined out of the llama.cpp tree changes none of those, so the cache would have kept servingReadyand the CLI would never have been asked.ManagedBinFingerprintnow carries the runtime's file count and total byte size, which both change when a file is taken.MANAGED_CAPABILITY_CACHE_SCHEMAgoes to 4 for the new field, andUNSLOTH_LLAMA_CPP_PATHis resolved the waydefault_managed_llama_dirresolves it, with a leading~expanded, since the Python reader callsexpanduserand an unexpanded value would fingerprint the wrong tree.Tests
tests/studio/install/test_installed_runtime_health.py, 9 tests: no marker isNonerather than broken, a missing runtime directory is distinguished from a gutted one, an empty directory is the shape a quarantine leaves and is not healthy, the verdict is delegated rather than duplicated, the default root honours the override,platform_only_hostagrees withdetect_hoston every platform boolean, and it runs no subprocess.Three Rust tests in
preflight::managed: a quarantined runtime is stale with its reason, a broken runtime with an empty reason falls back to a generic one, an unknown runtime is not stale.Green locally: 536 of 536 in the Tauri crate, 3955 of 3955 in
tests/studio/install.What this does not cover
Only the managed install under
~/.unsloth/llama.cpp(orUNSLOTH_LLAMA_CPP_PATH). A source build has no marker and is deliberately left alone, exactly as the keep-install path leaves it alone.The fingerprint is count and total size, not a hash. It catches a file being removed or quarantined, which is the reported failure. It would not catch a same-size in-place substitution, which is a different threat and is what signing covers.
What the user sees
The message this PR adds, against the message the same state produced before it. Both halves are the shipped startup screen out of a frontend built from that side's own tree (merge base
917af3894, PR head9c488e12d), driven with one preflight result:managed_stale, reasonllama_runtime_payload_incomplete, auto repair unavailable, which is the state a quarantined runtime reaches on a build that cannot repair itself.Before, a quarantined runtime read as an out of date install, so the advice was an update that reports the install is already current. After, it names the cause, keeps the reinstall command, and names the folder to allow in the antivirus, spelled the way the platform spells it (
%USERPROFILE%\.unsloth\llama.cppon Windows).