Files
suaveplan/openspec/archive/2026-05-11-network-discovery-peerjs/tasks.md
2026-05-27 23:29:53 +01:00

62 lines
2.7 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-discovery-peerjs
## Phase 1: Scaffold
- [ ] 1.1 Create `packages/network/network-discovery-peerjs/` with feature-module layout.
- [ ] 1.2 `package.json` at `0.1.0`, `"sideEffects": false`, subpath exports.
- [ ] 1.3 Test config via `createTestConfig()`; `tests/dep-graph.test.ts`.
- [ ] 1.4 Add `peerjs` to root `package.json` catalog (`network-discovery` group).
## Phase 2: Types + errors
- [ ] 2.1 Port `types.ts` → `src/types/types.ts` + sibling `.md`.
- [ ] 2.2 `defineCodes("NET_DISC_PEERJS", [...])`: `SIGNALING_FAILED`, `PEER_CONNECT_FAILED`, `ROOM_FULL`, `INVALID_OPTIONS`, `DISPOSED`.
- [ ] 2.3 Zod schemas for `PeerJSDiscoveryConfig`, `PeerJSMessage`, `PeerJSPeerMetadata`.
## Phase 3: Core strategy
- [ ] 3.1 Port `PeerJSDiscovery` orchestrator (`DiscoveryStrategy` impl).
- [ ] 3.2 Port `PeerConnectionManager` per-peer registry.
- [ ] 3.3 Port `RoomManager` logical rooms.
- [ ] 3.4 Port `PeerJSConnection` `RTCDataConnection` wrapper.
- [ ] 3.5 Port `PeerJSMessageHandlers` wire-format routing.
- [ ] 3.6 Replace event emitter with `@suaveplan/events` `EventBus`.
- [ ] 3.7 Replace interval loops with `@suaveplan/timing` scheduler + injectable `Clock`.
- [ ] 3.8 Reject construction without explicit `host` option (no public-server fallback).
- [ ] 3.9 Thread `AbortSignal` through `start`/`stop`/`connect`.
## Phase 4: Observability
- [ ] 4.1 Span `disc_peerjs.start`.
- [ ] 4.2 Counter `peers_discovered_total{outcome}`.
- [ ] 4.3 Histogram `signaling_duration_ms`.
## Phase 5: Integration
- [ ] 5.1 Integration test with `@suaveplan/network-bootstrap`: register PeerJS strategy, run a node against a local PeerJS broker, observe `peer:found`.
- [ ] 5.2 Optional: register discovered peers into `@suaveplan/service-discovery`.
## Phase 6: Tests + docs
- [ ] 6.1 Unit tests per feature module via `@suaveplan/testing/runner`.
- [ ] 6.2 fast-check property tests on peer dedup + room admission.
- [ ] 6.3 100/100/100/100 coverage gate.
- [ ] 6.4 Sibling `.md` per `.ts` impl file.
- [ ] 6.5 Root `README.md` with basic + advanced examples.
## Phase 7: Verification
- [ ] 7.1 `bunx turbo lint typecheck test --filter=@suaveplan/network-discovery-peerjs` green.
- [ ] 7.2 `bunx turbo test:coverage --filter=@suaveplan/network-discovery-peerjs` 100/100/100/100.
- [ ] 7.3 `bun run docs:check --filter=@suaveplan/network-discovery-peerjs` green.
- [ ] 7.4 `MANIFEST.md` regen.
- [ ] 7.5 `STATUS.md` row flipped from `–` to `✅`.
## Pre-archive checklist
- [ ] Row 1 — Phase 7 green.
- [ ] Row 2 — Parity 🚫 list empty (or React-story exception justified).
- [ ] Row 3 — `openspec/specs/network-discovery-peerjs/spec.md` written.
- [ ] Row 4 — Integration test against a local PeerJS broker passes.
- [ ] Row 5 — Folder archived.