docs: sync from backend 885745e — db audit wave 3

This commit is contained in:
Siavash Sameni
2026-06-06 21:27:10 +04:00
parent dd23f013ad
commit d8121b549b
2 changed files with 24 additions and 0 deletions

View File

@@ -11,6 +11,16 @@ entries on top. Maintained by agents per the rule in `../AGENTS.md`.
---
### 2026-06-06 — backend@61aa42a/885745e, frontend@c9e9ccf — DB audit Wave 3 points/referral consistency
**Commits:** `61aa42a` `885745e` `c9e9ccf`
**Touched:** backend `src/services/points/PointsService.ts`, `src/db/repositories/drizzle/DrizzlePointsRepo.ts`, `src/db/repositories/interfaces/IPointsRepo.ts`, `__tests__/points-referral-reward.test.ts`, `scripts/smoke/db-audit-service-regressions.sh`, `package-lock.json`; medium-batch files from `61aa42a`; frontend `package.json`; docs `09 - Audits/DB Query & Schema Audit - 2026-06-06.md`
**Why:** Continue the 8-wave Critical/High plan. Wave 3 closes H11/H12/H26 by moving referral rewards to one serializable repo mutation that commits points, referralStats, and the ledger row together; the docs also catch up the pushed `61aa42a` medium batch.
**Verification:** backend `npm test -- --runTestsByPath __tests__/points-referral-reward.test.ts --runInBand`, `BASE_URL=http://127.0.0.1:5001 scripts/smoke/db-audit-service-regressions.sh` (14 suites / 38 tests), `npm run typecheck`, `git diff --check`; frontend `git diff --check` for package bump. Pushed to Forgejo; `origin` remained unavailable and was intentionally skipped.
**Linked docs updated:** [[09 - Audits/DB Query & Schema Audit - 2026-06-06]]
---
### 2026-06-06 — backend@2abba67/3955430, frontend@698c4d7 — DB audit Wave 2 missing indexes
**Commits:** `2abba67` `3955430` `698c4d7`

View File

@@ -51,6 +51,20 @@ updated: 2026-06-06
| H39: `fundsLedgerEntries` missing composite indexes on `(paymentId,entryType)`, `(purchaseRequestId,entryType)`, `occurredAt` → migration `0021_missing_indexes.sql` | `2abba67` v2.9.19 |
| H41: `purchase_requests` missing composite index `(buyerId,status)`, `seller_offers` missing `(status,createdAt)` and `(sellerId,status)` → schema + migration `0021_missing_indexes.sql` | `3955430` v2.9.19 |
| H42: `seller_offers` missing partial index on `validUntil` for expiry sweeper queries → schema + migration `0021_missing_indexes.sql` | `3955430` v2.9.19 |
| M1: Request Network reconciliation serial per-payment HTTPS loop → bounded parallel status fetches with sequential DB application | `61aa42a` v2.9.20 |
| M3: `findPaymentById` payment + buyer + seller SELECTs → one joined payment/user query | `61aa42a` v2.9.20 |
| M4: `mirrorQuoteToPaymentMetadata` find-then-update → single JSONB metadata merge UPDATE | `61aa42a` v2.9.20 |
| M10: `ChatService.addParticipant` per-user validation loop → `userRepo.findManyByIds` batch lookup | `61aa42a` v2.9.20 |
| M20: delivery attempt delivery-info lookup + insert/select → single `INSERT ... SELECT` and joined list query | `61aa42a` v2.9.20 |
| M22: `findPgUsersByQuery` unbounded SELECT → 1000-row safety cap | `61aa42a` v2.9.20 |
| M23: `BlogService.getAllPosts` default limit 100 → default limit 20 | `61aa42a` v2.9.20 |
| M29: `payments.metadata->>'legacyOrderId'` path lacked index → partial functional index in migration `0022_more_indexes.sql` | `61aa42a` v2.9.20 |
| M34: `derived_destinations` missing `(buyerId,chainId)` index → schema index + migration `0022_more_indexes.sql` | `61aa42a` v2.9.20 |
| M37: `point_transactions` source-only queries could not use `(type,source)` index → `idx_pt_source` schema index + migration | `61aa42a` v2.9.20 |
| M42: `createPointTransaction` read-then-insert idempotency check → `onConflictDoNothing` upsert with conflict fetch | `61aa42a` v2.9.20 |
| H11: `processReferralReward` duplicate referrer snapshot reads → reuse atomic reward result for socket payload and return value | `885745e` v2.9.20 |
| H12: `updateReferralStats` count/update outside a transaction → serializable row-lock transaction | `885745e` v2.9.20 |
| H26: `processReferralReward` independent points + referralStats writes → one idempotent `grantReferralReward` transaction for points, referralStats, and ledger row | `885745e` v2.9.20 |
---