Repository navigation
Description
Rollup for a full trace of the API surface: every KNOWN_GAPS route traced to the screen that calls it, and every .from() in every route file checked against the schema.
Two independent failure modes came out of it, and they are worth separating because only one of them is visible to any existing test.
1. Routes that call tables which do not exist — 45 references, 24 names, 14 files
Invisible to the contract test, to typecheck and to the API suite. A wrong table name is indistinguishable from an empty result unless somebody happens to load the page. This has been found one endpoint at a time for months (#476, #481, #482, #618) and each instance looked like an isolated typo.
Guard, so it stops growing: #651 — parses every .from() against the checked-in generated types, fails on anything new, and fails again when a fixed entry is left in the baseline.
Ordered by consequence
| issue | why it is where it is | |
|---|---|---|
| P0 | #652 | CCPA disclosure reports hasData: false to a user with 14 records. Statutory. |
| P0 | #653 | Admin delete-user leaves certifications, applications and reviews behind, and returns success. |
| P1 | #654 | core.review_links grants only postgres — breaks review collection end to end, including the emailed link. One migration. |
| P1 | #655 | Org member list 500s; core.organization_members was never created. Membership is role_assignments.scope_org_id. |
| P1 | #657 | Wrong-schema cluster: webhooks, team job assignments, three office admin routes. Mechanical. |
| P1 | #656 | The whole /v1/onet router reads core.onet_*; the 40-table onet schema is seeded and unreachable. |
| P2 | #658 | Three routers built on tables that were never created — soft-skill history (8 refs), profile import (5), completion nudges. Needs decisions, not renames. |
| P2 | #659 | /v1/user-profiles/{userId} 500s on an unknown id instead of 404. |
| P2 | #618 | /v1/profiles/employers/{slug} queries core.employers; no consumer. Probably delete. |
Dependency
#651 (guard, merged first — everything else removes entries from its baseline)
├── #652, #653 ← independent, highest consequence, do first
├── #654 ← one migration, unblocks review links
├── #655 ─── depends on nothing; reuse lib/org-access.ts from #617
├── #657, #656 ← mechanical renames, parallelisable
└── #658, #659, #618 ← each needs a product decision first
#652 and #653 share a root cause with #657 but are listed separately because their consequence is not "an endpoint 500s" — it is a compliance statement and a data-deletion guarantee that are both wrong while appearing to work.
2. SDK contract gaps — 59, of which 16 are user-visible
Full tracing posted on #447. Every gap resolved to the UI that calls it through a parsed import graph.
| verdict | count |
|---|---|
| MOUNTED — a routed screen calls it and gets an error | 16 |
| UNMOUNTED — a component calls it, no screen renders that component | 5 |
| NO_CONSUMER — a hook exists, nothing imports it | 28 |
| NO_HOOK — an SDK method exists, no hook wraps it | 10 |
43 of 59 have no product behind them. The recommendation is to retire that SDK surface rather than implement it — building it ships endpoints nothing can call. Four gaps were closed this way already (#616, #617) by tracing first and implementing only what a screen actually calls.
What is genuinely solid
Worth stating, because the list above reads as a teardown and the surface is mostly healthy:
- 313 registered routes; only 21 have no SDK caller. The API and the SDK are well matched — this is not a sprawling surface with a thin client.
- Of 165 literal GET routes probed live, 152 answered correctly. The failures are concentrated in a handful of files, not spread across the codebase.
- The routes that were repaired during this work — reviews, skills analytics, work logs, organizations — held up under live probing including their authorization boundaries.
- The schema itself is fine. In almost every case the data exists and is correctly modelled; the route is looking in the wrong place.
Method
The tracer was wrong twice before it was right, in both directions, so the numbers above are the ones that survived validation against nine hand-verified cases. Details of the failure modes and the fixes are on #447 and #651 — worth reading before trusting any similar sweep.
Activity
thinkclay commentedon Aug 27, 2026
#652 and #653 are done — #663 (merged).
One correction to this epic: #653's description was wrong. I claimed the broken deletes leave data behind and report success. Every one of those tables cascades from
core.users, verified in a rolled-back transaction, so the deletion happens anyway. The real defect is that ten RESTRICT/NO ACTION references block the final delete after the two working hand-deletes have already run — so the endpoint destroys a user's skills and profile and then reports failure. Retitled and corrected on the issue.Both P0s shared a root cause worth knowing before touching the rest of this epic: a head-count against an unreadable table returns
{status: 204, error: null, count: null}. No error is raised, socount ?? 0reports a confident zero — and checkingerrorinstead does not fix it.count === nullis the only dependable signal. Any of the remaining issues that count rows will hit this.Schema guard baseline is down 45 → 33 references, 24 → 13 table names.
New issue from the work: #665 — the
/v1/feedbackrouter queries.schema("logs"), which PostgREST does not expose and which grants onlypostgres. Note the #651 guard cannot catch that class, since it skips schemas absent fromtypes.tsandlogsis absent precisely because it is unexposed.Next by consequence: #654 (one migration, unblocks review links end to end), then #655.
fix(api): the CCPA disclosure under-reported, and delete-user destroy…
thinkclay commentedon Aug 27, 2026
#654 and #655 are done — #667 (merged). Epic status: 4 of 9 closed.
Two things worth carrying into the remaining issues.
review_linksneeded policies, not just grants. The table had RLS enabled and no policies at all, so the grant alone would have left it failing closed. Migration 347 adds four owner-scoped policies alongside the grants. If #481's remaining tables are the same shape, a grants-only migration will not be enough there either — checkpg_policiesper table, not justrole_table_grants.RLS can make a wrong fix look right.
core.role_assignmentscarries one policy —user_id = auth.uid()— so the first version of the members list returned a one-member organization out of fifteen, with a 200 and a plausible-looking body. It needed the service client behindcanReadOrgInternals. Anything in this epic that lists other people's rows will hit the same trap, and it does not announce itself.Also fixed in passing, both found only by probing rather than reading:
GET /v1/reviews/linksselected with nosubject_user_idfilter, leaning entirely on a policy that did not exist.firstOfwas referenced by the new members handler but defined privately inwork-logs.ts; it typechecks and throws at runtime. Nowlib/postgrest.ts.Schema guard baseline: 45 → 32 references since this epic opened.
Migration 347 is applied locally only — it needs applying to dev/preview/prod with the next deploy.
Remaining: #657 and #656 (mechanical renames, parallelisable), then #658, #659, #618, #665 (each needs a product decision).
fix(api): type the middleware context, so 2,056 of the API's 2,467 ty…
fix(api): five routers addressed tables that do not exist, and one te…
fix(api): five routers addressed tables that do not exist, and one te…
fix(api): type the middleware context, so 2,056 of the API's 2,467 ty…
fix(api): five routers addressed tables that do not exist, and one te…
fix(api): five routers addressed tables that do not exist, and one te…
thinkclay commentedon Sep 10, 2026
Pointing at #728 — the iOS/Android store readiness epic — because this issue is now on its critical path rather than being general API-correctness work.
Two of its children were re-verified today against the running stack:
Both stores exercise the app during review, so a core screen returning 500 is a rejection risk. #476 additionally makes part of #690 unreachable: the per-message report control the stores require shipped and is correct, but the inquiry screen it renders on cannot load.
#728 sequences this epic first, on the reasoning that landing the schema work here may resolve #476, #482 and #658 together rather than three separate fixes. If that reading of the scope is wrong, say so on #728 and I will re-sequence.
thinkclay commentedon Sep 10, 2026
Deployed and verified across all three environments.
Functions and migrations were a month apart — the api edge function had not shipped since 2026-08-12, while migrations 348–350 were unapplied everywhere. Deploying functions first would have shipped broken endpoints, since
feedback.tsnow readscore.user_feedback(350) andmoderation.tsreadscore.content_reports/user_blocks(349). Migrations went first in each environment.Pre-flight on 348, which deletes duplicate
role_assignmentsrows before adding its unique constraint — it would have been a destructive change on production authorization data:No duplicates anywhere, so it was purely additive.
Migrations — 337, 347, 348, 349, 350, 351 applied and recorded. All three ledgers now read
unrecorded: 0. Dev had genuinely never had 337: preview and prod each had 6 notification cron jobs, dev had 0. It does now.Functions — all three on
cf5d17f88, smoke green (dev 5/5, preview 11/11, prod 7/7).The fixes, verified end to end against dev and preview with a real authenticated user:
/ccpa/data-summary/reviews/links/feedback/user-feedback/moderation/blocks/work-logs/public-feedThe CCPA 200 is the meaningful one: after #663 a failed count fails the request, so a 200 proves all thirteen counts resolved — every table and every filter column. Before this session it returned 200 while silently reporting zero.
Production was verified at the schema level rather than by creating an account in a live auth system: every table and column the CCPA handler reads confirmed present,
core.employersconfirmed gone, review-link grants confirmed onauthenticatedandservice_role.Three commits have landed on main since (#724, #726, #729) — all docs and CI, nothing under
supabase/functionsorsupabase/migrations, so the deployed commit is functionally current.fix(types): regenerate types.ts — the local database was right, not d…
fix(inquiries): delete two phantom routes, and stop 404ing the thread…
thinkclay commentedon Sep 10, 2026
Progress on the schema half. Two landed today.
#707 first, because the guard could not be trusted to measure anything else while three of its seven baseline entries described a stale catalogue rather than broken routes. That issue said regenerating
types.tslocally "silently deletes theapplication_statusenum" and treated it as local drift. The causality was backwards: migration 344 dropped that enum on purpose five migrations ago, because it was never used and its vocabulary was not the app's. The local database was right;types.tswas stale in the other direction. Regenerated after diffing to a temp file — the only removal across 271 diff lines is that enum (#736).Then #476. Two faults in one file, and only one was the one on the tin:
GET /andPOST /readcore.inquiries. Not a rename — the list filtered onsender_id/recipient_id, the create sentsubject/message/inquiry_type, none of which exist oncore.application_inquiries. Nothing called them, so they were deleted per this epic's own method, along with the two SDK methods (fix(inquiries): retire list() and create(), which called a table that never existed sdk#23).GET /by-application/{applicationId}— the real thread screen — 404'd for employers.checkApplicationAccessreadcore.applicationswith the request client, and RLS does not expose an org's applications to its staff. Same fault fix(api): an org admin 404'd on an application their own list returned #608/fix(api): an org admin passed both auth checks and then 404'd anyway #649 fixed inemployer-applications.ts. Fixing only that produced a 200 with a null body, because the inquiry and all its children were read the same way (fix(inquiries): delete two phantom routes, and stop 404ing the thread screen #738).Baseline now
So the schema half of this epic is #658 and nothing else — and #658 is the one the issue body already flags as needing product decisions rather than renames.
Two things for whoever takes it:
fix(api): create the two tables three live features were built on, re…
thinkclay commentedon Sep 10, 2026
The schema half of this epic is complete. #741 landed #658, and
BASELINE_BROKENin the #651 guard is now empty:Every route in the API now reads a table that exists. Because the guard's second assertion demands stale entries be removed, the baseline can only go down, and anything that appears in it from here is a regression rather than inherited debt.
Three things from the last stretch worth recording against the method section:
core.inquiries(fix(api): core.inquiries does not exist, so GET/POST /v1/inquiries always 500 #476) andcore.profile_completion_nudges(Three routers are built on tables that were never created #658) both had routes nothing reached. Tracing to the consumer before building saved two tables that would have served endpoints no screen calls — exactly the recommendation this epic makes for the SDK half.Inquiries.list()/create()and one coveringdismissNudge()passed for as long as they existed while the endpoints 500'd. A fixture that invents the endpoint cannot fail when the endpoint is missing.What remains is the SDK contract half — #447. Untouched by this stretch except for two live MOUNTED gaps reported there (
/v1/inquiries/templatesand/{id}/history, both called by hooks on the thread screen) and four methods retired by deletion.One caveat on "every route reads a real table": the guard checks table names only. #482's remaining half — a route selecting five columns that don't exist on a table that does — is outside its reach and still open.
thinkclay commentedon Sep 11, 2026
Part 1 of this epic is complete.
BASELINE_BROKENintable-references-exist.test.tsis empty, and the test fails on a stale entry as well as a new one — so it can only stay empty.The count in the title was 45 references across 24 names and 14 files. All of them are resolved:
onetschema, including the skills endpoint, which needed more than a renameTwo things worth recording, because both were not what the sweep recorded and would have been re-derived otherwise:
#657's fifth row was never a defect.
office-communities.ts:146already read.schema("core").from("users"). The guard reportedcommunity.usersbecause its parser buffers to the next semicolon and takes the first.schema()in the statement — and that line sits in aPromise.all([...])whose first element is.schema("community"). One statement, two chains, one schema. The parser now takes the nearest.schema()preceding each.from(), with a regression test.#482 was half-done and half-mis-scoped. The employers half went with #618. The organizations half had already been repaired at the select by #617 — but the response schema above it was never updated, so the endpoint answered 200 while its published contract was wrong in six ways:
descriptionandindustryare objects declared as strings,size/location/founded_yearexist in no table in any schema, andaddresswas returned undeclared. Nothing caught it because@hono/zod-openapidocuments rather than validates, and the SDK's msw handler hand-wrote the declared shape — so the tests asserted against a response the API cannot produce.That last pattern is worth generalising, since it has now produced three wrong contracts that a green suite certified (#618's employers, #482's organizations, and the envelope defect in #744): a mock written from the type can never catch a mismatch between the type and the API.
Part 2 remains
#447 — the SDK contract half,
KNOWN_GAPScurrently at 60. Actively in progress; two more live MOUNTED gaps were identified there today. Not touched from here to avoid duplicating that work.#744 was filed out of #482: two of the three public profile routes wrap in
{ data }and one does not, while the SDK declares all three bare. It is the same silent-drift class as this epic but needs a public-API decision rather than a fix.thinkclay commentedon Sep 15, 2026
Closing the epic: every phantom-schema child (#651–#659, #476, #481, #482, #616–#618) is closed. #447 (SDK/api contract drift) stays open on its own.