Skip to content

Stabilize daemon lifecycle after #47/#48 integration#55

Draft
Marsu6996 wants to merge 4 commits into
CodeAbra:mainfrom
Marsu6996:local/runtime-pr47-pr48
Draft

Stabilize daemon lifecycle after #47/#48 integration#55
Marsu6996 wants to merge 4 commits into
CodeAbra:mainfrom
Marsu6996:local/runtime-pr47-pr48

Conversation

@Marsu6996

@Marsu6996 Marsu6996 commented Jul 5, 2026

Copy link
Copy Markdown
Contributor

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 main so this PR only contains the net-new daemon stabilization commits.

Follow-up latency work has been split into draft stacked PRs:

Summary

Stabilize the daemon runtime behavior that surfaced once #47/#48 ran together:

  • wrapper heartbeat presence no longer pins the daemon awake;
  • stale sleep requests are normalized instead of replayed at boot;
  • completed sleep cycles stay terminal unless real activity wakes the daemon;
  • boot/sleep and active WAKE paths avoid heavy graph/session precache work;
  • HIPPEA session_open reads warm structural cache instead of rebuilding the runtime graph;
  • user-driven activity can wake immediately while non-user churn remains guarded;
  • state persistence snapshots daemon state before threaded writes.

No public API change, no scheduler model rewrite, no release/tag.

Review map

Suggested review order:

  1. fix(daemon): snapshot state before threaded save to end tick crash #47 snapshot save-state race
  2. Let daemon sleep with idle MCP wrappers #48 idle wrapper wake/sleep behavior
  3. this PR: integration stabilization on top of fix(daemon): snapshot state before threaded save to end tick crash #47/Let daemon sleep with idle MCP wrappers #48
  4. Reduce recall latency: macOS launchd throttling and cue embedding reuse #57 recall latency
  5. Bound topology latency with cached snapshots #58 topology latency

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 pytest installed.

Attribution

Designed by Marsu — Refined by Codex.

Co-Authored-By: Codex codex@openai.com

Marsu6996 and others added 3 commits July 5, 2026 07:07
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>
@Marsu6996 Marsu6996 changed the title Stabiliser le daemon runtime après intégration PR Stabilize daemon runtime after PR integration Jul 5, 2026
Designed by Marsu — Refined by Codex.

Co-Authored-By: Codex <codex@openai.com>
@Marsu6996 Marsu6996 marked this pull request as draft July 6, 2026 07:09
@Marsu6996 Marsu6996 force-pushed the local/runtime-pr47-pr48 branch from 625cf7c to 62dbd7a Compare July 6, 2026 07:16
@Marsu6996 Marsu6996 changed the title Stabilize daemon runtime after PR integration Stabilize daemon lifecycle after #47/#48 integration Jul 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant