Repository navigation
feat(skills): mount /v1/skills — snapshots and evidence (#447) - #615
Merged
Merged
Conversation
core.skill_snapshots and core.skill_evidence have existed for some time, and
features/skills-analytics renders five widgets against them on the live
/assessments route, plus ReviewImpactSummary inside the profile ReviewsWidget.
No router was ever mounted at /v1/skills, so all nine calls 404'd and every one
of those widgets showed its error state.
GET /v1/skills/snapshots list, and latest (same path, by limit)
GET /v1/skills/snapshots/timeline chart points, oldest first
GET /v1/skills/snapshots/{id} one snapshot
POST /v1/skills/snapshots take a snapshot
POST /v1/skills/snapshots/compare diff two of them
GET /v1/skills/evidence list, filterable
POST /v1/skills/evidence add
PATCH /v1/skills/evidence/{id} edit title/description/url
POST /v1/skills/evidence/{id}/verify vouch for someone else's
Snapshots are built server-side from the caller's current ratings; the client
sends only the trigger. Letting it post its own numbers would make the history a
record of what a client believed rather than of what the data said.
The arithmetic lives in lib/skill-snapshots.ts, away from the handlers, because
it is the only part with logic worth testing directly. Two decisions in there
worth knowing: the overall average is the mean of every rating rather than the
mean of the category means, so a category with one rating does not weigh as much
as one with ten; and a category present in only one of two compared snapshots
still appears in the diff, because a skill area the worker started rating is a
change worth showing.
Three things the live run caught:
- **Evidence with no skill reference 500'd.** core.skill_evidence has a check
constraint requiring soft_skill_id, or skill_taxonomy plus skill_ref_id. The
request schema allowed all three to be omitted, so the database rejected what
the API had accepted. The schema now mirrors the constraint and answers 400
naming what is missing.
- **Verification could not work through the user client.** skill_evidence_update
is `auth.uid() = user_id`, and verification is by definition someone else
vouching, so that policy and this feature are in direct conflict. Relaxing the
policy would be worse — RLS cannot restrict which columns a writer touches, so
a broader policy would also let a stranger rewrite the title. That one write
uses the service client, after the handler has checked the row exists and the
caller is not its owner.
- **Self-verification is refused** (403), and `verified` is not a writable field
on PATCH — the strict schema rejects it with a 400. A flag anyone can set on
their own evidence means nothing.
Verified against a live stack: two snapshots taken either side of a rating
change produced delta_overall 1.33 against previous_overall 3.67, compare agreed
(improvedCount 1), and a first snapshot correctly carried a null summary rather
than claiming it had not changed. Cross-user checks: editing another user's
evidence 404s, snapshotting another user 403s.
KNOWN_GAPS 73 -> 64. 13 new assertions on the snapshot arithmetic; 69 Deno
assertions pass overall.
Co-Authored-By: Claude Opus 5 <[email protected]>
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 9 more gaps in #447 (KNOWN_GAPS 73 → 64). Third instance of the same pattern: tables built, UI built, no router.
Nothing was mounted at
/v1/skillscore.skill_snapshotsandcore.skill_evidencehave existed for some time.features/skills-analyticsrenders five widgets against them on the live/assessmentsroute, andReviewImpactSummarysits inside the profileReviewsWidget. All nine calls 404'd, so every one of those widgets showed its error state.GET /v1/skills/snapshotslimit)GET /v1/skills/snapshots/timelineGET /v1/skills/snapshots/{id}POST /v1/skills/snapshotsPOST /v1/skills/snapshots/compareGET /v1/skills/evidencePOST /v1/skills/evidencePATCH /v1/skills/evidence/{id}POST /v1/skills/evidence/{id}/verifySnapshots are built server-side from the caller's current ratings; the client sends only the trigger. Letting it post its own numbers would make the history a record of what a client believed rather than of what the data said.
Two decisions in
lib/skill-snapshots.tsworth knowing: the overall average is the mean of every rating, not the mean of the category means — so a category with one rating does not weigh as much as one with ten. And a category present in only one of two compared snapshots still appears in the diff, because a skill area the worker started rating is a change worth showing.Three things the live run caught
Evidence with no skill reference 500'd.
core.skill_evidencehas a check constraint requiringsoft_skill_id, orskill_taxonomyandskill_ref_id. The schema allowed all three to be omitted, so the database rejected what the API had accepted. Now mirrored — 400 naming what is missing.Verification could not work through the user client.
skill_evidence_updateisauth.uid() = user_id, and verification is by definition someone else vouching — that policy and this feature are in direct conflict. Relaxing the policy would be worse: RLS cannot restrict which columns a writer touches, so a broader policy would also let a stranger rewrite the title. That single write uses the service client, after the handler confirms the row exists and the caller is not its owner.Self-verification is refused (403), and
verifiedis not writable on PATCH — the strict schema rejects it with 400. A flag anyone can set on their own evidence means nothing.Verification
Live, against a real stack:
Test rows removed afterwards. 13 new assertions on the snapshot arithmetic; 69 Deno assertions pass.
deno checkon the new route: same four error codes as every other route — #477's untyped context, no new categories.CI checks will show red without running — Actions billing block, #375.
🤖 Generated with Claude Code