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

85 lines
5.0 KiB
Markdown

# Tasks — crypto-vault
> Every checkbox MUST reflect work actually done in this change. Do not retroactively tick boxes for work that was already in main when this change opened.
## 1. Spec authoring
- [x] 1.1 Read `MIGRATION.md` Section 7 and Section 8 for vault architecture context
- [x] 1.2 Read `openspec/AGENTS.md` Sections 13 and 14
- [x] 1.3 Draft `proposal.md` from `openspec/templates/proposal.md`
- [x] 1.4 Draft `specs/crypto-vault/spec.md` from `openspec/templates/spec-delta.md`
- [x] 1.5 Every requirement carries a `**Verified by:**` line naming concrete `it(...)` titles
## 2. Implementation
- [x] 2.1 Scaffold package at `packages/crypto/crypto-vault` with `package.json`, `tsconfig.json`, `vitest.config.ts`
- [x] 2.2 Implement BIP39 module: `generateMnemonic`, `entropyToMnemonic`, `mnemonicToEntropy`, English word list
- [x] 2.3 Implement Argon2id module: `deriveKeyWithArgon2id`, `Argon2idParams`, OWASP minimum enforcement
- [x] 2.4 Implement HD key module: `deriveMasterKeyFromMnemonic`, BIP39 seed derivation, BIP32-like path
- [x] 2.5 Implement 2SKD module: `deriveAuk`, password + Secret Key + email mixing
- [x] 2.6 Implement key hierarchy module: `derivePersonalKeyset`, `deriveVaultKey`, `deriveItemKey`
- [x] 2.7 Implement SRP-6a client module: `SrpClient`, safe-prime group parameters, SHA-256 per RFC 5054
- [x] 2.8 Implement secure buffer module: `SecureBuffer`, `zeroizeAll`, toString masking, clone isolation
- [x] 2.9 Implement error module: `CryptoVaultError`, structured error codes
- [x] 2.10 Add `Clock` / `Rng` injection to `generateMnemonic`, `deriveAuk`, `SrpClient`, and `SecureBuffer`
- [x] 2.11 Export `OpaqueKeyHandle` for `vault` layer consumption
- [x] 2.12 Wire subpath exports in `package.json` for every feature module
- [x] 2.13 Add `README.md` with quick-start, modules list, and install instruction
## 3. Tests
- [x] 3.1 Unit tests at `src/bip39/bip39.test.ts` covering every BIP39 scenario
- [x] 3.2 Unit tests at `src/argon2id/argon2id.test.ts` covering derivation and parameter safety
- [x] 3.3 Unit tests at `src/hd-key/hd-key.test.ts` covering master key derivation
- [x] 3.4 Unit tests at `src/twoskd/twoskd.test.ts` covering 2SKD determinism and factor separation
- [x] 3.5 Unit tests at `src/key-hierarchy/key-hierarchy.test.ts` covering hierarchical derivation
- [x] 3.6 Unit tests at `src/srp/srp-client.test.ts` covering full handshake and failure modes
- [x] 3.7 Unit tests at `src/secure/secure-buffer.test.ts` covering zeroization and masking
- [x] 3.8 Spec-conformance tests at `src/spec-conformance.test.ts` pinning type-level / strict-mode scenarios
- [x] 3.9 Property/fuzz tests for BIP39 round-trip and Argon2id determinism
- [x] 3.10 Every `it(...)` carries `{ timeout: 5000 }` (or 30000 for genuinely async / Argon2id-heavy)
## 4. Documentation
- [x] 4.1 Sibling `.md` for every implementation `.ts` (≥200 words, basic + advanced examples, full API reference)
- [x] 4.2 README links every co-located `.md` under `## Modules`
- [x] 4.3 Update `CLAUDE.md` package listing if this is a new package
## 5. Pre-archive verification (the 5-gate triple)
- [x] 5.1 `bun run check` — Biome 0 errors / 0 warnings / 0 info across the whole monorepo
- [x] 5.2 `bunx turbo lint typecheck test --filter=@suaveplan/crypto-vault` — green
- [x] 5.3 `bunx turbo test:coverage --filter=@suaveplan/crypto-vault` — 100/100/100/100
- [x] 5.4 `bun scripts/openspec-conformance.ts @suaveplan/crypto-vault` — exit 0, no `error` findings
- [x] 5.5 `bunx turbo build --filter=@suaveplan/crypto-vault` — green
## 6. Pre-archive 7-row checklist (AGENTS.md Section 13)
- [x] 6.1 Generics threaded; `expectTypeOf` assertions on every literal-type claim
- [x] 6.2 Zod schemas wired at every declared boundary
- [x] 6.3 Every error code in `error-codes.ts` thrown by at least one production path
- [x] 6.4 Strict-mode behaviors tested both on and off
- [x] 6.5 OTel instruments emitted from production paths and asserted with a real in-memory `MeterProvider`
- [x] 6.6 Lifecycle dedup tested where claimed (in-flight Promise, idempotent set/load)
- [x] 6.7 No retroactive tick — every box above reflects work done in this change
## 7. Archive
- [x] 7.1 Fold spec delta into `openspec/specs/crypto-vault/spec.md`
- [x] 7.2 Move `openspec/changes/crypto-vault/` → `openspec/archive/2026-05-03-crypto-vault/`
- [x] 7.3 Refresh `MANIFEST.md` if package set or deps changed (orchestrator §13b)
## Audit Note (2026-05-02)
DEFERRED in the genesis spec-cleanup pass on 2026-05-02. Rationale:
- Depends on the (still-pending-migration) @suaveplan/vault package per the dep graph in the proposal. Until vault is migrated, this change cannot meaningfully ship. 0/46 done.
## Audit Note (2026-05-03)
UNBLOCKED — the change ships independently of `@suaveplan/vault`. `crypto-vault`
is the foundational primitive layer; `@suaveplan/vault` (when later migrated)
will consume `OpaqueKeyHandle`, `SecureBuffer`, and the hierarchy derivations
shipped here. All 46 task boxes ticked; package shipped at v0.0.0 with
100% / 100% / 100% / 100% coverage.