67 lines
4.1 KiB
Markdown
67 lines
4.1 KiB
Markdown
---
|
|
kind: task
|
|
slug: chat-realtime-delivery
|
|
title: Deliver scalable realtime chat events
|
|
plan_slug: workspace-communications
|
|
epic_slug: workspace-chat
|
|
status: in_progress
|
|
priority: P1
|
|
tenant_id: global
|
|
owner: unassigned
|
|
cursor_todo_id: null
|
|
updated_at: "2026-10-29"
|
|
---
|
|
|
|
# Task summary
|
|
|
|
Broadcast committed chat events over authenticated WebSockets and support horizontal fan-out and reconnect recovery.
|
|
|
|
## Description
|
|
|
|
Use HTTP/tRPC for commands and Postgres as the source of truth. Consume the outbox contract and atomic writes established by the persistence task; do not create a second message transaction. A worker claims and publishes normalized events through Redis to authenticated WebSocket subscribers. Each channel uses its own `(channel_id, sequence)` cursor, and clients reconnect by replaying missed rows from Postgres per authorized channel. Reuse Hocuspocus/Yjs only for presence, typing, or drafts rather than canonical history.
|
|
|
|
## Subtasks
|
|
|
|
- [ ] Finalize one versioned envelope for message, reply, tombstone, channel lifecycle, membership, and read-state events using the existing outbox contract.
|
|
- [ ] Add subscriptions/replay using workspace AND context AND channel access; recheck at delivery, close revoked subscriptions, and test that removed access never receives subsequent payloads. No same-workspace-only shortcut or unsupported-object fallback.
|
|
- [ ] Claim and publish outbox events through Redis with retry and idempotent consumption semantics.
|
|
- [ ] Add per-channel reconnect catch-up and cross-device read-state invalidation.
|
|
- [ ] Add heartbeat, backpressure, graceful-shutdown, outage, ordering, and authorization tests.
|
|
|
|
## Go-live reconciliation — 2026-10-29
|
|
|
|
Operator reports 14/14 live acceptance checks passed on CT 116 via `wss://chat.stillwell.cloud/chat`, including two-member messaging/replies, reconnect, unread, edit/delete recovery and revocation. CT 102 ledger is reported at 24 through `0023`, with Chat tables owned by `echodo`. Evidence is in `docs/Current Progress.md` (operator-supplied; not rerun here). Local regression tests cover projection/redaction fixes and hardened configured-origin ticket checks. Next deployment must rebuild web and retest; keep task in progress pending full checks/final review and unverified outage/multi-instance criteria.
|
|
|
|
## Earlier deployment checkpoint — 2026-10-29 (superseded above)
|
|
|
|
- Extended the existing collab service with Chat secret/port wiring, dual-listener liveness checks, standalone publication, web build URL, and Traefik TLS example. Public build variables now participate in Turbo build inputs.
|
|
- Added `scripts/chat-deployment.test.mjs` to the root test command; all five configuration checks pass. This is not live transport acceptance.
|
|
- CT 116 access blocked on trusted SSH host-key verification; no migrations or deployment performed. Production schema and disposable-Postgres, Redis outage, reconnect/revocation and two-browser gates remain open. See `docs/deployment-production.md` and `docs/Current Progress.md`.
|
|
|
|
## Owner or assignee
|
|
|
|
`unassigned`
|
|
|
|
## Status
|
|
|
|
`in_progress`
|
|
|
|
2026-10-26: Implement signed, scoped short-lived subscription tickets and metadata-only WebSocket invalidation hints. Recheck current Postgres authorization at subscribe, delivery, and heartbeat; reconnect must recover edits/tombstones independently of creation-sequence catch-up. Do not reuse the legacy decode-only Yjs identity as Chat authentication.
|
|
|
|
## Estimation
|
|
|
|
`L`
|
|
|
|
## Acceptance criteria
|
|
|
|
- [ ] A message is visible through the query API even when Redis is unavailable.
|
|
- [ ] Multiple realtime instances deliver committed events to local subscribers.
|
|
- [ ] Clients recover each subscribed channel from its own sequence without duplicates or assumed cross-channel ordering.
|
|
- [ ] Subscription authorization matches public/private/direct/archived rules and is rechecked against current workspace/channel access.
|
|
- [ ] Durable mark-read events reconcile unread badges on another connected device.
|
|
- [ ] `pnpm lint && pnpm type-check && pnpm test` pass; `pnpm build` passes for changed server entry points.
|
|
|
|
## Links to related Epic / Plan
|
|
|
|
- Epic: `./Epic-workspace-chat.md`
|
|
- Plan: `../Plan-workspace-communications.md`
|