fix(embedded): recover from daemon crashes transparently#1193
Merged
Conversation
_ensure_started() had a sticky short-circuit: once _started=True it never verified the daemon was still alive. If the daemon crashed, all subsequent calls failed with connection refused. Now _ensure_started() calls manager.is_running() (HTTP health check) each time and transparently restarts the daemon if it's unresponsive. Also simplifies __getattr__ by removing the redundant wrapper closure.
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.
Summary
HindsightEmbedded._ensure_started()had a sticky short-circuit: once_started=True, it never checked daemon liveness. If the daemon crashed, all subsequent calls failed with connection refused.manager.is_running()(HTTP GET/health) on each invocation and transparently restarts the daemon when it's unresponsive.__getattr__by removing the redundant wrapper closure that doubled the health-check overhead.Test plan
test_embedded_daemon_crash_recovery— starts client, stops daemon to simulate crash, verifies next operation restarts ithindsight-allembedded test suite for regressions:cd hindsight-all && uv run pytest tests/test_embedded.py -v