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,28 @@
# OpenSpec Change: network-plugin-content-delivery-throttle
- **Change ID**: network-plugin-content-delivery-throttle
- **Package**: `@suaveplan/network-plugin-content-delivery` (extension)
- **Status**: PROPOSED
- **Type**: extension
- **Date**: 2026-05-05
## Why
The core `network-plugin-content-delivery` change shipped the mesh-CDN primitives but deferred `BandwidthThrottler` — the rate-limiting layer that prevents file transfers from starving CRITICAL control messages. That deferral was per the parent proposal's `## Deferred to follow-up changes` block because the throttler couples to `@suaveplan/rate-limiter` (token-bucket implementation) and to `network-plugin-transport-manager` (BULK priority class).
This change adds `BandwidthThrottler` to the existing package without breaking the core surface.
## What changes
- **ADDED**: `BandwidthThrottler` class wrapping `@suaveplan/rate-limiter` with chunk-aware semantics (per-peer + global token buckets).
- **ADDED**: Integration with `network-plugin-transport-manager` BULK priority — chunk transfers tag every send with `priority: "bulk"`.
- **ADDED**: `cd:throttled` event when a chunk dispatch is delayed by the limiter.
- **ADDED**: `ContentDeliveryPlugin.throttler` getter wires the new subsystem onto the plugin facade.
## Verification approach
- `src/throttle/bandwidth-throttler.spec-conformance.test.ts` — pins per-peer and global rate enforcement, BULK priority tagging, throttle event emission.
## Migration impact
None — additive only.

View File

@@ -0,0 +1,21 @@
# Tasks — network-plugin-content-delivery-throttle
> Blocked on: `network-plugin-content-delivery` (core), `@suaveplan/rate-limiter`, `network-plugin-transport-manager`.
## 1. Implementation
- [x] 1.1 `src/throttle/bandwidth-throttler.ts` — `BandwidthThrottler`.
- [x] 1.2 Per-peer + global token buckets via `@suaveplan/rate-limiter`-style algorithm.
- [x] 1.3 Tag chunk dispatches with `priority: "bulk"` for transport manager.
- [x] 1.4 Emit `cd:throttled` on delayed dispatch.
- [x] 1.5 Wire `ContentDeliveryPlugin.throttler` getter.
## 2. Tests
- [x] 2.1 `src/throttle/bandwidth-throttler.spec-conformance.test.ts` — per-peer rate, global rate, BULK priority, event emission.
## 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).