From a064933c1f5fa770aba61659727c5ca99e563256 Mon Sep 17 00:00:00 2001 From: Benjamin Admin Date: Wed, 10 Jun 2026 16:10:34 +0200 Subject: [PATCH] docs(master-controls): list all 4 seeded mapping tables + sentinel caveat The guard probes mc_use_case_mappings as the existence sentinel, but the route also queries mc_verification, mc_regulations and mc_use_case_sync_state. Document that they are seeded together and that a half-seeded DB (sentinel present, a sibling missing) still 500s on the sibling's queries. Co-Authored-By: Claude Opus 4.7 --- .../app/api/sdk/v1/master-controls/route.ts | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/admin-compliance/app/api/sdk/v1/master-controls/route.ts b/admin-compliance/app/api/sdk/v1/master-controls/route.ts index 6c443e29..214f821b 100644 --- a/admin-compliance/app/api/sdk/v1/master-controls/route.ts +++ b/admin-compliance/app/api/sdk/v1/master-controls/route.ts @@ -15,10 +15,13 @@ const pool = new Pool({ connectionString: dbUrl }) let metaCache: { at: number; data: unknown } | null = null const META_TTL_MS = 120_000 -// The use-case mapping tables (mc_use_case_mappings/mc_verification/mc_regulations) -// are seeded per-environment and may not exist yet on a fresh/unseeded DB. Guard -// every mapping query so the route degrades to empty filters instead of a 500. -// Cached with a short TTL so it picks up the tables once that DB gets seeded. +// The use-case mapping tables (mc_use_case_mappings, mc_verification, +// mc_regulations, mc_use_case_sync_state) are seeded together per-environment +// and may not exist yet on a fresh/unseeded DB. We probe mc_use_case_mappings as +// the existence sentinel and guard every mapping query so the route degrades to +// empty filters instead of a 500. Short TTL so it picks up the tables once seeded. +// NB: the sentinel assumes the siblings are seeded together — a half-seeded DB +// (mappings present but e.g. mc_regulations missing) would still 500 on those. let mappingTablesCache: { at: number; present: boolean } | null = null async function hasMappingTables(): Promise { if (mappingTablesCache && Date.now() - mappingTablesCache.at < 300_000) {