Files
suaveplan/openspec/archive/2026-05-04-network-plugin-transport-manager/tasks.md
2026-05-27 23:29:53 +01:00

100 lines
4.5 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# Tasks — network-plugin-transport-manager
> Blocked on: `network-core`.
## 1. Scaffold
- [x] 1.1 `packages/network/network-plugin-transport-manager/` with `package.json`, `tsconfig.json`, `vitest.config.ts`, `README.md`.
- [x] 1.2 Workspace deps: `@suaveplan/network`, `@suaveplan/error`, `@suaveplan/types`, `@suaveplan/events`, `@suaveplan/timing`, `@suaveplan/rate-limiter`, `@opentelemetry/api`, `zod`.
- [x] 1.3 `sideEffects: false`.
## 2. Types
- [x] 2.1 `src/types/transport.types.ts` — `TransportEntry`, `TransportHealth`, `TransportCapability`.
- [x] 2.2 `src/types/priority.types.ts` — `MessagePriority`, `PriorityConfig`.
- [x] 2.3 `src/types/selector.types.ts` — `SelectorConfig`, `SelectionResult`.
- [x] 2.4 `src/error-codes.ts` — `defineCodes("NET_TM", [...])`.
## 3. Transport pool
- [x] 3.1 `src/pool/transport-pool.ts` — `TransportPool`.
- [x] 3.2 `register(transport)`, `unregister(transportId)`, `getHealth(transportId)`.
- [x] 3.3 Health score: 0–100 based on RTT, loss rate, stability.
## 4. Capability negotiator
- [x] 4.1 `src/negotiator/capability-negotiator.ts` — `CapabilityNegotiator`.
- [x] 4.2 Exchanges capability bitmap during `peer:connected`.
- [x] 4.3 Computes intersection of local and remote capabilities.
## 5. Transport selector
- [x] 5.1 `src/selector/transport-selector.ts` — `TransportSelector`.
- [x] 5.2 Selects transport based on priority + capability + health.
- [x] 5.3 CRITICAL: selects 2+ transports for redundant send.
## 6. Priority router
- [x] 6.1 `src/priority/priority-router.ts` — `PriorityRouter`.
- [x] 6.2 5 tiers: CRITICAL, HIGH, NORMAL, LOW, BULK.
- [x] 6.3 CRITICAL messages sent redundantly on 2+ transports.
## 7. Round-robin balancer
- [x] 7.1 `src/balancer/round-robin-balancer.ts` — `RoundRobinBalancer`.
- [x] 7.2 Distributes NORMAL and BULK across healthy transports.
## 8. Health monitor
- [x] 8.1 `src/health/transport-health-monitor.ts` — `TransportHealthMonitor`.
- [x] 8.2 Auto-pauses transport when health < threshold.
- [x] 8.3 Auto-resumes when health recovers.
## 9. Plugin wrapper
- [x] 9.1 `src/plugin/transport-manager-plugin.ts` — `TransportManagerPlugin` implements `NetworkPlugin`.
## 10. Spec
- [x] 10.1 Update `openspec/specs/network/spec.md` with `NET-TM` requirements.
## 11. Conformance tests
- [x] 11.1 `src/pool/pool.spec-conformance.test.ts` — registration, health, removal.
- [x] 11.2 `src/selector/selector.spec-conformance.test.ts` — priority, capability, health.
- [x] 11.3 `src/negotiator/negotiator.spec-conformance.test.ts` — exchange, intersection.
- [x] 11.4 `src/priority/priority.spec-conformance.test.ts` — 5 tiers, redundant CRITICAL.
- [x] 11.5 `src/balancer/balancer.spec-conformance.test.ts` — round-robin, distribution.
- [x] 11.6 `src/health/health.spec-conformance.test.ts` — degradation, pause, resume.
- [x] 11.7 `src/error-codes.spec-conformance.test.ts` — frozen registry.
## 12. Pre-emptive transport switching
- [x] 12.1 `src/analyzer/quality-trend-analyzer.ts` — `QualityTrendAnalyzer`, EMA slope for latency/loss/bandwidth.
- [x] 12.2 `src/selector/preemptive-selector.ts` — `PreemptiveSelector`, switches on trend before threshold.
- [x] 12.3 Smooth handoff: establish new before teardown, overlap window.
## 13. Session persistence
- [x] 13.1 `src/persistence/session-persistence-buffer.ts` — `SessionPersistenceBuffer`, buffers state during drops.
- [x] 13.2 `src/recovery/connection-recovery-manager.ts` — `ConnectionRecoveryManager`, exponential backoff with jitter.
- [x] 13.3 `src/recovery/session-continuity-guard.ts` — `SessionContinuityGuard`, replays buffered messages on recovery.
- [x] 13.4 Prioritized recovery: CRITICAL connections recover first.
## 14. Spec
- [x] 14.1 Update `openspec/specs/network/spec.md` with `NET-46`, `NET-60`.
## 15. Conformance tests
- [x] 15.1 `src/analyzer/analyzer.spec-conformance.test.ts` — trend detection, slope calculation.
- [x] 15.2 `src/selector/preemptive.spec-conformance.test.ts` — pre-emptive switch, smooth handoff.
- [x] 15.3 `src/persistence/persistence.spec-conformance.test.ts` — buffering, replay, sequence.
- [x] 15.4 `src/recovery/recovery.spec-conformance.test.ts` — backoff, jitter, continuity, priority.
## 16. Verify
- [x] 16.1 `bunx turbo lint typecheck test --filter=@suaveplan/network-plugin-transport-manager` green.
- [x] 16.2 `bunx turbo test:coverage --filter=@suaveplan/network-plugin-transport-manager` 100/100/100/100.
- [x] 16.3 `bun scripts/openspec-conformance.ts @suaveplan/network-plugin-transport-manager` PASS.