83 lines
2.7 KiB
Markdown
83 lines
2.7 KiB
Markdown
# Tasks: enterprise-crdt
|
|
|
|
- **Change ID**: enterprise-crdt
|
|
- **Package**: `@suaveplan/crdt`
|
|
- **Date**: 2026-04-24
|
|
|
|
## Prerequisites (must be published to Verdaccio first)
|
|
|
|
- [x] `@suaveplan/error`
|
|
- [x] `@suaveplan/types`
|
|
- [x] `@suaveplan/events`
|
|
- [x] `@suaveplan/diff`
|
|
|
|
## Tasks
|
|
|
|
### 1. Scaffold package
|
|
|
|
- [x] Create `universal/data/crdt/` directory tree per file layout in `proposal.md`
|
|
- [x] Write `package.json` (name `@suaveplan/crdt`, version `0.1.0`, `sideEffects: false`, correct workspace deps and catalog externals)
|
|
- [x] Write `tsconfig.json` extending `@suaveplan/typescript-config/library.json`
|
|
- [x] Write `vitest.config.ts` using `createTestConfig()` from `@suaveplan/testing/config`
|
|
|
|
### 2. Error codes (`src/error-codes.ts`)
|
|
|
|
- [x] Define `CrdtErrorCode` union type
|
|
- [x] Call `defineCodes` to register all `CRDT.*` codes
|
|
- [x] Export `registerCrdtErrorCodes()` and `CrdtError`
|
|
|
|
### 3. Types (`src/types/common.ts`)
|
|
|
|
- [x] Define and export `CRDT<TValue, TState>` interface and `CrdtOptions`
|
|
- [x] Write `common.md`
|
|
|
|
### 4. Core utilities
|
|
|
|
- [x] Implement `VectorClock` in `src/core/vector-clock/` with `increment`, `merge`, `compare`, Zod schema
|
|
- [x] Implement `CrdtSyncManager` in `src/core/sync-manager/` using `@suaveplan/diff` delta encoding
|
|
- [x] Each module: `.ts`, `.md`, `.types.ts`, `.test.ts`, `index.ts`
|
|
|
|
### 5. CRDT implementations
|
|
|
|
- [x] `GCounter` in `src/crdts/g-counter/`
|
|
- [x] `PNCounter` in `src/crdts/pn-counter/`
|
|
- [x] `ORSet<T>` in `src/crdts/or-set/`
|
|
- [x] `LWWRegister<T>` in `src/crdts/lww-register/`
|
|
- [x] `MVRegister<T>` in `src/crdts/mv-register/`
|
|
- [x] `TwoPSet<T>` in `src/crdts/two-p-set/`
|
|
- [x] `RGA<T>` in `src/crdts/rga/`
|
|
- [x] Each: `.ts`, `.md`, `.types.ts`, `.test.ts`, `index.ts`; Zod state schema; event-bus integration; `toJSON`/`fromJSON`
|
|
|
|
### 6. OTel instrumentation
|
|
|
|
- [x] Add spans, counters, histograms per `proposal.md` §4
|
|
|
|
### 7. Tests
|
|
|
|
- [x] Unit tests co-located with each CRDT (100% coverage target)
|
|
- [x] `tests/integration.test.ts` — two-replica merge scenarios for each CRDT type
|
|
- [x] `tests/property.test.ts` — fast-check CRDT laws (commutativity, associativity, idempotency) per `proposal.md` §5
|
|
|
|
### 8. Benchmarks (`src/__benchmarks__/crdt.bench.ts`)
|
|
|
|
- [x] Implement benchmark cases per `proposal.md` §6
|
|
|
|
### 9. Docs
|
|
|
|
- [x] Every `.ts` implementation file has a sibling `.md`
|
|
- [x] Root `README.md`
|
|
|
|
### 10. Pre-publish gate
|
|
|
|
- [x] `bunx turbo lint typecheck test --filter=@suaveplan/crdt` green
|
|
- [x] `bunx turbo test:coverage --filter=@suaveplan/crdt` ≥ 100% on touched modules
|
|
|
|
### 11. Publish
|
|
|
|
- [x] `bun scripts/publish.ts --package @suaveplan/crdt`
|
|
|
|
### 12. Archive
|
|
|
|
- [x] Fold spec delta into `openspec/specs/data/spec.md`
|
|
- [x] `mv openspec/changes/enterprise-crdt openspec/archive/2026-04-24-enterprise-crdt`
|