Repository navigation
fix(api): create the two tables three live features were built on, retire the third route - #741
Merged
Merged
Conversation
…tire the third route Closes #658, and with it the schema half of #660: BASELINE_BROKEN is empty. Three routers read tables that never existed. The issue said each needed a decision, not a rename, and the deciding evidence was the same question for all three — does anything reach this? **core.soft_skills_ratings — created.** Four routes, four SDK methods, four hooks, and THIRTEEN components: the profile radar, comparison and history widgets, the rating form, the skills-analytics widgets, the office job-form section, and both discover-jobs panes. A whole feature written against a table that was designed and never migrated. The shape is read off the router, not invented: versioned self-assessments where each PATCH writes max(version)+1, /history reads every version, /comparison reads the latest. Append-only by design, so no UPDATE or DELETE for the user — a corrected assessment is a new version and the old one stays in the timeline. UNIQUE (user_id, skill_id, version), rating CHECK 1..5 to match the route's zod, FK to core.soft_skills RESTRICT because the taxonomy retires by is_active, not by delete. lib/skill-snapshots.ts, which the issue worried was a second half-built version of the same idea, is not: it is pure arithmetic over core.skill_snapshots, a different and existing table. **core.profile_import_data — created.** GET/POST/DELETE, three hooks, ImportReviewScreen at /profile/resume/review, linked from the drawer. One staged import per user awaiting review, with the 24h expiry the route already enforces. UNIQUE (user_id): the route does delete-then-insert to keep one row, but that pair is not atomic, so the invariant is now the database's — a concurrent second save fails with 23505 instead of leaving two rows for GET's .limit(1).single() to pick between. **core.profile_completion_nudges — NOT created; the route is retired.** One route, one SDK method, one hook, and nothing behind the hook: no component imported useDismissNudgeMutation, and the three other "nudge" hits in the tree are prose about application next-steps. The upsert also named no onConflict target, so with a UUID primary key every "dismiss" would have inserted a fresh row — it was never a working upsert. Per #660's method, an endpoint no screen can reach does not get a table built for it. Scaffald/sdk#25 retires the method, types and mock-backed test. RLS follows the house rule for each kind of data. Ratings copy skill_snapshots_select: own rows, or anyone's when that profile's skills are visible — GET /soft takes ?userId= precisely so an employer can view a candidate's, through the request client. (user_skills_select_public has the same intent and compares prefs.user_id to itself, a tautology; the form here is the correct one.) Staging is own-rows-only for every operation; it is never public. Verified rather than trusted, all against the local stack: constraints every CHECK, UNIQUE and FK tried and rejected (verify354) live routes 14/14 — scripts/audit/test-658.mjs GET /soft 500 -> 200; PATCH writes v1 then v2 as a new version; history returns both; comparison 200; rating 9 rejected; import GET null -> POST 201 -> GET with expiry -> second POST replaces, exactly one row -> DELETE; nudges/dismiss 404; /completion/status still 200 RLS 5/5 — scripts/audit/test-658-rls.mjs, through PostgREST with two real sessions, not emulated JWT claims schema guard 6/6, BASELINE_BROKEN empty deno check profile-completion.ts 4 errors -> 3 (remainder pre-existing) typecheck 12/12 test:unit 8/8 lint 10/10 types.ts regenerated: only additions, application_status still correctly absent (#736). SDK pointer: e28fa9c..759b7ec.
Contributor
📊 Performance Benchmark Results |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #658 — and with it the schema half of #660.
BASELINE_BROKENis empty.Three routers read tables that never existed. The issue said each needed a decision, not a rename. The deciding evidence turned out to be the same question for all three: does anything actually reach this?
core.soft_skills_ratings— createdFour routes, four SDK methods, four hooks, and thirteen components: the profile radar, comparison and history widgets, the rating form, the skills-analytics widgets, the office job-form section, both discover-jobs panes. A whole feature written against a table that was designed and never migrated.
The shape is read off the router, not invented — versioned self-assessments where each
PATCHwritesmax(version)+1,/historyreads every version,/comparisonreads the latest. Append-only by design, so no UPDATE or DELETE for the user: a corrected assessment is a new version and the old one stays in the timeline.UNIQUE (user_id, skill_id, version)rating CHECK 1..5skill_id→soft_skillsRESTRICTis_active, not by delete; history must not lose rowslib/skill-snapshots.ts, which the issue worried was a second half-built version of the same idea, is not — it's pure arithmetic overcore.skill_snapshots, a different and existing table.core.profile_import_data— createdGET/POST/DELETE, three hooks,ImportReviewScreenat/profile/resume/review, linked from the drawer. One staged import per user awaiting review, with the 24h expiry the route already enforces.UNIQUE (user_id): the route does delete-then-insert to keep one row, but that pair isn't atomic. The invariant is now the database's — a concurrent second save fails with23505instead of leaving two rows forGET's.limit(1).single()to pick between.core.profile_completion_nudges— not created; the route is retiredOne route, one SDK method, one hook — and nothing behind the hook. No component imported
useDismissNudgeMutation; the three other "nudge" hits in the tree are prose about application next-steps, a different concept.It was also never a working upsert: the call named no
onConflicttarget, so with a UUID primary key every "dismiss" would have inserted a fresh row rather than recording one.Per #660's method, an endpoint no screen can reach does not get a table built for it. Scaffald/sdk#25 retires the method, its types, and its mock-backed test.
RLS follows the house rule for each kind of data
Ratings copy
skill_snapshots_select— own rows, or anyone's when that profile's skills are visible.GET /softtakes?userId=precisely so an employer can view a candidate's, through the request client. (user_skills_select_publichas the same intent but comparesprefs.user_idto itself — a tautology; the form here is the correct one.)Staging is own-rows-only for every operation. Never public.
Verified rather than trusted
All against the local stack.
The live probe, specifically:
The RLS probe uses two real signed-in sessions through PostgREST. My first attempt emulated JWT claims in psql, which is not how
auth.uid()reads them — it printedSETfor every check, which is not an answer. Worth knowing for the next person.types.tsregenerated: only additions;application_statusstill correctly absent (#736).🤖 Generated with Claude Code