a2a-Market WebSocket Realtime
Set up realtime delivery skeleton for buyer and operator clients.
Current status: publishable framework with stable event contracts, not full scale tuning.
Scope
- - Define channel naming and auth guard for buyer, node, and admin roles.
- Push canonical domain events with predictable payload shape.
- Manage reconnect semantics and last-event cursor replay.
Suggested Project Layout
- - INLINECODE0
- INLINECODE1
- INLINECODE2
- INLINECODE3
Minimum Contracts (MVP P0)
- 1.
subscribe(channel, cursor) validates permission and registers stream. - INLINECODE5 fans out to online subscribers.
- INLINECODE6 replays missed events within retention window.
- INLINECODE7 updates liveness and cleanup scheduling.
Required Event Coverage
- - INLINECODE8
- INLINECODE9
- INLINECODE10
- INLINECODE11
- INLINECODE12
Guardrails
- - Keep payloads versioned and backward compatible.
- Limit per-connection queue to prevent memory blowups.
- Drop unauthorized subscription attempts with structured error codes.
Implementation Backlog
- - Add presence channels and typing/status hints for negotiation UI.
- Add regional relay nodes for cross-region latency reduction.
Runtime Implementation
- - Status: implemented in local runtime package.
- Primary code paths:
- INLINECODE13
- Validation: covered by
runtime/tests and npm test in runtime/.
a2a-Market WebSocket 实时系统
为买家和操作员客户端搭建实时交付骨架。
当前状态:具备稳定事件合约的可发布框架,尚未进行大规模调优。
范围
- - 为买家、节点和管理员角色定义频道命名及认证守卫。
- 推送具有可预测负载结构的规范领域事件。
- 管理重连语义及最后事件游标重放。
建议项目结构
- - app/interfaces/ws/socketgateway.py
- app/application/services/realtimeservice.py
- app/infrastructure/ws/connectionregistry.py
- app/infrastructure/cache/replaycursor_store.py
最小合约(MVP P0)
- 1. subscribe(channel, cursor) 验证权限并注册数据流。
- publishevent(channel, event) 向在线订阅者广播事件。
- resume(channel, cursor) 在保留窗口内重放遗漏事件。
- heartbeat(connectionid) 更新活跃状态及清理调度。
必需事件覆盖范围
- - INTENTCREATED(意向已创建)
- QUOTERECEIVED(报价已接收)
- NEGOTIATIONSTARTED(协商已开始)
- ORDERCREATED(订单已创建)
- PAYMENT_SUCCEEDED(支付已成功)
防护措施
- - 保持负载版本化且向后兼容。
- 限制每个连接的队列大小,防止内存溢出。
- 使用结构化错误码拒绝未授权的订阅尝试。
实施待办事项
- - 为协商界面添加在线频道及输入/状态提示。
- 添加区域中继节点以减少跨区域延迟。
运行时实现
- - 状态:已在本地运行时包中实现。
- 主要代码路径:
- runtime/src/interfaces/ws/event-bus.js
- 验证:由 runtime/tests 及 runtime/ 中的 npm test 覆盖。