# Draft Corrections Pipeline - Preview

## Detection Patterns (Current)

| Pattern | Type | Confidence |
|---------|------|------------|
| `no, you should...` | explicit | 90% |
| `no, that's wrong` | explicit | 95% |
| `actually, you need to...` | explicit | 85% |
| `I told you before` | explicit | 90% |
| `don't do that` | explicit | 80% |
| `that's not how` | explicit | 85% |
| `wrong approach` | explicit | 90% |
| `you should have` | explicit | 75% |
| `stop/quit doing` | explicit | 85% |
| `next time, remember` | soft | 70% |
| `please don't forget` | soft | 60% |
| `that's not right/correct` | soft | 85% |
| `revert this/that/it` | revert | 95% |
| `undo this/that` | revert | 90% |
| `roll back` | revert | 90% |
| `why did you...` | frustration | 50% |
| `I already told you` | frustration | 70% |

### Proposed Additions
| Pattern | Type | Confidence |
|---------|------|------------|
| `that's wrong` (standalone) | explicit | 90% |
| `the correct way is` | explicit | 85% |
| `never do X` | explicit | 85% |
| `always do X instead` | explicit | 80% |
| `the rule is` | explicit | 80% |

---

## End-to-End Flow

### Step 1: Message Received
```
User: @aria no, you should always use PHT timezone, not UTC
```

### Step 2: Detection Runs (Automatic)
```python
detect_correction(message) 
→ (True, "explicit", 0.90)
```

### Step 3: Draft Created
```json
{
  "id": "COR-026",
  "status": "pending",
  "detected_at": "2026-02-17T08:00:00Z",
  "detection": {
    "type": "explicit",
    "confidence": 0.90,
    "source_channel": "discord"
  },
  "taught_by": "loewe",
  "authority": "member",
  "raw_message": "no, you should always use PHT timezone, not UTC",
  "what_i_did": "",           // Filled by AI or human
  "correct_behavior": "",      // Filled by AI or human
  "severity": "medium",
  "category": "communication"
}
```

### Step 4: Signal Logged
```jsonl
{"timestamp":"2026-02-17T08:00:00Z","type":"correction_received","from":"loewe","confidence":0.90,"draft_id":"COR-026"}
```

### Step 5: AI Response (Silent Logging)
```
Got it — I'll use PHT timezone instead of UTC for all time-related 
communications.
```
*(Draft created silently — no visible acknowledgment in response)*

---

## What Needs Human Review

Drafts in `agency/corrections/drafts/` need review to:

1. **Confirm validity** — Is this actually a correction?
2. **Fill context** — What did I do wrong? What's the correct behavior?
3. **Set severity** — low | medium | high | critical
4. **Set category** — deployment | qa | communication | security | etc.
5. **Add triggers** — Keywords that should retrieve this correction
6. **Approve** → Move to active corrections index

---

## Integration Points

### Option A: Inline in Claude Response
When I receive a message, before generating my response:
1. Run `integrate.py` on the message
2. If correction detected → create draft + plan acknowledgment
3. Generate response with acknowledgment embedded

**Pros:** Immediate, no delay
**Cons:** Adds latency to every response

### Option B: Post-Response Hook
After I send my response:
1. Async check runs on the message
2. If correction detected → create draft
3. Reply in thread: "📝 Logged as draft"

**Pros:** No response latency
**Cons:** Acknowledgment comes as separate message

### Option C: Parallel (Recommended)
1. Detection runs in parallel with response generation
2. If detected, append acknowledgment to response
3. If response already sent, reply in thread

**Pros:** Fast + reliable
**Cons:** Slightly more complex

---

## Final Configuration (Loewe 2026-02-17)

| Setting | Value |
|---------|-------|
| Confidence threshold | **70%** |
| Teaching patterns | Create drafts ✓ |
| CTO auto-approve | No — still draft stage |
| Acknowledgment | **Silent** — no explicit reply |
| Review queue | File-based (drafts/) |

All corrections ≥70% confidence are silently logged. No "📝 Logged" messages in responses.
