Decompose architecture into atomic, dependency-ordered tasks
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.
This commit is contained in:
50
tasks/001-core-pubsub-tests.md
Normal file
50
tasks/001-core-pubsub-tests.md
Normal file
@@ -0,0 +1,50 @@
|
||||
---
|
||||
id: core-pubsub-tests
|
||||
name: Write tests for createPubSub, EventEnvelope, and in-process event target
|
||||
status: pending
|
||||
depends_on: []
|
||||
scope: moderate
|
||||
risk: low
|
||||
impact: component
|
||||
level: implementation
|
||||
---
|
||||
|
||||
## Description
|
||||
|
||||
The core `createPubSub` factory, `EventEnvelope` type, and the in-process (default `EventTarget`) path have no tests. These are the foundation of the entire package — every adapter builds on `createPubSub`. Write comprehensive tests that verify the core contract.
|
||||
|
||||
The architecture specifies these behaviors:
|
||||
- `createPubSub()` with no config uses `new EventTarget()` (in-process)
|
||||
- `createPubSub({ eventTarget })` uses a custom event target
|
||||
- `publish(type, id, payload)` dispatches a `CustomEvent` with type `"type:id"` and `detail` as `EventEnvelope`
|
||||
- `subscribe(type, id)` returns a `Repeater<EventEnvelope>` (async iterable)
|
||||
- `publish` throws on event types starting with `__` (reserved for adapter control)
|
||||
- Topic scoping uses the `type:id` convention
|
||||
- `subscribe` cleanup: breaking out of the `for await` loop removes the listener
|
||||
|
||||
## Acceptance Criteria
|
||||
|
||||
- [ ] `test/create_pubsub.test.ts` exists and passes
|
||||
- [ ] Test: `publish` dispatches event with correct `type:id` topic
|
||||
- [ ] Test: `publish` throws on `__`-prefixed event types
|
||||
- [ ] Test: `subscribe` returns async iterable that yields `EventEnvelope` objects
|
||||
- [ ] Test: `subscribe` envelope has correct `type`, `id`, `payload` fields
|
||||
- [ ] Test: subscriber receives events only for the subscribed topic (type:id matching)
|
||||
- [ ] Test: multiple subscribers on the same topic all receive events
|
||||
- [ ] Test: subscriber cleanup — breaking out of `for await` loop removes the listener
|
||||
- [ ] Test: `createPubSub` with custom `eventTarget` dispatches to that target
|
||||
- [ ] Test: `createPubSub` without `eventTarget` uses `new EventTarget()` (in-process)
|
||||
|
||||
## References
|
||||
|
||||
- docs/architecture/api-surface.md
|
||||
- src/create_pubsub.ts
|
||||
- src/types.ts
|
||||
|
||||
## Notes
|
||||
|
||||
> To be filled by implementation agent
|
||||
|
||||
## Summary
|
||||
|
||||
> To be filled on completion
|
||||
Reference in New Issue
Block a user