Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 13 additions & 9 deletions CONTEXT.md
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ _Avoid_: Promotion Audit、Codex 版本门禁、源码验收、状态兼容检
_Avoid_: 自动更新、重复 PATH 配置、系统包管理、`sudo`、源码热加载、可配置保留策略、无限快照历史、状态迁移、每-Run Runner 绑定

**Runner Setup(Runner 环境准备)**:
源码树 `./setup.sh` 提供的、无需预先安装 Python 或 Git 的一次性公开入口;在用户开始使用 Runner 前,经集中检查和统一确认后补齐宿主依赖、委托 Source Runner Installer 完成本体安装并获取手动待办清单,区别于 Runner 本体安装、目标仓库准备和实际执行就绪判定。不在自动补装范围内的依赖转为手动待办,不因发行版缺少自动适配而中断所有可继续步骤,也不把尚缺关键条件的环境称为已就绪;CI、仓库忽略规则、任务标签与 Skills 由用户自行准备。
源码树 `./setup.sh` 提供的、无需预先安装 Python 或 Git 的一次性公开入口;在用户开始使用 Runner 前,经集中检查和统一确认后补齐宿主依赖、委托 Source Runner Installer 完成本体安装并获取手动待办清单,区别于 Runner 本体安装、目标仓库准备和实际执行就绪判定。不在自动补装范围内的依赖转为手动待办,不因发行版缺少自动适配而中断所有可继续步骤,也不把尚缺关键条件的环境称为已就绪;CI、任务标签与 Skills 由用户自行准备。
_Avoid_: 安装成功即能运行、自动初始化目标仓库、自动配置 CI、自动管理 Skills、非适配发行版一律拒绝

**Source Runner Installer(源码 Runner 安装器)**:
Expand Down Expand Up @@ -221,7 +221,7 @@ _Avoid_: 等待 Executor、自动 stop、运行中热更新、每-Run Snapshot
_Avoid_: 状态迁移、兼容性检查、自动回退、下载历史版本、任意历史选择

**Runner Uninstall(Runner 卸载)**:
用户在任一包含源码安装器的目录显式执行 `./install.sh --uninstall`,并在 Runner Management Quiescence 中删除全部受管 Runner Snapshot、Runner Generation、候选残留、内部 `active` 入口、本机受管 `agent-run` symlink 以及安装器添加的 PATH 受管配置。若存在活跃 Run Executor Session,卸载立即拒绝且不修改受管状态。若用户已把公开入口替换为非受管路径,卸载保留该内容并以有界 operational error 报告清理未完成。它保留固定 Runner Management Lock、GitHub App 持久配置、全局 Run 定位状态和各目标仓库中的 `.agent-run` Delivery Run 数据;v0.1 不提供连带删除用户配置或运行数据的 purge 模式。
用户在任一包含源码安装器的目录显式执行 `./install.sh --uninstall`,并在 Runner Management Quiescence 中删除全部受管 Runner Snapshot、Runner Generation、候选残留、内部 `active` 入口、本机受管 `agent-run` symlink 以及安装器添加的 PATH 受管配置。若存在活跃 Run Executor Session,卸载立即拒绝且不修改受管状态。若用户已把公开入口替换为非受管路径,卸载保留该内容并以有界 operational error 报告清理未完成。它保留固定 Runner Management Lock、GitHub App 持久配置、Run 定位状态、Runner 独立仓库及 Delivery Run 数据;v0.1 不提供连带删除用户配置或运行数据的 purge 模式。
_Avoid_: 删除 Delivery Run、删除 GitHub App 配置、删除非受管 shell 配置、`--purge`

**Run 内部监督(In-Run Supervision)**:
Expand Down Expand Up @@ -340,25 +340,29 @@ _Avoid_: Codex Worker、内容作者、智能审查者
改变权威 Git 历史、metadata 或 GitHub 外部持久状态的排他权限;临时 checkout 的源码编辑和一次性 Git 数据不属于该权限。该权限只属于 Publisher,不因 Codex Worker 的建议、代码修改或完成声明而转移。
_Avoid_: Agent 自治、结构化输出、候选就绪

