Run the nightly sleep cycle — memory consolidation from today's real conversations.

## Step 1: Extract conversations

Run:
python3 /home/aria/.openclaw/workspace/scripts/extract-daily-conversations.py --hours 26 --output-dir /tmp/daily-transcripts

(26h window catches any sessions the previous cycle may have missed)

If extracted count is 0, write "Sleep cycle: no conversations to process tonight." and stop.

## Step 2: Distill each transcript

For each .txt file in /tmp/daily-transcripts/:
- Skip if file is under 200 bytes
- Read the file
- Spawn a sub-agent (model: anthropic/claude-sonnet-4-6, timeoutSeconds: 90) with this task:

"Read the following conversation transcript and extract what's worth remembering long-term.

Output a concise summary (under 40 lines) with these sections:

### Facts & Decisions
- Atomic facts learned, configs changed, tools set up, products built
- Decisions made and their rationale
- Anything that changes how future work should be done

### Errors & Gotchas
- Mistakes made and corrections from humans
- Gotchas or undocumented behaviors discovered
- Things that didn't work and why

### Open Items
- Anything left unfinished, pending, or requiring follow-up
- Explicit 'remember this' requests

If this is trivial content (just greetings, ACKs, no decisions or actions), output exactly: NOTHING_NOTABLE

Transcript:
<transcript>
{content of the .txt file — paste in full}
</transcript>"

Collect all sub-agent outputs. Discard any that returned NOTHING_NOTABLE.

## Step 3: Consolidate into MEMORY.md

Read /home/aria/.openclaw/workspace/MEMORY.md.
Read /home/aria/.openclaw/workspace/memory/error-log.md.

For each distilled summary:
- New facts/decisions → add to appropriate section in MEMORY.md
- Contradicts existing fact → update the old entry, note the date
- Reinforces existing → skip (no duplicates)
- New errors/gotchas → append to memory/error-log.md in the existing format:
  `- 🏷️ **Short title** — What happened. What to do instead.`

If the summary has open items that look like unresolved blockers (not just normal pending work), note them in MEMORY.md under a "## Open Blockers" section (create if doesn't exist, or update existing).

## Step 4: Associative Processing (REM phase)

1. Re-read the full set of distilled summaries.
2. Look for cross-session patterns: recurring errors, repeated requests, emerging themes.
3. If a pattern shows up 3+ times across different sessions, it's worth a dedicated MEMORY.md entry.
4. Scan MEMORY.md for entries older than 30 days that reference temporary/resolved state (e.g. "port 3001 conflict", "AIDE scan running"). Remove or archive them.

## Step 5: Quality review of MEMORY.md

1. Read MEMORY.md end to end.
2. Remove outdated, resolved, or redundant entries.
3. Compress bloated sections — aim for signal density, not completeness.
4. Target: under 40KB. If over, trim the least-important entries.
5. Ensure sections have clear headers and the document reads coherently.

## Step 6: Cleanup

Delete /tmp/daily-transcripts/ when done.

## Step 7: Sleep cycle brief

Write a brief sleep report (under 25 lines) in this format:

---
🌙 Sleep Cycle — {DATE} {TIME} PHT

Sessions processed: {N}
NOTHING_NOTABLE: {N}
Meaningful sessions: {N}

**Added to MEMORY.md:**
- {bullet per new fact/decision added}

**Appended to error-log.md:**
- {bullet per new error/gotcha, or "none"}

**Removed from MEMORY.md:**
- {bullet per removed entry, or "none"}

**Patterns detected:**
- {cross-session patterns found, or "none"}

**Open items flagged:**
- {unresolved blockers noted, or "none"}
---

Post this report to Discord channel 1471453583890448553 (#aria-status).
