Repository navigation
feat(auth): packages/auth on Effect - #85
Conversation
|
Two-axis review of StandardsAuth’s own modules follow the Effect service spec: subpath namespaces, inline Hard
Judgement
SpecAgainst issue #74. “One file each” is a legitimate reading of one file per service: (a) Requirements missing or partial“No auth logic remains in Auth-group handlers did leave HttpApiTest is in place ( (b) Behaviour the spec did not ask for
(c) Looks implemented, looks wrongDropping those columns is inconsistent across drivers: JSON still writes Bearer parsing vs middleware. Spec puts parsing in auth. Effect’s decoder ( MethodThe ticket asked for a capability package, Effect services,
Worst method risk: dual Fastify+Effect dispatch for the auth group. YAGNIThe domain got smaller. The seam paid Effect rent. Most of that rent is the port’s required shape, not invention.
YAGNI pass. Worst excess is narrative comments, not extra services. Standards: 1 hard, 3 judgement. Worst in-axis: |
|
Went through the review. Pushed the fixes as one follow-up commit; lint, typecheck and the full suite (455) are green. Fixed
Not changed, with reasons
Ready to merge on green CI (base is #84). |
c9c05c4 to
4d73388
Compare
Tokens, principals, self-service minting with its quota, revocation and bearer parsing were spread across packages/db and apps/server/src/app.ts. They are now one Effect capability package, @patchy/auth: a Tokens service over @effect/sql-pg with SqlSchema row decoding and sql.withTransaction for the mint, the accounts/api_tokens/token_mints baseline as migrations 1-2, the server side of the Authorization middleware, and the auth HttpApi group built with HttpApiBuilder.group. Minting reports through @patchy/analytics and spends its per-minute limit through @patchy/limits. The Fastify app serves the group's four routes through the runtime seam and authenticates every protected request through Tokens; the JSON driver stands in for the Postgres tokens layer behind the same interface until the patches port deletes it. The draft migrations renumber to 3 onward.
JsonTokens.layer replaces the renamed jsonTokensLayer export; the auth handler in runtime.ts gets a make; the Authorization middleware reads the header through Bearer.parse so the Fastify guard and the API group accept the same forms (tabs, trailing whitespace); a stale clock note in the Postgres driver stops naming columns it no longer owns.
c467098 to
4593d55
Compare
Tokens, principals, self-service minting with its quota, revocation and bearer parsing were spread across
packages/db(internal-principals.ts,mint-quota.ts, the Postgres driver) andapps/server/src/app.ts, so the auth capability had no home the port could build on.They are now one Effect capability package,
@patchy/auth: aTokensservice over@effect/sql-pg(row decoding throughSqlSchemain one module,sql.withTransactionfor the mint, the quota counted inside it), theaccounts/api_tokens/token_mintsbaseline as migrations 1–2, the server side of theAuthorizationmiddleware, and theauthHttpApi group built withHttpApiBuilder.group. Minting reports through@patchy/analyticsand spends its per-minute limit through@patchy/limits. Tests run onit.layerover a migrated database andHttpApiTest.groups(PatchyApi, ["auth"])with good/bad bearer client layers, the 401 body asserted; the auth cases leftapp.postgres.test.tsand the db contract suite. Terms moved topackages/auth/CONTEXT.md; language-service warnings are errors for the package.Interim seam: the Fastify app serves the group's four routes by handing the request to the auth handlers through the runtime, and authenticates every protected request through
Tokens. The JSON driver keeps its token store behind the sameTokensinterface (jsonTokensLayer) until thepatchesport deletes it, so the packed-CLI e2e still runs against the Fastify server on the JSON driver. The draft migrations renumber to 3 onward.last_used_atandaccounts.self_service_minted_atare not in the rewritten baseline: nothing read them, and the mint record carries the provenance.Stacked on #84 (
feat/analytics-limits).Closes #74
Built by Claude Fable 5 via Claude Code.