P2-T2: Self-healing stale socket and PID file recovery#124
Merged
SoundBlaster merged 8 commits intomainfrom Mar 1, 2026
Merged
P2-T2: Self-healing stale socket and PID file recovery#124SoundBlaster merged 8 commits intomainfrom
SoundBlaster merged 8 commits intomainfrom
Conversation
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
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.
Description
Fixes a critical (P0) issue where a broker daemon crash leaves stale
broker.sockandbroker.pidfiles on disk. The proxy's_spawn_broker_if_neededpreviously checked onlysocket_path.exists()and skipped spawning if the socket file was present — even if nothing was listening. This silently blocked all future broker-mode sessions until the user manually deleted the files.Changes:
src/mcpbridge_wrapper/broker/proxy.py— Replace plainexists()guard with a connect-based liveness check. Ifsocket.connect()raisesOSError(coversConnectionRefusedError, TOCTOU race, and non-socket files), both stale files are removed and spawn proceeds normally.src/mcpbridge_wrapper/broker/daemon.py— Registeratexit.register(self._cleanup_files)after successful startup so socket/PID files are removed on abnormal interpreter exits (unhandled exceptions,sys.exit()), in addition to the existing SIGTERM/SIGINT handlers.Tests:
test_spawn_noop_when_socket_existsto mocksocket.connect()success (live broker scenario).TestBrokerProxyStaleSocket(3 tests): stale socket triggers spawn, stale files are removed, live socket skips spawn.TestBrokerDaemonAtExit(1 test):atexit.registercalled with_cleanup_filesafterstart().Type of Change
Quality Gates
make test- All tests pass with ≥90% coverage (719 passed, 5 skipped; 91.78% coverage)make lint- No linting errors (ruff check src/— all checks passed)make format- Code is properly formattedmake typecheck- Type checking passesmake doccheck- Documentation is synced with DocC (if docs changed)Documentation Sync
Testing
Checklist