Files
suaveplan/openspec/archive/2026-05-25-api-auth/tasks.md
2026-05-27 23:29:53 +01:00

3.4 KiB

Tasks — @suaveplan/api-auth

Every checkbox MUST reflect work actually done in this change.

0. Pre-flight (non-negotiable)

  • 0.1 Confirm clean working tree (git status reports nothing) and no in-flight worktrees with uncommitted work (git worktree list then git status in each)
  • 0.2 If any worktrees exist under .claude/worktrees/, account for each one: still-active agent, work-pending-merge, or stale-and-prune. Stale worktrees MUST be removed (git worktree remove) before opening a new one — code that has been lost twice on main is the failure mode this guards against.
  • 0.3 Confirm the package set in MANIFEST.md matches find packages -maxdepth 3 -name package.json count. Drift here means a prior change archived without regenerating the manifest.

1. Spec authoring

  • 1.1 Read design doc §2.3 (auth two contracts), §6 step 3 (auth in pipeline + CSRF), §7 step 3 (security schemes for OpenAPI)
  • 1.2 Read openspec/specs/api-auth/spec.md (does not exist yet)
  • 1.3 Read openspec/AGENTS.md Sections 13, 14
  • 1.4 Draft proposal.md
  • 1.5 Source-mapping table
  • 1.6 Draft specs/api-auth/spec.md
  • 1.7 **Verified by:** line on every requirement

2. Implementation

  • 2.1 Scaffold packages/api-stack/api/api-auth/ ("version": "0.1.0", "sideEffects": false, deps: @suaveplan/api-types, @suaveplan/error, @suaveplan/types, tslib, zod)
  • 2.2 src/resolver/ — SessionResolver interface
  • 2.3 src/chain/ — SessionResolverChain runtime
  • 2.4 src/security-scheme/ — SecuritySchemeContribution + Zod schema (import z from "zod")
  • 2.5 src/csrf-policy/ — CsrfPolicy helper
  • 2.6 src/session-adapter/ — composite AuthAdapter
  • 2.7 src/capability-id/ — AUTH_SESSION_CAPABILITY_ID + assignability assertion
  • 2.8 src/error-codes/ — AUTH_CODES
  • 2.9 src/testing/ — runAuthSessionConformance(factory)
  • 2.10 src/index.ts — explicit named re-exports
  • 2.11 package.json exports per subpath

3. Tests

  • 3.1 Unit tests per feature
  • 3.2 Spec-conformance type tests
  • 3.3 Property test on chain ordering (Fisher-Yates of null-returning resolvers + one non-null wins)
  • 3.4 Every it(...) carries { timeout: 5000 }

4. Documentation

  • 4.1 Sibling .md for every implementation .ts
  • 4.2 README.md linking every .md
  • 4.3 No CLAUDE.md update

5. Pre-archive verification

  • 5.1 bun run check — 0/0/0
  • 5.2 bunx turbo lint typecheck test --filter=@suaveplan/api-auth — green (55/55 tests)
  • 5.3 bunx turbo test:coverage --filter=@suaveplan/api-auth — 100/100/100/100
  • 5.4 bun scripts/openspec-conformance.ts packages/api-stack/api/api-auth — exit 0
  • 5.5 bunx turbo build --filter=@suaveplan/api-auth — green

6. Pre-archive 7-row checklist

  • 6.1 Generics on SessionResolver<P extends Principal>; expectTypeOf assertions
  • 6.2 Zod wired at security-scheme boundary
  • 6.3 Every AUTH_CODES entry thrown
  • 6.4 Chain fail-closed-on-throw strict-mode tested (default fail-closed; opt-in continue-on-throw)
  • 6.5 OTel — N/A (adapters emit)
  • 6.6 Lifecycle dedup — dispose() idempotent; tested
  • 6.7 No retroactive tick

7. Archive

  • 7.1 Fold spec delta
  • 7.2 Move to openspec/archive/<yyyy-mm-dd>-api-auth/
  • 7.3 Tick umbrella 1.7
  • 7.4 Refresh MANIFEST.md