# Decision Archaeology

- **Command:** `lore decisions <query>`
- **Confidence:** 82%
- **Tier:** 2
- **Status:** proposed
- **Effort:** medium — search pipeline + regex pattern matching on notes

## What

Search for discussion notes that contain decision-making language. Use the existing
search pipeline but boost notes containing patterns like "decided", "agreed",
"will go with", "tradeoff", "because we", "rationale", "the approach is", "we chose".
Return the surrounding discussion context.

## Why

This is gitlore's unique value proposition — "why was this decision made?" is the
question that no other tool answers well. Architecture Decision Records are rarely
maintained; the real decisions live in discussion threads. This mines them.

## Data Required

All exists today:
- `documents` + search pipeline (for finding relevant entities)
- `notes` (body text for pattern matching)
- `discussions` (for thread context)

## Implementation Sketch

```
1. Run existing hybrid search to find entities matching the query topic
2. For each result entity, query all discussion notes
3. Score each note against decision-language patterns:
   - Strong signals (weight 3): "decided to", "agreed on", "the decision is",
     "we will go with", "approved approach"
   - Medium signals (weight 2): "tradeoff", "because", "rationale", "chosen",
     "opted for", "rejected", "alternative"
   - Weak signals (weight 1): "should we", "proposal", "option A", "option B",
     "pros and cons"
4. Return notes scoring above threshold, with surrounding context (previous and
   next note in discussion thread)
5. Sort by: search relevance * decision score
```

### Decision Patterns (regex)

```rust
const STRONG_PATTERNS: &[&str] = &[
    r"(?i)\b(decided|agreed|approved)\s+(to|on|that)\b",
    r"(?i)\bthe\s+(decision|approach|plan)\s+is\b",
    r"(?i)\bwe('ll| will| are going to)\s+(go with|use|implement)\b",
    r"(?i)\blet'?s\s+(go with|use|do)\b",
];

const MEDIUM_PATTERNS: &[&str] = &[
    r"(?i)\b(tradeoff|trade-off|rationale|because we|opted for)\b",
    r"(?i)\b(rejected|ruled out|won't work|not viable)\b",
    r"(?i)\b(chosen|selected|picked)\b.{0,20}\b(over|instead of)\b",
];
```

## Human Output

```
Decisions related to "authentication"

group/backend !234 — "Refactor auth middleware"
  Discussion #a1b2c3 (alice, 3w ago):
    "We decided to use JWT with short-lived tokens instead of session cookies.
     The tradeoff is more complexity in the refresh flow, but we get stateless
     auth which scales better."
    Decision confidence: HIGH (3 strong pattern matches)

group/backend #42 — "Auth architecture review"
  Discussion #d4e5f6 (bob, 2mo ago):
    "After discussing with the security team, we'll go with bcrypt for password
     hashing. Argon2 is theoretically better but bcrypt has wider library support."
    Decision confidence: HIGH (2 strong pattern matches)
```

## Downsides

- Pattern matching is imperfect; may miss decisions phrased differently
- May surface "discussion about deciding" rather than actual decisions
- Non-English discussions won't match
- Requires good search results as input (garbage in, garbage out)

## Extensions

- `lore decisions --recent` — decisions made in last 30 days
- `lore decisions --author alice` — decisions made by specific person
- Export as ADR (Architecture Decision Record) format
- Combine with timeline for chronological decision history
