Skip to content

fix(seeds): the CSI trade taxonomy was never seeded, so skills could not be added (#583) - #602

Merged
thinkclay merged 1 commit into
mainfrom
claude/fix-583-csi-seed
Aug 12, 2026
Merged

thinkclay merged 1 commit into
mainfrom
claude/fix-583-csi-seed

Conversation

@thinkclay

@thinkclay thinkclay commented Aug 12, 2026 •

Copy link
Copy Markdown
Contributor

Addresses the main body of #583. Part of #594.

The catalog was never loaded

POST /v1/profiles/skills/search-parents returned {"skills":[]} for every query in every local environment — "electrical", "conc", anything — so nobody could add a trade skill to a profile. Not a developer, not a test, not a reviewer. Every skills screen was an empty state, which is why skills bugs were undetectable by construction.

data.masterformat is populated by scripts/seed-csi.ts, and nothing invokes it. config.toml declares sql_paths = ['./seeds/*.sql'], so a TypeScript script is not part of supa db reset and never has been.

The fix

Converted to a real seed: 8,953 rows generated from the same scripts/seed-csi-2020.csv, reproducing that script's identity rules exactly so the two cannot disagree —

id       = uuid5(uuid5(URL, 'scaffald:skills:csi2018'), code_key)
code_key = '03-11-13-16'   code_display = '03 11 13.16'

Deterministic ids mean re-running is a no-op rather than a duplicate set, and rows referencing a skill survive a reset. Ordered parent-before-child so the self-referencing parent_id FK resolves in one pass. Numbered 000 so it lands before 014_seed-worker-profiles.sql, which resolves trade skills by code_key.

Depth distribution: 35 / 1,406 / 5,031 / 2,481.

Seed 014 now fails loudly

014's CSI insert joins data.masterformat and matched zero rows against the empty table — reporting success while planting none of the six skills its own header advertises. That is exactly the failure mode its header warns about ("an empty state and a broken query look identical"), and it is how this stayed hidden: marcus scored 100% completion beside a widget reading "No skills added yet".

It now asserts its own inserts landed, and names data.masterformat's row count in the exception so the cause is in the message rather than something you have to go looking for.

Not done here, and why

Not verified against a live database. Docker is unavailable in this environment, so the seed has not been applied and search-parents has not been re-probed. The generated SQL is checked structurally only (row count, depth distribution, parent linkage spot-checked on 26-05-05-00 → 26-05-00-00). This wants a pnpm supa db reset before it is trusted.

The two 404ing endpoints are left alone. #583 proposed deleting them or their hooks. On inspection they have live consumers, so deleting the hooks is not correct and the endpoints are genuinely missing:

endpoint status live consumers
GET /v1/profiles/skills/user 404 useWorkLogForm, WorkLogDetailScreen
GET /v1/profiles/skills/legacy 404 SkillsWidget, rendered on other-user profiles via user-profile-right

That is a wider breakage than #583 described — the work-log skill picker and the skills section of every other-user profile — and it needs a decision about implementing the endpoints rather than a guess at their contract under time pressure. Filed separately as #603 and noted on #583.

🤖 Generated with Claude Code

…not be added (#583)

POST /v1/profiles/skills/search-parents returned {"skills":[]} for every query
in every local environment — "electrical", "conc", anything — so nobody could
add a trade skill to a profile. Not a developer, not a test, not a reviewer.
Every skills screen was an empty state, which is why skills bugs were
undetectable by construction.

The catalog was never loaded. data.masterformat is populated by
scripts/seed-csi.ts, and nothing invokes it: config.toml declares
sql_paths = ['./seeds/*.sql'], so a TypeScript script is not part of
`supa db reset` and never has been.

Converted to a real seed. 8,953 rows generated from the same
scripts/seed-csi-2020.csv, reproducing that script's identity rules exactly so
the two cannot disagree — id = uuid5(uuid5(URL,'scaffald:skills:csi2018'),
code_key). Deterministic ids mean re-running is a no-op and rows referencing a
skill survive a reset. Ordered parent-before-child so the self-referencing
parent_id FK resolves in one pass, and numbered 000 so it lands before 014,
which resolves trade skills by code_key.

014's CSI insert joins data.masterformat and matched zero rows against the empty
table, reporting success while planting none of the six skills its own header
advertises. That is exactly the failure mode its header warns about — "an empty
state and a broken query look identical" — and it is how this stayed hidden:
marcus scored 100% completion beside a widget reading "No skills added yet". It
now asserts its own inserts landed, and names data.masterformat's row count in
the failure so the cause is in the message.

Not verified against a live database: Docker is unavailable in this environment,
so the seed has not been applied and search-parents has not been re-probed. The
generated SQL is checked structurally (row count, depth distribution 35/1406/
5031/2481, parent linkage spot-checked on 26-05-05-00 -> 26-05-00-00).

Co-Authored-By: Claude Opus 5 <[email protected]>
@thinkclay
thinkclay merged commit 807f7fb into main Aug 12, 2026
5 of 7 checks passed
@thinkclay
thinkclay deleted the claude/fix-583-csi-seed branch August 12, 2026 03:53
thinkclay added a commit that referenced this pull request Aug 12, 2026
…real profile (#584) (#605)

The Profile Wizard was 15 source files, 12 test files and a live
/v1/profile-wizard router with no route anywhere that rendered it. Nothing
imported it outside its own directory. It was unreachable in the shipped app,
while carrying nearly half the passing test files in the profile feature —
which is how it inflated the apparent health of a feature it was not part of.

Two things were missing, and both had to be fixed for either to be worth doing.

Reachability: /profile/wizard now renders it, declared in the profile layout,
with ROUTES.PROFILE.WIZARD and a "Guided setup" entry point on the profile
overview beside Request review and Share profile. It is a peer of the section
editors, not a replacement — the wizard is the guided path for a new worker, the
editors are how anyone changes one thing later.

Persistence: POST /v1/profile-wizard/complete writes wizard progress into
core.preferences and touches nothing else, so finishing all six steps left the
actual profile empty. The wizard now commits through the same endpoints the
profile editors use — PATCH /v1/profiles/general, POST /v1/profiles/experience,
POST /v1/profiles/education, PATCH /v1/profiles/employment — rather than giving
the server a second write path per section. One write path, one set of
validation rules, one place for a bug to live.

The commit runs before the wizard is marked complete, so a failed write cannot
leave a user with a finished wizard and an empty profile. Sections are written
independently and one failure does not abort the rest: someone who filled in
five steps should not lose all five because certifications 500'd. Failures are
named in a toast pointing at the profile.

Skills and certifications are deliberately NOT committed yet. Both write paths
key off catalog ids, and the wizard's pickers resolve those against endpoints
that are currently broken — the CSI catalog was unseeded until #602, and two
skills endpoints still 404 (#603). Writing half-resolved ids would put rows in
core.user_skills that are harder to clean up than to skip. Noted inline.

The field mapping is extracted to wizard-to-profile.ts and unit-tested rather
than inlined: the wizard says "bio" where the profile says "about", and getting
that wrong is silent — the PATCH succeeds and the text lands nowhere visible.

Co-authored-by: Claude Opus 5 <[email protected]>
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.

1 participant