Stabilize daemon lifecycle after #47/#48 integration#55
Draft
Marsu6996 wants to merge 4 commits into
Draft
Conversation
save_state ran in a worker thread (via asyncio.to_thread) over the live `state` dict while the event loop kept mutating it, so json.dump could hit "RuntimeError: dictionary changed size during iteration". That crash propagated out of the scheduler tick and silently froze consolidation: episodes kept being captured but never got consolidated/indexed, so recall only ever returned older, already-consolidated memories. It surfaces under concurrent load (several MCP wrappers hitting the daemon at once). Route every threaded save through a new _persist() helper that deepcopies `state` synchronously in the event-loop thread — atomic w.r.t. other coroutines — then hands the isolated snapshot to the writer thread. Covers all save_state offload sites. Adds a regression test. Designed by Marsu — Refined by Claude. Co-Authored-By: Claude <noreply@anthropic.com>
Keep wrapper heartbeats and watchdog probes from pinning the daemon awake, and wake the launchd-managed daemon on demand before MCP tool calls. Reduce recall CPU by limiting the max-node community gate to the current candidate embeddings, while preserving deterministic ordering and non-finite embedding guards. Cover wrapper wake gating, readiness timeout, recall concurrency, and max-node gate edge cases. Designed by Marsu — Refined by Codex. Co-Authored-By: Codex <codex@openai.com>
Designed by Marsu — Refined by Codex. Co-Authored-By: Codex <codex@openai.com>
Designed by Marsu — Refined by Codex. Co-Authored-By: Codex <codex@openai.com>
625cf7c to
62dbd7a
Compare
This was referenced Jul 6, 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.
Draft / stacked PR
Do not merge before #47 and #48.
This PR is the daemon-lifecycle integration layer after #47/#48. It currently includes the #47 and #48 commits so the integration behavior can be validated together. After #47 and #48 merge, this branch will be rebased onto
mainso this PR only contains the net-new daemon stabilization commits.Follow-up latency work has been split into draft stacked PRs:
ProcessType=Backgroundremoval + cue embedding reuse)Summary
Stabilize the daemon runtime behavior that surfaced once #47/#48 ran together:
session_openreads warm structural cache instead of rebuilding the runtime graph;No public API change, no scheduler model rewrite, no release/tag.
Review map
Suggested review order:
Validation
Pre-split validation on this branch covered targeted daemon / recall / session / sleep / identity / socket suites, wrapper typecheck/tests, and live daemon checks. After splitting out the latency commit, GitHub CI should be treated as the authoritative check for this draft.
Local post-split pytest was not rerun because no compatible local Python environment currently has
pytestinstalled.Attribution
Designed by Marsu — Refined by Codex.
Co-Authored-By: Codex codex@openai.com