Initial Commit
This commit is contained in:
@@ -0,0 +1,104 @@
|
||||
# Tasks: enterprise-browser-network-discovery-hybrid
|
||||
|
||||
**Change ID**: enterprise-browser-network-discovery-hybrid
|
||||
**Package**: `@suaveplan/network-discovery-hybrid`
|
||||
**Target path**: `browser/network/network-discovery-hybrid`
|
||||
**Prerequisite packages on Verdaccio**: `@suaveplan/network`, `@suaveplan/error`, `@suaveplan/types`
|
||||
|
||||
---
|
||||
|
||||
## 1. Scaffold
|
||||
|
||||
- [x] Create directory tree per `proposal.md`.
|
||||
- [x] `package.json` at version `0.1.0`, `"sideEffects": false`.
|
||||
- `dependencies`: `@suaveplan/network workspace:^`, `@suaveplan/error workspace:^`, `@suaveplan/types workspace:^`, `zod catalog:forms`, `@opentelemetry/api catalog:observability`, `tslib catalog:build`
|
||||
- `peerDependencies` + `peerDependenciesMeta.optional: true`: `@suaveplan/network-discovery-peerjs`, `@suaveplan/network-discovery-trystero`, `@suaveplan/network-discovery-webtorrent`, `@suaveplan/network-discovery-crdt`, `@suaveplan/network-discovery-gundb`
|
||||
- `devDependencies`: above five sibling packages as `workspace:^`, `vitest catalog:testing`, `@vitest/coverage-istanbul catalog:testing`, `@suaveplan/testing workspace:^`, `react catalog:browser`, `@types/react catalog:browser`
|
||||
- [x] `tsconfig.json`, `vitest.config.ts` (pool: forks).
|
||||
|
||||
---
|
||||
|
||||
## 2. Error codes
|
||||
|
||||
- [x] `STRATEGY_LOAD_FAILED`, `STRATEGY_UNAVAILABLE`, `HYBRID_NO_HEALTHY_STRATEGY`.
|
||||
- [x] `registerHybridErrorCodes()` — call eagerly.
|
||||
|
||||
---
|
||||
|
||||
## 3. In-tree `MemoryDiscoveryStrategy` (`src/internal/memory-discovery-strategy.ts`)
|
||||
|
||||
- [x] Implement a minimal `DiscoveryStrategy` for unit tests — typed correctly against the real interface, no duck typing.
|
||||
|
||||
---
|
||||
|
||||
## 4. `PeerTracker` (`src/peer-tracker/`)
|
||||
|
||||
- [x] Implement deduplication of peer sets across strategies; track `PeerSource` per peer.
|
||||
- [x] Write `peer-tracker.test.ts`, `peer-tracker.md`.
|
||||
|
||||
---
|
||||
|
||||
## 5. `StrategyLoader` (`src/strategy-loader/`)
|
||||
|
||||
- [x] Implement dynamic peer-dep loading: check if the package is present in the module graph; return `STRATEGY_LOAD_FAILED` typed error if missing — never returns `null` silently.
|
||||
- [x] Write `strategy-loader.test.ts`, `strategy-loader.md`.
|
||||
|
||||
---
|
||||
|
||||
## 6. `StrategyManager` (`src/strategy-manager/`)
|
||||
|
||||
- [x] Implement health tracking, priority tie-breaking (alphabetical on equal score), back-pressure per strategy.
|
||||
- [x] Wire OTel counters for strategy health transitions.
|
||||
- [x] Write `strategy-manager.test.ts`, `strategy-manager.md`.
|
||||
|
||||
---
|
||||
|
||||
## 7. `Lifecycle` (`src/lifecycle/`)
|
||||
|
||||
- [x] Implement start/stop sequencing across all strategies with timeout per strategy.
|
||||
- [x] Wire OTel histogram `discovery.hybrid.failover_ms`.
|
||||
- [x] Write `lifecycle.test.ts`, `lifecycle.md`.
|
||||
|
||||
---
|
||||
|
||||
## 8. `HybridDiscoveryManager` (`src/hybrid-discovery-manager/`)
|
||||
|
||||
- [x] Implement orchestrator composing all sub-modules.
|
||||
- [x] `static presets.browserP2P()` returning a `HybridDiscoveryConfig` wiring PeerJS + Trystero.
|
||||
- [x] Write `hybrid-discovery-manager.test.ts`, `hybrid-discovery-manager.md`, `hybrid-discovery-manager.types.ts`.
|
||||
|
||||
---
|
||||
|
||||
## 9. Presets (`src/presets/`)
|
||||
|
||||
- [x] Implement `presets` object with `browserP2P()`.
|
||||
- [x] Write `presets.md`.
|
||||
|
||||
---
|
||||
|
||||
## 10. Tests (all ≤500 lines each)
|
||||
|
||||
- [x] `tests/config.test.ts` — config schema validation.
|
||||
- [x] `tests/config-advanced.test.ts` — priority ordering, back-pressure, tie-breaking.
|
||||
- [x] `tests/runtime.test.ts` — start/stop, failover, peer dedup.
|
||||
- [x] `tests/runtime-failover.test.ts` — strategy degraded → failover → recovery.
|
||||
- [x] All tests use real `MemoryDiscoveryStrategy` or real sibling packages — no `__mocks__/`.
|
||||
|
||||
---
|
||||
|
||||
## 11. Zod schema + docs
|
||||
|
||||
- [x] `HybridDiscoveryConfigSchema`; register in `@suaveplan/schema-registry`.
|
||||
- [x] Story (`src/hybrid-discovery-manager/hybrid-discovery.stories.tsx`) with React devDep declared.
|
||||
- [x] Write `.md` per module; `README.md` with sibling install matrix.
|
||||
|
||||
---
|
||||
|
||||
## 12. Verify and publish
|
||||
|
||||
- [x] `bunx turbo lint typecheck test --filter=@suaveplan/network-discovery-hybrid` — green.
|
||||
- [x] `bunx turbo test:coverage` — 100%.
|
||||
- [x] No `__mocks__/` directory, no `vi.mock`, no `any`.
|
||||
- [x] Missing-peer-dep scenario returns typed error (not silent null).
|
||||
- [x] `bun scripts/publish.ts --package @suaveplan/network-discovery-hybrid`.
|
||||
- [x] Archive to `openspec/archive/2026-04-24-enterprise-browser-network-discovery-hybrid/`.
|
||||
Reference in New Issue
Block a user