# Tasks — network-discovery-hybrid ## Phase 1: Scaffold - [ ] 1.1 Create `packages/network/network-discovery-hybrid/` with feature-module layout. - [ ] 1.2 `package.json` at `0.1.0`, `"sideEffects": false`, subpath exports. - [ ] 1.3 Declare optional peer-deps on the five sibling discovery packages with `peerDependenciesMeta.{...}.optional: true`. - [ ] 1.4 Test config via `createTestConfig()`; `tests/dep-graph.test.ts`. ## Phase 2: Types + errors - [ ] 2.1 Port `types.ts` → `src/types/types.ts` + sibling `.md`. - [ ] 2.2 `defineCodes("NET_DISC_HYBRID", [...])` per parity checklist. - [ ] 2.3 Zod schemas for `HybridDiscoveryConfig`, `StrategyConfig`, `StrategyPriority`. ## Phase 3: Core orchestrator - [ ] 3.1 Port `HybridDiscoveryManager` orchestrator. - [ ] 3.2 Port `StrategyManager` (health + priority). - [ ] 3.3 Port `Lifecycle` start/stop FSM. - [ ] 3.4 Port `PeerTracker` deduped peer set with `PeerSource`. - [ ] 3.5 Port `StrategyLoader` dynamic loader (resolves optional peer-deps lazily). ## Phase 4: Banned-mock removal - [ ] 4.1 DELETE `__mocks__/strategy-mock.ts` — do not port. - [ ] 4.2 Author a real in-package `TestStrategy` fixture implementing `DiscoveryStrategy` deterministically (no `vi.mock` / `jest.mock`). - [ ] 4.3 Verify zero `: any` usage in production source. ## Phase 5: Observability - [ ] 5.1 Counter `hybrid.peer_sources_total{strategy}`. - [ ] 5.2 Histogram `hybrid.strategy_health_score{strategy}`. - [ ] 5.3 Gauge `hybrid.active_strategies`. ## Phase 6: Integration (REAL strategies — no mocks) - [ ] 6.1 Integration test: register all five Wave-2 siblings, verify peer dedup with `PeerSource` correctness. - [ ] 6.2 Integration test: simulate degradation of one strategy (cut signaling), verify priority-based fallback to next-healthiest. - [ ] 6.3 Integration test: lifecycle (start all → stop one → restart) idempotency. ## Phase 7: Tests + docs - [ ] 7.1 Unit tests via `@suaveplan/testing/runner`. - [ ] 7.2 fast-check property tests: peer dedup commutativity, priority-order stability. - [ ] 7.3 100/100/100/100 coverage gate. - [ ] 7.4 Sibling `.md` per `.ts` impl file. - [ ] 7.5 Root `README.md` with basic + advanced examples. ## Phase 8: Verification - [ ] 8.1 `bunx turbo lint typecheck test --filter=@suaveplan/network-discovery-hybrid` green. - [ ] 8.2 `bunx turbo test:coverage --filter=@suaveplan/network-discovery-hybrid` 100/100/100/100. - [ ] 8.3 `bun run docs:check --filter=@suaveplan/network-discovery-hybrid` green. - [ ] 8.4 `MANIFEST.md` regen. - [ ] 8.5 `STATUS.md` row flipped. ## Pre-archive checklist - [ ] Row 1 — Phase 8 green. - [ ] Row 2 — Parity 🚫 list empty (mocks/stories both legitimately dropped with justification). - [ ] Row 3 — `openspec/specs/network-discovery-hybrid/spec.md` written. - [ ] Row 4 — Integration test against all five real siblings passes. - [ ] Row 5 — Folder archived.