Repository navigation
feat(moderation): report content, report people, block people - #703
Merged
Merged
Conversation
…cement Backend half of #690. Scaffald carries UGC with no way to report content, report a person, or block anyone; Play's UGC policy and Apple Guideline 1.2 both require all three. Two tables, kept apart on purpose. A report is a request for moderator attention — queued, reviewed, resolved. A block is the user's own boundary — immediate, reversible, needs nobody's approval. Conflating them means either blocks wait on moderation or reports silently mute people. The constraints were tested by trying to break them, because #675 was a UNIQUE that never fired: self-block, self-report, duplicate block and a second open report on the same subject are all rejected, and reporting again after resolution is allowed. Enforcement is symmetric and is the half that matters. A block that is only recorded is worse than none — the user believes they are unreachable and they are not. RLS deliberately lets a user see only rows where they are the blocker, so a client cannot discover who blocked them; that is right for privacy and useless for filtering, hence core.blocked_user_ids() as SECURITY DEFINER. Applied to the inquiry thread and the community feed. The feed filters in the query rather than after it, so paging is not silently shortened. Three schema assumptions were wrong and checked rather than trusted: inquiry_comments uses sender_id not author_id, jobs uses created_by_user_id, and there is no shared getServiceClient to import. Wrong here is silent — the report still files, just with nobody attached. scripts/audit/test-moderation.mjs: 20/20 against the local stack. Still to come: SDK resource, hooks, and the UI surfaces. Nothing is user-reachable yet.
App half of #690. The backend landed in the previous commit; nothing was user-reachable until now, and a store reviewer checks the UI. Three surfaces: community post report, in the author row so it is visible without opening the post inquiry message report, per message settings the list of people you have blocked, with unblock One ReportSheet and one ReportAction rather than a dialog per screen. Beyond tidiness: a reviewer is looking for whether reporting is FINDABLE, and an affordance that looks different everywhere reads as missing wherever they happen not to look. The sheet mounts only while open. Rendering it permanently-hidden made every message row in a thread instantiate two mutations and require a QueryClient to draw a flag icon — which is how this broke InquiryCommentThread's existing tests. Fixing the design fixed the tests; I did not touch them. Smaller decisions worth their comments: - `other` with no details is disabled rather than rejected, so nobody discovers the server rule by being refused - a 409 (already reported) shows as done, not as a failure — the user pressed the button and the outcome they wanted is true - the confirmation promises review, not removal or a timeline - blocking is offered after reporting, not instead of it - report controls are named per subject ("Report Alice Chen"), because a screen-reader user in a thread otherwise hears "Report" a dozen times - blocks list shows a short id: the API deliberately returns ids, since seeing someone you blocked should not require loading their profile. Joining the profile in is nicer and is a follow-up. SDK: Scaffald/sdk#20, pointer 2ae9506..4f6730a. typecheck 12/12, test:unit 7/7 --skip-nx-cache (1151/1151 in scf-core), lint 10/10, moderation API 20/20, and scripts/audit/smoke-report-block.mjs confirms the settings surface renders in the running app rather than only compiling.
thinkclay
added a commit
that referenced
this pull request
Sep 2, 2026
The content-rating draft carried a caveat on 'Users Interact: Yes' — the app let people interact and gave them no way to report or block. #703 closed that, so the caveat comes off and the acceptance box is ticked. Also strikes the corresponding launch blocker from the listing doc. It was the item most likely to actually get the listing rejected.
thinkclay
added a commit
that referenced
this pull request
Sep 2, 2026
The content-rating draft carried a caveat on 'Users Interact: Yes' — the app let people interact and gave them no way to report or block. #703 closed that, so the caveat comes off and the acceptance box is ticked. Also strikes the corresponding launch blocker from the listing doc. It was the item most likely to actually get the listing rejected.
5 tasks
Contributor
📊 Performance Benchmark Results |
thinkclay
added a commit
that referenced
this pull request
Sep 2, 2026
…open #703 added routes/moderation.ts with a bare `new OpenAPIHono()`, so it arrived with the same untyped context this branch removes everywhere else: 27 type errors, 3 after parameterizing it. Co-Authored-By: Claude Opus 5 <[email protected]>
4 tasks
thinkclay
added a commit
that referenced
this pull request
Sep 2, 2026
…en routes The reference test fails on unmodified main: routes/moderation.ts reads core.content_reports and core.user_blocks, and neither is in types.ts. Both tables exist in the database — #703 shipped their migrations without regenerating the checked-in types, so the routes are right and the catalogue is stale. Regenerating is not the fix and was tried: `supa:generate` against the local stack adds the three expected objects and also deletes the application_status enum, which the local database does not have and types.ts does. See #707. Listed rather than excused, so the count still only goes down — once types.ts is regenerated these go stale and the test demands their removal. Refs #707 Co-Authored-By: Claude Opus 5 <[email protected]>
thinkclay
added a commit
that referenced
this pull request
Sep 2, 2026
…since before this branch
`Lint REST API Code` runs `deno fmt --check` in functions/api and is red on
main: 16 of 141 files unformatted there. This branch's single-line import
rewrites — `import { type ApiEnv, authMiddleware } from ...` — exceed the line
width and pushed it to 30.
Formatting all 141 rather than only my 14 makes the check pass rather than fail
less, which is the point of having it.
Verified: `deno fmt --check` clean, `deno lint` clean across 137 files, and
`deno check` unchanged at 414 errors — the same 411 measured before the rebase
plus moderation.ts's 3, which arrived with #703.
Co-Authored-By: Claude Opus 5 <[email protected]>
thinkclay
added a commit
that referenced
this pull request
Sep 2, 2026
…en routes The reference test fails on unmodified main: routes/moderation.ts reads core.content_reports and core.user_blocks, and neither is in types.ts. Both tables exist in the database — #703 shipped their migrations without regenerating the checked-in types, so the routes are right and the catalogue is stale. Regenerating is not the fix and was tried: `supa:generate` against the local stack adds the three expected objects and also deletes the application_status enum, which the local database does not have and types.ts does. See #707. Listed rather than excused, so the count still only goes down — once types.ts is regenerated these go stale and the test demands their removal. Refs #707 Co-Authored-By: Claude Opus 5 <[email protected]>
thinkclay
added a commit
that referenced
this pull request
Sep 2, 2026
…pe errors were never real (#704) * fix(api): type the middleware context, so 2,056 of the API's 2,467 type errors were never real `authMiddleware` stored `supabase`, `user`, `authType` and friends on a plain untyped `Context`, and no route file parameterized its app — every one constructed a bare `new OpenAPIHono()` or `new Hono()`. So `c.get("supabase")` inferred as `never` (or `{}` in a whole-program check) and every property access on it was an error. `deno check` over `functions/api`, before and after declaring the shape once and using it in all 81 files that build an app: Found 2467 errors -> Found 411 errors TS2769 No overload matches this call 812 -> 0 TS2339 Property does not exist on type 1091 -> 18 TS18046 X is of type unknown 137 -> 5 TS7006 Parameter implicitly has any type 51 -> 5 This does NOT make `pnpm test:deno:types` pass. 411 errors remain, dominated by 364 TS2345 where a handler's return type does not match the OpenAPI `responses` map it declares — a real contract gap, and adjacent to the schema work in #660. What it does is make the gate capable of carrying signal at all: a genuine type error is no longer one of two thousand. Two of the surviving errors are real defects the typing exposed, both fixed here: **Notification counts were always zero.** `PATCH /v1/notifications/read-all` and `DELETE /v1/notifications` did .update({...}).eq(...).select("*", { count: "exact", head: true }) `select()` after a mutation is PostgrestTransformBuilder's returning-clause overload, which takes columns only — `PostgrestQueryBuilder.select(columns, options)` is the one that accepts `{ count, head }`. The options object was silently discarded, `count` came back null, and both endpoints reported `updated_count: 0` / `deleted_count: 0` on every call. `count` now goes on `update()` / `delete()`, where it belongs. **A fire-and-forget error handler that could not fire.** The api_keys `last_used_at` touch ended in `.then(...).catch(...)`. PostgREST builders resolve with `{ error }` rather than rejecting, so a failed update never reached the catch — and the builder's `then()` returns `PromiseLike<void>`, which has no `.catch` at all, so it was not even well-typed. It now reads the error off the resolved value. Also normalizes `c.set("organization", ...)`: the embedded `organizations: organization_id (...)` relation is typed as an array because supabase-js cannot infer cardinality from the select string, while PostgREST returns an object. Nothing reads this key today, so it was latent rather than live. Closes #477 Co-Authored-By: Claude Opus 5 <[email protected]> * fix(api): type moderation.ts too, which landed while this branch was open #703 added routes/moderation.ts with a bare `new OpenAPIHono()`, so it arrived with the same untyped context this branch removes everywhere else: 27 type errors, 3 after parameterizing it. Co-Authored-By: Claude Opus 5 <[email protected]> * style(api): run deno fmt, which the Format Check has been failing on since before this branch `Lint REST API Code` runs `deno fmt --check` in functions/api and is red on main: 16 of 141 files unformatted there. This branch's single-line import rewrites — `import { type ApiEnv, authMiddleware } from ...` — exceed the line width and pushed it to 30. Formatting all 141 rather than only my 14 makes the check pass rather than fail less, which is the point of having it. Verified: `deno fmt --check` clean, `deno lint` clean across 137 files, and `deno check` unchanged at 414 errors — the same 411 measured before the rebase plus moderation.ts's 3, which arrived with #703. Co-Authored-By: Claude Opus 5 <[email protected]> --------- Co-authored-by: Claude Opus 5 <[email protected]>
thinkclay
added a commit
that referenced
this pull request
Sep 2, 2026
…en routes The reference test fails on unmodified main: routes/moderation.ts reads core.content_reports and core.user_blocks, and neither is in types.ts. Both tables exist in the database — #703 shipped their migrations without regenerating the checked-in types, so the routes are right and the catalogue is stale. Regenerating is not the fix and was tried: `supa:generate` against the local stack adds the three expected objects and also deletes the application_status enum, which the local database does not have and types.ts does. See #707. Listed rather than excused, so the count still only goes down — once types.ts is regenerated these go stale and the test demands their removal. Refs #707 Co-Authored-By: Claude Opus 5 <[email protected]>
thinkclay
added a commit
that referenced
this pull request
Sep 2, 2026
…st entry was a phantom (#711) * fix(api): five routers addressed tables that do not exist, and one test entry was a phantom Part of #660. The sweep behind #651 left a machine-checkable list — `BASELINE_BROKEN` in table-references-exist.test.ts, which reads the generated types.ts and needs no database. It counted 32 broken references across 12 table names. This takes it to 17 across 5. **#656 — the O*NET router addressed the wrong schema entirely.** `core .onet_occupations` and `core.onet_skills` exist in no schema; the data lives in `onet`, whose key column is `onetsoc_code`, not `onet_code`. Four occupation reads now select from `onet.occupation_data`, aliasing `onet_code:onetsoc_code` so the response shape the SDK consumes does not change. The skills endpoint needed more than a rename. `onet.skills` is raw O*NET measure data — one row per (onetsoc_code, element_id, scale_id), scale "IM" being importance and "LV" level — with no skill name and no `category` column, where the handler assumed a flat table with `importance` and `category`. It now reads the IM rows, resolves names from `onet.content_model_reference` in a second query (there is no declared FK, so PostgREST cannot embed it), and derives `category` from the element-id prefix, which is the actual O*NET taxonomy. The wire fields `importance` and `category` are preserved. **#657 — four wrong-schema references,** each verified against the running database rather than only against types.ts: public.webhooks exists; core.webhooks does not core.job_team_assignments exists; core.team_job_assignments does not core.certifications exists; public.certifications does not core.user_education exists; public.user_education does not The last two carried no `.schema()` call at all, so they defaulted to public and returned `count: null` rather than erroring — which is why the university student count silently read 0 for every university instead of failing. **#657's fifth row was not a real defect.** office-communities.ts:146 already read `.schema("core").from("users")`. The test reported it as `community.users` because its parser buffers to the next semicolon and takes the *first* `.schema()` in the statement — and that line sits in a `Promise.all([...])` whose first element is `.schema("community")`. One statement, two chains, one schema. The parser now takes the nearest `.schema()` *preceding* each `.from()`, which still catches the office-users.ts delete-cascade bug it was written for (those are separate statements, so each lands in its own buffer). A regression test covers the multi-chain case, and the phantom entry is gone. **#659 — a 500 where a 404 was already declared.** `GET /v1/user-profiles/ {userId}` used `.single()`, and PostgREST answers that with "Cannot coerce the result to a single JSON object" on zero rows, which arrived as an error and was reported as a server fault. A profile that does not exist is an ordinary outcome, and a 500 makes the client retry something that can never succeed. Now `.maybeSingle()` with an explicit 404, query errors still separate. Verified: the reference test passes with 6 entries removed and the new regression case; `deno check` over functions/api stays at 411 errors, so none of this adds any. Not verified: the O*NET tables are empty in the local seed, so the row-level behaviour of the rewritten skills endpoint is unexercised. The shape is checked against information_schema and the generated types; the scale ids come from the O*NET content model. #656's "returns real rows for a seeded code" cannot be met until that data is loaded. Closes #656 Closes #657 Closes #659 Co-Authored-By: Claude Opus 5 <[email protected]> * test(api): record #703's moderation refs as types-staleness, not broken routes The reference test fails on unmodified main: routes/moderation.ts reads core.content_reports and core.user_blocks, and neither is in types.ts. Both tables exist in the database — #703 shipped their migrations without regenerating the checked-in types, so the routes are right and the catalogue is stale. Regenerating is not the fix and was tried: `supa:generate` against the local stack adds the three expected objects and also deletes the application_status enum, which the local database does not have and types.ts does. See #707. Listed rather than excused, so the count still only goes down — once types.ts is regenerated these go stale and the test demands their removal. Refs #707 Co-Authored-By: Claude Opus 5 <[email protected]> --------- Co-authored-by: Claude Opus 5 <[email protected]>
This was referenced Sep 10, 2026
thinkclay
added a commit
that referenced
this pull request
Sep 10, 2026
…rifted (#736) 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.
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 #690.
Scaffald carries user-generated content — community posts and comments, inquiry threads between an employer and a candidate, profiles, job posts — and had no way to report content, report a person, or block anyone. Google Play's UGC policy and Apple's Guideline 1.2 both require all three. Apple's applies now, not eventually:
1.17.1is on TestFlight.Two ideas, kept apart
Conflating them means either blocks wait on moderation or reports silently mute people. Both are wrong.
Enforcement is the half that matters
A block that is only recorded is worse than no block: the user believes they are unreachable and they are not. So it is symmetric — if A blocks B, neither sees the other — and applied on the read paths (inquiry thread, community feed).
That symmetry is why it needs a
SECURITY DEFINERfunction. RLS deliberately lets a user see only rows where they are the blocker, so a client cannot enumerate who blocked them — right for privacy, useless for filtering a feed:The community feed filters in the query rather than after it — filtering post-hoc would silently shorten pages and break the cursor.
Constraints tested by trying to break them
#675 was a
UNIQUEthat never fired, so these were attacked rather than trusted: self-block, self-report, duplicate block, and a second open report on the same subject are all rejected — and reporting again after resolution is allowed, because content changes and situations escalate.scripts/audit/test-moderation.mjs— 20/20 against the local stack.Three schema assumptions were wrong
Checked rather than trusted, and wrong here is silent — the report still files, just with nobody attached to it:
inquiry_commentsusessender_id, notauthor_idjobsusescreated_by_user_idgetServiceClientto importUI
Report on a community post (author row, visible without opening it), on an inquiry message (per message), and manage blocked people in Settings so blocking is not a one-way door only support can open.
One
ReportSheetand oneReportActionrather than a dialog per screen — a reviewer is checking whether reporting is findable, and an affordance that looks different everywhere reads as missing wherever they don't look.The sheet mounts only while open. Rendering it permanently-hidden made every message row instantiate two mutations and require a QueryClient just to draw a flag icon — which is how this broke
InquiryCommentThread's existing tests. Fixing the design fixed the tests; I didn't touch them.Smaller calls, each with its reasoning in the code:
otherwith no details is disabled, not rejected — nobody should discover a server rule by being refusedReport Alice Chen) — a screen-reader user in a thread otherwise hears "Report" a dozen timesVerified
SDK: Scaffald/sdk#20, pointer
2ae9506..4f6730a.Not in scope
The blocked list shows a short id rather than a name — the API returns ids deliberately, since seeing someone you blocked shouldn't require loading their profile. Joining the profile in is nicer, and is a follow-up.
Moderators triage
core.content_reportsdirectly for now; theflaggedstatus and existing community review queue are the natural home for a proper surface.🤖 Generated with Claude Code