2.0 KiB
2.0 KiB
OpenSpec Change: network-plugin-content-delivery-store
- Change ID: network-plugin-content-delivery-store
- Package:
@suaveplan/network-plugin-content-delivery(extension) - Status: PROPOSED
- Type: extension
- Date: 2026-05-05
Why
The core network-plugin-content-delivery change (commit landing 2026-05-05) ships ChunkIndex, ChunkRequestRouter, RedundancyManager, IntegrityVerifier, and the ContentDeliveryPlugin facade — the mesh-CDN primitives that don't require external integrations. The ChunkStore subsystem was deferred per the parent proposal's ## Deferred to follow-up changes block because it requires deep coupling to @suaveplan/drive (browser OPFS/IndexedDB, Node filesystem) and an LRU eviction policy that warrants its own design + test surface.
This change adds ChunkStore to the existing package without breaking the core surface.
What changes
- ADDED:
ChunkStoreinterface over@suaveplan/drivefor persisting chunks. Browser path uses OPFS/IndexedDB via the existing drive adapter; Node path uses the filesystem driver. - ADDED: TTL-based eviction with LRU ordering — chunks evicted oldest-first when the store exceeds
maxBytesor when the chunk's age exceedsmaxAgeMs. - ADDED:
ChunkStoreEventbus topic (cd:chunk-stored,cd:chunk-evicted) soChunkIndexcan react to local state without polling. - ADDED:
ContentDeliveryPlugin.storegetter wires the new subsystem onto the plugin facade. - ADDED:
NETWORK_CD_CODES.STORE_QUOTA_EXCEEDEDif the new code is needed for backpressure (decision deferred until implementation).
Verification approach
src/store/chunk-store.spec-conformance.test.ts— pins put/get round-trip, TTL expiry, LRU eviction, byte-budget enforcement.src/store/chunk-store.eviction.spec-conformance.test.ts— pins eviction order under mixed insert / read traffic.
Migration impact
None — additive only. Existing consumers of ContentDeliveryPlugin see one new optional config field (store?: ChunkStoreConfig).