fix(daemon): self-evict when socket is taken over; safe unlink-on-close#13
Merged
couragehong merged 1 commit intoJun 9, 2026
Merged
Conversation
runed is meant to be a singleton on $RUNED_HOME/embedding.sock, but when the home dir is recreated out from under a running daemon (e.g. a dev `rm -rf ~/.runed` + reinstall) the socket path and lock files get new inodes, so the single-instance guards fail open and a second daemon spawns. The old daemon keeps running on a path that no longer points at it, and nothing reaps it -- orphan daemons accumulate. Separately, Go's UnixListener unlink-on-close lets a dying daemon delete a healthy peer's socket file that happens to occupy the same path. - ipc.Listen disables net's unconditional unlink-on-close and records the bound socket's (dev,ino); Close removes the file only if the path still refers to our own socket, and StillOwned exposes the same check. A cross-platform Listener interface carries StillOwned to callers. - runed runs a self-eviction watchdog: if its socket is unlinked or rebound by another daemon, it triggers the normal graceful shutdown and cancels the daemon context, exiting 0 so the supervisor stays down rather than restarting into the stolen path. Boot-failure paths return nil when evicted so an eviction during self-bootstrap also exits 0. Adds regression tests: StillOwned transitions, and that an evicted listener's Close does not delete a socket another listener rebound. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
jh-lee-cryptolab
approved these changes
Jun 9, 2026
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.
runed is meant to be a singleton on $RUNED_HOME/embedding.sock, but when the home dir is recreated out from under a running daemon (e.g. a dev
rm -rf ~/.runed+ reinstall) the socket path and lock files get new inodes, so the single-instance guards fail open and a second daemon spawns. The old daemon keeps running on a path that no longer points at it, and nothing reaps it -- orphan daemons accumulate. Separately, Go's UnixListener unlink-on-close lets a dying daemon delete a healthy peer's socket file that happens to occupy the same path.Adds regression tests: StillOwned transitions, and that an evicted listener's Close does not delete a socket another listener rebound.