Problem
PostgreSQL authority recovery paths perform N+1 work at supported bounds: export fetches referenced generations one query per distinct receipt generation, while restore awaits individual INSERTs for receipt/session/security-event rows. A large canonical restore can issue tens of thousands of round trips inside one transaction.
Acceptance criteria
- Export fetches all referenced generations with one bounded JOIN/ANY query.
- Restore uses set-based INSERT/UNNEST or bounded batches inside the same transaction.
- Identity, digest, watermark, receipt replay, and maintenance-fence invariants remain unchanged.
- Tests exercise documented maximum-domain shapes and demonstrate bounded query count.
Evidence
Review anchors: packages/core/src/storage/sql/authority.ts around PostgreSQL export (~2378) and restore (~2498).
Problem
PostgreSQL authority recovery paths perform N+1 work at supported bounds: export fetches referenced generations one query per distinct receipt generation, while restore awaits individual INSERTs for receipt/session/security-event rows. A large canonical restore can issue tens of thousands of round trips inside one transaction.
Acceptance criteria
Evidence
Review anchors: packages/core/src/storage/sql/authority.ts around PostgreSQL export (~2378) and restore (~2498).