A.1-4 多事件源支持 — 命名源 + 优先级 + 选择性监听 #27

Open
opened 2026-06-12 21:41:02 +08:00 by orion · 1 comment
Owner

来源

Doc-Code Aligner 差距:事件驱动调度循环 → v0.2 目标「多事件源支持」

现状

代码已有 agent.event_queues dict,支持多个命名队列(通过 DSL 的 event_sources 声明),
但功能停留在「不同队列接收事件」层面:

  • agent.py:__init__ — 已根据 sm_def["event_sources"] 创建多个队列
  • 但事件投递默认只发 message_queue

待做

  • 事件路由:dispatch_event 支持指定目标 event_source(不只是 agent_id)
  • 源声明:DSL 支持定义事件源类型(mq/rest/ws/file)
  • 优先级队列:高优先级事件进入 event_queues["urgent"],低优先级进 event_queues["batch"]
  • 选择性监听:Agent 状态机可声明「当前状态只监听某些源」

估时

中(1-2 天)

## 来源 Doc-Code Aligner 差距:事件驱动调度循环 → v0.2 目标「多事件源支持」 ## 现状 代码已有 `agent.event_queues` dict,支持多个命名队列(通过 DSL 的 `event_sources` 声明), 但功能停留在「不同队列接收事件」层面: - `agent.py:__init__` — 已根据 `sm_def["event_sources"]` 创建多个队列 - 但事件投递默认只发 `message_queue` ## 待做 - [ ] 事件路由:`dispatch_event` 支持指定目标 `event_source`(不只是 agent_id) - [ ] 源声明:DSL 支持定义事件源类型(mq/rest/ws/file) - [ ] 优先级队列:高优先级事件进入 `event_queues["urgent"]`,低优先级进 `event_queues["batch"]` - [ ] 选择性监听:Agent 状态机可声明「当前状态只监听某些源」 ## 估时 中(1-2 天)
Author
Owner

评价

已有基础(未充分测试):

  • event_sources 在 DSL 中已经支持(_resolve_event_queues
  • _wait_multi_source 已经实现(asyncio.FIRST_COMPLETED)
  • 事件缓冲区(_event_buffer)已经实现

缺失:

  1. 优先级——哪个队列先消费(可用 asyncio.PriorityQueue
  2. 选择性监听——只在某些状态下监听某些源(可在状态定义的 event_sources 字段限定)
  3. 完整的测试覆盖(当前只有 _wait_multi_source 被 Pipeline 测试间接覆盖)

建议: 这是一个"补测试 + 加两个小特性"的任务,三件事可以分开做:

  • P0: 补现有 _wait_multi_source 的测试
  • P1: 选择性监听
  • P2: 优先级

估算: 中等,3-4 个文件。

## 评价 **已有基础(未充分测试):** - `event_sources` 在 DSL 中已经支持(`_resolve_event_queues`) - `_wait_multi_source` 已经实现(asyncio.FIRST_COMPLETED) - 事件缓冲区(`_event_buffer`)已经实现 **缺失:** 1. 优先级——哪个队列先消费(可用 `asyncio.PriorityQueue`) 2. 选择性监听——只在某些状态下监听某些源(可在状态定义的 `event_sources` 字段限定) 3. 完整的测试覆盖(当前只有 `_wait_multi_source` 被 Pipeline 测试间接覆盖) **建议:** 这是一个"补测试 + 加两个小特性"的任务,三件事可以分开做: - P0: 补现有 `_wait_multi_source` 的测试 - P1: 选择性监听 - P2: 优先级 **估算:** 中等,3-4 个文件。
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
bixiu/bixiweave#27
No description provided.