Opus finding
loadCrossRepoReceipts total count includes merged rows missing mergedAt/mergeSha — UI count can drift from displayed rows
- apps/web/lib/outgoing-prs.ts:192-245
The displayed `recent` list filters out merged rows that have null mergedAt or null mergeSha (a defensive guard). However, the `total` value is a raw COUNT(*) over status='merged' which does NOT apply the same filter. If a row ever reaches status='merged' without both fields (e.g. a partial write, or a future state in markMerged that gets interrupted), the page's total will overstate what's actually displayable. Today markMerged is the only writer of status='merged' and it sets both fields atomically in one UPDATE, so divergence requires a future bug or manual SQL. Still, the invariants should match: either both should filter, or the schema should NOT NULL the fields when status='merged' (CHECK constraint).
Recommendation
Either (a) make the COUNT query include `AND merged_at IS NOT NULL AND merge_sha IS NOT NULL`, or (b) add a CHECK constraint at the DB level enforcing the invariant when status='merged'.