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

+9
View File
@@ -124,6 +124,15 @@ class RetrievalServerTests(unittest.TestCase):
self.assertEqual(stopped.exception.code, 3)
self.assertEqual(calls[0][2:], ['search', '--query', 'two words'])
def test_daemon_identity_changes_with_code_version(self):
with TemporaryDirectory() as temporary:
data_dir = Path(temporary)
with patch.object(MODULE, 'code_version', return_value='aaaaaaaaaaaa'):
old_address, old_lock = MODULE.daemon_address(data_dir), MODULE.daemon_lock_path(data_dir)
with patch.object(MODULE, 'code_version', return_value='bbbbbbbbbbbb'):
self.assertNotEqual(MODULE.daemon_address(data_dir), old_address)
self.assertNotEqual(MODULE.daemon_lock_path(data_dir), old_lock)
def test_preferred_device_uses_cuda_with_cpu_fallback(self):
with patch.dict('sys.modules', torch=SimpleNamespace(cuda=SimpleNamespace(is_available=lambda: True))):
self.assertEqual(MODULE.preferred_device(), 'cuda')