**User Repository(用户仓库)**:
维护者自行管理的本地 Git checkout。Runner 仅用它只读识别目标远端,不修改其文件、索引、引用或 Git 元数据,也不借用其 Git object store 创建 worktree。未推送的本地内容不进入交付;获取交付后的远端代码由维护者自行完成。
_Avoid_: Runner 工作区、共享 Git 元数据、合并后自动更新用户分支

**Local Delivery Workspace(本地交付工作区)**:
维护者发起并恢复 Delivery Run 的准确本地 Git 仓库根目录,也是任务唯一性和 Run Executor Session 排他权的本地范围。两个独立本地仓库根目录由维护者自行协调,Controller 不扫描、不关联、不阻止它们对同一远端 Parent 各自启动 Run。Controller 为 Run 创建的 Managed Development Checkout 仍隶属原工作区,不是可重复启动该任务的新工作区。
_Avoid_: 主机级仓库注册表、跨 clone 锁、磁盘扫描、把 Managed Development Checkout 当作新的操作根
Runner 在用户数据目录中为准确远端 Repository 管理的独立克隆,以及与其关联的运行状态和受管 worktree。相同本机用户从不同目录或不同用户 clone 启动同一 Repository 时定位到同一工作区;生命周期写入仅发生在 Runner 工作区和获准的远端。Managed Development Checkout 隶属该工作区,不产生新的任务身份。
_Avoid_: 用户仓库、启动目录、借用用户仓库的 worktree、跨用户或跨主机协调、磁盘扫描

**Delivery Task(交付任务)**:
由准确 Repository 与 Parent Issue 共同标识的稳定远端交付对象。同一 Local Delivery Workspace 内,一个 Delivery Task 同时最多拥有一个未完成 Delivery Run;已完成或已放弃的 Run 保留为不可变历史,维护者可以显式创建一个后继 Run。不同 Repository 或同一 Repository 的不同 Parent Issue 是不同 Delivery Task,必须能够并行推进。
_Avoid_: 裸 `run_id`、单张 Child Ticket、整个 Repository、主机全局任务、跨独立本地仓库的唯一性承诺
由准确 Repository 与 Parent Issue 共同标识的稳定远端交付对象。同一用户在本机对一个 Delivery Task 同时最多拥有一个未完成 Delivery Run,不因启动目录或用户 clone 不同而重复创建;已完成或已放弃的 Run 保留为不可变历史,维护者可以显式创建一个后继 Run。不同 Repository 或同一 Repository 的不同 Parent Issue 是不同 Delivery Task,必须能够并行推进。
_Avoid_: 裸 `run_id`、单张 Child Ticket、整个 Repository、以启动目录区分任务、跨用户或跨主机唯一性承诺

**Delivery Run(交付运行)**:
由一次人工授权在一个 Local Delivery Workspace 中启动、覆盖一个 Delivery Task 的 Parent Issue 及其相关 Ticket、并以最终整体验收结束的交付范围。一个 Run 拥有独立身份和集成边界;同一工作区内同一 Delivery Task 的多个 Run 只能按时间先后存在,不能并行。普通 `run` 本身就是创建或恢复授权:没有未完成 Run 且 Parent 当前可执行时创建后继 Run,旧终态 Run 只保留为历史,不复活、不覆盖。
_Avoid_: 单张 Ticket、单次 Codex 执行、长期后台服务、同一 Parent 的并行 Run、复活或覆盖终态 Run、额外 `--new-run`

