4.2 KiB
4.2 KiB
Tasks — add-cache-storage-cbor-codec
Every checkbox MUST reflect work actually done in this change. Additive only — no behaviour change to existing codecs.
1. Pre-flight
- 1.1 Re-read
openspec/AGENTS.md§0c (delta format) and §13 (gate order) - 1.2 Confirm
@suaveplan/cborships on genesis withencode,decode,Tagged,type TagHandlerin the root barrel - 1.3 Confirm
packages/flow/cache-storage/src/codec/codec.types.tsexposesCodec<T>and thatstorage-cache.tsdefaults toJsonCodec(no behaviour change needed) - 1.4 Numbered checklist of every
### Requirementand#### Scenarioinspecs/cache-storage/spec.mdexists in working notes (AGENTS §0c step 6)
2. Package wiring
- 2.1 Add
@suaveplan/cbortopackages/flow/cache-storage/package.jsondependenciesatworkspace:^ - 2.2 Add subpath export
./codec/structured-clonemirroring the shape of./codec/jsonand./codec/identity - 2.3 Confirm
sideEffectsarray remains correct (no new side-effect file added)
3. Error registry extension
- 3.1 Extend
CACHE_STORAGE_CODESinsrc/errors/errors.tswithCODEC_UNSUPPORTED_TYPEandCODEC_UNKNOWN_TAG - 3.2 Update
src/errors/errors.mdFeatures + API Reference to list the two new codes (doc-drift gate §4a)
4. Implementation — StructuredCloneCodec
- 4.1
src/codec/structured-clone.ts—StructuredCloneCodec<T> implements Codec<T>; lift table perdesign.md; encode/decode against@suaveplan/cbor - 4.2
src/codec/structured-clone.md— sibling docs (≥200 words, basic + advanced examples, API reference, implementation notes) - 4.3
src/codec/index.ts— explicit named re-export ofStructuredCloneCodec - 4.4 Confirm file size ≤300 lines; split if needed (e.g. lift table to
src/codec/structured-clone.tags.ts)
5. Conformance harness
- 5.1
src/codec/conformance.ts—runCodecConformance(codec, { name, supportsStructuredClone })covering primitives, nested objects, arrays,Date,Map,Set,Uint8Array,bigint(positive + negative),RegExp,URL, deep nesting, empty collections - 5.2
src/codec/conformance.md— sibling docs - 5.3
src/codec/conformance.test.ts— harness self-test: a deliberately brokenCodec<unknown>must cause the harness to fail (no tautological green)
6. Tests
- 6.1
src/codec/structured-clone.test.ts— invokerunCodecConformance(new StructuredCloneCodec(), { name: "StructuredCloneCodec", supportsStructuredClone: true }); plus direct tests forCODEC_UNSUPPORTED_TYPE(encode() => {},Symbol("x"),new WeakMap()) andCODEC_UNKNOWN_TAG(decode a CBOR-encodedTagged(9999, "x")) - 6.2 Extend
src/codec/json.test.tswithrunCodecConformance(new JsonCodec<unknown>(), { name: "JsonCodec", supportsStructuredClone: false }) - 6.3 Extend
src/codec/identity.test.tswithrunCodecConformance(new IdentityCodec(), { name: "IdentityCodec", supportsStructuredClone: false })— usingUint8Arraypayloads only - 6.4 Extend
src/errors/errors.test.tsto assert the two new codes are reachable - 6.5 Every
it(...)carries{ timeout: 5000 } - 6.6 All test imports via
@suaveplan/testing/runner(§7)
7. Gates (§13 order)
- 7.1 Spec reconciliation — walk every
### Requirement/#### Scenarioagainst impl - 7.2
bunx turbo lint typecheck test --filter=@suaveplan/cache-storage - 7.3
bunx turbo test:coverage --filter=@suaveplan/cache-storage— 100/100/100/100 - 7.4
bunx turbo build --filter=@suaveplan/cache-storage - 7.5 Banned-pattern, barrel-shape, runner-import, missing-
.md, bare-version scans (zero output) - 7.6
bunx turbo test --filter=...@suaveplan/cache-storage— dependent sweep (@suaveplan/cache-redismust remain green)
8. Manifest & archival
- 8.1
bun scripts/folder-reorg/generate-manifest.ts - 8.2 Update
packages/flow/cache-storage/README.mdModules section with the new codec - 8.3
bunx markdownlint-cli2 --fix - 8.4 Fold
specs/cache-storage/spec.mdintoopenspec/specs/cache-storage/spec.md(merge## ADDEDblock into existing spec) - 8.5 Move change folder →
openspec/archive/<yyyy-mm-dd>-add-cache-storage-cbor-codec/