garrytan/gbrainmarkdown explorer
garrytan/gbrainmaster
skills / migrations

v0.23.0

skills/migrations/v0.23.0.md


version: 0.23.0 feature_pitch: headline: "gbrain dream now actually dreams: conversation transcripts → reflections, originals, and 25-year patterns." description: | The maintenance cycle gains two new phases: synthesize and patterns. The 8-phase order is now: lint → backlinks → sync → synthesize → extract → patterns → embed → orphans.

Synthesize reads conversation transcripts (e.g., OpenClaw session corpus,
meeting transcripts) and writes brain-native pages: reflections to
`wiki/personal/reflections/...`, originals to `wiki/originals/ideas/...`,
timeline entries on existing people pages.

Patterns runs after extract (so the graph is fresh) and surfaces
recurring themes across reflections — when ≥3 reflections mention the
same motif, a pattern page is written to `wiki/personal/patterns/...`
citing every reflection that constitutes its evidence.

Hard guarantees: subagent writes are bounded to an explicit allow-list
(sourced from `_brain-filing-rules.json`). Edited transcripts produce
new slugs (content-hash suffix) — never silently overwrite. A 12-hour
cooldown bounds spend at ~$1-2/day under autopilot.

recipe: skills/maintain/SKILL.md tiers: null

v0.23.0 Migration: Dream cycle synthesize + patterns phases

Audience: host agents reading this after gbrain apply-migrations has run. The synthesize phase ships disabled by default — set dream.synthesize.session_corpus_dir to opt in.

Mechanical migration: automatic, no action required

gbrain upgrade chains to gbrain apply-migrations --yes, which runs:

  • migration v25 — creates the dream_verdicts table: (file_path TEXT, content_hash TEXT, worth_processing BOOL, reasons JSONB, judged_at TIMESTAMPTZ, PRIMARY KEY(file_path, content_hash)). Cache for the cheap Haiku verdict so backfill re-runs skip already-judged transcripts. RLS-enabled when running as a BYPASSRLS role.

The migration is idempotent. Safe to re-run.

What changes for existing brains

gbrain dream (and gbrain autopilot) now run an 8-phase cycle:

lint → backlinks → sync → synthesize → extract → patterns → embed → orphans

If dream.synthesize.enabled is false (the default, post-migration), the synthesize and patterns phases emit status: "skipped", reason: "not_configured" and the cycle continues to the next phase. Existing autopilot users see zero behavior change until they configure synthesize.

To enable synthesize on your brain

Three steps. Take them when ready — there is no rush.

# 1. Point at the directory where your conversation transcripts live.
#    OpenClaw stores session transcripts at memory/.dreams/session-corpus/<YYYY-MM-DD>.txt
#    by default. If you have a different layout, point at that.
gbrain config set dream.synthesize.session_corpus_dir /path/to/transcripts

# 2. Enable the phase.
gbrain config set dream.synthesize.enabled true

# 3. Preview without spending real LLM tokens (runs cheap Haiku verdict only).
gbrain dream --phase synthesize --dry-run --json

Tunables (sensible defaults; override only if needed)

# Skip transcripts shorter than this many characters (default 2000).
gbrain config set dream.synthesize.min_chars 2000

# Word-boundary regex patterns to skip. Default ["medical","therapy"].
# Each entry auto-wraps as \b<entry>\b — "medical" matches "medical advice"
# but NOT "comedical". Pass full regex (e.g. ^therapy:) for advanced patterns.
gbrain config set dream.synthesize.exclude_patterns '["medical","therapy"]'

# Synthesize model (default: claude-sonnet-4-6).
gbrain config set dream.synthesize.model claude-sonnet-4-6

# Hours between synthesize runs (the v1 spend cap; default 12 → ~$1-2/day).
gbrain config set dream.synthesize.cooldown_hours 12

# Patterns lookback window in days (default 30).
gbrain config set dream.patterns.lookback_days 30

# Minimum distinct reflections needed to name a pattern (default 3).
gbrain config set dream.patterns.min_evidence 3

Allow-list source of truth

The synthesize subagent's allowed write paths live in skills/_brain-filing-rules.json under dream_synthesize_paths.globs:

{
  "dream_synthesize_paths": {
    "globs": [
      "wiki/personal/reflections/*",
      "wiki/originals/*",
      "wiki/personal/patterns/*",
      "wiki/people/*",
      "dream-cycle-summaries/*"
    ]
  }
}

Editing this list is the ONLY way to add a new directory the synthesizer can write to. The subagent's put_page calls are gated server-side; even on prompt-injection success the write is bounded to these prefixes.

Slug discipline

Reflections: wiki/personal/reflections/YYYY-MM-DD-<topic>-<hash[:6]> Originals: wiki/originals/ideas/YYYY-MM-DD-<idea>-<hash[:6]> Patterns: wiki/personal/patterns/<theme> Summary: dream-cycle-summaries/YYYY-MM-DD

The 6-char content-hash suffix on reflections / originals means an edited transcript produces a NEW slug — the original reflection is preserved alongside the new one. No silent overwrite.

Lowercase alphanumeric and hyphens only. NO underscores, NO file extensions.

Provenance

Every put_page call from the synthesize subagent shows up in subagent_tool_executions with full input. The orchestrator collects slugs by querying that table — NOT pages.updated_at — so the cycle's write list cannot accidentally include manual edits or sync output.

What's deferred to v1.1

  • Auto git commit + push. v1 writes markdown files to brain_dir but does NOT git add / commit / push. Either commit yourself or let gbrain autopilot handle it. v1.1 will add explicit --commit / --push flags with handling for dirty worktree, staged changes, auth failure, and non-fast-forward push.
  • Daily token budget cap. Cooldown alone is the spend bound at v1 scale. If real-world telemetry surfaces a problem, v1.1 adds an explicit daily_token_budget config.
  • Cross-modal pattern review. Patterns currently runs against reflections only. Future revision could roll up across reflections, meetings, and timeline entries together.

Verify after upgrade

# Schema migration applied?
gbrain doctor

# Phase ordering correct?
gbrain dream --help    # shows the 8-phase pipeline

# Dry-run against a single transcript (cheap Haiku call only):
gbrain dream --phase synthesize --input /tmp/some-transcript.txt --dry-run --json

If any step fails, file an issue with gbrain doctor output and the contents of ~/.gbrain/upgrade-errors.jsonl if it exists.

Continue exploring589 Markdown documents in the local repository