**Run 定位索引(Run Locator Index)**:
本机维护的最小 Run ID 到仓库根和 state 目录的定位记录。新登记同时保存 Repository 与 Parent number,作为 state 或 checkout 丢失时仍可核验的路由身份,不复制生命周期状态。查询兼容缺少这对字段的旧记录;可读取的 state、checkout 与路由身份必须一致,只有身份足以证明无关的记录才可排除。可能匹配但身份不足、状态失效或身份冲突时要求维护者显式消歧;查询成功和失败均不回填、删除或迁移索引与历史 Run,不扫描磁盘。索引最多保留最近 32 条,且不参与 Agent 编排、GitHub 状态、权限或生命周期 mutation。
本机维护的最小 Run ID 到 Runner 独立仓库根和 state 目录的定位记录,存放于 Runner 数据目录。新登记同时保存 Repository 与 Parent number,作为 state 或 checkout 丢失时仍可核验的路由身份,不复制生命周期状态。查询兼容缺少这对字段的旧记录;可读取的 state、checkout 与路由身份必须一致,只有身份足以证明无关的记录才可排除。可能匹配但身份不足、状态失效或身份冲突时要求维护者显式消歧;查询成功和失败均不回填、删除或迁移索引与历史 Run,不扫描磁盘。索引最多保留最近 32 条,且不参与 Agent 编排、GitHub 状态、权限或生命周期 mutation。
_Avoid_: 全盘搜索、历史 state 迁移、跨仓库自动 mutation、Agent 执行日志、第二套 Run state

**Local Delivery Task Index(本地交付任务索引)**:
一个 Local Delivery Workspace 内维护的最小活动 Delivery Task 到唯一未完成 Run 及其 state 目录的指针。它只保存任务身份、Run 身份和位置,不复制生命周期状态、不参与 Agent 编排,也不跨独立本地仓库目录发现或阻止 Run。Run Executor Session 结束不删除指针中的未完成 Run;下次显式 `run` 继续它。指针若仍指向已完成或已放弃的 Run,新授权可将它替换为后继 Run;指向缺失、损坏或身份不一致的 Run 则 fail closed,不扫描其他目录、不猜测、不创建第二个 Run。
_Avoid_: 主机级索引、第二套 Run state、完整 Run 历史、磁盘扫描、远端任务注册表、静默覆盖冲突、复活终态 Run
一个 Local Delivery Workspace 内维护的最小活动 Delivery Task 到唯一未完成 Run 及其 state 目录的指针。它只保存任务身份、Run 身份和位置,不复制生命周期状态、不参与 Agent 编排;来自不同用户 clone 的同一任务共用该指针。Run Executor Session 结束不删除指针中的未完成 Run;下次显式 `run` 继续它。指针若仍指向已完成或已放弃的 Run,新授权可将它替换为后继 Run;指向缺失、损坏或身份不一致的 Run 则 fail closed,不扫描其他目录、不猜测、不创建第二个 Run。
_Avoid_: 第二套 Run state、完整 Run 历史、磁盘扫描、远端任务注册表、静默覆盖冲突、复活终态 Run

**Merge 结果对账(Merge Outcome Reconciliation)**:
Publisher 发出带精确 head 绑定的 merge intent 后,如网络或 GitHub 响应使结果未知,先在 GitHub 只读事实中对账:已 MERGED 即恢复成功;仍 OPEN 且 head、base、Required Checks 与 mergeability 仍全部匹配时,最多重试同一 intent 三次;任一矛盾状态才停止为人工处理。结果读取使用 GitHub 事件与只读状态的监督预算。
Expand Down
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,14 @@ The `agent-run` command runs Codex to implement the tickets in dependency order.
checks the results against the requirements and sends any problems back to the development agent.
Implementation, verification, and fixes run in a loop, managed by the program.

Once the requirements, tickets, and environment are ready, run this in the target repository:
Once the requirements, tickets, and environment are ready, run this from any directory:

```bash
agent-run run <parent-issue> --repo OWNER/REPO
```

Runner develops in an independent clone of the remote and leaves your local checkout unchanged. You can continue the same repository and Parent task from different directories.

The main workflow:

