65 lines
4.0 KiB
Markdown
65 lines
4.0 KiB
Markdown
# Tasks: enterprise-diff
|
|
|
|
## 1. Scaffold
|
|
- [x] 1.1 Create `universal/primitives/diff/` with `package.json`, `tsconfig.json`, `tsconfig.lib.json`, `vite.config.ts`, `vitest.config.ts`, `README.md` skeleton.
|
|
- [x] 1.2 Register 100/100/100/100 coverage thresholds in `vitest.config.ts`; `provider: 'istanbul'`.
|
|
- [x] 1.3 Cross-cutting guard tests in `tests/`: dep-graph, no-disallowed, tree-shake, file-size budget.
|
|
- [x] 1.4 Add package to root `CLAUDE.md` listing, `README.md` table, `FOLDERS.yml`.
|
|
|
|
## 2. Errors + schemas
|
|
- [x] 2.1 `src/errors/diff-error.ts` — `DiffError` extends `SuaveplanError`; `defineCodes` for `DIFF.INVALID_PATCH`, `DIFF.TEST_FAILED`, `DIFF.PATH_INVALID`, `DIFF.APPLY_FAILED`, `DIFF.INVERT_FAILED`.
|
|
- [x] 2.2 Auto-register codes via side-effect import in `src/index.ts`.
|
|
- [x] 2.3 Zod schemas: `OperationSchema`, `PatchSchema`, `PatchOptionsSchema`, `DiffOptionsSchema`, `HistoryStateSchema`, `SyncDeltaSchema` in `*.schemas.ts` siblings.
|
|
- [x] 2.4 Tests: error construction, code narrowing, `{ path?, operation?, reason? }` context fields.
|
|
|
|
## 3. Path module
|
|
- [x] 3.1 `src/path/path.ts` — `parsePath`, `formatPath`, `appendPath`, `concatPaths`, `comparePaths`, `pathEquals`, `isPrefix`, `parentPath`, `lastSegment`, `escapeSegment`, `unescapeSegment`.
|
|
- [x] 3.2 Co-located `src/path/path.md`.
|
|
- [x] 3.3 Unit tests + property tests: `parsePath(formatPath(p)) === p`; escape round-trip.
|
|
|
|
## 4. Utils module
|
|
- [x] 4.1 `src/utils/utils.ts` — `deepClone`, `deepEqual`, `hashValue`, `stringify`, `isObject`, `isPrimitive`, `getValueAtPath`, `setValueAtPath`, `setValueAtPathMut`, `insertValueAtPath`, `insertValueAtPathMut`, `deleteValueAtPath`, `deleteValueAtPathMut`.
|
|
- [x] 4.2 Co-located `src/utils/utils.md`.
|
|
- [x] 4.3 Unit tests covering edge cases: root path, array index beyond length, circular refs.
|
|
|
|
## 5. Operations
|
|
- [x] 5.1 `src/operations/operations.ts` — `createAdd`, `createCopy`, `createMove`, `createRemove`, `createReplace`, `createTest`, `invertOperation`, `invertPatch`, `operationsConflict`, `validateOperation`, `validatePatch`.
|
|
- [x] 5.2 Co-located `src/operations/operations.md`.
|
|
- [x] 5.3 Unit tests for each factory + invert round-trip + conflict detection.
|
|
|
|
## 6. Diff algorithm
|
|
- [x] 6.1 `src/diff/diff.ts` — structural diff with configurable `ArrayStrategy` (`'index' | 'lcs'`).
|
|
- [x] 6.2 Co-located `src/diff/diff.md`.
|
|
- [x] 6.3 Property tests: `applyPatch(doc, diff(a, b)) === b`.
|
|
|
|
## 7. Patch apply/revert
|
|
- [x] 7.1 `src/patch/patch.ts` — `applyPatch`, `revertPatch`; OTel counters + histogram.
|
|
- [x] 7.2 Co-located `src/patch/patch.md`.
|
|
- [x] 7.3 Unit tests: each operation type, failure modes, `test` op semantics; `PatchResult` shape.
|
|
|
|
## 8. History
|
|
- [x] 8.1 `src/history/history.ts` — `History` class with `push`, `undo`, `redo`, branch truncation; `createHistory` factory.
|
|
- [x] 8.2 Co-located `src/history/history.md`.
|
|
- [x] 8.3 Unit tests: linear undo/redo, branch-truncation on push, bounded size, listener notifications.
|
|
|
|
## 9. Sync manager
|
|
- [x] 9.1 `src/sync/sync.ts` — `SyncManager` class; `createSync` factory; delta push/pull; optimistic rebasing.
|
|
- [x] 9.2 Co-located `src/sync/sync.md`.
|
|
- [x] 9.3 Unit tests: concurrent deltas, conflict resolution, listener notifications.
|
|
|
|
## 10. Documentation + index
|
|
- [x] 10.1 Public `src/index.ts` — re-exports only; no side effects besides code-registry import.
|
|
- [x] 10.2 Subpath exports in `package.json` per feature module.
|
|
- [x] 10.3 Root `README.md` with Install / Quick-start / Modules links.
|
|
|
|
## 11. Benchmarks
|
|
- [x] 11.1 `src/__benchmarks__/diff.bench.ts`, `apply.bench.ts`, `revert.bench.ts`, `sync-push.bench.ts`.
|
|
- [x] 11.2 Publish baseline throughput numbers in README.
|
|
|
|
## 12. Ship gate
|
|
- [x] 12.1 `bunx turbo lint typecheck test --filter=@suaveplan/diff` — green.
|
|
- [x] 12.2 `bunx turbo test:coverage --filter=@suaveplan/diff` — 100/100/100/100.
|
|
- [x] 12.3 `bunx turbo build --filter=@suaveplan/diff` — green.
|
|
- [x] 12.4 Banned-pattern scan + missing-`.md` scan return zero output.
|
|
- [x] 12.5 Fold spec delta into `openspec/specs/diff/spec.md`; archive change folder.
|