Commit cc0185f
Windows: guard the source-build and whisper.cpp probes on an unreadable install tree (#7757)
* Windows: guard the source-build and whisper.cpp probes on an unreadable install tree
Follow-up to #7735, which routed the prebuilt llama.cpp probes through
three-state path probing but left two gaps.
Phase 4 read $LlamaServerBin with a bare Test-Path under "Stop". A forced
compile, a pinned PR or a custom llama source skips Phase 3.4 entirely, so on
those routes this was the first probe inside the tree and a denied build\
aborted with the raw "Test-Path : Access is denied" the merged PR set out to
remove. It now probes three-state, and the CMakeCache.txt read below it is
guarded too: a listed file can still deny the read, which the probe cannot see.
The probe is skipped for a linked UNSLOTH_LOCAL_LLAMA_CPP_DIR, where it would
read through the junction into the user's own checkout, and the denial reports
-OwnershipUnverified under a custom home, where nothing on this route has
proven the tree is ours.
The whisper.cpp phase promises failure is never fatal, but under a custom
UNSLOTH_STUDIO_HOME an unreadable tree exited the whole run, taking llama.cpp
inference down with it. Assert-StudioOwnedOrAbsent gains a -NonFatal mode that
hands the denial back instead; an unowned tree still stops. The check stays
behind the installer-exists gate it used to sit inside, so a tree without
install_whisper_prebuilt.py remains the no-op it was.
Backend: _is_runnable let Path.is_file() propagate EACCES. Now that setup
leaves a denied whisper.cpp in place, that turned into a 500 out of
/api/inference/audio/stt/status, the one endpoint reporting both dictation
engines, so the setup message promising Transformers dictation still works was
not true. It reads as engine-unavailable instead.
* Harden the denial contract tests against surviving mutations
Mutation testing found six ways to reintroduce the bugs this branch fixes
while the tests stayed green.
Assert-StudioOwnedOrAbsent: the -NonFatal returns were counted, not ordered.
Moving one below its Exit-PathAccessDenied makes it dead code and the whisper
phase fatal again; hoisting one above the custom-home gate reports a fresh
install as unreadable. Each return is now pinned immediately above the exit it
pre-empts, with no unpaired return allowed.
The whisper denial branch had no assertion scoped to its own body. Both
phrases it was checked for already occur elsewhere in the phase, so the branch
could be turned back into an Exit-SetupFailure and stay green. The branch is
now sliced out and checked for step/Yellow, both phrases, and the absence of
any exit.
The installer gate was checked for presence, not for being a conjunct, so
-or-joining or negating it reopened the installer-less tree the test is named
for. The denial subject was unpinned, so it could name llama-server.exe and
tell the user to move aside one file instead of the tree.
Slice terminators are now asserted through one helper: an unasserted
terminator does not fail, it silently widens the window to end-of-file and
makes everything inside it near-vacuous.
The whisper binary probe test gated its only behavioural case on geteuid() == 0,
which silently drops it in any root container. It probes for a real denial
instead. Two pre-existing exact counts in the ownership guard tests become
floors: this branch consumed the last of their headroom, so the next
legitimate route added there would break two tests that say nothing about it.
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* Fix the -NonFatal negative control for Windows ACL semantics
The control probed a marker file that did not exist. Windows reports a
missing child of a denied directory as absent rather than throwing, so the
control read as "this host cannot deny" and failed the suite on
windows-latest while passing under chmod on Linux. It now probes a file that
exists inside the locked tree, matching the control the suite already uses.
That difference also splits the routes by platform for a tree with no
ownership marker, which is the fresh custom-home case: Linux catches it on the
marker probe, Windows has to catch it on the adoptable-state read. Added a
case that accepts either route and rejects anything but Denied, so the Windows
one is exercised for the first time.
* Detect a denied tree that has no ownership marker on Windows
Staging CI on windows-latest caught this. Get-StudioAdoptableState decided
"denied" only from probes of two marker files inside the tree, but Windows
reports a MISSING child of an unreadable directory as absent rather than
throwing. A denied tree holding neither marker therefore returned "No", and
Assert-StudioOwnedOrAbsent fell through to "path is not an Unsloth-owned
install" and exited: the wrong cause, and fatal, on the only platform any of
this runs on. It also defeated the whisper -NonFatal path, since an unowned
tree is still fatal by design.
Listing the directory itself distinguishes "no markers here" from "cannot
look", so that is the fallback when neither probe reported a denial. A
readable tree with no markers still returns "No" as before, and the catch
swallows anything that is not a denial because this helper must not throw.
This also corrects the message a denied custom-home llama.cpp tree produced on
Windows, which reported the same wrong cause.
chmod 000 blocks the child probes outright, so it never reached the new code.
chmod 111 allows stat of a named child while forbidding a listing, which is
exactly the Windows shape, so the test now covers both and the negative
control fires only on the 111 case.
* Tighten comments in the denied-tree and whisper install changes
---------
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>1 parent 259ec3b commit cc0185f
6 files changed
Lines changed: 358 additions & 16 deletions
File tree
- studio
- backend/core/inference
- tests
- studio
- install
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
172 | 172 | | |
173 | 173 | | |
174 | 174 | | |
175 | | - | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
176 | 181 | | |
177 | 182 | | |
178 | 183 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2940 | 2940 | | |
2941 | 2941 | | |
2942 | 2942 | | |
| 2943 | + | |
| 2944 | + | |
| 2945 | + | |
| 2946 | + | |
| 2947 | + | |
| 2948 | + | |
| 2949 | + | |
| 2950 | + | |
2943 | 2951 | | |
2944 | 2952 | | |
2945 | 2953 | | |
| |||
2950 | 2958 | | |
2951 | 2959 | | |
2952 | 2960 | | |
2953 | | - | |
| 2961 | + | |
| 2962 | + | |
| 2963 | + | |
| 2964 | + | |
2954 | 2965 | | |
2955 | 2966 | | |
2956 | 2967 | | |
| |||
2959 | 2970 | | |
2960 | 2971 | | |
2961 | 2972 | | |
| 2973 | + | |
2962 | 2974 | | |
2963 | 2975 | | |
2964 | 2976 | | |
2965 | 2977 | | |
2966 | 2978 | | |
2967 | 2979 | | |
| 2980 | + | |
2968 | 2981 | | |
2969 | 2982 | | |
2970 | 2983 | | |
2971 | 2984 | | |
2972 | 2985 | | |
| 2986 | + | |
2973 | 2987 | | |
2974 | 2988 | | |
2975 | 2989 | | |
| |||
4333 | 4347 | | |
4334 | 4348 | | |
4335 | 4349 | | |
| 4350 | + | |
| 4351 | + | |
| 4352 | + | |
| 4353 | + | |
| 4354 | + | |
| 4355 | + | |
4336 | 4356 | | |
4337 | 4357 | | |
4338 | 4358 | | |
| |||
4372 | 4392 | | |
4373 | 4393 | | |
4374 | 4394 | | |
4375 | | - | |
| 4395 | + | |
4376 | 4396 | | |
4377 | 4397 | | |
4378 | 4398 | | |
| |||
4466 | 4486 | | |
4467 | 4487 | | |
4468 | 4488 | | |
4469 | | - | |
| 4489 | + | |
| 4490 | + | |
| 4491 | + | |
| 4492 | + | |
| 4493 | + | |
| 4494 | + | |
| 4495 | + | |
| 4496 | + | |
| 4497 | + | |
| 4498 | + | |
4470 | 4499 | | |
4471 | | - | |
4472 | | - | |
| 4500 | + | |
| 4501 | + | |
| 4502 | + | |
| 4503 | + | |
| 4504 | + | |
| 4505 | + | |
| 4506 | + | |
| 4507 | + | |
4473 | 4508 | | |
4474 | 4509 | | |
4475 | 4510 | | |
| |||
4485 | 4520 | | |
4486 | 4521 | | |
4487 | 4522 | | |
4488 | | - | |
| 4523 | + | |
4489 | 4524 | | |
4490 | 4525 | | |
4491 | 4526 | | |
| |||
4519 | 4554 | | |
4520 | 4555 | | |
4521 | 4556 | | |
4522 | | - | |
| 4557 | + | |
4523 | 4558 | | |
4524 | 4559 | | |
4525 | 4560 | | |
| |||
5063 | 5098 | | |
5064 | 5099 | | |
5065 | 5100 | | |
5066 | | - | |
| 5101 | + | |
5067 | 5102 | | |
5068 | 5103 | | |
5069 | | - | |
| 5104 | + | |
5070 | 5105 | | |
5071 | 5106 | | |
5072 | 5107 | | |
5073 | 5108 | | |
5074 | 5109 | | |
5075 | | - | |
| 5110 | + | |
5076 | 5111 | | |
5077 | 5112 | | |
5078 | 5113 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
102 | 102 | | |
103 | 103 | | |
104 | 104 | | |
105 | | - | |
| 105 | + | |
106 | 106 | | |
107 | 107 | | |
108 | 108 | | |
109 | 109 | | |
110 | 110 | | |
111 | 111 | | |
112 | | - | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
113 | 116 | | |
| 117 | + | |
114 | 118 | | |
115 | 119 | | |
116 | 120 | | |
117 | | - | |
| 121 | + | |
118 | 122 | | |
119 | 123 | | |
120 | 124 | | |
| |||
232 | 236 | | |
233 | 237 | | |
234 | 238 | | |
235 | | - | |
| 239 | + | |
236 | 240 | | |
237 | 241 | | |
238 | 242 | | |
| |||
265 | 269 | | |
266 | 270 | | |
267 | 271 | | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
0 commit comments