Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS
JavaScript ai-agentsdashboarddeveloper-toolsdigital-twinquantified-selfsecond-brainself-hostedtailscale
fix: refresh Qwen verification cache after harmless file changes (#8857)
[._.]/ Adam Eivy642108e07110
diff --git a/docs/features/voice.md b/docs/features/voice.mdindex 24e8ad1cd5..209205f25e 100644--- a/docs/features/voice.md+++ b/docs/features/voice.md@@ -27,7 +27,8 @@ metadata; those artifacts are not evidence of model readiness. Runtime probesstill report inference unavailable. Model download readiness is separate: itrequires a verified snapshot marker and all required files. Unchanged verifiedfiles use their size, change timestamps, and filesystem identity; changed files-are rehashed before they can report ready; old metadata-only model folders remain unavailable. Use Piper for working local speech until #8857 delivers a real+are rehashed before they can report ready. Windows probes rehash all files because+Python does not expose a reliable change timestamp there; old metadata-only model folders remain unavailable. Use Piper for working local speech until #8857 delivers a realadapter and an intelligibility smoke run. No model download runs automatically.Interactive profile benchmarks measure elapsed time until the buffered WAV isdiff --git a/scripts/qwen3_tts_runner.py b/scripts/qwen3_tts_runner.pyindex b9f66ea658..340db3c867 100755--- a/scripts/qwen3_tts_runner.py+++ b/scripts/qwen3_tts_runner.py@@ -17,6 +17,7 @@ import osimport reimport jsonimport sys+import tempfilefrom pathlib import Path@@ -37,6 +38,18 @@ REQUIRED_FILES = ()+def publish_json(path: Path, data: dict) -> None:+ descriptor, temporary = tempfile.mkstemp(prefix=".verified-", dir=path.parent)+ try:+ with os.fdopen(descriptor, "w") as output:+ json.dump(data, output)+ output.flush()+ os.fsync(output.fileno())+ os.replace(temporary, path)+ finally:+ Path(temporary).unlink(missing_ok=True)++def file_fingerprint(path: Path) -> list[int]:stat = path.stat()return [stat.st_size, stat.st_mtime_ns, stat.st_ctime_ns, stat.st_ino, stat.st_dev]@@ -71,14 +84,34 @@ def installed_snapshot(model_dir: Path, model_id: str) -> Path | None:if manifest["model_id"] != model_id or not re.fullmatch(r"[0-9a-f]{40}", revision):return Nonesnapshot = model_dir / revision+ cache_path = snapshot / ".verification.json"+ try:+ cache = json.loads(cache_path.read_text())+ if not isinstance(cache, dict):+ cache = {}+ except (OSError, ValueError):+ cache = {}+ refreshed = {}+ changed = Falsefor filename in REQUIRED_FILES:path = snapshot / filename- metadata = manifest["files"][filename]+ metadata = dict(manifest["files"][filename])+ cached = cache.get(filename)+ if isinstance(cached, dict) and all(cached.get(key) == metadata[key] for key in ("size", "algorithm", "digest")):+ metadata = cached# The verified bytes stay valid while their filesystem identity and# change timestamps match. Rehash changed files, including equal-size# replacements, without rereading multi-GB weights on every status.- if file_fingerprint(path) != metadata.get("fingerprint"):- verify_file(path, metadata)+ # Windows Python reports creation time as ctime, not change time;+ # it cannot prove unchanged bytes when mtime has been restored.+ if sys.platform == "win32" or file_fingerprint(path) != metadata.get("fingerprint"):+ metadata["fingerprint"] = verify_file(path, metadata)+ changed = True+ refreshed[filename] = metadata+ if changed:+ # Per-revision cache cannot overwrite the readiness pointer when a+ # concurrent download publishes a newer revision.+ publish_json(cache_path, refreshed)return snapshotexcept (OSError, ValueError, KeyError, TypeError):return None@@ -121,18 +154,9 @@ def download_model(model_id: str, models_dir: Path) -> dict:metadata["fingerprint"] = verify_file(snapshot / filename, metadata)verified_files[filename] = metadata- marker = model_dir / "verified.json"- # Unique temporary markers also make separate explicit CLI downloads safe.- import tempfile- descriptor, temporary = tempfile.mkstemp(prefix=".verified-", dir=model_dir)- try:- with os.fdopen(descriptor, "w") as output:- json.dump({"model_id": model_id, "revision": revision, "files": verified_files}, output)- output.flush()- os.fsync(output.fileno())- os.replace(temporary, marker)- finally:- Path(temporary).unlink(missing_ok=True)+ publish_json(model_dir / "verified.json", {+ "model_id": model_id, "revision": revision, "files": verified_files,+ })return {"ok": True, "modelId": model_id, "revision": revision, "path": str(snapshot)}diff --git a/scripts/qwen3_tts_runner.test.js b/scripts/qwen3_tts_runner.test.jsindex 09d6d7f5dd..9433887345 100644--- a/scripts/qwen3_tts_runner.test.js+++ b/scripts/qwen3_tts_runner.test.js@@ -58,12 +58,21 @@ with tempfile.TemporaryDirectory() as temp:assert snapshot == Path(result["path"])# Repeated status checks do not rehash unchanged multi-GB weights.verifier = runner.verify_file- runner.verify_file = lambda *args: (_ for _ in ()).throw(AssertionError("rehashed unchanged file"))- assert runner.installed_snapshot(model_dir, model_id) == snapshot- runner.verify_file = verifier+ if sys.platform != "win32":+ runner.verify_file = lambda *args: (_ for _ in ()).throw(AssertionError("rehashed unchanged file"))+ assert runner.installed_snapshot(model_dir, model_id) == snapshot+ runner.verify_file = verifierassert len(calls) == len(runner.REQUIRED_FILES)- # A metadata-only directory or incomplete codec must never report installed.+ # A harmless touch refreshes the cache after one verification.codec = snapshot / "speech_tokenizer/model.safetensors"+ stat = codec.stat()+ os.utime(codec, ns=(stat.st_atime_ns, stat.st_mtime_ns + 1000000))+ assert runner.installed_snapshot(model_dir, model_id) == snapshot+ if sys.platform != "win32":+ runner.verify_file = lambda *args: (_ for _ in ()).throw(AssertionError("rehashed refreshed file"))+ assert runner.installed_snapshot(model_dir, model_id) == snapshot+ runner.verify_file = verifier+ # A metadata-only directory or incomplete codec must never report installed.original = codec.stat()codec.write_bytes(b"x" * original.st_size)os.utime(codec, ns=(original.st_atime_ns, original.st_mtime_ns))