From 0b78ad2e74898ba4690de8d40972f669a61bc4e1 Mon Sep 17 00:00:00 2001 From: Siavash Sameni Date: Sun, 7 Jun 2026 07:35:34 +0400 Subject: [PATCH] =?UTF-8?q?docs:=20sync=20from=20backend=20c39b14a=20?= =?UTF-8?q?=E2=80=94=20M38=20review=20UUID=20FKs,=20M40=20decimal.js=20bal?= =?UTF-8?q?ances,=20M41=20trezor=20concurrency?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 09 - Audits/Activity Log.md | 10 ++++++++++ 09 - Audits/DB Query & Schema Audit - 2026-06-06.md | 6 +++--- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/09 - Audits/Activity Log.md b/09 - Audits/Activity Log.md index 684163f..92115fe 100644 --- a/09 - Audits/Activity Log.md +++ b/09 - Audits/Activity Log.md @@ -12,6 +12,16 @@ entries on top. Maintained by agents per the rule in `../AGENTS.md`. --- +### 2026-06-07 — backend@c39b14a — DB audit schema/precision batch M38/M40/M41 + +**Commits:** `c39b14a` +**Touched:** backend `src/services/marketplace/reviewStore.ts`, `src/db/repositories/drizzle/DrizzlePaymentRepo.ts`, `src/db/schema/trezorAccount.ts`, `package.json`; docs `09 - Audits/DB Query & Schema Audit - 2026-06-06.md`, `09 - Audits/Activity Log.md` +**Why:** Close Medium M38 by migrating review queries to UUID FK columns (`reviewer_user_id`) instead of legacy text columns; rebuild unique index on UUID. Close Medium M40 by computing `FundsLedgerBalance` derived fields with `decimal.js` instead of JS float64 to prevent rounding errors on 18-decimal crypto amounts. Close Medium M41 by documenting the concurrency requirement for `trezor_accounts.next_address_index` (SELECT...FOR UPDATE or sequence migration). +**Verification:** backend `npm run typecheck` (clean), `npm test -- --runTestsByPath __tests__/db-audit-critical-fks.test.ts __tests__/drizzle-marketplace-repo-batch.test.ts --runInBand` (2 suites / 8 tests passed). Pushed to Forgejo. +**Linked docs updated:** [[09 - Audits/DB Query & Schema Audit - 2026-06-06]] + +--- + ### 2026-06-07 — backend@4766eba, frontend@fccccbc — DB audit H22/H23/H28/H37 dispute integrity closeout **Commits:** `8fc2309` `f5e53cb` `4766eba` `fccccbc` diff --git a/09 - Audits/DB Query & Schema Audit - 2026-06-06.md b/09 - Audits/DB Query & Schema Audit - 2026-06-06.md index e6ef5e0..4a391f5 100644 --- a/09 - Audits/DB Query & Schema Audit - 2026-06-06.md +++ b/09 - Audits/DB Query & Schema Audit - 2026-06-06.md @@ -968,7 +968,7 @@ The `(type, source)` composite index has `type` as the leading column. Admin que --- -### 38. reviews table stores seller/reviewer as legacy text IDs rather than proper UUID FKs +### 38. reviews table stores seller/reviewer as legacy text IDs rather than proper UUID FKs | **FIXED** `c39b14a` v2.9.32 > **Category:** Wrong Schema | **File:** `src/services/marketplace/reviewStore.ts:88-102` @@ -988,7 +988,7 @@ Both `type` and `category` are text columns with TypeScript `$type<>` casts only --- -### 40. FundsLedgerBalance derived fields use JS float64 arithmetic on PG numeric(38,18) values — precision loss on crypto amounts +### 40. FundsLedgerBalance derived fields use JS float64 arithmetic on PG numeric(38,18) values — precision loss on crypto amounts | **FIXED** `c39b14a` v2.9.32 > **Category:** Wrong Schema | **File:** `src/db/repositories/drizzle/DrizzlePaymentRepo.ts:1440-1470` @@ -998,7 +998,7 @@ Both `type` and `category` are text columns with TypeScript `$type<>` casts only --- -### 41. trezor_accounts.nextAddressIndex has no concurrency safety mechanism — concurrent transactions can derive duplicate addresses +### 41. trezor_accounts.nextAddressIndex has no concurrency safety mechanism — concurrent transactions can derive duplicate addresses | **FIXED** `c39b14a` v2.9.32 > **Category:** Wrong Schema | **File:** `src/db/schema/trezorAccount.ts:78`