cockpit: a repository file not read concludes nothing; the plan cache follows conformity's installers

- registry_snapshot: a pin file or a target's installer not read this time (a checkout rewriting it) left its
  checkpoints absent or stray, and the Library offered to fetch what is on the disk for the cache's 5 minutes.
  What was said before stands, and nothing of that read is kept.
- conformity_state: the cache's key lists the installers conformity.py reads from its SIDE instead of a list
  kept by hand, which missed install-flash-unsloth.sh (the Unsloth GGUF lane's default and two targets).

Found by the second review of v1.49.0.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Hasan BasbunarandClaude Opus 5.5 committed 2026-11-15 14:09:17 +01:00
1 parent 33affbce3d
commit dafaff6efa
3 files changed
+71 -9

No files matched your search

+22 -9
View File
@@ -2456,8 +2456,10 @@ def conformity_state():
# is part of what the plan depends on, so it busts the cache too
"qwen38-flash-unsloth.service")]
+ [CONFIG_DIR / n for n in ("launch-flash.sh", "installed.json", "api-key", "text-lane")]
+ [REPO_DIR / n for n in ("install.sh", "install-kolibri.sh", "install-image.sh", "install-video.sh",
"CHANGELOG.md")])
# the installers conformity.py reads (its SIDE): a list of them here missed the Unsloth GGUF lane's,
# whose default and two targets observe reads (second review of v1.49.0)
+ [REPO_DIR / n for n in sorted({"install.sh", "CHANGELOG.md"}
| {script for script, _ in mod.SIDE.values()})])
key = (lane,) + tuple(_mtime_ns(f) for f in files)
if _CONFORM_CACHE.get("key") != key:
items = mod.plan(CONFIG_DIR, lane, {}, repo_dir=REPO_DIR, units_dir=UNIT_DIR)
@@ -3808,14 +3810,12 @@ TARGET_FILES = {"flash-unsloth": ("install-flash-unsloth.sh", "FLASH_UNSLOTH_PAR
def target_files(target: str) -> list | None:
"""The paths of its repository a target of TARGET_FILES serves, as its installer pins them; [] when the installer
is not read or pins none so (nothing of it then counts as there); None for a target that serves a whole repository."""
pins none so (nothing of it then counts as there); None for a target that serves a whole repository. OSError when
the installer is not read: the caller concludes nothing from that."""
if target not in TARGET_FILES:
return None
script, prefix = TARGET_FILES[target]
try:
return rg.pinned_paths((REPO_DIR / script).read_text(), prefix)
except OSError:
return []
return rg.pinned_paths((REPO_DIR / script).read_text(), prefix)
def target_unit(target: str) -> Path:
@@ -6117,11 +6117,12 @@ def registry_snapshot(max_age: float = 300.0) -> dict:
if REGISTRY_CACHE["data"] and time.time() - REGISTRY_CACHE["ts"] < max_age:
return REGISTRY_CACHE["data"]
pins = {}
unread = [] # the repository's files not read this time (a checkout rewriting one, say)
for f in rg.PIN_FILES:
try:
pins.update(rg.parse_pins((REPO_DIR / f).read_text()))
except OSError:
pass
unread.append(f)
caches = lane_caches()
models = []
for d in caches:
@@ -6193,7 +6194,11 @@ def registry_snapshot(max_age: float = 300.0) -> dict:
var = TARGET_PIN[t]
repo, rev = rg.PIN_MODELS[var], pins.get(var, "")
allow = rg.video_allow(switch_text, variant or "fl2va") if t == "video" else None
files = target_files(t)
try:
files = target_files(t)
except OSError:
unread.append(TARGET_FILES[t][0])
files = None
state = ckpt_state(t, repo, rev, files or allow, files)
dvar = TARGET_DRAFT_PIN.get(t)
if dvar:
@@ -6212,6 +6217,14 @@ def registry_snapshot(max_age: float = 300.0) -> dict:
for m in models if not m["managed"]],
"images": [i for i in images if i["engine"]],
"ts": time.time()}
if unread:
# without a pin file, its checkpoints read absent or stray and the Library offers to fetch what is on the
# disk (second review of v1.49.0): what was said before stands, and nothing of this read is kept, so the
# next call reads again
if REGISTRY_CACHE["data"]:
return REGISTRY_CACHE["data"]
REGISTRY_CACHE.update(ts=0.0, data=None)
return data
REGISTRY_CACHE.update(ts=time.time(), data=data)
return data
LOGIN_FAILS: dict[str, list] = {}
@@ -139,6 +139,20 @@ class TheUpdateTierCarriesIt(unittest.TestCase):
self.assertEqual([(i["group"], i["knob"], i["value"]) for i in got["items"]],
[("moves", "FLASH_UNSLOTH_TARGET", "flash-unsloth")])
def test_every_installer_observe_reads_busts_the_plan_cache(self):
# conformity.py reads the side lanes' installers (its SIDE: defaults, the Unsloth GGUF lane's two targets); a
# list of them kept by hand in the cache's key missed install-flash-unsloth.sh (second review of v1.49.0)
cp, _, _ = self.box("cockpit_conform_side", key_at=OLD_BOX)
seen = []
real = cp._mtime_ns
cp._mtime_ns = lambda f: seen.append(Path(f)) or real(f)
self.addCleanup(setattr, cp, "_mtime_ns", real)
cp._CONFORM_CACHE.clear()
cp.conformity_state()
scripts = {script for script, _ in cp._conformity().SIDE.values()}
self.assertIn("install-flash-unsloth.sh", scripts)
self.assertLessEqual({cp.REPO_DIR / n for n in scripts}, set(seen))
def test_what_cannot_be_read_is_not_said(self):
cp, _, _ = self.box("cockpit_conform_e", key_at=OLD_BOX)
mod = cp._conformity()
+35
View File
@@ -156,6 +156,41 @@ class Fetch(unittest.TestCase):
draft.unlink()
self.assertEqual(states(), ("incomplete", "absent"))
def test_an_installer_not_read_this_time_concludes_nothing(self):
# a checkout rewriting install-flash-unsloth.sh: its pins and its targets' files unread, the two GGUF targets
# read absent and the Library offered to fetch 85 GB on the disk, for the cache's 5 minutes (second review of
# v1.49.0). What was said stands, and the next call reads again.
import re
text = (REPO / "install-flash-unsloth.sh").read_text()
snap = self.hub / "models--unsloth--Qwen3.8-Flash-Next-GGUF" / "snapshots" / self.pins["FLASH_UNSLOTH_REV"]
for rel in re.findall(r'^FLASH_UNSLOTH_(?:IQ3_)?PART[1-4]="([^"=]+)=', text, re.M):
(snap / rel).parent.mkdir(parents=True, exist_ok=True)
(snap / rel).write_text("w")
draft = (self.hub / "models--ggml-org--Qwen3.8-Flash-Next-GGUF" / "snapshots" / self.pins["FLASH_UNSLOTH_DRAFT_REV"]
/ re.search(r'^FLASH_UNSLOTH_DRAFT="([^"=]+)=', text, re.M).group(1))
draft.parent.mkdir(parents=True)
draft.write_text("w")
said = {t: self.targets()[t]["state"] for t in ("flash-unsloth", "flash-unsloth-iq3")}
self.assertEqual(said, {"flash-unsloth": "complete", "flash-unsloth-iq3": "complete"})
# the same repository without that one file
half = self.tmp / "half-repo"
shutil.rmtree(half, ignore_errors=True)
half.mkdir()
for f in REPO.iterdir():
if f.name != "install-flash-unsloth.sh":
(half / f.name).symlink_to(f)
real = self.cp.REPO_DIR
self.cp.REPO_DIR = half
self.addCleanup(setattr, self.cp, "REPO_DIR", real)
got = self.targets()
self.assertEqual({t: got[t]["state"] for t in said}, said)
# nothing said before: this read is handed, and not kept
self.cp.REGISTRY_CACHE.update(ts=0.0, data=None)
self.targets()
self.assertIsNone(self.cp.REGISTRY_CACHE["data"])
self.cp.REPO_DIR = real
self.assertEqual({t: self.targets()[t]["state"] for t in said}, said)
def test_the_action_runs_the_switch_with_fetch_and_nothing_else(self):
code, body = self.cp.start_action("fetch", {"target": "kolibri-nvfp4"})
self.assertEqual(code, 202, body)