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

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: ChunkStore interface over @suaveplan/drive for 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 maxBytes or when the chunk's age exceeds maxAgeMs.
  • ADDED: ChunkStoreEvent bus topic (cd:chunk-stored, cd:chunk-evicted) so ChunkIndex can react to local state without polling.
  • ADDED: ContentDeliveryPlugin.store getter wires the new subsystem onto the plugin facade.
  • ADDED: NETWORK_CD_CODES.STORE_QUOTA_EXCEEDED if 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).