# Metrics & Integration Automations

Data collection, validation, and dashboard integration.

## Scripts

| Script | Source | Purpose |
|--------|--------|---------|
| `backfill_retro.py` | `../../scripts/backfill_retro.py` | Seed retrospective data from Gitea history |
| `pre_commit_checks.py` | `../../scripts/pre_commit_checks.py` | CI hygiene validation |

## Backfill Retrospective

One-time script to populate `.loop/retro/` from Gitea merged PRs:

```bash
python3 scripts/backfill_retro.py
```

This seeds the cycle retrospective log so the LOOPSTAT panel isn't empty on new setups.

## Pre-commit Checks

Runs automatically before commits to catch common issues:

- ImportError regressions
- Model name assertions
- Platform-specific path issues
- Syntax errors in test files
- Black formatting

```bash
# Run manually
python3 scripts/pre_commit_checks.py

# Or via pre-commit hook
bash scripts/pre-commit-hook.sh
```

## Dashboard Integration

Metrics automations write to:

| File | Purpose |
|------|---------|
| `.loop/retro/cycles.jsonl` | Cycle retrospective log |
| `.loop/retro/summary.json` | Rolling statistics |
| `.loop/retro/insights.json` | Introspection recommendations |
| `.loop/automation_state.json` | Current automation states |

These feed the Mission Control dashboard at `/mission-control`.
