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:
parent
1bc7580ecc
commit
e39a16498c
34 changed files with 2541 additions and 1555 deletions
|
|
@ -0,0 +1,44 @@
|
|||
## ADDED Requirements
|
||||
|
||||
### Requirement: Git branch as task execution unit
|
||||
每个任务 SHALL 关联一个 Git 分支。Agent 在该分支上工作,通过 PR 提交结果。分支命名约定:`task/{task_id}`(例如 `task/org%2Frepo%2342`)。
|
||||
|
||||
#### Scenario: Agent creates branch for task
|
||||
- **WHEN** Agent 领取任务 org/repo#42
|
||||
- **THEN** Agent SHALL 在目标仓库创建分支 `task/org%2Frepo%2342`(基于 master/main)
|
||||
|
||||
#### Scenario: Agent pushes commits to task branch
|
||||
- **WHEN** Agent 执行过程中产生代码变更
|
||||
- **THEN** Agent SHALL 推送 commit 到对应的 task 分支
|
||||
|
||||
### Requirement: PR webhook as completion notification
|
||||
Agent 完成任务后 SHALL 在 Forgejo 创建 Pull Request。Forgejo 的 PR webhook 触发 Orchestrator 状态更新,替代不可靠的直接通知。
|
||||
|
||||
#### Scenario: Agent creates PR → Orchestrator receives webhook
|
||||
- **WHEN** Agent 为任务 org/repo#42 创建 PR
|
||||
- **AND** Forgejo 触发 `pull_request.opened` webhook
|
||||
- **THEN** Orchestrator SHALL 收到 webhook,识别 PR 标题或分支名中的 task_id
|
||||
- **AND** 将任务状态更新为 `review_pending`(等待 receipt 验证)
|
||||
|
||||
#### Scenario: PR merged → receipt auto-validated
|
||||
- **WHEN** PR 被 merge
|
||||
- **AND** Forgejo 触发 `pull_request.merged` webhook
|
||||
- **THEN** Orchestrator SHALL 自动将任务状态转为 `completed`,生成 receipt
|
||||
- **AND** 在对应 Issue 添加评论:`✅ Task completed — PR #15 merged`
|
||||
|
||||
### Requirement: Task branch and PR naming convention
|
||||
Orchestrator SHALL 在任务详情中返回预期的分支名和 PR 标题格式,供 Agent 使用。
|
||||
|
||||
#### Scenario: Task detail includes branch info
|
||||
- **WHEN** Agent 查询 `GET /api/v1/tasks/org/repo#42`
|
||||
- **THEN** 返回 JSON SHALL 包含 `branch_name` 和 `pr_title` 字段
|
||||
- **AND** `branch_name` 格式为 `task/{url_encoded_task_id}`
|
||||
- **AND** `pr_title` 格式为 `feat: {issue_title} (#{issue_number})`
|
||||
|
||||
### Requirement: Push events as progress tracking
|
||||
Forgejo push webhook SHALL 作为 Agent 工作进度的间接信号。
|
||||
|
||||
#### Scenario: Agent pushes to task branch
|
||||
- **WHEN** Forgejo 触发 `push` webhook,目标分支匹配 `task/*` 模式
|
||||
- **THEN** Orchestrator SHALL 记录该 push 事件作为任务进度信号
|
||||
- **AND** 更新任务的 `last_activity_at` 时间戳
|
||||
Loading…
Add table
Add a link
Reference in a new issue