Skip to content

feat: add Dream Mode overnight self-reflection - #933

Merged
AmitoVrito merged 5 commits into
SynapseKit:mainfrom
DhruvGarg111:feat/issue-749-dream-mode
Aug 16, 2026
Merged

AmitoVrito merged 5 commits into
SynapseKit:mainfrom
DhruvGarg111:feat/issue-749-dream-mode

Conversation

@DhruvGarg111

Copy link
Copy Markdown
Collaborator

Summary

Implements issue #749, Dream Mode: an explicit, local-first overnight reflection runner that replays the day's signed traces, distills durable corrections, proposes human-reviewed LivingMemory patches, refreshes KnowledgeMesh state, flags stale memories, and emits a signed audit bundle.

Detailed implementation plan delivered

  • Add typed Dream Mode contracts for configuration, schedules, power state, lessons, stale-memory candidates, mesh consolidation candidates, trace windows, and serializable run reports.
  • Add a local SQLite state store for idempotent trace ingestion, complete-run replay windows, memory-read timestamps, stale-memory reporting, and morning-briefing persistence.
  • Add an injectable scheduler with idle_30m/idle_30m or HH:MM parsing, per-trigger de-duplication, Windows/Linux power monitoring, Windows idle monitoring, cancellation, and fail-closed plugged-in policy.
  • Add deterministic offline lesson extraction plus an injected async model backend path. The model path is bounded by budget_tokens; oversized traces never invoke the backend.
  • Orchestrate replay, lesson distillation, LivingMemory proposals, KnowledgeMesh reindex/duplicate candidates, report-only stale pruning, signed AuditTracer output, and a concise terminal briefing.
  • Keep all mutations opt-in and gated: no background task on import/constructor, memory patches remain pending, entity matches are proposals only, stale pruning never deletes, and audit bundles are locally signed.
  • Expose synapsekit dream run/status, public package exports, documentation, and an executable example.

Safety boundaries

  • Trace bundles are loaded locally and validated with ReplayEngine/hash-chain verification before distillation.
  • EdgeRuntime can be passed as the backend, preserving its local-first and explicit cloud-fallback policy.
  • LivingMemory remains the approval boundary; Dream Mode never applies a patch automatically.
  • KnowledgeMesh duplicate/entity work is report-only; no automatic merges or deletes.
  • Stale-memory pruning is report-only.
  • The scheduler refuses to run when power state is unknown or the machine is not plugged in by default.
  • Token and transcript limits prevent unbounded overnight work.

Verification

  • Dream Mode focused suite: 6 passed
  • LivingMemory regressions: 14 passed
  • EdgeRuntime regressions: 15 passed
  • KnowledgeMesh regressions: 14 passed
  • Signed audit regressions: 66 passed
  • Ruff lint: passed
  • Ruff formatting: passed
  • Bounded mypy: passed for 7 Dream Mode source/CLI modules
  • compileall: passed
  • async-blocking gate: clean, 544 files scanned
  • git diff --check: passed

The normal pytest plugin environment has an unrelated installed logfire/OpenTelemetry version mismatch. Async suites were verified with only the repository-relevant pytest-asyncio plugin enabled.

Commits

  1. feat(dream): add local reflection contracts and state
  2. feat(dream): orchestrate audited overnight reflection
  3. test(dream): cover safety and morning briefing workflows

Closes #749

@AmitoVrito
AmitoVrito merged commit 7271b00 into SynapseKit:main Aug 16, 2026
14 checks passed
@AmitoVrito

Copy link
Copy Markdown
Collaborator

Merged into main 🎉 Thank you, @DhruvGarg111 — Dream Mode is a genuinely elegant piece of work: the fail-closed power gating, report-only pruning, and signed-bundle boundaries are exactly right.

Applied a few review fixes on the way in (all with regression tests):

  • Hash-chain order reconstruction — records arrive sorted by (timestamp, event_id), so events sharing a timestamp were reordered out of true prev_hash/hash order and verify_chain silently dropped the whole run. Now relinked into chain order before verifying, with a warning (not a silent drop) on genuinely broken chains.
  • ingest_traces is now async and offloads its SQLite writes (async-first).
  • dream status is fully read-only — no more throwaway signing key / dir creation just to print a briefing.

Shipped as part of the v2.1 [Unreleased] changelog. 🙏

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.

v2.1 (beyond): Dream Mode — overnight offline self-reflection, distills lessons from the day

2 participants