Opus finding
loadCrossRepoReceipts orders by mergedAt DESC NULLS LAST but the type guarantees mergedAt is non-null for merged rows — NULLS LAST is dead code that hides invariant violations
lowmaintainabilitymedium
- apps/web/lib/receipts.ts:135-155
Since status='merged' rows are expected to have non-null mergedAt, `NULLS LAST` is meaningless under the intended invariant and quietly hides any rows that violate it (they'd sort to the end and may get cut by LIMIT). Combined with the lack of a CHECK constraint (above), this is a defensive but silent mask.
Recommendation
Either add a CHECK constraint making NULLS LAST unreachable, or log a warning when the loader observes null mergedAt for a status='merged' row.