```mermaid
Expand Down
4 changes: 3 additions & 1 deletion README.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,14 @@ agent-run 把拆好的任务交给 Codex 自动推进,减少人工安排下一
同时,它会单独调用 Codex 做验收,检查开发结果是否符合需求,把发现的问题交回开发 Agent 修复。
开发、验收、修复和复验因此可以自动循环进行。

确定需求和任务拆分、完成环境配置后,在目标仓库执行:
确定需求和任务拆分、完成环境配置后,在终端执行:

```bash
agent-run run <parent-issue> --repo OWNER/REPO
```

Runner 独立克隆远端代码进行开发,用户本地仓库保持不变。相同仓库和 Parent 的任务可从不同目录继续。

下面是主要流程:

```mermaid
Expand Down
2 changes: 2 additions & 0 deletions docs/adr/0010-task-scoped-run-executor.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ status: accepted

# 每个 Delivery Task 由操作系统托管一个短生命周期 Executor

后续修订:[ADR 0013](0013-runner-owned-delivery-workspace.md) 将 Local Delivery Workspace 改为 Runner 独立克隆,并将同一 Repository/Parent 的唯一性收敛到本机当前用户。下文以用户仓库根区分任务、要求维护者自行协调不同 clone 的规则由该 ADR 取代;Executor、Action 与任务级短锁合同继续适用。

后续修订:[ADR 0011](0011-resume-interrupted-output-step.md) 为 Executor 仍存活时的 Worker 普通异常增加一次同 Thread 自动恢复,并对准确容量错误允许持续恢复,并明确失联状态的耗时展示。Executor 自身消失后不自动重放、等待显式恢复的规则继续适用。

后续修订:[ADR 0012](0012-noncancellable-final-approval.md) 将最终批准定义为执行期间不可取消、失败后显式恢复的完整交付操作。下文 `approve` 在意图应用和握手后返回并释放准入的原规则,以及可在此后停止最终交付的含义,由该 ADR 取代;恢复原最终批准操作的 `resume` 同样适用。其他动作、终端独立性、短锁和执行者所有权合同保持不变。
Expand Down
25 changes: 25 additions & 0 deletions docs/adr/0013-runner-owned-delivery-workspace.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
---
status: accepted
---

# Runner 独立管理交付工作区

Runner 曾把命令启动时的用户仓库作为交付工作区,向其中写入状态、分支和 worktree 元数据。合并后仅移动已检出分支的引用,还可能使文件和索引与该引用不一致。用户仓库应由维护者自行管理,交付权限不包含更新它的授权。

## 决策

Runner 只读识别用户仓库的远端,也支持在任意目录通过 `--repo` 指定目标;实际交付从远端建立独立克隆,不共享用户仓库的 Git 元数据。只使用远端已推送内容,Git 和远端交付仍沿用原有授权规则。

同一用户在本机对同一 Repository/Parent 复用唯一未完成 Delivery Run、Executor 槽位和 Action 准入门。不同启动目录和用户 clone 不产生新任务身份,不同 Parent 仍可并行。这取代 [ADR 0010](0010-task-scoped-run-executor.md) 中以用户仓库根区分任务、由维护者协调不同 clone 的约定;不扩展为跨用户或跨主机协调。

长期数据统一放在 `$XDG_DATA_HOME/agent-run/`,默认 `~/.local/share/agent-run/`,包括安装快照、独立仓库、运行状态、日志和定位索引;路径规则由一个入口定义。配置与临时运行文件继续按生命周期分开。安装、卸载和任务清理各自只管理其负责的内容,卸载保留任务数据。

成功或显式放弃后清理可安全删除的受管 worktree,保留运行记录;失败、暂停和人工等待保留开发现场。丢弃未提交成果仍需额外显式授权,不按时间自动删除。Worker 只获得本轮 checkout 所需的访问,Runner 安装和控制数据继续隔离。

## 后果

