Initial Commit
This commit is contained in:
86
openspec/changes/archive/2026-05-04-network-core/tasks.md
Normal file
86
openspec/changes/archive/2026-05-04-network-core/tasks.md
Normal file
@@ -0,0 +1,86 @@
|
||||
# Tasks — network-core
|
||||
|
||||
> Blocked on: none. Consumes existing genesis packages only.
|
||||
|
||||
## 1. Scaffold
|
||||
|
||||
- [x] 1.1 `packages/network/network/` with `package.json` (`@suaveplan/network@0.0.0`), `tsconfig.json`, `vitest.config.ts`, `README.md`.
|
||||
- [x] 1.2 Workspace deps: `@suaveplan/error`, `@suaveplan/types`, `@suaveplan/events`, `@suaveplan/streams`, `@suaveplan/bitpacker`, `@suaveplan/serialize`, `@opentelemetry/api`, `zod`.
|
||||
- [x] 1.3 No external runtime deps beyond catalog.
|
||||
|
||||
## 2. Types and contracts
|
||||
|
||||
- [x] 2.1 `src/types/plugin.types.ts` — `NetworkPlugin`, `PluginContext`, `PluginLifecycle`.
|
||||
- [x] 2.2 `src/types/envelope.types.ts` — `MessageEnvelope`, `EnvelopeHeaders`, Zod schema.
|
||||
- [x] 2.3 `src/types/transport.types.ts` — `Transport`, `TransportConfig`, `PeerInfo`.
|
||||
- [x] 2.4 `src/types/node.types.ts` — `NetworkNodeConfig`, `NetworkNodeState`.
|
||||
- [x] 2.5 `src/error-codes.ts` — `defineCodes("NET", [...])` frozen registry.
|
||||
|
||||
## 3. Plugin manager
|
||||
|
||||
- [x] 3.1 `src/plugin/plugin-manager.ts` — `use(plugin)`, `installAll()`, `startAll()`, `stopAll()`, `disposeAll()` in correct order.
|
||||
- [x] 3.2 Lifecycle dedup: installing the same plugin twice is a no-op.
|
||||
|
||||
## 4. Network bus
|
||||
|
||||
- [x] 4.1 `src/bus/network-bus.ts` — wraps `@suaveplan/events` with topic-based routing, bounded queue, interceptors.
|
||||
- [x] 4.2 Topics: `peer:joined`, `peer:left`, `peer:latency`, `election:vote`, `election:completed`, `failover:triggered`, `message:received`, `topology:changed`.
|
||||
|
||||
## 5. Message router
|
||||
|
||||
- [x] 5.1 `src/router/message-router.ts` — `route(envelope)` resolves `targetId` to transport, `broadcast()` fans out to all transports.
|
||||
- [x] 5.2 `broadcast` skips the sender.
|
||||
|
||||
## 6. Network node
|
||||
|
||||
- [x] 6.1 `src/node/network-node.ts` — `use(plugin)`, `start()`, `stop()`, `send()`, `broadcast()`, `on(event)`.
|
||||
- [x] 6.2 Envelope validation via Zod before routing.
|
||||
- [x] 6.3 Idempotent `start()` / `stop()`.
|
||||
|
||||
## 7. Spec
|
||||
|
||||
- [x] 7.1 `openspec/specs/network/spec.md` — requirements `NET-01` through `NET-05` and `NET-12`.
|
||||
|
||||
## 8. Conformance tests
|
||||
|
||||
- [x] 8.1 `src/plugin/plugin.spec-conformance.test.ts` — lifecycle order, duplicate install no-op.
|
||||
- [x] 8.2 `src/node/node.spec-conformance.test.ts` — send, broadcast, envelope validation, plugin wiring.
|
||||
- [x] 8.3 `src/bus/bus.spec-conformance.test.ts` — FIFO, backpressure, interceptor.
|
||||
- [x] 8.4 `src/router/router.spec-conformance.test.ts` — unicast, broadcast, skip-sender.
|
||||
- [x] 8.5 `src/envelope/envelope.spec-conformance.test.ts` — Zod accept/reject.
|
||||
- [x] 8.6 `src/error-codes.spec-conformance.test.ts` — frozen registry.
|
||||
- [x] 8.7 `tests/dep-graph.test.ts` — no cycles, tree-shake clean.
|
||||
|
||||
## 10. API versioning
|
||||
|
||||
- [x] 10.1 `src/versioning/version-info.ts` — `VersionInfo`, semantic versioning, compatibility check.
|
||||
- [x] 10.2 `src/versioning/version-manager.ts` — `VersionManager`, migration paths, stability classification.
|
||||
- [x] 10.3 `src/versioning/version-negotiator.ts` — `VersionNegotiator`, exchanges versions during handshake.
|
||||
- [x] 10.4 Version embedded in `MessageEnvelope` headers.
|
||||
|
||||
## 11. Network timestamps
|
||||
|
||||
- [x] 11.1 `src/timing/network-timestamp.ts` — `NetworkTimestamp`, ISO8601/unix/custom, timezone, precision.
|
||||
- [x] 11.2 `src/timing/clock.ts` — `Clock` interface, injectable for testing.
|
||||
- [x] 11.3 `src/timing/timestamp-comparer.ts` — `TimestampComparer`, `isAfter`, `isBefore`, `compare`.
|
||||
|
||||
## 12. Standardized event constants
|
||||
|
||||
- [x] 12.1 `src/events/network-events.ts` — `NetworkEvents`, frozen enum of all standard bus topics.
|
||||
- [x] 12.2 Node lifecycle, message, hierarchy, plugin, system topics.
|
||||
|
||||
## 13. Spec
|
||||
|
||||
- [x] 13.1 Update `openspec/specs/network/spec.md` with `NET-53`, `NET-54`, `NET-55`.
|
||||
|
||||
## 14. Conformance tests
|
||||
|
||||
- [x] 14.1 `src/versioning/versioning.spec-conformance.test.ts` — compatibility, negotiation, rejection.
|
||||
- [x] 14.2 `src/timing/timing.spec-conformance.test.ts` — formats, timezone, precision, comparison.
|
||||
- [x] 14.3 `src/events/events.spec-conformance.test.ts` — constants, no typos, coverage.
|
||||
|
||||
## 15. Verify
|
||||
|
||||
- [x] 15.1 `bunx turbo lint typecheck test --filter=@suaveplan/network` green.
|
||||
- [x] 15.2 `bunx turbo test:coverage --filter=@suaveplan/network` 100/100/100/100.
|
||||
- [x] 15.3 `bun scripts/openspec-conformance.ts @suaveplan/network` PASS.
|
||||
Reference in New Issue
Block a user