Skip to content

feat(reviews): implement the ten endpoints the review wizard already called (#447) - #614

Merged
thinkclay merged 1 commit into
mainfrom
claude/feat-reviews-api
Aug 12, 2026
Merged

thinkclay merged 1 commit into
mainfrom
claude/feat-reviews-api

Conversation

@thinkclay

Copy link
Copy Markdown
Contributor

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.reviews and its five child tables have existed since migration 099. ReviewWizard drives 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.

added
GET /reviews/my-reviews reviews the caller has written
GET /reviews/soft-skills/by-category catalog grouped for the wizard 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

Authorization

Ownership is this system's entire integrity, so it lives in one helper rather than being retyped in ten handlers. loadOwnReview filters on id and author_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. authenticated had no DELETE grant on review_skill_ratings or review_soft_skill_votes, and both replace their set rather than merging (the reviewer sends the full list, so a removed skill must 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.

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.

overall:    {"totalReviews":1,"recommendCount":1,"recommendPercentage":100}
categories: [{"category":"reliability","averageRating":4,"frequency":1}]
skills:     [{"skillName":"Electrical (test)","averageRating":4,"frequency":1}]
strengths:  [{"name":"Deadline Management","count":1,"category":"reliability"}]
timeline:   [{"month":"2026-08","count":1,"avgRating":1}]

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 check on the changed route: same four error codes as the HEAD baseline, scaled by handler count — all #477's untyped context, no new categories.

KNOWN_GAPS drops 83 → 73, and the contract suite is added to test: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

…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]>
@thinkclay
thinkclay merged commit 46fd10d into main Aug 12, 2026
6 of 15 checks passed
@thinkclay
thinkclay deleted the claude/feat-reviews-api branch August 12, 2026 11:48
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