用户自行拉取远端交付结果;Runner 不再修改用户仓库的文件、索引、引用或 Git 元数据。目录按需创建,无法创建时明确失败,不回退到用户仓库。

独立克隆增加一份受管 Git 数据,换取清晰的所有权、恢复和清理边界。仅把 worktree 移到仓库外仍会共享用户 `.git`,不足以满足该边界,因此不采用。

旧任务及旧位置的数据不纳入此次变更:不迁移、恢复或清理,也不要求升级前先收尾。
12 changes: 7 additions & 5 deletions docs/agent-guide.en.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ You are the engineer responsible for installing and running `agent-run` for the
Deliver actual results, verification evidence, unmet requirements, and next steps. For installation-only requests, stop after setup. For run requests, follow the task to completion or a boundary requiring human action.

Follow the user's instructions and the target repository's `AGENTS.md`. Use current Issue/PR data, the installed version's `--help`, and query results as evidence.
Read documentation matching the selected source version. Record the tool source directory, target repository directory, and `OWNER/REPO`.
Read documentation matching the selected source version. Record the tool source directory, target `OWNER/REPO`, and user checkout directory if used.

## Choose an entry point

Expand All @@ -27,15 +27,17 @@ Read only the relevant branch and its required references. Detailed operation re
When subtasks exist, verify native GitHub sub-issues and `blockedBy` relationships; body lists do not define the task graph.
With no subtasks, use Parent-only delivery. Eligible tasks must be open, have `ready-for-agent`, and have none of `needs-triage`, `needs-info`, or `ready-for-human`. Unresolved blockers prevent selection.

2. Locate and start the task from the target repository with its project environment configured. Replace placeholders with actual values:
2. Locate and start the task from a shell with the project environment configured. With `--repo`, commands work from any directory; inside a user checkout, omit it to discover the remote without modifying that checkout. Replace placeholders with actual values:

```bash
agent-run runs --repo OWNER/REPO
agent-run run <parent-issue> --repo OWNER/REPO
agent-run status --parent <parent-issue> --repo OWNER/REPO --json
```

`run` creates or attaches to the unfinished task for the same Parent. Follow query instructions when human action is pending.
Runner clones the remote independently and leaves the user checkout unchanged. Only pushed content reaches the Agent; users update their own files, index, and branches.
On first creation, the managed clone inherits only the effective Git `user.name` and `user.email` from the launch environment, without copying other repository-local Git settings.
For the same local user, `run` creates or attaches to one unfinished task for the same Repository/Parent, regardless of the launch directory. Follow query instructions when human action is pending.
If multiple candidates exist, resolve repository and Parent identity rather than choosing the most recent. A command returning does not mean delivery is complete.

3. Use `status` for the current work and next action. For process evidence, read
Expand All @@ -48,7 +50,7 @@ Report status, PR links if any, actual acceptance/required-check results, and ou
## Human action and recovery

Before changing run state, read the [command boundary table](agent-run.md#命令边界与状态轮转) and select the action for the current state.
Run mutation commands from the target repository with the actual Parent and `--repo OWNER/REPO`.
Run mutation commands from any directory with the actual Parent and `--repo OWNER/REPO`.

| Situation | Action |
| --- | --- |
Expand All @@ -61,4 +63,4 @@ Run mutation commands from the target repository with the actual Parent and `--r
| Pause | Use `stop`; Ctrl-C or closing the terminal only ends observation, while the background task continues |
| Abandon | Follow `abandon` boundaries; preserve uncommitted work by default and require explicit authorization for forced discard |

For exhausted limits, changed scope, or incompatible state, report the decision needed. Recover through the public CLI; never edit `.agent-run` state to bypass gates.
For exhausted limits, changed scope, or incompatible state, report the decision needed. Recover through the public CLI; never edit persistent run state to bypass gates. See [local state and cleanup](agent-run.md#本地状态与清理) for directory ownership and retention.
Loading
Loading