19 tasks covering core testing, Redis hardening, WebSocket client/server adapters, Worker adapter, and final review gates. Iroh adapters are tracked as a deferred placeholder blocked on the @alkdev/iroh fork. Phases: core validation → Redis hardening → review gate → WebSocket adapters → review gate → Worker adapter → review gate → final validation.
2.5 KiB
2.5 KiB
id, name, status, depends_on, scope, risk, impact, level
| id | name | status | depends_on | scope | risk | impact | level | ||
|---|---|---|---|---|---|---|---|---|---|
| websocket-server-tests | Write tests for WebSocket server event target adapter | pending |
|
moderate | medium | component | implementation |
Description
Write tests for createWebSocketServerEventTarget. This requires mocking multiple WebSocket connections and simulating the fan-out behavior.
Test scenarios from the architecture doc:
- Topic-based fan-out — dispatchEvent sends only to connections subscribed to that event type
- Subscription protocol —
__subscribe/__unsubscribecontrol events correctly update the subscription map - Incoming aggregation — messages from any spoke dispatch to local listeners
- Connection add/remove — new connections are tracked, disconnections clean up all subscriptions
- Backpressure disconnect — slow consumers exceeding threshold are disconnected
- Backpressure callback —
onBackpressureis called before disconnecting - Direct messaging — events dispatched to
"direct:${spokeId}"reach only the target spoke - Mixed topology — server adapter and client adapters can communicate bidirectionally
Acceptance Criteria
test/event-target-websocket-server.test.tsexists and passes- Mock strategy for multiple WebSocket connections established
- Test:
addConnection/removeConnectiontrack connections correctly - Test:
__subscribecontrol event adds connection to topic's subscriber set - Test:
__unsubscribecontrol event removes connection from topic's subscriber set - Test:
dispatchEventsends only to connections subscribed to that topic - Test: connections NOT subscribed to a topic do NOT receive events for that topic
- Test: malformed JSON from spokes is silently ignored
- Test: invalid
__subscribewith empty/malformed topic is ignored - Test: backpressure threshold disconnect — connections exceeding
maxBufferedAmountare closed with code 1013 - Test:
onBackpressurecallback fires before disconnect - Test:
onConnectioncallback receives spoke target and WebSocket - Test:
onDisconnectioncallback fires on connection close - Test:
dispatchEventalways returnstrue - Test: send failure (ws.send throws) removes connection and fires
onDisconnection
References
- docs/architecture/event-targets/websocket-server.md (Test Plan section)
- src/event-target-websocket-server.ts
Notes
To be filled by implementation agent
Summary
To be filled on completion