feat: dual execution model (SSH CLI + HTTP pull)

- ExecutionMode enum: SshCli (orchestrator dispatches) | HttpPull (agent pulls)
- SSH CLI executor: spawn remote agents via ssh + CLI template
- Local subprocess as SSH special case (localhost)
- HostConfig with capability matching and load-based selection
- Dispatch loop: scan created tasks → select host → execute → update
- CliAdapterConfig: CLI templates for Codex and Claude Code
- Structured prompt construction (Issue → goal/constraints/validation)
- Output parsers: Codex JSON, Claude Code JSON, raw fallback
- TaskStatus::ReviewPending + review_count loop limit
- Forgejo webhook: pull_request (opened→review_pending, merged→completed)
- Forgejo webhook: push events (task/* branch → last_activity_at)
- HTTP API: dequeue only returns http_pull tasks
- HTTP API: status update only for http_pull mode
- Token auth config for http_pull agents
- Adapter module rewritten: AgentAdapter trait removed → config-driven CLI templates
- New fields: execution_mode, assigned_host, branch_name, pr_title, last_activity_at, review_count
- 30/30 tests pass
This commit is contained in:
Zer4tul 2026-05-12 14:07:56 +08:00
parent 1bc7580ecc
commit e39a16498c
34 changed files with 2541 additions and 1555 deletions

View file

@ -0,0 +1,37 @@
## ADDED Requirements
### Requirement: Remote host configuration
Orchestrator SHALL 支持配置多台远程主机,每台主机包含 SSH 连接信息和可用 Agent 列表。
#### Scenario: Host configuration format
- **WHEN** 配置远程主机
- **THEN** 配置 SHALL 包含:`{host_id, hostname, ssh_user, ssh_port, ssh_key_path, work_dir, agents: [{agent_type, max_concurrency}]}`
#### Scenario: Host with multiple agents
- **WHEN** 一台主机配置了多个 Agent例如同时有 Codex 和 Claude Code
- **THEN** Orchestrator SHALL 跟踪每个 Agent 的并发数,不超过 max_concurrency
### Requirement: Host health check
Orchestrator SHALL 能检查远程主机的 SSH 连通性和 Agent CLI 可用性。
#### Scenario: SSH connectivity check
- **WHEN** Orchestrator 检查 host-worker-02
- **THEN** SHALL 尝试 SSH 连接并执行 `echo ok`
- **AND** 连接失败时标记主机为 `unreachable`
#### Scenario: Agent CLI availability check
- **WHEN** Orchestrator 检查 host-worker-02 上的 Codex
- **THEN** SHALL 执行 `which codex``codex --version`
- **AND** CLI 不存在时标记该 Agent 为 `unavailable`
### Requirement: Host selection for task assignment
当任务的执行模式为 `ssh_cli`Orchestrator SHALL 选择合适的主机执行。
#### Scenario: Select host by capability and availability
- **WHEN** 任务需要 `code:rust` 能力
- **THEN** SHALL 选择配置了对应 Agent 且当前并发数未满的主机
- **AND** 多个候选主机时优先选择负载最低的
#### Scenario: No available host
- **WHEN** 没有可用主机匹配任务需求
- **THEN** 任务保持 `created` 状态,等待主机可用