# Fact Extraction Process

Run this as an isolated subagent. Extract facts from recent conversations and update memory files.

## Steps

### 1. Gather Recent Conversations
- Read `memory/YYYY-MM-DD.md` for today (and yesterday if early in the day)
- Read recent Discord thread histories if available via `sessions_list`
- Focus on **new information** — skip routine status updates

### 2. Extract Facts
For each conversation, identify:

**People Facts** → `memory/facts/people.md`
- Communication preferences (format, tone, detail level)
- Roles, responsibilities, expertise
- Corrections they made (what was wrong → what's right)
- Relationships between people

**Decisions** → `memory/facts/decisions.md`
- Technical decisions (tool choices, architecture, patterns)
- Process decisions (workflows, approvals, standards)
- Business decisions (pricing, strategy, priorities)
- Include: who decided, when, and why

**Technical Notes** → `memory/facts/technical.md`
- Bug patterns and fixes
- Configuration details (ports, URLs, credentials)
- Integration notes (API quirks, rate limits)
- Build/deploy learnings

**Preferences** → `memory/facts/preferences.md`
- UI/UX preferences (formatting, layout, colors)
- Communication preferences (channels, timing, format)
- Tool preferences
- Working style preferences

### 3. Conflict Resolution
Before writing each fact:
1. Run `memory_search` with the fact as query
2. If a similar fact exists (same topic, same person):
   - **Update in place** — don't duplicate
   - Add changelog: `(updated YYYY-MM-DD, was: X → now: Y)`
3. If no match: append as new fact

### 4. Fact Format
Each fact should be structured as:
```markdown
- **[fact]** — [source: person, date] [confidence: high/medium/low]
```

Confidence levels:
- **high** — Explicitly stated ("I want X", "Use Y", "We decided Z")
- **medium** — Implied from behavior or context
- **low** — Inferred, may need confirmation

### 5. What NOT to Extract
- Routine greetings or small talk
- Temporary states ("I'm busy right now")
- Information already well-documented in MEMORY.md
- Secrets, passwords, or sensitive credentials (reference location only)

### 6. Log Output
After extraction, append to today's `memory/YYYY-MM-DD.md`:
```markdown
## Fact Extraction Run (HH:MM GMT+8)
- Extracted: N new facts, M updates
- Sources: [list of conversations reviewed]
```
