Initial Commit

This commit is contained in:
2026-05-27 23:29:53 +01:00
commit fbc70f96e6
10000 changed files with 1102152 additions and 0 deletions

View File

@@ -0,0 +1,30 @@
# 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`).

View File

@@ -0,0 +1,22 @@
# Tasks — network-plugin-content-delivery-store
> Blocked on: `network-plugin-content-delivery` (core), `@suaveplan/drive`.
## 1. Implementation
- [x] 1.1 `src/store/chunk-store.ts` — `ChunkStore` over `@suaveplan/drive` (pluggable `ChunkStoreAdapter`).
- [x] 1.2 LRU + TTL eviction with `maxBytes` and `maxAgeMs` budgets.
- [x] 1.3 Bus events: `cd:chunk-stored`, `cd:chunk-evicted`.
- [x] 1.4 Wire `ContentDeliveryPlugin.store` getter through the facade.
- [x] 1.5 Add `ChunkStoreConfig` to `ContentDeliveryPluginConfig` as an optional field.
## 2. Tests
- [x] 2.1 `src/store/chunk-store.spec-conformance.test.ts` — put/get, TTL, LRU.
- [x] 2.2 `src/store/chunk-store.eviction.spec-conformance.test.ts` — eviction order under mixed traffic.
## 3. Verify
- [x] 3.1 `bunx turbo lint typecheck test --filter=@suaveplan/network-plugin-content-delivery` green.
- [x] 3.2 `bunx turbo test:coverage --filter=@suaveplan/network-plugin-content-delivery` 100/100/100/100.
- [x] 3.3 `bun scripts/openspec-conformance.ts @suaveplan/network-plugin-content-delivery` PASS (build green; CLAUDE-Rule-11 runner imports verified).