# Tasks โ€” service-discovery ## Phase 1: Scaffold - [ ] 1.1 Create `packages/network/service-discovery/` with standard package layout. - [ ] 1.2 `package.json` at `0.1.0`, `"sideEffects": false`, subpath exports. - [ ] 1.3 Test config via `createTestConfig()`. - [ ] 1.4 `tests/dep-graph.test.ts`. ## Phase 2: Types + errors - [ ] 2.1 Port `types.ts` โ†’ `src/types/types.ts` + sibling `.md`. - [ ] 2.2 `defineCodes("SVC_DISC", [...])`: `DUPLICATE_REGISTRATION`, `QUERY_INVALID`, `REGISTRY_FULL`, `INVALID_OPTIONS`. - [ ] 2.3 Zod schemas for `ServiceDescriptor`, `ServiceQuery`, options. ## Phase 3: Core registry - [ ] 3.1 Port `ServiceRegistry` register/deregister/query. - [ ] 3.2 `watch(query)` AsyncIterable with AbortSignal-aware termination. - [ ] 3.3 TTL + stale-entry expiry over injectable `Clock`. ## Phase 4: Adapters - [ ] 4.1 Optional persistent backing via `@suaveplan/storage` `AbstractStorage`. - [ ] 4.2 Optional `NetworkBus` integration emitting `service:registered`/`:deregistered`/`:expired`. ## Phase 5: Observability - [ ] 5.1 Counters (`svc_disc.registrations_total{outcome}`, `svc_disc.queries_total`). - [ ] 5.2 Histogram (`svc_disc.query_duration_ms`). - [ ] 5.3 Gauge (`svc_disc.active_services`). ## Phase 6: Tests + docs - [ ] 6.1 Unit tests per feature module via `@suaveplan/testing/runner`. - [ ] 6.2 fast-check property tests: TTL monotonicity, query determinism. - [ ] 6.3 100/100/100/100 coverage gate. - [ ] 6.4 Sibling `.md` doc 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/service-discovery` green. - [ ] 7.2 `bunx turbo test:coverage --filter=@suaveplan/service-discovery` 100/100/100/100. - [ ] 7.3 `bun run docs:check --filter=@suaveplan/service-discovery` green. - [ ] 7.4 `MANIFEST.md` regen. - [ ] 7.5 `STATUS.md` row flipped. ## Pre-archive checklist - [ ] Row 1 โ€” Phase 7 green. - [ ] Row 2 โ€” Parity ๐Ÿšซ list empty (or each row justified per AGENTS.md ยง0a). - [ ] Row 3 โ€” `openspec/specs/service-discovery/spec.md` written. - [ ] Row 4 โ€” Folder archived.