Skip to content

chore(server): remove the reader report form and its table - #80

Merged
allisonmahmood merged 3 commits into
mainfrom
chore/remove-reports
Aug 28, 2026
Merged

allisonmahmood merged 3 commits into
mainfrom
chore/remove-reports

Conversation

@allisonmahmood

Copy link
Copy Markdown
Owner

Closes #69.

Readers could flag a served page through a footer link, a /report/:draftId form, and a draft_reports table. That was PatchPage's free-service safety valve; nothing builds on it, and it was the one reader-facing surface that would otherwise leak into packages/serving during the Effect port (#56).

This removes the whole entry point: the routes and their scoped form parser, the form and acknowledgement pages, the wrapper footer (a served page is now the sandboxed frame and nothing else), the report rate limit and PATCHY_REPORT_RATE_LIMIT_PER_MINUTE, migration 0006_draft_reports, the report rows on both db drivers, the draft.reported analytics event, and every test and doc that described them. Moderation (GET /api/drafts/:id, principal listing, disable/delete/revoke) is untouched.

No page-level rate limit survives. Every remaining limiter (protectedApi, authenticatedUpload, selfServiceMint, draftCreate) is on /api/*, so serving does not import limits.

Notes for the ticket: docs/API.md does not exist; skills/patchy/SKILL.md and README.md only use "report" as an ordinary word, so needed no change. docs/adr/ADR-0001 still says "report-driven takedown" and is left as a dated record. Both drivers skip ledger IDs they no longer know, so a dev store that already ran 0006 still boots.

Made with Claude Fable 5 in Claude Code.

allisonmahmood and others added 2 commits August 28, 2026 21:56
Reports (GET/POST /report/:draftId, the draft_reports table, the wrapper
footer) were PatchPage's free-service safety valve; nothing builds on
them and they were the one reader-facing surface that would otherwise
leak into packages/serving. Removed the routes, the form and footer, the
report rate limit and its env var, migration 0006, the db rows on both
drivers, the draft.reported analytics event, and every test and doc that
mentioned them. Moderation stays.

No page-level rate limit survives: every remaining limiter is on /api/*.

Made with Claude Fable 5 in Claude Code.

Co-Authored-By: Claude Fable 5 <[email protected]>
The ui-consistency review spec still described the report form and the
wrapper footer, a Postgres test title still said it recorded a report,
and renderDraftWrapper took a homeUrl it never rendered.

Made with Claude Fable 5 in Claude Code.

Co-Authored-By: Claude Fable 5 <[email protected]>
@github-actions github-actions Bot added area:server Touches the server area area:docs Touches the docs area size:l 501-1,000 changed lines labels Aug 28, 2026
@allisonmahmood

Copy link
Copy Markdown
Owner Author

Code review (PR 80 × issue 69)

Two-axis /code-review against origin/main...HEAD (fef5234, 322bad2), plus separate agents on #69 intent, the deletion method, YAGNI, leftover traces, the serving surface, and whether moderation survived. CI is green on this HEAD.


Standards

packages/db/src/upload-contract.test.ts:1104 — hard. docs/agents/domain.md (glossary vocabulary in test names) and post-diff apps/server/CONTEXT.md (Report deleted). Title still answers a reported draft with the principal and token behind it while this PR renamed sibling tests to moderation/takedown. Rename to the remaining concept, e.g. a moderation read.

apps/server/src/render.ts vs untouched apps/server/src/render.test.ts — hard. .agents/skills/ui-consistency/SKILL.md: focused tests in render.test.ts when rendered structure, escaping, or defaulting changes; a visual-only class change does not. The wrapper lost the footer, dropped homeUrl, and replaced flex+footer with html, body { height: 100% } and an iframe that fills the viewport. app.test.ts serves a draft as the framed document and nothing else covers no-footer at the HTTP seam; it is not a render.test.ts structure test. Add one there (no footer/chrome, sandbox/srcdoc/title, default title). Do not fail on a real-browser scroll check — the same spec says not to fail for an artifact the tools cannot produce.

Deleting 0006_draft_reports — not a violation. packages/db/README.md “IDs immutable once merged” is overridden by the ticket’s “delete 0006 outright” (no production database). The README parenthetical that 0006 shipped, was removed, and a leftover ledger id is ignored is the exception record, not leftover feature docs.

.agents/skills/effect-service-conventions/SKILL.md — no Effect service findings. Dropping /report/* matches the #54 serving list (/, /d/*, /healthz). Pre-port Fastify is not held to Effect conventions.

complaint / flagged in .agents/skills/patchy-mint-token/SKILL.md and docs/SELF_HOSTING.md — judgement, not hard. The glossary has no replacement noun. Those words name an out-of-band operator procedure, not a stored primitive. Mixing them with takedown is drift, not a #54/#56 contradiction.

Markup itself matches the UI spec: first-party pages still compose htmlPage; renderDraftWrapper stays the exception (own head, locked CSP, no script, frame only).

Baseline smells (judgement)

Mysterious Name — apps/server/src/app.test.ts: leftover const reported = ( and titles "Reported" / "Reported publisher" in hunks already rewritten to flagged/takedown.

Shotgun Surgery — suppressed: one-concern feature deletion across the layers that owned reports; repo standard wins.

No Duplicated Code, Speculative Generality, or Feature Envy in the change.


Spec

Ordinary English “report” (analytics capture, CLI status, SECURITY.md, triage “reporter”) is not in scope. Findings below are the reader-report domain.

(a) Missing or partial

“Done when: No route, table, type, test or doc mentions reports”

Three leftovers:

  1. Doc. packages/db/README.md still names `0006_draft_reports` and “the report feature”. Tombstone for a deleted step; still a mention. Spec also said “Delete migration 0006_draft_reports outright … dev instances reset” — the note documents skip-in-place instead of reset.

  2. Test. packages/db/src/upload-contract.test.ts still has it("answers a reported draft with the principal and token behind it". Body is findDraftForModeration; title still uses the domain term. Nearby app.test.ts still uses fixture title "Reported", token name "Reported publisher", and local reported for the moderation GET.

  3. Doc. docs/adr/ADR-0001 still has “later report to”, “reported draft to owning principal”, and “report-driven takedown”. The PR left this as a dated record; the Do list did not name ADRs, but done-when is unqualified.

Otherwise the Do list holds: /report/:draftId gone; form/footer/getDraftReportPath gone; PATCHY_REPORT_RATE_LIMIT_PER_MINUTE / reportRateLimitPerMinute / limiters.report gone; 0006 deleted from SCHEMA_MIGRATIONS (not a DROP TABLE follow-up); recordDraftReport / listDraftReports / draft_reports types gone; report cases stripped from app.test.ts / app.postgres.test.ts; CONTEXT.md dropped Report; moderation (GET /api/drafts/:id, principal list, disable/delete/revoke) remains. docs/API.md does not exist; skills/patchy/SKILL.md and README use ordinary English. PR body records no page-level limiter survives (remaining buckets are all /api/*; serving would not import limits). mint-token report→complaint is done.

(b) Scope creep

None that changes behaviour. mint-token/ui-consistency/effect-service-conventions, draft.reported analytics, and dropping unused homeUrl are required to drop the surface. The README tombstone is extra relative to “dev instances reset” and is the (a) mention.

(c) Implemented wrong

None. Drivers already iterate shipped IDs only, so a leftover 0006 ledger row is ignored; they did not add a DROP TABLE migration.


Intent (#69 vs what landed)

The ticket is port-prep, not a drive-by delete: strip the one reader-facing surface that would otherwise leak into packages/serving (/report/*, footer, form parser, page-level limiter, draft_reports, draft.reported) so later tickets never carry it. Keep moderation.

That is what landed. The serving contract is now “sandboxed frame and nothing else.” SELF_HOSTING.md states the product meaning: complaints arrive out of band; the four admin endpoints still close a pasted /d/:id. The #56 question is answered in the PR body and is true in code: no page-level limiter survives, every remaining bucket is on /api/*, so serving does not import limits.

The product gap is the one the ticket accepted: there is no longer a stored feed of flags. listDraftReports was already a direct DB read with no HTTP inbox. After this, the operator needs a URL. There is no “which drafts have been flagged.” For a private-company cloud that is coherent; it is not a replacement queue.

Verdict: mostly matched. Drift is leftover vocabulary (answers a reported draft, ADR-0001 left dated on purpose), not a leftover feature.


Method

Elegant. Deleting 0006 from SCHEMA_MIGRATIONS is the smallest correct method given no production database. A 0007 DROP TABLE would have been this repo’s first destructive step, and keeping 0006 so a fresh install creates then drops a table that never shipped is worse. Residue on a dirty local store (Postgres draft_reports + a ledger row; JSON extra draftReports key) is inert: apply loops already skip unknown IDs, JSON guards already ignore extra keys. No new skip machinery was added. shippedLedgerEntries was already on main.

The Fastify plugin (urlencoded parser scoped so it could not leak onto /api) was deleted whole, not papered over. Follow-through was surgical: env var, limiter, report-page CSP, getDraftReportPath, footer CSS, unused homeUrl. Mint is now the only unauthenticated write. form-action 'none' stays because the wrapper still must not submit, not because a sibling report page needs form-action 'self'.

Tests: deleting the report cases instead of converting them to “/report/:id 404s” matches the repo’s preference against deletion-regression tests. The wrapper test was rewritten into the new contract (serves a draft as the framed document and nothing else). Bookmarked /report/:id now hits the generic HTML 404 (“Draft not found”) even when the draft still exists — acceptable for a deleted surface; a 410 would be extra ceremony.

Leaving ADR-0001 dated is the right method for an ADR. Rewriting it to satisfy “no doc mentions reports” would falsify the trust-model history. The PR body names that exception.


YAGNI / leftover complexity

The leftover serving surface is the small model. renderDraftWrapper is title, a handful of viewport-fill rules, one sandboxed srcdoc iframe, and an HTML comment. createRateLimiters is four /api limiters. Types, rpt_ ids, and listDraftReports are gone.

Trim, don’t rewrite:

  • docs/SELF_HOSTING.md still says “seven business events” above a six-row table.
  • apps/server/src/analytics.ts still says “a reason a reader typed” and “seven call sites” (six remain: two mints, create/update, disable, delete, expiry).
  • apps/server/src/analytics.test.ts still says “The seven are the whole list”.
  • Rename upload-contract.test.ts “answers a reported draft…”.
  • The README 0006 parenthesis is a cheap scar for dirty-dev-ledger behaviour, not new machinery. Fine to keep.

23 files / 1243 deletions is the feature’s real surface, not shotgun. The Effect-skill one-liner dropping /report/* from the decided serving shape is in-scope: that leak is why this ticket exists.


Summary

  • Standards: 2 hard findings, 1 judgement, 1 smell. Worst: wrapper structure changed and render.test.ts was not updated (ui-consistency).
  • Spec: 3 leftover-mention findings under done-when; no missing behaviour, no wrong implementation, no behavioural scope creep. Worst: the domain word “report” still lives in a test title and a README tombstone (ADR-0001 is a named, dated exception).

…rt wording

The ui-consistency spec asks for a focused render.test.ts case when
rendered structure changes; the wrapper lost its footer without one.
Also renames the last test fixtures still named for reports and fixes
the analytics docs that still counted seven events.

Made with Claude Fable 5 in Claude Code.

Co-Authored-By: Claude Fable 5 <[email protected]>
@allisonmahmood

Copy link
Copy Markdown
Owner Author

Went through the review against the source. Every concrete finding was real; addressed in 752e403.

Fixed

  • render.test.ts now has focused renderDraftWrapper cases (frame-only structure, sandbox/srcdoc/title, default and escaped titles) — the ui-consistency spec asks for one when rendered structure changes, and the wrapper had only the HTTP-seam test.
  • upload-contract.test.ts: "answers a reported draft…" → "answers a moderation read…".
  • app.test.ts: reported → culprit, "Reported" / "Reported publisher" fixtures → "Flagged…".
  • Stale counts: SELF_HOSTING.md "seven business events" → six; analytics.ts "seven call sites" and "a reason a reader typed" dropped; analytics.test.ts "The seven" → six.

Left as-is, on purpose

  • docs/adr/ADR-0001 still says "report-driven takedown". It is a dated decision record; rewriting it would falsify the trust-model history. The review agreed.
  • packages/db/README.md keeps the one-line note that 0006 shipped and was removed. It is the only place that explains why a dirty dev ledger may list an ID the code no longer has; both drivers skip unknown ledger IDs, so the note describes real behaviour, not new machinery.
  • "complaint"/"flagged" wording in SELF_HOSTING.md and the mint-token skill stays: the glossary has no stored noun left for this, and those words name an out-of-band procedure, not a primitive.

Gate on HEAD: lint, typecheck, 1812 tests, prettier — all green locally; CI running on 752e403.

@allisonmahmood
allisonmahmood merged commit 32a796e into main Aug 28, 2026
7 checks passed
@allisonmahmood
allisonmahmood deleted the chore/remove-reports branch August 28, 2026 21:41
This was referenced Sep 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:docs Touches the docs area area:server Touches the server area size:l 501-1,000 changed lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

chore(server): remove reports

1 participant