- ExecutionMode enum adds Undecided variant (default for new tasks)
- Webhook creates tasks as Undecided instead of hardcoded SshCli
- Dispatch loop: Phase 1 matches ssh_cli hosts, Phase 2 marks remaining as HttpPull
- Dequeue now returns http_pull AND undecided tasks (atomic claim)
- New endpoint: POST /api/v1/tasks/{id}/assign for coordinator explicit assignment
- Backward compatible: existing SshCli/HttpPull tasks unaffected
- 37 tests passing (6 new)
36 lines
1.6 KiB
Markdown
36 lines
1.6 KiB
Markdown
## Why
|
||
|
||
任务创建时硬编码 `execution_mode = SshCli`(forgejo.rs:234),导致所有从 webhook 创建的任务都走 ssh_cli 路径。
|
||
|
||
实际场景中,执行模式应该在 dispatch 时动态决定:
|
||
- Hermes 是 http_pull agent(有自己的调度器),无法被 SSH 调度
|
||
- Claude Code 在 WSL2 上可以被 SSH 调度,但 arm0 到 WSL2 的连通性可能变化
|
||
- 未来可能一个任务同时有 ssh_cli 和 http_pull 的 agent 都能做
|
||
|
||
当前硬编码导致的问题:
|
||
- Hermes dequeue 拿不到任务(因为任务被标记为 ssh_cli,dequeue 只查 http_pull)
|
||
- 需要手动改 DB 才能让 http_pull agent 接任务
|
||
- coordinator 无法显式指派任务给特定 agent
|
||
|
||
## What Changes
|
||
|
||
- `ExecutionMode` enum 新增 `Undecided` 变体(任务创建时的默认值)
|
||
- Webhook 创建任务时不再硬编码 `SshCli`
|
||
- Dispatch loop 动态决定执行模式:
|
||
- 有匹配的 ssh_cli host 且 agent online → ssh_cli(立即执行)
|
||
- 没有匹配的 ssh_cli host → 标记为 http_pull(等待 agent dequeue)
|
||
- 新增 API:coordinator 可以显式指派任务给特定 agent(指定 agent_id)
|
||
- dequeue API 查询条件更新:`execution_mode IN ('http_pull', 'undecided')`
|
||
|
||
## Capabilities
|
||
|
||
### Modified Capabilities
|
||
- `task-lifecycle`: 任务状态机增加 undecided → ssh_cli/http_pull 的自动转换
|
||
- `agent-registry`: dispatch 逻辑改为两阶段匹配
|
||
|
||
## Impact
|
||
|
||
- **数据模型**:`ExecutionMode` enum 新增 `Undecided`
|
||
- **API**:新增指派端点,dequeue 查询条件变更
|
||
- **dispatch loop**:核心调度逻辑重写
|
||
- **向后兼容**:已有的 `ssh_cli`/`http_pull` 任务不受影响
|