Description:
Formally specify the WS protocol (messages, subscriptions, replay, errors) in AsyncAPI, validate all inbound/outbound messages against it at runtime in non-production, and add protocol version negotiation.
Problem Statement & Context:
The WS protocol has grown (subscriptions, filters, replay) but lives only in code. Integrators reverse-engineer it and any change risks silent breakage.
Scope & Acceptance Criteria:
docs/asyncapi.yaml covering all message types; served at /docs/ws.
Sec-WebSocket-Protocol: vortex.v1 negotiation; unknown versions rejected with close code 1002.
- Runtime schema validation (dev/test) and CI check that emitted messages conform.
- Types generated for the SDK from the spec.
- Out of scope: breaking protocol changes.
Implementation Guidelines:
- Key Files/Modules:
src/intents/intents.gateway.ts, new docs/asyncapi.yaml, scripts/generate-client.ts.
- Design/Architecture: Spec as source of truth; zod/ajv validators generated or hand-mirrored with CI parity test.
- Edge Cases/Constraints: Clients without subprotocol default to v1 for compatibility.
- Testing: Contract test asserting every message in
test/ws-gateway.e2e-spec.ts validates.
Definition of "Done": Common DoD.
Resources:
Common Definition of "Done" (applies in addition to the criteria above):
- Code written, tested, and documented (TSDoc on public APIs, README/runbook/ADR updates where behaviour changes).
- All acceptance criteria met;
npm run lint, npm run typecheck, npm test, npm run test:e2e pass in CI.
- PR follows
.github/PULL_REQUEST_TEMPLATE, uses a Conventional Commit title (enforced by commitlint), includes test output / metrics screenshots, and references the issue.
- New env vars are added to
.env.example variants and src/config/env.validation.ts (the check:env-drift script must pass).
- Reviewed and approved by at least one CODEOWNER.
Description:
Formally specify the WS protocol (messages, subscriptions, replay, errors) in AsyncAPI, validate all inbound/outbound messages against it at runtime in non-production, and add protocol version negotiation.
Problem Statement & Context:
The WS protocol has grown (subscriptions, filters, replay) but lives only in code. Integrators reverse-engineer it and any change risks silent breakage.
Scope & Acceptance Criteria:
docs/asyncapi.yamlcovering all message types; served at/docs/ws.Sec-WebSocket-Protocol: vortex.v1negotiation; unknown versions rejected with close code 1002.Implementation Guidelines:
src/intents/intents.gateway.ts, newdocs/asyncapi.yaml,scripts/generate-client.ts.test/ws-gateway.e2e-spec.tsvalidates.Definition of "Done": Common DoD.
Resources:
Common Definition of "Done" (applies in addition to the criteria above):
npm run lint,npm run typecheck,npm test,npm run test:e2epass in CI..github/PULL_REQUEST_TEMPLATE, uses a Conventional Commit title (enforced by commitlint), includes test output / metrics screenshots, and references the issue..env.examplevariants andsrc/config/env.validation.ts(thecheck:env-driftscript must pass).