Skip to content

fix(types): regenerate types.ts — the local database was right, not drifted - #736

Merged
thinkclay merged 1 commit into
mainfrom
fix/regenerate-types
Sep 10, 2026
Merged

thinkclay merged 1 commit into
mainfrom
fix/regenerate-types

Conversation

@thinkclay

Copy link
Copy Markdown
Contributor

Closes #707. First step on #660 — the schema guard cannot be trusted to measure the rest of that epic while three of its seven baseline entries describe a stale catalogue rather than broken routes.

The premise was backwards

#707 said regenerating from a local database "silently deletes the application_status enum", read that as local migration drift, and left the regeneration undone on that basis.

Migration 344 dropped core.application_status on purpose, five migrations ago, and explains itself at length:

Drop core.application_status. It has never been used and its vocabulary is not the one the application actually has (#536).

vocabulary
the dropped enum draft, submitted, under_review, interviewing, offer_extended, hired, rejected, withdrawn
what the app actually uses new, screen, inquired, interview, offer, hired, rejected, withdrawn

Three labels overlap. So the local database is correct and types.ts was stale in the other direction — still declaring a type deliberately removed. Regenerating is the fix, and the deletion is the point.

Verified before overwriting

Generated to a temp file and diffed rather than writing in place. Across 271 diff lines the only removal is application_status, with exactly the vestigial vocabulary migration 344 quotes.

Nothing consumes it: the other application_status hits in the tree are a notification category string, unrelated to the Postgres enum, and there is no Enums['application_status'] consumer anywhere.

Baseline

Three entries were never broken references — real tables, correct routes, a catalogue that hadn't caught up after #703 and #712:

before   7 entries, 3 of them not actually broken
after    4 entries, all genuinely missing tables

What remains is honest, and is the real remaining surface of #660:

reference refs issue
core.soft_skills_ratings 8 #658
core.profile_import_data 5 #658
core.inquiries 2 #476
core.profile_completion_nudges 1 #658

Verified

guard      6/6  — including "BASELINE_BROKEN has no stale entries"
typecheck  12/12

That stale-entry assertion is the one that would have caught this being left half-done, and it is why the baseline shrinks rather than being edited around.

🤖 Generated with Claude Code

…rifted

Closes #707. First step on #660, because the schema guard cannot be trusted to
measure the rest of that epic while three of its seven baseline entries are
about a stale catalogue rather than broken routes.

#707 said regenerating from a local database "silently deletes the
application_status enum" and treated that as local migration drift, which is
why it was left undone. The causality is backwards.

Migration 344 DROPPED core.application_status on purpose, five migrations ago,
and says why at length: the type was never used, and its vocabulary was not the
one the app has. It declared draft / submitted / under_review / interviewing /
offer_extended / hired / rejected / withdrawn, while the real vocabulary is the
CHECK constraint on core.applications.status — new / screen / inquired /
interview / offer / hired / rejected / withdrawn. Three labels overlap.

So the local database is CORRECT and types.ts was stale in the other direction,
still declaring a type that was deliberately removed. Regenerating is the fix,
and the deletion is the point.

Verified before overwriting anything: generated to a temp file and diffed. The
only removal in 271 diff lines is application_status, with exactly the vestigial
vocabulary migration 344 quotes. Nothing consumes the type — the
`application_status` hits elsewhere in the tree are a notification category
string, unrelated to the Postgres enum, and there is no Enums['application_status']
consumer anywhere.

Three baseline entries go with it: core.content_reports and core.user_blocks
(mine, #703) and core.user_feedback (#712). All three were real tables with
correct routes, listed only because the catalogue had not caught up.

  before   7 entries, 3 of them not actually broken
  after    4 entries, all genuinely missing tables

What remains in the baseline is now honest, and is the actual remaining surface
of #660:

  core.soft_skills_ratings      8   #658
  core.profile_import_data      5   #658
  core.inquiries                2   #476
  core.profile_completion_nudges 1  #658

Guard: 6/6, including "BASELINE_BROKEN has no stale entries", which is the
assertion that would have caught this being left half-done. Typecheck 12/12.
@thinkclay
thinkclay merged commit 08491ee into main Sep 10, 2026
7 of 8 checks passed
@thinkclay
thinkclay deleted the fix/regenerate-types branch September 10, 2026 20:32
@github-actions

Copy link
Copy Markdown
Contributor

📊 Performance Benchmark Results


thinkclay added a commit that referenced this pull request Sep 10, 2026
…tire the third route (#741)

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

types.ts is stale: #703's moderation tables are missing, and regenerating locally deletes application_status

1 participant