Skip to content

Local UI to run and train LLMs and diffusion models. Supports GGUF, MLX, Qwen3.8, DeepSeek-V4.1, MiniMax-H3, Gemma 4, FLUX and more.

Studio: install from a package index that lags PyPI (#14133)

Daniel Han888ccc54dfaa
diff --git a/.github/workflows/studio-windows-inference-smoke.yml b/.github/workflows/studio-windows-inference-smoke.yml
index 7fcae4bc6e4..45fa0d6ea67 100644
--- a/.github/workflows/studio-windows-inference-smoke.yml
+++ b/.github/workflows/studio-windows-inference-smoke.yml
@@ -199,6 +199,8 @@ jobs:
if ($LASTEXITCODE) { exit $LASTEXITCODE }
pwsh -NoProfile -File tests/studio/test_unsloth_torch_override.ps1
if ($LASTEXITCODE) { exit $LASTEXITCODE }
+ pwsh -NoProfile -File tests/studio/test_relax_unsloth_floors_to_index.ps1
+ if ($LASTEXITCODE) { exit $LASTEXITCODE }
# cross-platform-parity-ci.yml, which is the host it describes.
# uninstall.ps1: native uninstall must keep the shared unsloth.ico while a
diff --git a/install.ps1 b/install.ps1
index f79b94eebf3..c3083706a29 100644
--- a/install.ps1
+++ b/install.ps1
@@ -10719,6 +10719,54 @@ main()
$_desktopMinVer = if ($env:UNSLOTH_DESKTOP_BACKEND_VERSION) { $env:UNSLOTH_DESKTOP_BACKEND_VERSION.Trim() } else { "" }
$_unslothDesktopInstallSpec = if ($_desktopMinVer) { "unsloth>=$_desktopMinVer" } else { $null }
$_unslothReleaseInstallSpec = if ($_unslothDesktopInstallSpec) { $_unslothDesktopInstallSpec } else { "unsloth>=2026.10.6" }
+ $_unslothZooInstallSpec = "unsloth-zoo>=2026.10.6"
+
+ # Twin of install.sh's _relax_unsloth_floors_to_index (#14031).
+ function Resolve-UnslothFloorsForIndex {
+ param([string]$ReleaseSpec, [string]$ZooSpec, [string]$DesktopVersion, [string]$Marker)
+ $result = @{ Release = $ReleaseSpec; Zoo = $ZooSpec; Available = $null }
+ Remove-Item -LiteralPath $Marker -Force -ErrorAction SilentlyContinue
+ $prevEap = $ErrorActionPreference
+ $ErrorActionPreference = "Continue"
+ try {
+ # --output-file: a uv.toml output-file would otherwise be overwritten by every probe.
+ $probeOut = Join-Path $VenvDir ".unsloth-index-probe.txt"
+ $newest = {
+ param([string[]]$Requirements, [string]$Name)
+ Remove-Item -LiteralPath $probeOut -Force -ErrorAction SilentlyContinue
+ $null = @($Requirements) | & $script:UvExe pip compile --python $VenvPython --no-deps --resolution highest --no-header --no-annotate --quiet --output-file $probeOut - 2>$null
+ $ok = $LASTEXITCODE -eq 0
+ $lines = if ($ok -and (Test-Path -LiteralPath $probeOut)) { @(Get-Content -LiteralPath $probeOut) } else { @() }
+ Remove-Item -LiteralPath $probeOut -Force -ErrorAction SilentlyContinue
+ if (-not $ok) { return $null }
+ foreach ($line in $lines) { if ("$line".Trim() -match "^$Name==([0-9][0-9A-Za-z.+!-]*)") { return $Matches[1] } }
+ return ""
+ }
+ if ($null -ne (& $newest @($ReleaseSpec, $ZooSpec) "unsloth")) { return $result }
+ # The newest zoo, then the newest unsloth not above it (an unsloth never needs a newer zoo), pinned as a pair.
+ $zoo = & $newest @("unsloth-zoo") "unsloth-zoo"
+ if (-not $zoo) { return $result }
+ $unsloth = & $newest @("unsloth<=$zoo") "unsloth"
+ if (-not $unsloth) { return $result }
+ substep "[WARN] your package index does not have $ReleaseSpec yet; installing unsloth $unsloth, the newest it has" "Yellow"
+ $result.Release = "unsloth==$unsloth"
+ $result.Zoo = "unsloth-zoo==$zoo"
+ $result.Available = $unsloth
+ if ($DesktopVersion) {
+ $json = '{"requested": "' + $DesktopVersion + '", "available": "' + $unsloth + '"}'
+ try { [System.IO.File]::WriteAllText($Marker, $json + "`n", (New-Object System.Text.UTF8Encoding($false))) } catch { }
+ }
+ } catch {
+ } finally {
+ $ErrorActionPreference = $prevEap
+ }
+ return $result
+ }
+ $_floors = Resolve-UnslothFloorsForIndex -ReleaseSpec $_unslothReleaseInstallSpec -ZooSpec $_unslothZooInstallSpec `
+ -DesktopVersion $_desktopMinVer -Marker (Join-Path $VenvDir "unsloth_feed_ceiling.json")
+ $_unslothReleaseInstallSpec = $_floors.Release
+ $_unslothZooInstallSpec = $_floors.Zoo
+ if ($_floors.Available -and $_unslothDesktopInstallSpec) { $_unslothDesktopInstallSpec = $_unslothReleaseInstallSpec }
if ($_Migrated) {
Write-TauriLog "STEP" "Installing unsloth"
@@ -10729,7 +10777,7 @@ main()
# --no-deps means unsloth's own metadata is never read, so this spec IS the zoo
# floor for this path. Keep it equal to the unsloth_zoo floor in pyproject.toml
# (tests/test_installer_zoo_floor_parity.py enforces that).
- $baseInstallExit = Invoke-InstallCommandRetry -Label "install unsloth (migrated no-torch)" { & $script:UvExe pip install --python $VenvPython --no-deps --reinstall-package unsloth --reinstall-package unsloth-zoo "$_unslothReleaseInstallSpec" "unsloth-zoo>=2026.10.6" }
+ $baseInstallExit = Invoke-InstallCommandRetry -Label "install unsloth (migrated no-torch)" { & $script:UvExe pip install --python $VenvPython --no-deps --reinstall-package unsloth --reinstall-package unsloth-zoo "$_unslothReleaseInstallSpec" "$_unslothZooInstallSpec" }
if ($baseInstallExit -eq 0) {
# Resolve pydantic WITH deps so pip pins pydantic-core
# to the matching version (no-torch-runtime.txt below
@@ -10753,7 +10801,7 @@ main()
$script:TorchOverridesFile = New-UnslothTorchOverridesFile -PythonExe $VenvPython
$_migOverrides = @()
if ($script:TorchOverridesFile) { $_migOverrides = @("--overrides", $script:TorchOverridesFile) }
- $baseInstallExit = Invoke-InstallCommandRetry -Label "install unsloth (migrated)" { & $script:UvExe pip install --python $VenvPython @_migOverrides --reinstall-package unsloth --reinstall-package unsloth-zoo "$_unslothReleaseInstallSpec" "unsloth-zoo>=2026.10.6" }
+ $baseInstallExit = Invoke-InstallCommandRetry -Label "install unsloth (migrated)" { & $script:UvExe pip install --python $VenvPython @_migOverrides --reinstall-package unsloth --reinstall-package unsloth-zoo "$_unslothReleaseInstallSpec" "$_unslothZooInstallSpec" }
if ($script:TorchOverridesFile) {
Remove-UnslothTempFileQuietly -Path $script:TorchOverridesFile
$script:TorchOverridesFile = $null
@@ -11034,7 +11082,7 @@ main()
# No-torch: install unsloth + unsloth-zoo with --no-deps, then
# runtime deps (typer, safetensors, transformers, etc.) with --no-deps.
# --no-deps: this spec IS the zoo floor here. Kept equal to pyproject.toml's.
- $baseInstallExit = Invoke-InstallCommandRetry -Label "install unsloth (no-torch)" { & $script:UvExe pip install --python $VenvPython --no-deps --upgrade-package unsloth --upgrade-package unsloth-zoo "$_unslothReleaseInstallSpec" "unsloth-zoo>=2026.10.6" }
+ $baseInstallExit = Invoke-InstallCommandRetry -Label "install unsloth (no-torch)" { & $script:UvExe pip install --python $VenvPython --no-deps --upgrade-package unsloth --upgrade-package unsloth-zoo "$_unslothReleaseInstallSpec" "$_unslothZooInstallSpec" }
if ($baseInstallExit -eq 0) {
# Same pydantic-with-deps trick as the migrated branch.
$baseInstallExit = Invoke-InstallCommandRetry -Label "install pydantic" { & $script:UvExe pip install --python $VenvPython pydantic }
@@ -11054,11 +11102,11 @@ main()
# Freeze the trio so this with-deps resolve cannot downgrade the pinned build.
$script:TorchOverridesFile = New-UnslothTorchOverridesFile -PythonExe $VenvPython
if ($script:TorchOverridesFile) {
- $baseInstallExit = Invoke-InstallCommandRetry -Label "install unsloth (local)" { & $script:UvExe pip install --python $VenvPython --upgrade-package unsloth --overrides $script:TorchOverridesFile "$_unslothReleaseInstallSpec" "unsloth-zoo>=2026.10.6" }
+ $baseInstallExit = Invoke-InstallCommandRetry -Label "install unsloth (local)" { & $script:UvExe pip install --python $VenvPython --upgrade-package unsloth --overrides $script:TorchOverridesFile "$_unslothReleaseInstallSpec" "$_unslothZooInstallSpec" }
Remove-UnslothTempFileQuietly -Path $script:TorchOverridesFile
$script:TorchOverridesFile = $null
} else {
- $baseInstallExit = Invoke-InstallCommandRetry -Label "install unsloth (local)" { & $script:UvExe pip install --python $VenvPython --upgrade-package unsloth "$_unslothReleaseInstallSpec" "unsloth-zoo>=2026.10.6" }
+ $baseInstallExit = Invoke-InstallCommandRetry -Label "install unsloth (local)" { & $script:UvExe pip install --python $VenvPython --upgrade-package unsloth "$_unslothReleaseInstallSpec" "$_unslothZooInstallSpec" }
}
} else {
$_unslothPkg = if ($PackageName -eq "unsloth" -and $_unslothDesktopInstallSpec) { $_unslothDesktopInstallSpec } else { $PackageName }
@@ -11095,7 +11143,7 @@ main()
Write-TauriLog "STEP" "Installing unsloth"
substep "installing unsloth (this may take a few minutes)..."
if ($StudioLocalInstall) {
- $baseInstallExit = Invoke-InstallCommandRetry -Label "install unsloth (auto torch backend)" { & $script:UvExe pip install --python $VenvPython "unsloth-zoo>=2026.10.6" "$_unslothReleaseInstallSpec" --torch-backend=auto }
+ $baseInstallExit = Invoke-InstallCommandRetry -Label "install unsloth (auto torch backend)" { & $script:UvExe pip install --python $VenvPython "$_unslothZooInstallSpec" "$_unslothReleaseInstallSpec" --torch-backend=auto }
if ($baseInstallExit -ne 0) {
Write-StudioLine "[ERROR] Failed to install unsloth (exit code $baseInstallExit)" -ForegroundColor Red
return (Exit-InstallFailure "Failed to install unsloth (exit code $baseInstallExit)" $baseInstallExit)
diff --git a/install.sh b/install.sh
index 0532ecd307a..16a874983e2 100755
--- a/install.sh
+++ b/install.sh
@@ -8193,6 +8193,39 @@ if [ -n "${UNSLOTH_DESKTOP_BACKEND_VERSION:-}" ]; then
_unsloth_desktop_install_spec="unsloth>=${UNSLOTH_DESKTOP_BACKEND_VERSION}"
fi
_unsloth_release_install_spec="${_unsloth_desktop_install_spec:-unsloth>=2026.10.6}"
+_unsloth_zoo_install_spec="unsloth-zoo>=2026.10.6"
+
+# An index lagging PyPI (mirror, delayed feed, cutoff) may lack these floors (#14031): lower them to its newest release.
+# The marker tells Desktop preflight this older backend is the newest available, so it is not repaired forever.
+_UNSLOTH_FEED_CEILING_MARKER="$VENV_DIR/unsloth_feed_ceiling.json"
+# Resolves stdin without dependencies, printing NAME's newest version. --output-file: a uv.toml output-file would
+# otherwise be overwritten by every probe.
+_rfi_newest() {
+ _rfi_out="$VENV_DIR/.unsloth-index-probe.txt"
+ rm -f "$_rfi_out"
+ uv pip compile --python "$_VENV_PY" --no-deps --resolution highest --no-header --no-annotate --quiet \
+ --output-file "$_rfi_out" - > /dev/null 2>&1 || { rm -f "$_rfi_out"; return 1; }
+ sed -n "s/^$1==\([0-9][0-9A-Za-z.+!-]*\).*/\1/p" "$_rfi_out"
+ rm -f "$_rfi_out"
+}
+_relax_unsloth_floors_to_index() {
+ rm -f "$_UNSLOTH_FEED_CEILING_MARKER"
+ printf '%s\n%s\n' "$_unsloth_release_install_spec" "$_unsloth_zoo_install_spec" | _rfi_newest unsloth > /dev/null && return 0
+ # The newest zoo, then the newest unsloth not above it (an unsloth never needs a newer zoo), pinned as a pair.
+ _rfi_zoo=$(printf 'unsloth-zoo\n' | _rfi_newest unsloth-zoo) || return 0
+ [ -n "$_rfi_zoo" ] || return 0
+ _rfi_unsloth=$(printf 'unsloth<=%s\n' "$_rfi_zoo" | _rfi_newest unsloth) || return 0
+ [ -n "$_rfi_unsloth" ] || return 0
+ substep "[WARN] your package index does not have $_unsloth_release_install_spec yet; installing unsloth $_rfi_unsloth, the newest it has" "$C_WARN"
+ _unsloth_release_install_spec="unsloth==$_rfi_unsloth"
+ _unsloth_zoo_install_spec="unsloth-zoo==$_rfi_zoo"
+ if [ -n "$_unsloth_desktop_install_spec" ]; then
+ _unsloth_desktop_install_spec=$_unsloth_release_install_spec
+ printf '{"requested": "%s", "available": "%s"}\n' "$UNSLOTH_DESKTOP_BACKEND_VERSION" "$_rfi_unsloth" \
+ > "$_UNSLOTH_FEED_CEILING_MARKER" 2>/dev/null || true
+ fi
+}
+_relax_unsloth_floors_to_index
if [ "$_MIGRATED" = true ]; then
# Migrated env: force-reinstall unsloth+unsloth-zoo, keeping torch unless the ROCm repair fires.
@@ -8205,7 +8238,7 @@ if [ "$_MIGRATED" = true ]; then
# (tests/test_installer_zoo_floor_parity.py enforces that).
run_install_cmd_retry "install unsloth (migrated no-torch)" uv pip install --python "$_VENV_PY" --no-deps \
--reinstall-package unsloth --reinstall-package unsloth-zoo \
- "$_unsloth_release_install_spec" "unsloth-zoo>=2026.10.6"
+ "$_unsloth_release_install_spec" "$_unsloth_zoo_install_spec"
# Resolve pydantic WITH deps so pip pins pydantic-core to the
# matching version (no-torch-runtime.txt below is --no-deps).
# All transitive deps are torch-free.
@@ -8220,7 +8253,7 @@ if [ "$_MIGRATED" = true ]; then
run_install_cmd_retry "install unsloth (migrated)" uv pip install --python "$_VENV_PY" \
${_UNSLOTH_TORCH_OVERRIDES:+--overrides "$_UNSLOTH_TORCH_OVERRIDES"} \
--reinstall-package unsloth --reinstall-package unsloth-zoo \
- "$_unsloth_release_install_spec" "unsloth-zoo>=2026.10.6"
+ "$_unsloth_release_install_spec" "$_unsloth_zoo_install_spec"
[ -n "$_UNSLOTH_TORCH_OVERRIDES" ] && rm -f "$_UNSLOTH_TORCH_OVERRIDES"
_UNSLOTH_TORCH_OVERRIDES=""
fi
@@ -8449,7 +8482,7 @@ elif [ -n "$TORCH_INDEX_URL" ]; then
# --no-deps: this spec IS the zoo floor here. Kept equal to pyproject.toml's.
run_install_cmd_retry "install unsloth (no-torch)" uv pip install --python "$_VENV_PY" --no-deps \
--upgrade-package unsloth --upgrade-package unsloth-zoo \
- "$_unsloth_release_install_spec" "unsloth-zoo>=2026.10.6"
+ "$_unsloth_release_install_spec" "$_unsloth_zoo_install_spec"
# Same pydantic-with-deps trick as the migrated branch.
run_install_cmd_retry "install pydantic (with deps for compatible core)" \
uv pip install --python "$_VENV_PY" pydantic
@@ -8468,7 +8501,7 @@ elif [ -n "$TORCH_INDEX_URL" ]; then
elif [ "$STUDIO_LOCAL_INSTALL" = true ]; then
run_install_cmd_retry "install unsloth (local)" uv pip install --python "$_VENV_PY" \
${_UNSLOTH_TORCH_OVERRIDES:+--overrides "$_UNSLOTH_TORCH_OVERRIDES"} \
- --upgrade-package unsloth "$_unsloth_release_install_spec" "unsloth-zoo>=2026.10.6"
+ --upgrade-package unsloth "$_unsloth_release_install_spec" "$_unsloth_zoo_install_spec"
substep "overlaying local repo (editable)..."
run_install_cmd "overlay local repo" uv pip install --python "$_VENV_PY" -e "$_REPO_ROOT" --no-deps
substep "overlaying unsloth-zoo from git ${_ZOO_REF}..."
@@ -8499,7 +8532,7 @@ else
tauri_log "STEP" "Installing Unsloth"
substep "installing unsloth (this may take a few minutes)..."
if [ "$STUDIO_LOCAL_INSTALL" = true ]; then
- run_install_cmd_retry "install unsloth (auto torch backend)" uv pip install --python "$_VENV_PY" "unsloth-zoo>=2026.10.6" "$_unsloth_release_install_spec" --torch-backend=auto
+ run_install_cmd_retry "install unsloth (auto torch backend)" uv pip install --python "$_VENV_PY" "$_unsloth_zoo_install_spec" "$_unsloth_release_install_spec" --torch-backend=auto
substep "overlaying local repo (editable)..."
run_install_cmd "overlay local repo" uv pip install --python "$_VENV_PY" -e "$_REPO_ROOT" --no-deps
substep "overlaying unsloth-zoo from git ${_ZOO_REF}..."
diff --git a/studio/install_python_stack.py b/studio/install_python_stack.py
index 40470e75d54..6f10d933245 100644
--- a/studio/install_python_stack.py
+++ b/studio/install_python_stack.py
@@ -10344,6 +10344,73 @@ def _mirror_retry(args: "tuple[str, ...]", output: bytes, rerun) -> "bool | None
return ok
+FEED_CEILING_MARKER = "unsloth_feed_ceiling.json"
+
+
+def _desktop_unsloth_spec(package_name: str) -> str:
+ """Desktop's backend floor, lowered to a lagging index's newest release (#14031).
+
+ Twin of install.sh's _relax_unsloth_floors_to_index.
+ """
+ desktop_min_ver = os.environ.get("UNSLOTH_DESKTOP_BACKEND_VERSION", "").strip()
+ if not (desktop_min_ver and package_name == "unsloth"):
+ return package_name
+ spec = f"unsloth>={desktop_min_ver}"
+ marker = Path(sys.prefix) / FEED_CEILING_MARKER
+ try:
+ marker.unlink()
+ except OSError:
+ pass
+ if not USE_UV:
+ return spec
+
+ def newest(requirement: str, name: str = "unsloth") -> "str | None":
+ # --output-file: a uv.toml output-file would otherwise be overwritten by every probe.
+ with tempfile.TemporaryDirectory() as scratch:
+ out = Path(scratch) / "probe.txt"
+ argv = ["uv", "pip", "compile", "--python", sys.executable, "--no-deps"]
+ argv += ["--resolution", "highest", "--no-header", "--no-annotate", "--quiet"]
+ argv += ["--output-file", str(out), "-"]
+ try:
+ result = subprocess.run(
+ argv,
+ input = requirement + "\n",
+ stdout = subprocess.DEVNULL,
+ stderr = subprocess.DEVNULL,
+ text = True,
+ timeout = 120,
+ **_windows_hidden_subprocess_kwargs(),
+ )
+ text = out.read_text(encoding = "utf-8") if result.returncode == 0 else None
+ except (OSError, subprocess.SubprocessError):
+ return None
+ if text is None:
+ return None
+ match = re.search(rf"^{name}==([0-9][0-9A-Za-z.+!-]*)", text, re.MULTILINE)
+ return match.group(1) if match else None
+
+ if newest(spec) is not None:
+ return spec
+ # The newest zoo, then the newest unsloth not above it (an unsloth never needs a newer zoo).
+ zoo = newest("unsloth-zoo", "unsloth-zoo")
+ available = newest(f"unsloth<={zoo}") if zoo else None
+ if available is None:
+ return spec
+ _note(
+ f"[WARN] your package index does not have {spec} yet; "
+ f"installing unsloth {available}, the newest it has",
+ _warn,
+ )
+ try:
+ marker.write_text(
+ json.dumps({"requested": desktop_min_ver, "available": available}) + "\n",
+ encoding = "utf-8",
+ )
+ except OSError:
+ pass
+ return f"unsloth=={available}"
+
+
def pip_install(
label: str,
*args: str,
@@ -12594,12 +12661,7 @@ def install_python_stack() -> int:
elif NO_TORCH:
# No-torch update path: --no-deps throughout (PyPI metadata makes torch a hard dep).
_progress("base packages (no torch)")
- desktop_min_ver = os.environ.get("UNSLOTH_DESKTOP_BACKEND_VERSION", "").strip()
- unsloth_spec = (
- f"{package_name}>={desktop_min_ver}"
- if (desktop_min_ver and package_name == "unsloth")
- else package_name
- )
+ unsloth_spec = _desktop_unsloth_spec(package_name)
pip_install(
f"Updating {package_name} + unsloth-zoo (no-torch mode)",
"--no-cache-dir",
@@ -12652,12 +12714,7 @@ def install_python_stack() -> int:
)
else:
_progress("base packages")
- desktop_min_ver = os.environ.get("UNSLOTH_DESKTOP_BACKEND_VERSION", "").strip()
- unsloth_spec = (
- f"{package_name}>={desktop_min_ver}"
- if (desktop_min_ver and package_name == "unsloth")
- else package_name
- )
+ unsloth_spec = _desktop_unsloth_spec(package_name)
with _FreezeNewTorchForCoreUpdate():
pip_install(
"Updating core packages",
diff --git a/studio/src-tauri/src/preflight/managed.rs b/studio/src-tauri/src/preflight/managed.rs
index 4787f5528a0..581372dedd0 100644
--- a/studio/src-tauri/src/preflight/managed.rs
+++ b/studio/src-tauri/src/preflight/managed.rs
@@ -1,6 +1,7 @@
use super::types::ManagedProbe;
use super::version::{
- managed_backend_version_stale_reason, DESKTOP_MANAGEABILITY_VERSION, DESKTOP_PROTOCOL_VERSION,
+ compare_versions, expected_backend_version, managed_backend_version_stale_reason,
+ parse_version, DESKTOP_MANAGEABILITY_VERSION, DESKTOP_PROTOCOL_VERSION,
};
use log::{info, warn};
use serde::{Deserialize, Serialize};
@@ -905,7 +906,7 @@ fn cache_matches(cache: &ManagedCapabilityCache, fingerprint: &ManagedBinFingerp
&& cache.marker_size == fingerprint.marker_size
&& cache.marker_mtime_ms == fingerprint.marker_mtime_ms
&& cache.llama_runtime == fingerprint.llama_runtime
- && desktop_capability_ready(&cache.capability)
+ && managed_capability_ready(Path::new(&fingerprint.bin_path), &cache.capability)
}
fn read_cached_capability(fingerprint: &ManagedBinFingerprint) -> Option<DesktopCapability> {
@@ -1202,10 +1203,56 @@ fn desktop_capability_stale_reason(capability: &DesktopCapability) -> Option<Str
managed_backend_version_stale_reason(capability.version.as_deref())
}
+#[cfg(test)]
fn desktop_capability_ready(capability: &DesktopCapability) -> bool {
desktop_capability_stale_reason(capability).is_none()
}
+/// Beside pyvenv.cfg, written by the installers when the package index lacked this
+/// build's backend release (#14031): a repair would only reinstall the same one.
+const FEED_CEILING_MARKER: &str = "unsloth_feed_ceiling.json";
+
+#[derive(Deserialize)]
+struct FeedCeiling {
+ requested: String,
+ available: String,
+}
+
+fn feed_ceiling_holds(bin: &Path, version: Option<&str>, expected: &str) -> bool {
+ let (Some(venv_dir), Some(version)) = (bin.parent().and_then(Path::parent), version) else {
+ return false;
+ };
+ let Ok(bytes) = fs::read(venv_dir.join(FEED_CEILING_MARKER)) else {
+ return false;
+ };
+ let Ok(ceiling) = serde_json::from_slice::<FeedCeiling>(&bytes) else {
+ return false;
+ };
+ // An update can keep an installed release above the ceiling; a newer app re-grades.
+ let installed = parse_version(version);
+ let available = parse_version(&ceiling.available);
+ let (Some(installed), Some(available)) = (installed, available) else {
+ return false;
+ };
+ ceiling.requested == expected && compare_versions(&installed, &available).is_ge()
+}
+
+fn managed_capability_stale_reason(bin: &Path, capability: &DesktopCapability) -> Option<String> {
+ let reason = desktop_capability_stale_reason(capability)?;
+ let version = capability.version.as_deref();
+ if reason == "desktop_backend_version_outdated"
+ && feed_ceiling_holds(bin, version, expected_backend_version())
+ {
+ info!("Managed preflight: backend {version:?} is the newest the package index has; not repairing");
+ return None;
+ }
+ Some(reason)
+}
+
+fn managed_capability_ready(bin: &Path, capability: &DesktopCapability) -> bool {
+ managed_capability_stale_reason(bin, capability).is_none()
+}
+
/// The reason an unbuildable context is reported under, if that is what went
/// wrong. Checked after a probe that did run and failed anyway.
fn working_directory_reason() -> Option<String> {
@@ -1303,7 +1350,7 @@ pub(super) async fn probe_managed_bin(bin: PathBuf) -> ManagedProbe {
) {
write_cached_capability(fingerprint, &capability);
}
- if desktop_capability_ready(&capability) {
+ if managed_capability_ready(&bin, &capability) {
info!(
"Managed preflight: cli ready for {:?} in {}ms",
bin,
@@ -1316,11 +1363,9 @@ pub(super) async fn probe_managed_bin(bin: PathBuf) -> ManagedProbe {
bin,
started.elapsed().as_millis()
);
- return ManagedProbe::Stale {
- bin,
- reason: desktop_capability_stale_reason(&capability)
- .unwrap_or_else(|| "desktop_capability_incompatible".to_string()),
- };
+ let reason = managed_capability_stale_reason(&bin, &capability)
+ .unwrap_or_else(|| "desktop_capability_incompatible".to_string());
+ return ManagedProbe::Stale { bin, reason };
}
info!(
@@ -1384,6 +1429,48 @@ mod tests {
}
}
+ #[test]
+ fn a_feed_ceiling_marker_covers_only_the_release_it_names() {
+ let venv = std::env::temp_dir().join(format!(
+ "unsloth-feed-ceiling-{}-{:?}",
+ std::process::id(),
+ std::thread::current().id()
+ ));
+ let bin = venv.join("bin").join("unsloth");
+ fs::create_dir_all(bin.parent().unwrap()).unwrap();
+ assert!(!feed_ceiling_holds(&bin, Some("2026.10.3"), "2026.10.6"));
+
+ fs::write(
+ venv.join(FEED_CEILING_MARKER),
+ r#"{"requested": "2026.10.6", "available": "2026.10.3"}"#,
+ )
+ .unwrap();
+ assert!(feed_ceiling_holds(&bin, Some("2026.10.3"), "2026.10.6"));
+ // A newer app wants a newer backend; a backend the update kept above the ceiling is fine.
+ assert!(!feed_ceiling_holds(&bin, Some("2026.10.3"), "2026.10.8"));
+ assert!(feed_ceiling_holds(&bin, Some("2026.10.4"), "2026.10.6"));
+ assert!(!feed_ceiling_holds(&bin, Some("2026.10.2"), "2026.10.6"));
+ assert!(!feed_ceiling_holds(&bin, None, "2026.10.6"));
+
+ // It only ever answers "outdated": a backend below the floor is still repaired.
+ let mut capability = healthy_capability();
+ capability.version = Some("2026.5.2".to_string());
+ fs::write(
+ venv.join(FEED_CEILING_MARKER),
+ r#"{"requested": "2026.8.4", "available": "2026.5.2"}"#,
+ )
+ .unwrap();
+ assert_eq!(
+ managed_capability_stale_reason(&bin, &capability).as_deref(),
+ Some("desktop_backend_version_too_old")
+ );
+ assert!(managed_capability_ready(&bin, &healthy_capability()));
+
+ fs::write(venv.join(FEED_CEILING_MARKER), "not json").unwrap();
+ assert!(!feed_ceiling_holds(&bin, Some("2026.10.3"), "2026.10.6"));
+ let _ = fs::remove_dir_all(&venv);
+ }
+
#[test]
fn complete_install_is_ready() {
assert_eq!(desktop_capability_stale_reason(&healthy_capability()), None);
diff --git a/studio/src-tauri/src/preflight/version.rs b/studio/src-tauri/src/preflight/version.rs
index 715ec74fb71..d7a204ecd0e 100644
--- a/studio/src-tauri/src/preflight/version.rs
+++ b/studio/src-tauri/src/preflight/version.rs
@@ -102,7 +102,7 @@ fn suffix_part_valid(value: &str) -> bool {
})
}
-fn compare_versions(left: &ParsedVersion, right: &ParsedVersion) -> Ordering {
+pub(super) fn compare_versions(left: &ParsedVersion, right: &ParsedVersion) -> Ordering {
match left.release.cmp(&right.release) {
Ordering::Equal => compare_suffixes(&left.suffix, &right.suffix),
ordering => ordering,
diff --git a/tests/python/test_install_python_stack.py b/tests/python/test_install_python_stack.py
index d205dc19ddb..4c8bffeb978 100644
--- a/tests/python/test_install_python_stack.py
+++ b/tests/python/test_install_python_stack.py
@@ -7,6 +7,7 @@ import contextlib
import importlib
import inspect
import io
+import json
import os
import re
import shutil
@@ -17,6 +18,7 @@ from pathlib import Path
from unittest import mock
import pytest
+from packaging.version import Version
def _shared_setup_1(installs, monkeypatch):
@@ -2720,29 +2722,106 @@ class TestDuplicateCoreMetadataRepair:
class TestDesktopBackendVersionConstraint:
- """Verify that UNSLOTH_DESKTOP_BACKEND_VERSION adds the floor pin when upgrading unsloth."""
-
- def test_spec_includes_floor_when_env_set(self):
- with mock.patch.dict(os.environ, {"UNSLOTH_DESKTOP_BACKEND_VERSION": "2026.8.15"}):
- desktop_min_ver = os.environ.get("UNSLOTH_DESKTOP_BACKEND_VERSION", "").strip()
- package_name = "unsloth"
- unsloth_spec = (
- f"{package_name}>={desktop_min_ver}"
- if (desktop_min_ver and package_name == "unsloth")
- else package_name
- )
- assert unsloth_spec == "unsloth>=2026.8.15"
-
- def test_spec_bare_when_env_unset(self):
- with mock.patch.dict(os.environ, {}, clear = True):
- desktop_min_ver = os.environ.get("UNSLOTH_DESKTOP_BACKEND_VERSION", "").strip()
- package_name = "unsloth"
- unsloth_spec = (
- f"{package_name}>={desktop_min_ver}"
- if (desktop_min_ver and package_name == "unsloth")
- else package_name
- )
- assert unsloth_spec == "unsloth"
+ """UNSLOTH_DESKTOP_BACKEND_VERSION floors the unsloth upgrade, lowered only for a lagging index (#14031)."""
+
+ @staticmethod
+ def _fake_uv(have, zoo = None):
+ def run(
+ argv,
+ input = None,
+ **kwargs,
+ ):
+ assert argv[:3] == ["uv", "pip", "compile"] and "--no-deps" in argv
+ out = Path(argv[argv.index("--output-file") + 1])
+ floor = re.search(r">=(\S+)", input)
+ if floor and Version(floor.group(1)) > Version(have):
+ return subprocess.CompletedProcess(argv, 1)
+ if input.strip() == "unsloth-zoo":
+ out.write_text(f"unsloth-zoo=={zoo or have} \\\n", encoding = "utf-8")
+ else:
+ cap = re.search(r"<=(\S+)", input)
+ pick = min(have, cap.group(1), key = Version) if cap else have
+ out.write_text(f"unsloth=={pick}\n", encoding = "utf-8")
+ return subprocess.CompletedProcess(argv, 0)
+
+ return run
+
+ def _spec(
+ self,
+ tmp_path,
+ env,
+ have = "2026.10.3",
+ package = "unsloth",
+ zoo = None,
+ ):
+ with (
+ mock.patch.dict(os.environ, env, clear = True),
+ mock.patch.object(ips.sys, "prefix", str(tmp_path)),
+ mock.patch.object(ips, "USE_UV", True),
+ mock.patch.object(
+ ips,
+ "_uv_config_index_policy",
+ return_value = {
+ "unreadable": False,
+ "no_index": None,
+ "extra_indexes": [],
+ "default_index": None,
+ },
+ ),
+ mock.patch.object(ips.subprocess, "run", side_effect = self._fake_uv(have, zoo)) as run,
+ ):
+ return ips._desktop_unsloth_spec(package), run.call_count
+
+ def test_spec_includes_floor_when_env_set(self, tmp_path):
+ spec, calls = self._spec(tmp_path, {"UNSLOTH_DESKTOP_BACKEND_VERSION": "2026.8.15"})
+ assert spec == "unsloth>=2026.8.15"
+ assert calls == 1, "an index that has the release answers the one probe"
+
+ def test_spec_bare_when_env_unset(self, tmp_path):
+ assert self._spec(tmp_path, {})[0] == "unsloth"
+ assert (
+ self._spec(tmp_path, {"UNSLOTH_DESKTOP_BACKEND_VERSION": "2026.10.6"}, package = "x")[0]
+ == "x"
+ )
+
+ def test_lagging_index_lowers_floor_and_writes_marker(self, tmp_path):
+ env = {
+ "UNSLOTH_DESKTOP_BACKEND_VERSION": "2026.10.6",
+ "UV_DEFAULT_INDEX": "https://feed.example/simple",
+ }
+ spec, _ = self._spec(tmp_path, env)
+ assert spec == "unsloth==2026.10.3"
+ marker = json.loads((tmp_path / ips.FEED_CEILING_MARKER).read_text(encoding = "utf-8"))
+ assert marker == {"requested": "2026.10.6", "available": "2026.10.3"}
+
+ # Once the index has the release, the floor stays and the marker goes.
+ spec, _ = self._spec(tmp_path, env, have = "2026.10.6")
+ assert spec == "unsloth>=2026.10.6"
+ assert not (tmp_path / ips.FEED_CEILING_MARKER).exists()
+
+ def test_extra_index_beside_pypi_counts(self, tmp_path):
+ # first-index: a lagging UV_INDEX mirror shadows PyPI for the packages it carries.
+ env = {
+ "UNSLOTH_DESKTOP_BACKEND_VERSION": "2026.10.6",
+ "UV_INDEX": "https://feed.example/simple",
+ }
+ assert self._spec(tmp_path, env)[0] == "unsloth==2026.10.3"
+ env = {
+ "UNSLOTH_DESKTOP_BACKEND_VERSION": "2026.10.6",
+ "UV_EXCLUDE_NEWER_PACKAGE": "unsloth=2026-10-09",
+ }
+ assert self._spec(tmp_path, env)[0] == "unsloth==2026.10.3"
+
+ def test_zoo_lagging_unsloth_caps_the_backend(self, tmp_path):
+ env = {
+ "UNSLOTH_DESKTOP_BACKEND_VERSION": "2026.10.6",
+ "UV_INDEX": "https://feed.example/simple",
+ }
+ assert self._spec(tmp_path, env, zoo = "2026.10.2")[0] == "unsloth==2026.10.2"
+
+ def test_upload_cutoff_alone_counts(self, tmp_path):
+ env = {"UNSLOTH_DESKTOP_BACKEND_VERSION": "2026.10.6", "UV_EXCLUDE_NEWER": "2026-10-09"}
+ assert self._spec(tmp_path, env)[0] == "unsloth==2026.10.3"
class TestRecordlessDistributionRecovery:
diff --git a/tests/sh/test_relax_unsloth_floors_to_index.sh b/tests/sh/test_relax_unsloth_floors_to_index.sh
new file mode 100755
index 00000000000..d92846bbc0d
--- /dev/null
+++ b/tests/sh/test_relax_unsloth_floors_to_index.sh
@@ -0,0 +1,132 @@
+#!/bin/bash
+# SPDX-License-Identifier: AGPL-3.0-only
+# Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0
+# A package index that lags PyPI must not make every install unsatisfiable (#14031): install.sh lowers its
+# unsloth / unsloth-zoo floors to the newest release that index has, and only then. uv is a stub.
+set -e
+
+SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
+. "$SCRIPT_DIR/_harness.sh"
+INSTALL_SH="${1:-$SCRIPT_DIR/../../install.sh}"
+_FUNC_FILE=$(mktemp)
+for fn in _rfi_newest _relax_unsloth_floors_to_index; do
+ sed -n "/^${fn}()/,/^}/p" "$INSTALL_SH" >> "$_FUNC_FILE"
+done
+# shellcheck disable=SC1090
+. "$_FUNC_FILE"
+rm -f "$_FUNC_FILE"
+
+VENV_DIR=$(mktemp -d)
+_VENV_PY="$VENV_DIR/bin/python"
+_UNSLOTH_FEED_CEILING_MARKER="$VENV_DIR/unsloth_feed_ceiling.json"
+CALLS="$VENV_DIR/calls"
+SUBSTEPS="$VENV_DIR/substeps"
+substep() { echo "$1" >> "$SUBSTEPS"; }
+export XDG_CONFIG_HOME="$VENV_DIR/xdg" UV_CONFIG_FILE="" XDG_CONFIG_DIRS=""
+unset UV_DEFAULT_INDEX UV_INDEX_URL UV_INDEX UV_EXTRA_INDEX_URL UV_EXCLUDE_NEWER UV_EXCLUDE_NEWER_PACKAGE
+cd "$VENV_DIR"
+
+# The index serves unsloth releases $FEED_UNSLOTH_ALL (newest $FEED_UNSLOTH by default) and unsloth-zoo $FEED_ZOO;
+# a floor above what it has is unsatisfiable, FEED_DOWN=1 fails every resolve (an unreachable index), and zoo lines
+# carry --hash continuations as with uv.toml's generate-hashes.
+uv() {
+ echo "$*" >> "$CALLS"
+ _req=$(cat)
+ _of=""; _prev=""
+ for _a in "$@"; do [ "$_prev" = "--output-file" ] && _of=$_a; _prev=$_a; done
+ [ "${FEED_DOWN:-0}" = 1 ] && return 2
+ case "$_req" in
+ *">="*)
+ [ "$FEED_UNSLOTH" = "$NEED_UNSLOTH" ] && [ "$FEED_ZOO" = "$NEED_ZOO" ] || return 1
+ printf 'unsloth==%s\nunsloth-zoo==%s\n' "$FEED_UNSLOTH" "$FEED_ZOO" > "$_of" ;;
+ unsloth-zoo) printf 'unsloth-zoo==%s \\\n --hash=sha256:00\n' "$FEED_ZOO" > "$_of" ;;
+ "unsloth<="*)
+ _best=""
+ for _v in ${FEED_UNSLOTH_ALL:-$FEED_UNSLOTH}; do
+ [ "$(printf '%s\n%s\n' "$_v" "${_req#unsloth<=}" | sort -V | tail -n 1)" = "${_req#unsloth<=}" ] && _best=$_v
+ done
+ [ -n "$_best" ] || return 1
+ printf 'unsloth==%s\n' "$_best" > "$_of" ;;
+ esac
+}
+NEED_UNSLOTH=2026.10.6; NEED_ZOO=2026.10.6
+
+_run() {
+ : > "$CALLS"; : > "$SUBSTEPS"
+ _unsloth_desktop_install_spec=""
+ [ -n "${UNSLOTH_DESKTOP_BACKEND_VERSION:-}" ] && _unsloth_desktop_install_spec="unsloth>=$UNSLOTH_DESKTOP_BACKEND_VERSION"
+ _unsloth_release_install_spec="${_unsloth_desktop_install_spec:-unsloth>=$NEED_UNSLOTH}"
+ _unsloth_zoo_install_spec="unsloth-zoo>=$NEED_ZOO"
+ _relax_unsloth_floors_to_index
+}
+
+echo "=== index that has the release (PyPI): floors kept, one probe ==="
+FEED_UNSLOTH=2026.10.6; FEED_ZOO=2026.10.6
+echo stale > "$_UNSLOTH_FEED_CEILING_MARKER"
+_run
+assert_eq "release floor kept" "unsloth>=2026.10.6" "$_unsloth_release_install_spec"
+assert_eq "one probe" "1" "$(wc -l < "$CALLS" | tr -d ' ')"
+assert_contains "probe ignores dependencies" "$(cat "$CALLS")" "pip compile --python $_VENV_PY --no-deps"
+assert_contains "probe never writes a configured output-file" "$(cat "$CALLS")" "--output-file $VENV_DIR/.unsloth-index-probe.txt"
+assert_eq "probe scratch removed" "no" "$([ -f "$VENV_DIR/.unsloth-index-probe.txt" ] && echo yes || echo no)"
+assert_eq "nothing printed" "" "$(cat "$SUBSTEPS")"
+assert_eq "a leftover marker is dropped" "no" "$([ -f "$_UNSLOTH_FEED_CEILING_MARKER" ] && echo yes || echo no)"
+
+echo "=== index a week behind: floors lowered to what it has ==="
+export UV_DEFAULT_INDEX=https://feed.example/simple
+FEED_UNSLOTH=2026.10.3; FEED_ZOO=2026.10.4
+_run
+assert_eq "release floor lowered" "unsloth==2026.10.3" "$_unsloth_release_install_spec"
+assert_eq "zoo floor lowered, hash lines and all" "unsloth-zoo==2026.10.4" "$_unsloth_zoo_install_spec"
+assert_contains "says why" "$(cat "$SUBSTEPS")" "does not have unsloth>=2026.10.6 yet; installing unsloth 2026.10.3"
+assert_eq "no marker without Desktop" "no" "$([ -f "$_UNSLOTH_FEED_CEILING_MARKER" ] && echo yes || echo no)"
+
+echo "=== zoo lagging unsloth on the index: the newest unsloth that zoo can serve ==="
+FEED_UNSLOTH_ALL="2026.10.1 2026.10.2 2026.10.3"; FEED_UNSLOTH=2026.10.3; FEED_ZOO=2026.10.2
+_run
+assert_eq "unsloth capped at the zoo" "unsloth==2026.10.2" "$_unsloth_release_install_spec"
+assert_eq "zoo floor" "unsloth-zoo==2026.10.2" "$_unsloth_zoo_install_spec"
+unset FEED_UNSLOTH_ALL; FEED_ZOO=2026.10.3
+
+echo "=== Desktop on that index: its floor too, and the marker it reads ==="
+UNSLOTH_DESKTOP_BACKEND_VERSION=2026.10.6
+_run
+assert_eq "desktop floor lowered" "unsloth==2026.10.3" "$_unsloth_desktop_install_spec"
+assert_eq "release floor follows" "unsloth==2026.10.3" "$_unsloth_release_install_spec"
+assert_eq "marker" '{"requested": "2026.10.6", "available": "2026.10.3"}' "$(cat "$_UNSLOTH_FEED_CEILING_MARKER")"
+_marker_ok=$(python3 -c 'import json,sys; d=json.load(open(sys.argv[1])); print(d["requested"], d["available"])' "$_UNSLOTH_FEED_CEILING_MARKER")
+assert_eq "marker is JSON" "2026.10.6 2026.10.3" "$_marker_ok"
+
+echo "=== feed caught up: marker cleared on the next run ==="
+FEED_UNSLOTH=2026.10.6; FEED_ZOO=2026.10.6
+_run
+assert_eq "desktop floor kept" "unsloth>=2026.10.6" "$_unsloth_desktop_install_spec"
+assert_eq "marker gone" "no" "$([ -f "$_UNSLOTH_FEED_CEILING_MARKER" ] && echo yes || echo no)"
+unset UNSLOTH_DESKTOP_BACKEND_VERSION
+
+echo "=== unreachable index: floors kept, the install reports the real error ==="
+FEED_DOWN=1
+_run
+assert_eq "release floor kept" "unsloth>=2026.10.6" "$_unsloth_release_install_spec"
+assert_eq "zoo floor kept" "unsloth-zoo>=2026.10.6" "$_unsloth_zoo_install_spec"
+FEED_DOWN=0
+
+echo "=== upload cutoff alone also counts ==="
+unset UV_DEFAULT_INDEX
+export UV_EXCLUDE_NEWER=2026-10-09T00:00:00Z
+FEED_UNSLOTH=2026.10.3; FEED_ZOO=2026.10.3
+_run
+assert_eq "release floor lowered" "unsloth==2026.10.3" "$_unsloth_release_install_spec"
+unset UV_EXCLUDE_NEWER
+
+echo "=== index from uv.toml ==="
+mkdir -p "$XDG_CONFIG_HOME/uv"
+printf '[[index]]\nurl = "https://feed.example/simple"\ndefault = true\n' > "$XDG_CONFIG_HOME/uv/uv.toml"
+_run
+assert_eq "release floor lowered" "unsloth==2026.10.3" "$_unsloth_release_install_spec"
+
+cd /
+rm -rf "${VENV_DIR:?}"
+echo ""
+echo "Results: $PASS passed, $FAIL failed"
+[ "$FAIL" -eq 0 ]
diff --git a/tests/studio/test_relax_unsloth_floors_to_index.ps1 b/tests/studio/test_relax_unsloth_floors_to_index.ps1
new file mode 100644
index 00000000000..26fc6418359
--- /dev/null
+++ b/tests/studio/test_relax_unsloth_floors_to_index.ps1
@@ -0,0 +1,140 @@
+#!/usr/bin/env pwsh
+# SPDX-License-Identifier: AGPL-3.0-only
+# Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0
+# A package index that lags PyPI must not make every install unsatisfiable (#14031): install.ps1 lowers
+# its unsloth / unsloth-zoo floors to the newest release that index has, and only then. The Windows port
+# of tests/sh/test_relax_unsloth_floors_to_index.sh; uv is a stub.
+# Run: pwsh -NoProfile -File tests/studio/test_relax_unsloth_floors_to_index.ps1
+
+$ErrorActionPreference = "Stop"
+$root = (Resolve-Path ([System.IO.Path]::Combine($PSScriptRoot, "..", ".."))).Path
+$installPath = Join-Path $root "install.ps1"
+
+function Get-FunctionAsts([string]$Path, [string[]]$Names) {
+ $tokens = $null; $errors = $null
+ $ast = [System.Management.Automation.Language.Parser]::ParseFile($Path, [ref]$tokens, [ref]$errors)
+ if ($errors) { $errors | ForEach-Object { $_.ToString() }; throw "$Path has parse errors" }
+ foreach ($name in $Names) {
+ $fn = $ast.FindAll({ param($n)
+ $n -is [System.Management.Automation.Language.FunctionDefinitionAst] -and $n.Name -eq $name
+ }, $true)
+ if ($fn.Count -ne 1) { throw "expected exactly one $name in $Path, found $($fn.Count)" }
+ $fn[0].Extent.Text
+ }
+}
+foreach ($text in (Get-FunctionAsts $installPath @("Resolve-UnslothFloorsForIndex"))) {
+ Invoke-Expression $text
+}
+
+$script:Pass = 0; $script:Fail = 0
+function Assert-Eq([string]$Label, $Expected, $Actual) {
+ if ("$Expected" -eq "$Actual") { Write-Host " PASS: $Label"; $script:Pass++ }
+ else { Write-Host " FAIL: $Label (expected '$Expected', got '$Actual')"; $script:Fail++ }
+}
+
+$scratch = Join-Path ([System.IO.Path]::GetTempPath()) "relax-floors-$PID"
+New-Item -ItemType Directory -Force -Path $scratch | Out-Null
+$marker = Join-Path $scratch "unsloth_feed_ceiling.json"
+$VenvPython = Join-Path $scratch "python.exe"
+$VenvDir = $scratch
+$script:Substeps = @()
+function substep([string]$Message, [string]$Color) { $script:Substeps += $Message }
+foreach ($n in "UV_DEFAULT_INDEX", "UV_INDEX_URL", "UV_INDEX", "UV_EXTRA_INDEX_URL", "UV_EXCLUDE_NEWER", "UV_EXCLUDE_NEWER_PACKAGE") {
+ Remove-Item "Env:$n" -ErrorAction SilentlyContinue
+}
+$env:UV_CONFIG_FILE = ""; $env:APPDATA = $scratch; $env:ProgramData = $scratch
+Push-Location $scratch
+
+# The index serves unsloth $Feed.Unsloth and unsloth-zoo $Feed.Zoo; a floor above either is unsatisfiable.
+$script:Feed = @{ Unsloth = "2026.10.3"; Zoo = "2026.10.3"; Down = $false; All = $null }
+$script:Calls = @()
+$script:UvExe = {
+ $script:Calls += ($args -join " ")
+ $req = @($input) -join "`n"
+ $of = $args[[array]::IndexOf($args, "--output-file") + 1]
+ if ($script:Feed.Down) { $global:LASTEXITCODE = 2; return }
+ $global:LASTEXITCODE = 0
+ $out = if ($req -match '>=') {
+ if (-not ($script:Feed.Unsloth -eq "2026.10.6" -and $script:Feed.Zoo -eq "2026.10.6")) { $global:LASTEXITCODE = 1; return }
+ @("unsloth==$($script:Feed.Unsloth)", "unsloth-zoo==$($script:Feed.Zoo)")
+ } elseif ($req -eq "unsloth-zoo") {
+ # As uv.toml's generate-hashes prints it.
+ @("unsloth-zoo==$($script:Feed.Zoo) \", " --hash=sha256:00")
+ } elseif ($req -match '^unsloth<=(.+)$') {
+ $cap = [version]$Matches[1]
+ $all = if ($script:Feed.All) { $script:Feed.All } else { @($script:Feed.Unsloth) }
+ $best = @($all | Where-Object { [version]$_ -le $cap } | Sort-Object { [version]$_ }) | Select-Object -Last 1
+ if (-not $best) { $global:LASTEXITCODE = 1; return }
+ @("unsloth==$best")
+ }
+ Set-Content -LiteralPath $of -Value $out
+}
+function Invoke-Resolve([string]$Desktop = "") {
+ $script:Calls = @(); $script:Substeps = @()
+ $release = if ($Desktop) { "unsloth>=$Desktop" } else { "unsloth>=2026.10.6" }
+ Resolve-UnslothFloorsForIndex -ReleaseSpec $release -ZooSpec "unsloth-zoo>=2026.10.6" -DesktopVersion $Desktop -Marker $marker
+}
+
+Write-Host "=== index that has the release (PyPI): floors kept, one probe ==="
+$script:Feed.Unsloth = "2026.10.6"; $script:Feed.Zoo = "2026.10.6"
+Set-Content -LiteralPath $marker -Value "stale"
+$r = Invoke-Resolve
+Assert-Eq "release floor kept" "unsloth>=2026.10.6" $r.Release
+Assert-Eq "one probe" 1 $script:Calls.Count
+Assert-Eq "probe ignores dependencies" $true ($script:Calls[0] -like "pip compile --python $VenvPython --no-deps*")
+Assert-Eq "probe never writes a configured output-file" $true ($script:Calls[0] -like "*--output-file $(Join-Path $scratch '.unsloth-index-probe.txt')*")
+Assert-Eq "probe scratch removed" $false (Test-Path -LiteralPath (Join-Path $scratch ".unsloth-index-probe.txt"))
+Assert-Eq "nothing printed" 0 $script:Substeps.Count
+Assert-Eq "a leftover marker is dropped" $false (Test-Path -LiteralPath $marker)
+
+Write-Host "=== index a week behind: floors lowered to what it has ==="
+$env:UV_DEFAULT_INDEX = "https://feed.example/simple"
+$script:Feed.Unsloth = "2026.10.3"; $script:Feed.Zoo = "2026.10.4"
+$r = Invoke-Resolve
+Assert-Eq "release floor lowered" "unsloth==2026.10.3" $r.Release
+Assert-Eq "zoo floor lowered, hash lines and all" "unsloth-zoo==2026.10.4" $r.Zoo
+Assert-Eq "says why" $true ($script:Substeps[0] -like "*does not have unsloth>=2026.10.6 yet; installing unsloth 2026.10.3*")
+Assert-Eq "no marker without Desktop" $false (Test-Path -LiteralPath $marker)
+
+Write-Host "=== zoo lagging unsloth on the index: the newest unsloth that zoo can serve ==="
+$script:Feed.All = @("2026.10.1", "2026.10.2", "2026.10.3"); $script:Feed.Zoo = "2026.10.2"
+$r = Invoke-Resolve
+Assert-Eq "unsloth capped at the zoo" "unsloth==2026.10.2" $r.Release
+Assert-Eq "zoo floor" "unsloth-zoo==2026.10.2" $r.Zoo
+$script:Feed.All = $null; $script:Feed.Zoo = "2026.10.3"
+
+Write-Host "=== Desktop on that index: the marker it reads ==="
+$r = Invoke-Resolve -Desktop "2026.10.6"
+Assert-Eq "release floor lowered" "unsloth==2026.10.3" $r.Release
+$m = Get-Content -LiteralPath $marker -Raw | ConvertFrom-Json
+Assert-Eq "marker requested" "2026.10.6" $m.requested
+Assert-Eq "marker available" "2026.10.3" $m.available
+$bytes = [System.IO.File]::ReadAllBytes($marker)
+Assert-Eq "marker has no BOM" $true ($bytes[0] -eq [byte][char]'{')
+
+Write-Host "=== feed caught up: marker cleared on the next run ==="
+$script:Feed.Unsloth = "2026.10.6"; $script:Feed.Zoo = "2026.10.6"
+$r = Invoke-Resolve -Desktop "2026.10.6"
+Assert-Eq "release floor kept" "unsloth>=2026.10.6" $r.Release
+Assert-Eq "marker gone" $false (Test-Path -LiteralPath $marker)
+
+Write-Host "=== unreachable index: floors kept ==="
+$script:Feed.Down = $true
+$r = Invoke-Resolve
+Assert-Eq "release floor kept" "unsloth>=2026.10.6" $r.Release
+Assert-Eq "zoo floor kept" "unsloth-zoo>=2026.10.6" $r.Zoo
+$script:Feed.Down = $false
+
+Write-Host "=== upload cutoff alone also counts ==="
+Remove-Item Env:UV_DEFAULT_INDEX
+$env:UV_EXCLUDE_NEWER = "2026-10-09T00:00:00Z"
+$script:Feed.Unsloth = "2026.10.3"; $script:Feed.Zoo = "2026.10.3"
+$r = Invoke-Resolve
+Assert-Eq "release floor lowered" "unsloth==2026.10.3" $r.Release
+Remove-Item Env:UV_EXCLUDE_NEWER
+
+Pop-Location
+Remove-Item -LiteralPath $scratch -Recurse -Force -ErrorAction SilentlyContinue
+Write-Host ""
+Write-Host "Results: $($script:Pass) passed, $($script:Fail) failed"
+if ($script:Fail -ne 0) { exit 1 }
diff --git a/tests/test_installer_zoo_floor_parity.py b/tests/test_installer_zoo_floor_parity.py
index 1caa03950f2..b7d807c1702 100644
--- a/tests/test_installer_zoo_floor_parity.py
+++ b/tests/test_installer_zoo_floor_parity.py
@@ -24,6 +24,11 @@ INSTALL_PS1 = REPO / "install.ps1"
EXPECTED_NO_DEPS_SITES = 4
_ZOO_SPEC = re.compile(r"""unsloth[-_]zoo\s*(?:>=|==)\s*[0-9][^"'\s]*""")
+_ZOO_VAR_ASSIGN = re.compile(
+ r"""^\s*\$?(?:_unsloth_zoo_install_spec|_unslothZooInstallSpec)\s*=\s*"(unsloth-zoo>=[0-9][^"]*)"$""",
+ re.MULTILINE,
+)
+_ZOO_VAR_USE = re.compile(r"\$(?:_unsloth_zoo_install_spec|_unslothZooInstallSpec)\b")
def _logical_lines(path: Path) -> list[tuple[int, str]]:
@@ -85,9 +90,16 @@ def _installer_sites() -> list[tuple[str, int, str, bool]]:
if path.suffix == ".sh"
else list(enumerate(path.read_text(encoding = "utf-8").splitlines(), start = 1))
)
+ # The install lines name the floor through one variable, which the lagging-index
+ # fallback may lower at run time (#14031); its assignment carries the shipped floor.
+ assigned = _ZOO_VAR_ASSIGN.findall(path.read_text(encoding = "utf-8"))
+ assert (
+ len(assigned) == 1
+ ), f"{path.name}: expected one zoo floor variable assignment, found {assigned}"
for number, text in lines:
if "pip install" not in text:
continue
+ text = _ZOO_VAR_USE.sub(assigned[0], text)
no_deps = "--no-deps" in text
for spec in _ZOO_SPEC.findall(text):
sites.append((path.name, number, spec, no_deps))