3.9 KiB
3.9 KiB
Tasks — @suaveplan/api-ws-broker-redis
Every checkbox MUST reflect work actually done in this change.
0. Pre-flight (non-negotiable)
- 0.1 Confirm clean working tree (
git statusreports nothing) and no in-flight worktrees with uncommitted work (git worktree listthengit statusin each) - 0.2 If any worktrees exist under
.claude/worktrees/, account for each one: still-active agent, work-pending-merge, or stale-and-prune. Stale worktrees MUST be removed (git worktree remove) before opening a new one — code that has been lost twice on main is the failure mode this guards against. - 0.3 Confirm the package set in
MANIFEST.mdmatchesfind packages -maxdepth 3 -name package.jsoncount. Drift here means a prior change archived without regenerating the manifest.
1. Spec authoring
- 1.1 Read design doc §11.3, §11.5, §11.6, §12.6
- 1.2 Read umbrella Stage 7 acceptance
- 1.3 Read sibling
openspec/changes/api-ws-bun/for reconnect-buffer integration - 1.4 Read
openspec/AGENTS.mdSections 13 and 14 - 1.5 Draft
proposal.md - 1.6 Draft
specs/api-ws-broker-redis/spec.md - 1.7 Every requirement carries a
**Verified by:**line
2. Implementation
- 2.1 Scaffold
packages/api/api-ws-broker-redis/ - 2.2
src/options/options.ts—RedisWsBrokerOptionsZod schema - 2.3
src/broker/redis-broker.ts—createRedisWsBroker(opts); implementsWsBrokercontract - 2.4
src/publish/publish.ts—broker.broadcast; gzip abovecompressionThresholdBytes - 2.5
src/subscribe/subscribe.ts— channel pattern subscription; deliver to localConnectionRegistry - 2.6
src/event-buffer/event-buffer.ts— Redis sorted-set per(tenant, topic); cap + TTL; replay-by-lastEventId - 2.7
src/health/health.ts—broker.healthz() - 2.8
src/reconnect/reconnect.ts— auto-reconnect on connection loss; replay buffered messages on resume - 2.9
src/instruments/instruments.ts— every OTel instrument per proposal - 2.10
src/error-codes.ts— 10WS_BROKER_REDIS_*codes - 2.11
src/index.ts— explicit named re-exports
3. Tests
- 3.1 Unit tests, every
it(...){ timeout: 5000 } - 3.2 Conformance test against
WsBrokercontract - 3.3 Redis integration tests via
@suaveplan/testing-integration-redis({ timeout: 30000 }) - 3.4 Two-host fan-out integration test (
{ timeout: 60000 }) - 3.5 Health-probe test pins recovery after Redis bounce
- 3.6 All tests import from
@suaveplan/testing/runner
4. Documentation
- 4.1 Sibling
.mdper implementation file - 4.2
README.mddocumenting key-prefix conventions, sorted-set schema for the event buffer, and operational notes (Redis memory sizing tied toeventBufferMaxEvents * eventBufferTtlSec)
5. Pre-archive verification
- 5.1
bun run check— 0/0/0 - 5.2
bunx turbo lint typecheck test --filter=@suaveplan/api-ws-broker-redis— green - 5.3
bunx turbo test:coverage --filter=@suaveplan/api-ws-broker-redis— 100/100/100/100 - 5.4
bun scripts/openspec-conformance.ts @suaveplan/api-ws-broker-redis— exit 0 - 5.5
bunx turbo build --filter=@suaveplan/api-ws-broker-redis— green
6. Pre-archive 7-row checklist
- 6.1 Generics on broker payload types;
expectTypeOfon literal-type claims - 6.2 Zod schemas on options + on inbound payloads (deserialise validation)
- 6.3 Every
WS_BROKER_REDIS_*code thrown by a production path - 6.4 Strict-mode tested (compression on vs off; buffer TTL respected)
- 6.5 OTel instruments asserted against in-memory
MeterProvider - 6.6 Lifecycle dedup: reconnect does not duplicate buffer writes
- 6.7 No retroactive tick
7. Archive
- 7.1 Fold spec delta into
openspec/specs/api-ws-broker-redis/spec.md - 7.2 Move to
openspec/archive/<yyyy-mm-dd>-api-ws-broker-redis/ - 7.3 Tick Stage-7 row in umbrella tasks
- 7.4 Refresh
MANIFEST.md