Repository navigation
Closed
Labels
Description
Problem
Tokens, principals, self-service mint, quota and revocation are spread across packages/db (internal-principals.ts, mint-quota.ts, the Postgres driver) and apps/server/src/app.ts. They become one capability package that implements the auth API group.
Do
packages/auth: services for token minting + mint quota, principal lookup bysha256(token), revocation and bearer parsing, one file each per.agents/skills/effect-service-conventions/SKILL.md; failures asSchema.TaggedErrorwith structured fields; row decoding throughSqlSchemain one module.- Migrations 1–2 rewritten as the baseline for
accounts,api_tokens,token_mints(integer ids in the global sequence), registered in thesqlmigrator's record. - Implements the
authHttpApi group frompackages/apiwithHttpApiBuilder.groupand the server-side bearer middleware (Authorization.of({ bearer })providing the current principal).sql.withTransactionwhere today's code holds a manual transaction for minting. - Emits its analytics events through
packages/analytics; mint rate limiting throughpackages/limits. - Interim: Fastify serves the group's routes through the seam (the handler layer is called via
runPromise); theservingticket replaces the seam withHttpApiBuilder.layer. - Tests:
it.layeron a migrated database,HttpApiTest.groups(PatchyApi, ["auth"])for the routes (good/bad tokens as twoHttpApiMiddleware.layerClientlayers), the 401 body asserted; split the auth cases out ofapp.postgres.test.ts. - Move token / principal / mint / quota / revocation terms from
apps/server/CONTEXT.mdtopackages/auth/CONTEXT.md;packages/auth/docs/adr/if a decision meets the tests. Promote the language-service warnings toerrorfor the package.
Done when
No auth logic remains in packages/db or app.ts; the auth group passes HttpApiTest; the packed-CLI e2e still passes against the Fastify server.
Decisions implemented
Spec §1, §2, §3, §6, §7; Package decomposition by capability.
Filed from the Effect v4 port spec (#68) by the map task Write the port spec and file the build tickets.
Activity