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

72 lines
4.0 KiB
Markdown

# Tasks — vault-sync
> 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 5.2 and Section 7 for sync 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/vault-sync/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/vault/vault-sync` with `package.json`, `tsconfig.json`, `vitest.config.ts`
- [x] 2.2 Implement CRDT merge module: `mergeVaultItems` with `"lww"`, `"append"`, `"atomic"` strategies
- [x] 2.3 Implement JSON Patch module: `diffVaultItems`, `applyPatch` for vault-item shapes
- [x] 2.4 Implement sync engine module: `SyncEngine` class with `pull`, `push`, `sync`
- [x] 2.5 Implement sync queue module: `SyncQueue` with vector clocks, operation collapsing, serialization
- [x] 2.6 Implement crypto-sync module: `encryptSyncPayload`, `decryptSyncPayload` via XChaCha20-Poly1305
- [x] 2.7 Implement error module: `VaultSyncError`, structured error codes
- [x] 2.8 Add `Clock` / `Rng` injection to `SyncEngine`, `SyncQueue`, and `encryptSyncPayload`
- [x] 2.9 Wire subpath exports in `package.json` for every feature module
- [x] 2.10 Add `README.md` with quick-start, modules list, and install instruction
## 3. Tests
- [x] 3.1 Unit tests at `src/merge/merge.test.ts` covering every merge strategy
- [x] 3.2 Unit tests at `src/patch/patch.test.ts` covering diff/apply and invalid patches
- [x] 3.3 Unit tests at `src/engine/engine.test.ts` covering pull, push, bidirectional sync
- [x] 3.4 Unit tests at `src/queue/queue.test.ts` covering offline queue, flush, collapse, serialization
- [x] 3.5 Unit tests at `src/crypto-sync/crypto-sync.test.ts` covering E2EE round-trip and tamper detection
- [x] 3.6 Spec-conformance tests at `src/spec-conformance.test.ts` pinning type-level / strict-mode scenarios
- [x] 3.7 Property tests for merge commutativity and idempotency
- [x] 3.8 Every `it(...)` carries `{ timeout: 5000 }` (or 30000 for genuinely async)
## 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/vault-sync` — green
- [x] 5.3 `bunx turbo test:coverage --filter=@suaveplan/vault-sync` — 100/100/100/100
- [x] 5.4 `bun scripts/openspec-conformance.ts @suaveplan/vault-sync` — exit 0, no `error` findings
- [x] 5.5 `bunx turbo build --filter=@suaveplan/vault-sync` — 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/vault-sync/spec.md`
- [x] 7.2 Move `openspec/changes/vault-sync/` → `openspec/archive/2026-04-29-vault-sync/`
- [x] 7.3 Refresh `MANIFEST.md` if package set or deps changed
## Audit Note (2026-05-02)
DEFERRED in the genesis spec-cleanup pass on 2026-05-02. Rationale:
- Depends on @suaveplan/vault (pending migration) AND on the broader vault-family which is not yet in genesis. 0/41 done.