Repository navigation
feat(reviews): implement the ten endpoints the review wizard already called (#447) - #614
Merged
Merged
Conversation
…called (#447) core.reviews and its five child tables have been in place since migration 099, and ReviewWizard drives a full multi-step flow against @scaffald/sdk. The router implemented four of the thirteen endpoints the SDK exposes, so every step of writing a review 404'd. Same shape as the profile epic: a good database, a built UI, and no wire between them. Added: GET /reviews/my-reviews reviews the caller has written GET /reviews/soft-skills/by-category the catalog grouped for the tabs GET /reviews/{id}/draft reopen a part-written review PATCH /reviews/{id}/draft whole-blob autosave PATCH /reviews/{id}/step wizard progress PATCH /reviews/{id}/skill-ratings technical scores PATCH /reviews/{id}/category-rating one category at a time PATCH /reviews/{id}/soft-skill-votes strengths and improvements PATCH /reviews/{id}/comment body + public visibility GET /reviews/analytics aggregates for a subject Ownership is the review system's whole integrity, so it lives in one helper rather than being retyped per handler: loadOwnReview filters on id AND author_user_id, and a miss is a 404 rather than a 403 — the convention #608/#609 settled on, because "exists but not yours" leaks that it exists. Verified against a live stack: another user's draft is 404 on both read and write. Mutations additionally require the review to still be a draft. A submitted review is a published statement about someone; letting the author keep editing would change what a reader already saw. Three things the live run caught that static reading would not have: - **Two endpoints 500'd on "permission denied".** `authenticated` had no DELETE grant on review_skill_ratings or review_soft_skill_votes, and both endpoints replace their set rather than merging — the reviewer sends the full list, so a removed skill has to actually disappear. Migration 346 adds the grants, plus a DELETE policy on review_skill_ratings mirroring its insert predicate (review_soft_skill_votes already had an author-scoped ALL policy). Same class as #481: RLS and a policy exist, the GRANT that makes the policy reachable does not, and it surfaces as a server error rather than a permission one. - **Analytics resolved skill names from the wrong table.** I joined data.masterformat; review_skill_ratings.skill_id has a foreign key to core.skills. It returned blank names until a live call showed it. - **POST /{id}/submit was destroying the review.** It set `metadata: { status: "submitted" }` — a whole-object write over the jsonb column holding the draft body, the wizard's step progress and the is_public flag the comment step had just saved. Everything the reviewer filled in was dropped at the moment they submitted it. Now merged, and it checks ownership like the rest. KNOWN_GAPS drops 83 -> 73, and the contract suite is added to test:api:rest:suite — it has never run in CI, which is the same gap #604 fixed for __tests__/lib. 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 10 of the 83 gaps in #447. Picked this cluster because it is the largest single one and it delivers a working feature rather than just shrinking a list.
A good database, a built UI, and no wire between them
core.reviewsand its five child tables have existed since migration 099.ReviewWizarddrives a full multi-step flow against@scaffald/sdk. The router implemented 4 of the 13 endpoints the SDK exposes — so every step of writing a review 404'd. Same shape as the profile epic.GET /reviews/my-reviewsGET /reviews/soft-skills/by-categoryGET /reviews/{id}/draftPATCH /reviews/{id}/draftPATCH /reviews/{id}/stepPATCH /reviews/{id}/skill-ratingsPATCH /reviews/{id}/category-ratingPATCH /reviews/{id}/soft-skill-votesPATCH /reviews/{id}/commentGET /reviews/analyticsAuthorization
Ownership is this system's entire integrity, so it lives in one helper rather than being retyped in ten handlers.
loadOwnReviewfilters on id andauthor_user_id; a miss is 404, not 403 — the convention #608/#609 settled on, because "exists but is not yours" leaks that it exists.Mutations additionally require the review to still be a draft: a submitted review is a published statement about someone, and letting the author keep editing changes what a reader already saw.
Verified against a live stack — another user's draft returns 404 on both read and write.
Three things only the live run caught
Two endpoints 500'd on
permission denied.authenticatedhad no DELETE grant onreview_skill_ratingsorreview_soft_skill_votes, and both replace their set rather than merging (the reviewer sends the full list, so a removed skill must actually disappear). Migration346adds the grants plus a DELETE policy onreview_skill_ratingsmirroring its insert predicate —review_soft_skill_votesalready had an author-scopedALLpolicy. Same class as #481: RLS and a policy exist, the GRANT that makes the policy reachable does not, and it surfaces as a server error rather than a permission one.Analytics resolved skill names from the wrong table. I joined
data.masterformat;review_skill_ratings.skill_idhas a foreign key tocore.skills. It returned blank names until a live call showed it.POST /{id}/submitwas destroying the review. It setmetadata: { status: "submitted" }— a whole-object write over the jsonb column holding the draft body, the wizard's step progress, and theis_publicflag the comment step had just saved. Everything the reviewer filled in was dropped at the moment they submitted it. Now merged, and it checks ownership like the rest.Verification
Full wizard flow driven against a live stack: create draft → step → skill-ratings → category-rating → soft-skill-votes → comment → draft autosave → re-read (every write survived) → submit → analytics.
Test rows removed afterwards. 56 Deno assertions pass (11 new on the ownership helper, covering the someone-else's-review and already-submitted cases).
deno checkon the changed route: same four error codes as the HEAD baseline, scaled by handler count — all #477's untyped context, no new categories.KNOWN_GAPSdrops 83 → 73, and the contract suite is added totest:api:rest:suite— it has never run in CI, the same gap #604 fixed for__tests__/lib.CI checks will show red without running — Actions billing block, #375.
🤖 Generated with Claude Code