fix(retrieval): version the daemon by code hash

Derive the daemon address and start lock from a hash of server.py, so an
updated server never reuses a daemon still running older code.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Julian lechnerandClaude Opus 5.5 committed 2026-10-01 13:13:03 +02:00
1 parent 4e4a10604d
commit 2354ce2c2c
3 files changed
+18 -3

No files matched your search

+8 -2
View File
@@ -226,12 +226,18 @@ def reciprocal_rank_fusion(*rankings):
return sorted(scores, key=lambda identifier: (-scores[identifier], identifier))
def code_version() -> str:
"""Hash of this file, so a daemon started by older code is never reused after an update."""
return hashlib.sha256(Path(__file__).read_bytes()).hexdigest()[:12]
def daemon_lock_path(data_dir: Path) -> Path:
return data_dir / "daemon.starting"
return data_dir / f"daemon-{code_version()}.starting"
def daemon_address(data_dir: Path) -> str:
digest = hashlib.sha256(os.path.normcase(str(data_dir.resolve())).encode()).hexdigest()[:16]
identity = os.path.normcase(str(data_dir.resolve())) + "|" + code_version()
digest = hashlib.sha256(identity.encode()).hexdigest()[:16]
if os.name == "nt":
return r"\\.\pipe\ai-config-retrieval-" + digest
return str(data_dir / f"daemon-{digest}.sock")