Skip to content
maenifold
GitHub

Sleep Consolidation (Memory Transfer)

3 steps

Specialist workflow for the Cognitive Sleep Cycle. Transfers high-value episodic memory (thinking sessions) into durable semantic storage (memory:// notes). Mirrors biological consolidation: hippocampal replay identifies candidates, slow-wave phase distills insights, REM phase discovers novel connections.

Triggers

sleep consolidationconsolidate memoriesmemory transferepisodic to semanticthinking consolidation

Steps

  1. 1.

    Memory Replay (Hippocampal Phase)

    Identify consolidation candidates from recent episodic memory.

    1. Run recent_activity to retrieve thinking sessions and significant events since last consolidation
    2. Score significance: decisions made, lessons learned, insights gained, bugs fixed, patterns recognized
    3. Identify high-significance events (3+ concept connections, decision points, novel insights)
    4. Filter out low-value noise: routine operations, trivial queries, incomplete sessions
    5. Create ranked candidate list with significance scores and rationale

    Significance scoring criteria:

    • Decision points: +3 (choices that affected outcomes)
    • Lessons learned: +3 (explicit learning from experience)
    • Novel insights: +2 (new understanding or connections)
    • Bug fixes: +2 (problem-solution pairs worth preserving)
    • Pattern recognition: +2 (recurring themes across sessions)
    • Concept density: +1 per 3 [[WikiLinks]] in source

    Output: List of consolidation candidates with significance scores (threshold: score >= 4)

    Enhanced Thinking
    Tools:recent_activity*sequential_thinking*
    Effort:medium
    Guardrails
    • recency_window: Process thinking sessions from last 24-48 hours
    • significance_threshold: Only promote candidates with score >= 4
    • concept_density_check: Flag sessions with 3+ [[WikiLinks]] for review
  2. 2.

    Consolidation (Slow-Wave Phase)

    Distill high-value episodic content into durable semantic memory.

    1. For each consolidation candidate, extract core insights and distill into wiki-style knowledge
    2. ALWAYS search existing memory:// first for related notes to update rather than duplicate
    3. If related note exists: edit_memory to append or integrate new insights
    4. If no related note: write_memory to create new semantic note
    5. Ensure every consolidated note has minimum 5 [[WikiLinks]] for graph integration
    6. Cross-link to existing knowledge structure

    Consolidation transforms:

    • Episodic: "I debugged the auth issue by checking token expiry"
    • Semantic: "[[JWT]] [[token-validation]] requires checking [[expiry]] before [[signature-verification]] to avoid timing attacks"

    Note: read_memory IS allowed in this workflow (NFR-7.11.1). Reading content for consolidation is intentional access that SHOULD boost the decay clock.

    Enhanced Thinking
    Tools:search_memories*read_memorywrite_memory*edit_memory
    Effort:high
    Guardrails
    • search_before_write: ALWAYS search for existing notes before creating new ones
    • wikilink_density: Minimum 5 [[concepts]] per consolidated note
    • update_preference: Prefer editing existing notes over creating new ones
    • no_duplicates: Never create a note if a related one already exists
    • no_custodian_folder: NEVER write to custodian/ - write to appropriate knowledge folders (research/, tech/, etc.)
  3. 3.

    Dream Synthesis (REM Phase)

    Discover novel connections between recently consolidated concepts.

    1. Select 3-5 high-value [[concepts]] from the consolidation phase
    2. Run find_similar_concepts on each to discover unexpected semantic neighbors
    3. Use build_context to explore relationship neighborhoods (depth 2)
    4. Identify surprising connections not already explicit in the graph
    5. Generate testable hypotheses about relationships worth investigating

    Dream outputs:

    • Novel connection: "[[JWT]] is semantically close to [[session-management]] but they're not linked in the graph"
    • Hypothesis: "Consolidating JWT and session docs might reduce context-building overhead"
    • Investigation candidate: "The [[decay]] concept appears near [[garbage-collection]] - explore memory management parallels"

    Focus on connections that could improve future retrieval or reveal hidden knowledge structure.

    Enhanced Thinking
    Tools:find_similar_concepts*build_contextsequential_thinking*
    Effort:high
    Guardrails
    • novelty_focus: Prioritize connections NOT already explicit in the graph
    • hypothesis_quality: Hypotheses must be testable or actionable
    • concept_limit: Process maximum 5 concepts per dream cycle
    • output_format: Return connections and hypotheses as workflow output - do NOT write to memory://