Repository navigation
feat(patches): packages/patches owns records, uploads, retention and the sweep - #87
Conversation
/code-review — PR 87 vs issue 76Two-axis review of StandardsHard
Judgement (smells / port shape)
No documented-standard breach in No UI consistency findings. Spec(a) Missing / partial“ “Delete everything left in “Depends on (b) Not asked for
Dropping (c) Looks implemented, but offMost of the checklist holds: Rollback vs “failing MethodThe cut is the one the ticket asked for, not an extra service zoo.
YAGNIWhat is already the small model: one What I would still cut:
The two 15-field structs (
Intent vs what landedIssue 76 asked for the patches capability to own records, the upload contract, the clock, the sweep, and the group; for That is what landed, with the deviations the PR named (limits on create, no Standards: 2 hard, 3 judgement. Worst: |
|
Went through the review. Pushed the fixes in the follow-up commit; here is what was taken and what was not. Fixed
Left as is, with reasons
|
8457bbb to
63a902d
Compare
Patch records, versions, the upload contract, visits, retention, pins, moderation and the patch quota lived in packages/db behind a two-driver port, with the expiry sweep in apps/server. They become the `patches` capability on Effect: `Patches` (rows, decoded through SqlSchema in one module), `Content` (the one place bytes are touched: put, insert, rollback on a refused row; the served read), `ExpirySweep` (one `sweep` the server forks hourly on Schedule.spaced), and the `patches` HttpApi group. Migration 3 is the baseline with `patches` / `patch_versions` naming; `draft` is gone from tables and code. The JSON driver, the PatchyDb port and its contract suite are deleted (ADR-0003, Postgres only); packages/db keeps only the migration seam. The Fastify app serves both API groups through one runtime seam and reads pages through `Content`; its tests run on a Postgres clone per app.
Catch the upload refusals with catchTags in Content.upload and the handler instead of branching on _tag; inject the put and delete faults in Content.test through alternate ContentStore layers; sweepOne answers a delta rather than mutating a shared bag; drop the getObject seam; the Fastify test titles say patch.
…ith it verify-server-image.sh asserted PATCHY_DB_FILE and read the JSON-file database, which this branch deletes. Remove it, the docker-save artifact validator, the docker CI job, the docker turbo task and the root scripts that ran them.
The server now requires DATABASE_URL, so the e2e starts an embedded Postgres under its temp root and reads its assertions from SQL instead of the deleted metadata.json. embedded-postgres is imported lazily and its process-exiting signal handlers removed, so the harness's own cleanup runs.
e1a3d42 to
c2ad92b
Compare
Problem
Everything about a patch — its record and versions, the upload contract, visits and the retention clock, pins, moderation, the quota — lived in
packages/dbbehind a two-driverPatchyDbport, with the expiry sweep bolted onto the Fastify app. Every rule existed twice (SQL and TypeScript) with a 1,300-line contract suite holding them equal, and the tables and code still saiddrafta ticket after the wire stopped.Solution
packages/patchesis the capability on Effect:Patches(every row, decoded throughSqlSchemain one module — the retention clock, the visit top-up and the revocation freeze are SQL fragments read on the Effect clock),Content(the one place bytes are touched: put, insert, rollback on a refused row; the read a served page is built from),ExpirySweep(onesweepthe server forks withEffect.repeat(…, Schedule.spaced("1 hour"))), and thepatchesHttpApiBuildergroup. Migration 3 is the baseline withpatches/patch_versions;draftis gone from tables and code.The JSON driver and the
PatchyDbport are deleted (ADR-0003, Postgres only);packages/dbkeeps only themigrateDatabaseseam. The Fastify app serves both API groups through one runtime seam, reads pages throughContent, and its tests run on a Postgres clone per app. Tests:it.layeron a migrated database,HttpApiTest.groups(PatchyApi, ["patches"]), the sweep driven byTestClock, the rollback with a failingContentStorelayer.pnpm devserves uploads end to end throughpatches → content-store.Deviations from #76, named:
patchesalso depends onlimits: the per-token create limit is spent inside the upload handler (same as auth's mint limit), so the422 → 429 → 403order stays.upload_eventsandvisibilityare not in the baseline — nothing read them.hasScopeandrefusemoved into@patchy/apiso both groups share them;PatchQuotaExceededis listed beforeForbiddenso a client decoding a 403 keepscode.packages/dbkeeps the migration seam rather than a factory: with one driver the factory was the seam.draftidentifiers, rendered copy (Live draft host, the<!-- draft:… -->marker) and the self-hosting/Docker e2e scripts that started the JSON driver are left for the CLI and clean-up tickets.Stacked on #86.
Closes #76
Built by Claude Fable 5 via Claude Code.