Repository navigation
Conversation
A daemon was observed alive, listening and serving a connected client after its discovery lock file and registry entry had disappeared. The lock is the only way a proxy finds a daemon (it carries the auth token), so every new proxy for that root started a second daemon, which crashed on the DB the first one held. While serving, the daemon now checks its publication every few seconds and rewrites a missing lock with its own pid, socket path and the same auth token, plus a missing registry entry, logging a warning to its log. A lock naming a different live pid is left alone. The check is cancelled first in _graceful_shutdown, so it can never re-publish after shutdown removes the lock. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Brings in the 24 commits merged to main since this branch was last updated, including chunkhound#534's rust-checks fix. No conflicts. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
A proxy finds its daemon only through the runtime lock file (
daemon-locks/<hash>.json), which also carries the auth token. We observed a daemon on Windows that was alive, listening on its TCP port and serving a connected client, while both its lock file and its registry entry were gone. Its own_graceful_shutdownhad not run: the client was still connected. We have not established what removed the files.The effect was that every new
chunkhound mcpfor that root found no lock and started a second daemon. That daemon then failed on the database the first one still held. This went on for at least two hours, until the first daemon's last client disconnected.Change
chunkhound/daemon/server.py: while serving, the daemon checks its own publication every_PUBLICATION_CHECK_INTERVAL(5 s).Lifecycle:
_pid_poll_task. A daemon that lost the startup race never runs it._graceful_shutdowncancels and awaits the task beforeremove_lockandremove_registry_entry. The check itself contains noawait, so it cannot re-publish after shutdown removes the files.write_lockstill recordsprocess_started_atfor the daemon's own process, sostop_daemon's identity check is unchanged.Test
tests/unit/test_daemon_republish_lock.py::test_serving_daemon_republishes_deleted_lockruns the realrun()loop with a mockedinitializeand IPC server, a 0.05 s interval, and real discovery files undertmp_path. It deletes the lock and the registry entry, then asserts both reappear with the same pid, auth token and socket path. It also asserts the lock is gone after shutdown. With the task'screate_taskline removed, it fails with...daemon-locks\<hash>.json did not appear.The existing daemon tests (
tests/test_daemon_smoke.py,tests/test_daemon_startup_order.pyand thetests/unit/test_daemon_*.pyfiles) give the same result with and without the change: 92 passed, 4 skipped, 7 failed. All 7 failures are intest_daemon_smoke.py(SubprocessCrashError) on Windows, and they fail onmaintoo.Live check on a fork build: with a daemon serving, deleting its lock and registry entry by hand had both re-published within a second with the same pid and token, and a new proxy then attached to the running daemon.
When running these tests locally, set both
CHUNKHOUND_DAEMON_RUNTIME_DIRandCHUNKHOUND_DAEMON_REGISTRY_DIRto temporary directories. With only the first set, the registry still points at the real directory that live daemons use.🤖 Generated with Claude Code, reviewed by FStrasz