# "What Changed?" Digest

- **Command:** `lore digest --since <date>`
- **Confidence:** 93%
- **Tier:** 1
- **Status:** proposed
- **Effort:** medium — multiple queries across event tables, formatting logic

## What

Generate a structured summary of all activity since a given date: issues
opened/closed, MRs merged, labels changed, milestones updated, key discussions.
Group by project and sort by significance (state changes > merges > label changes >
new comments).

Default `--since` is 1 day (last 24 hours). Supports `7d`, `2w`, `YYYY-MM-DD`.

## Why

"What happened while I was on PTO?" is the most universal developer question. This
is a killer feature that leverages ALL the event data gitlore has ingested. No other
local tool provides this.

## Data Required

All exists today:
- `resource_state_events` (opened/closed/merged/reopened)
- `resource_label_events` (label add/remove)
- `resource_milestone_events` (milestone add/remove)
- `merge_requests` (merged_at for merge events)
- `issues` (created_at for new issues)
- `discussions` (last_note_at for active discussions)

## Implementation Sketch

```
1. Parse --since into ms epoch timestamp
2. Query each event table WHERE created_at >= since
3. Query new issues WHERE created_at >= since
4. Query merged MRs WHERE merged_at >= since
5. Query active discussions WHERE last_note_at >= since
6. Group all events by project
7. Within each project, sort by: state changes first, then merges, then labels
8. Format as human-readable sections or robot JSON
```

### SQL Queries

```sql
-- State changes in window
SELECT rse.*, i.iid as issue_iid, mr.iid as mr_iid,
       COALESCE(i.title, mr.title) as title,
       p.path_with_namespace
FROM resource_state_events rse
LEFT JOIN issues i ON rse.issue_id = i.id
LEFT JOIN merge_requests mr ON rse.merge_request_id = mr.id
JOIN projects p ON rse.project_id = p.id
WHERE rse.created_at >= ?1
ORDER BY rse.created_at DESC;

-- Newly merged MRs
SELECT mr.iid, mr.title, mr.author_username, mr.merged_at,
       p.path_with_namespace
FROM merge_requests mr
JOIN projects p ON mr.project_id = p.id
WHERE mr.merged_at >= ?1
ORDER BY mr.merged_at DESC;

-- New issues
SELECT i.iid, i.title, i.author_username, i.created_at,
       p.path_with_namespace
FROM issues i
JOIN projects p ON i.project_id = p.id
WHERE i.created_at >= ?1
ORDER BY i.created_at DESC;
```

## Human Output Format

```
=== What Changed (last 7 days) ===

group/backend (12 events)
  Merged:
    !234  Refactor auth middleware          (alice, 2d ago)
    !231  Fix connection pool leak          (bob, 5d ago)
  Closed:
    #89   Login timeout on slow networks    (closed by alice, 3d ago)
  Opened:
    #95   Rate limiting returns 500         (charlie, 1d ago)
  Labels:
    #90   +priority::high                   (dave, 4d ago)

group/frontend (3 events)
  Merged:
    !45   Update dashboard layout           (eve, 6d ago)
```

## Robot Mode Output

```json
{
  "ok": true,
  "data": {
    "since": "2025-01-20T00:00:00Z",
    "projects": [
      {
        "path": "group/backend",
        "merged": [ { "iid": 234, "title": "...", "author": "alice" } ],
        "closed": [ { "iid": 89, "title": "...", "actor": "alice" } ],
        "opened": [ { "iid": 95, "title": "...", "author": "charlie" } ],
        "label_changes": [ { "iid": 90, "label": "priority::high", "action": "add" } ]
      }
    ],
    "summary": { "total_events": 15, "projects_active": 2 }
  }
}
```

## Downsides

- Can be overwhelming for very active repos; needs `--limit` per category
- Doesn't capture nuance (a 200-comment MR merge is more significant than a typo fix)
- Only shows what gitlore has synced; stale data = stale digest

## Extensions

- `lore digest --author alice` — personal activity digest
- `lore digest --project group/backend` — single project scope
- `lore digest --format markdown` — paste-ready for Slack/email
- Combine with weekly-digest for scheduled summaries
