|
| 1 | +# Dream Consolidation: Passive Knowledge Growth |
| 2 | + |
| 3 | +## How It Works |
| 4 | + |
| 5 | +```mermaid |
| 6 | +sequenceDiagram |
| 7 | + participant User |
| 8 | + participant Claude as AI Assistant |
| 9 | + participant Hook as session-end hook |
| 10 | + participant LLM as Fast LLM (cheap tier) |
| 11 | + participant KG as Knowledge Graph (SQLite) |
| 12 | +
|
| 13 | + User->>Claude: Work on tasks in a session |
| 14 | + Claude->>Claude: Complete task 1, task 2, task 3... |
| 15 | +
|
| 16 | + Note over User,Claude: Session ends (user closes, context full, or circuit breaker) |
| 17 | +
|
| 18 | + Claude->>Hook: hook session-end fires |
| 19 | + Hook->>Hook: Load session state (tasks_completed > 0?) |
| 20 | +
|
| 21 | + alt No tasks completed |
| 22 | + Hook->>Hook: Skip dream consolidation |
| 23 | + else Tasks were completed |
| 24 | + Hook->>Hook: Collect completion summaries from all completed tasks |
| 25 | + Hook->>LLM: "Extract architectural decisions, patterns, constraints from these completed tasks" |
| 26 | + LLM-->>Hook: JSON findings (type, title, description) |
| 27 | +
|
| 28 | + loop For each finding |
| 29 | + Hook->>KG: IngestFindings(source_agent="dream", confidence=0.6) |
| 30 | + KG->>KG: Dedup against existing nodes (similarity check) |
| 31 | + KG->>KG: Store new nodes or skip duplicates |
| 32 | + end |
| 33 | +
|
| 34 | + Hook-->>User: "Dream: extracted N knowledge items from session" |
| 35 | + end |
| 36 | +``` |
| 37 | + |
| 38 | +## Knowledge Flow |
| 39 | + |
| 40 | +```mermaid |
| 41 | +flowchart TD |
| 42 | + subgraph "Manual (explicit)" |
| 43 | + B[tw bootstrap] --> |"Scan repo, call LLM agents"| KG[(Knowledge Graph)] |
| 44 | + R[/taskwing:remember/] --> |"User-initiated"| KG |
| 45 | + end |
| 46 | +
|
| 47 | + subgraph "Automatic (passive)" |
| 48 | + SE[Session End Hook] --> |"Analyze completed tasks"| D[Dream Consolidation] |
| 49 | + D --> |"source_agent=dream\nconfidence=0.6"| KG |
| 50 | + end |
| 51 | +
|
| 52 | + subgraph "Consumption" |
| 53 | + KG --> |"ask tool"| AI[AI Assistant Context] |
| 54 | + KG --> |"task enrichment"| TC[Task Context] |
| 55 | + KG --> |"FormatCompact()"| PC[Plan Context] |
| 56 | + end |
| 57 | +
|
| 58 | + style D fill:#9b59b6,color:#fff |
| 59 | + style KG fill:#3498db,color:#fff |
| 60 | + style B fill:#2ecc71,color:#fff |
| 61 | +``` |
| 62 | + |
| 63 | +## Confidence Tiers |
| 64 | + |
| 65 | +| Source | Agent | Confidence | When | |
| 66 | +|---|---|---|---| |
| 67 | +| Bootstrap (LLM agents) | doc, code, deps, git | 0.8-1.0 | Explicit `tw bootstrap` run | |
| 68 | +| User-initiated | remember | 1.0 | User calls `/taskwing:remember` | |
| 69 | +| Dream consolidation | dream | 0.6 | Automatic at session end | |
| 70 | + |
| 71 | +Dream findings have lower confidence because they're inferred from task completion summaries, not from direct code/doc evidence. They won't overwrite higher-confidence bootstrap findings during dedup (UpsertNodeBySummary preserves the higher-confidence version). |
| 72 | + |
| 73 | +## What Gets Extracted |
| 74 | + |
| 75 | +The dream prompt asks the LLM to identify: |
| 76 | +- **Decisions**: Technology choices made during the session ("chose Redis over Memcached for caching") |
| 77 | +- **Patterns**: Recurring approaches established ("all API handlers follow the middleware chain pattern") |
| 78 | +- **Constraints**: Rules discovered or enforced ("never deploy without running the security scan") |
| 79 | + |
| 80 | +Only findings that would be valuable for **future sessions** are extracted. Implementation details, debugging steps, and ephemeral work are filtered by the LLM prompt. |
0 commit comments