Files
2026-05-27 23:29:53 +01:00

4.9 KiB
Raw Permalink Blame History

Tasks — @suaveplan/api-secrets-vault

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 (§3, §5, §13.2)
  • 1.2 Read openspec/AGENTS.md Sections 13 and 14
  • 1.3 Draft proposal.md
  • 1.4 Draft specs/api-secrets-vault/spec.md
  • 1.5 Every requirement carries **Verified by:**

2. Implementation

  • 2.1 Scaffold packages/api-stack/api/api-secrets-vault/
  • 2.2 src/adapter/ — createVaultSecretsAdapter
  • 2.3 src/allowlist/ — per-plugin allowlist enforcement
  • 2.4 src/watcher/ — vault secret.updated → bus secret.changed
  • 2.5 src/error-codes/error-codes.ts (feature-folder per CLAUDE.md "No flat modules at src/ root")
  • 2.6 src/index.ts — explicit named re-exports + side-effect error-codes import
  • 2.7 src/from-vault/ — fromVault(vault: Vault) bridge to a real @suaveplan/vault.Vault
  • 2.8 src/otel/ — getSecretsVaultInstruments + api.secrets.reads_total{backend="vault"} counter
  • 2.9 src/types/ — structural VaultSecretsBackend contract

3. Tests

  • 3.1 src/adapter/adapter.test.ts
  • 3.2 src/adapter/adapter.spec-conformance.test.ts — passes runSecretsConformance
  • 3.3 src/watcher/watcher.test.ts
  • 3.4 tests/dep-graph.test.ts
  • 3.5 Every it(...) carries { timeout: 5000 } (30000 for crypto-heavy unlock; 120000 for the shared beforeAll)
  • 3.6 src/allowlist/allowlist.test.ts — INVALID_OPTIONS / NOT_ALLOWED arms
  • 3.7 src/error-codes/error-codes.test.ts — registry shape + class identity
  • 3.8 src/otel/instruments.test.ts — counter emission
  • 3.9 src/from-vault/from-vault.test.ts — WRITE_FAILED error wrapping (structural shim around vault.items; integration suite drives the bridge against the real Vault)
  • 3.10 tests/integration.test.ts — REAL @suaveplan/vault.Vault end-to-end (shared beforeAll unlock + OWASP-min Argon2id params + separate locked-vault describe to isolate zeroizeAll())

4. Documentation

  • 4.1 Sibling .md per implementation .ts (docs:check → 7/7 = 100%)
  • 4.2 README.md ## Modules
  • 4.3 Update CLAUDE.md package listing (orchestrator)

5. Pre-archive verification (the 5-gate triple)

  • 5.1 bun run check — biome clean (no fixes applied on rerun)
  • 5.2 bunx turbo lint typecheck test --filter=@suaveplan/api-secrets-vault — green
  • 5.3 bunx turbo test:coverage --filter=@suaveplan/api-secrets-vault — 100/100/100/100 across adapter, allowlist, error-codes, from-vault, otel, watcher
  • 5.4 bun scripts/openspec-conformance.ts packages/api-stack/api/api-secrets-vault — PASS (0 error, 0 warn, 0 info)
  • 5.5 bunx turbo build --filter=@suaveplan/api-secrets-vault — vite build clean, dts emitted

6. Pre-archive 7-row checklist

  • 6.1 Generics threaded — SuaveplanError<SecretsVaultCode> parameterises throwables; no unknown leaks in public d.ts (conformance verified)
  • 6.2 Zod schemas wired at boundaries — allowlist, adapter, watcher all validate construction options with safeParse and raise SECRETS_VAULT.INVALID_OPTIONS on failure
  • 6.3 Every SECRETS_VAULT.* code thrown by a production path — NOT_FOUND, NOT_ALLOWED, VAULT_LOCKED, VAULT_UNAVAILABLE, WRITE_FAILED, INVALID_OPTIONS all asserted in tests against real throw sites
  • 6.4 Strict-mode: locked vault raises VAULT_LOCKED from BOTH get and require; no plaintext fallback (covered by adapter.test.ts + integration locked-vault describe)
  • 6.5 OTel api.secrets.reads_total{backend="vault"} asserted — adapter.test.ts::"get returns stored value AND increments reads_total" flushes the in-memory exporter and finds the metric
  • 6.6 Lifecycle dedup — adapter dispose() idempotent (3× call test); watcher subscription single (listenerCount === 1 assertion); watcher dispose idempotent + survives lazy backend unsubscribes (in-listener disposed-flag guard)
  • 6.7 No retroactive tick — every box ticked above reflects evidence in this branch

7. Archive

  • 7.1 Fold spec delta into openspec/specs/api-secrets-vault/spec.md
  • 7.2 Move folder to archive
  • 7.3 Tick 8.14 in umbrella tasks
  • 7.4 Refresh MANIFEST.md