Skip to content
This repository was archived by the owner on Oct 17, 2026. It is now read-only.
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
4 changes: 2 additions & 2 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,11 @@
- Hook and brief-format decision: `docs/adr/0010-retire-orchestration-hook-and-rigid-briefs.md`
- Installation ownership decision: `docs/adr/0008-deterministic-installer-and-global-rules.md`
- Worktree-root decision: `docs/adr/0009-coordinate-independent-worktree-roots.md`
- Delivery Review boundary decision: `docs/adr/0011-separate-delivery-review-from-orchestration.md`
- Review policy ownership decision: `docs/adr/0011-separate-delivery-review-from-orchestration.md`
- Legacy cleanup boundary decision: `docs/adr/0012-remove-legacy-cleanup-from-installation.md`
- Current projection uninstall decision: `docs/adr/0013-safe-current-projection-uninstall.md`
- Review-threshold decision: `docs/adr/0014-risk-hypothesis-gate-threshold.md`
- Review-timing decision: `docs/adr/0015-review-at-primary-branch-integration.md`
- PR Review and merge-check timing decision: `docs/adr/0015-review-at-primary-branch-integration.md`
- Decisions: create `docs/adr/` only when a hard-to-reverse choice needs a durable record.

## Update gate
Expand Down
13 changes: 8 additions & 5 deletions CONTEXT.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ from agents derived inside one task.

**Integration Root**:
The root Codex task that coordinates independent worktree lanes and owns the accepted integration
branch and combined validation. It owns Pre-merge Review only when it also owns the primary-branch
merge.
branch and combined validation. It owns PR Review when handling that PR, and Pre-merge Review
when it also owns the primary-branch merge.
_Avoid_: parent agent, integration worker

**Worktree Root**:
Expand All @@ -31,8 +31,11 @@ report; new code writing waits for a new user direction or explicit exit. Leavin
user's explicit consent.
_Avoid_: default orchestration, persistent manager mode, mandatory pipeline

**PR Review**:
Risk-based assessment of a pinned PR candidate, started after creation or update or on an explicit
review request, independently of CI availability.
_Avoid_: merge authorization, automatic repository monitoring

**Pre-merge Review**:
The mandatory root-task quality gate applied to the latest pinned candidate diff immediately before
it enters the repository's primary branch. It is separate from ordinary validation and delegation
admission.
The final check that valid risk Review and required validation cover the latest pinned candidate diff before it enters the primary branch; it may reuse an earlier PR Review.
_Avoid_: implementation delegation, proactive delegation
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

A disciplined, cross-platform orchestration system for Codex custom subagents and independent Worktree Roots. It gives each root task a concrete operating model for deciding when to delegate, what context every subagent receives, who may write, how parallel worktree lanes are integrated, how results are accepted, and how much independent review a change needs.

Codex Orchestration is deliberately not a “spawn as many agents as possible” framework. Simple work stays with the main agent. Read-only agents can investigate in parallel by evidence area or independent viewpoint, while each root task follows a local single-writer lease. When the user explicitly requests official Codex worktrees and the work can be partitioned safely, one Integration Root may coordinate up to three independent Worktree Roots for isolated parallel implementation. Each Worktree Root behaves like a normal root task inside its assigned lane; neither the Integration Root nor its local workers write the repository until every declared handoff is accepted, after which it serially merges the batch and owns combined validation. It owns the final Review only when the batch is about to merge into the primary branch.
Codex Orchestration is deliberately not a “spawn as many agents as possible” framework. Simple work stays with the main agent. Read-only agents can investigate in parallel by evidence area or independent viewpoint, while each root task follows a local single-writer lease. When the user explicitly requests official Codex worktrees and the work can be partitioned safely, one Integration Root may coordinate up to three independent Worktree Roots for isolated parallel implementation. Each Worktree Root behaves like a normal root task inside its assigned lane; neither the Integration Root nor its local workers write the repository until every declared handoff is accepted, after which it serially merges the batch and owns combined validation. It handles PR Review for the integrated candidate and confirms valid coverage before an authorized primary-branch merge.

An optional manager-only mode is enabled only by an explicit request such as “enable orchestration
mode”, “main agent pure orchestration”, or “delegate everything to subagents”. For that current root
Expand Down Expand Up @@ -79,7 +79,7 @@ The repository is the only source of truth for its portable Skills, Agents, inst

## What makes it different

- **Delegation has a threshold.** Subagents are used only when parallel evidence, specialization, or a bounded worker can materially improve the result; the separate pre-merge gate authorizes only its selected read-only Reviewers.
- **Delegation has a threshold.** Subagents are used only when parallel evidence, specialization, or a bounded worker can materially improve the result; the separate PR Review policy authorizes only its selected read-only Reviewers.
- **Manager-only is explicit and ephemeral.** A clear user request can make the current root task a strong-delegation manager: code investigation goes to `explorer`, implementation/tests/validation go to a leased Worker, and the root cannot silently take over after failure. After three unsuccessful rounds, only read-only re-decomposition or a blocker report remains; the user must give a new direction or explicitly consent before new code work.
- **Handoffs preserve useful compression.** Delegation uses compact natural-language briefs with optional task, context, handoff, and reference sections instead of inventing mandatory fields or temporary documents. When a calling Skill or Agent role supplies a machine-validated return schema, that specialized contract still applies. Agents recover ordinary repository context and return traceable evidence.
- **Task language is local.** Setup can persist English or Simplified Chinese delegation prose while role names, paths, and external protocol literals stay stable.
Expand All @@ -97,7 +97,7 @@ The repository is the only source of truth for its portable Skills, Agents, inst
model judgments on one question, and `hybrid` runs that same-question panel alongside separate
specialist workstreams. `single` remains the ordinary one-agent path, not a multi-agent
evaluation mode.
- **Review is a primary-branch integration gate.** `codex-review-gate` runs only when the current root is about to merge a pull request, branch, or accepted Worktree integration branch into a Git repository's primary branch. Ordinary task completion, unmerged handoff, pull-request creation or update without an imminent merge, and repositories without Git history stay with normal validation and do not enter R0-R3. When the gate applies, it classifies the latest candidate diff: R0 covers fully verified changes with no material failure hypothesis; R1 uses one matching Reviewer for one localized, validated, recoverable hypothesis; R2 covers multiple independent risks, broad or hard-to-recover contracts, sensitive boundaries, or material uncertainty; R3 adds focused remediation and adversarial verification for changed trust boundaries or high-impact failure. Additional seats follow only additional material hypotheses, never a quota.
- **Review starts with PR work; merge checks reuse it.** `codex-review-gate` runs after creating or updating a PR, when asked to review an existing PR including external contributions, and before an authorized primary-branch merge. Review is independent of CI and runs alongside relevant checks when configured; without CI, use appropriate local validation. Ordinary local completion and branch-only handoff do not trigger it. R0 uses main-agent validation, R1 selects one matching Reviewer, R2 covers broader or uncertain risks, and R3 adds adversarial verification. At merge, reuse evidence that covers the latest candidate and supplement only affected risks; merging and changes to a contributor's branch require their own authority. This policy does not install a GitHub event listener.
- **Review findings preserve evidence classes.** Reviewers stay within the assigned change boundary and risk. When a finding depends on a task or spec requirement or a repository standard, they cite that source and identify the evidence class without starting a generic Standards/Spec pass. Judgment calls remain labelled, and checks conclusively covered by current passing tooling are omitted unless that coverage is itself in question. After an accepted finding is fixed, the original Reviewer verifies that finding through a same-thread targeted follow-up; this does not restart a full Review loop merely to obtain a clean report.
- **Tests must earn their maintenance cost.** Writable Agents add tests only when they supply unique confidence at a correct observable seam, preferring an existing test at the lowest-cost appropriate layer. The test-reliability Reviewer also identifies coverage-chasing, redundant, implementation-bound, prose-bound, flaky, or retired-compatibility tests, but recommends removal only when equivalent behavior and failure protection remain.
- **Simplification review is explicit, read-only, and self-contained.** The optional `simplicity-reviewer` finds removable code, unnecessary abstractions, duplicated defenses, and overbuilt tests without replacing correctness, security, or performance review.
Expand Down Expand Up @@ -135,7 +135,7 @@ worker. Use risk-appropriate reviewers, and do not take over silently if a worke

- A root-task orchestration Skill that owns delegation briefs, local write leases, Worktree Root coordination, acceptance, and reusable Agent execution.
- An explicit, current-root-only manager-only branch with adaptive strong delegation and no silent code-work takeover.
- An independent `codex-review-gate` Skill that defines the pre-merge R0–R3 route and authorizes only its selected read-only Reviewers; the merge-owning root executes classification, remediation, and integration.
- An independent `codex-review-gate` Skill that defines the PR/merge R0–R3 route and authorizes only its selected read-only Reviewers; the review-owning root handles classification and authorized remediation; the merge-owning root retains integration.
- The complete `diagnosing-bugs` and `prototype` method Skills used by their corresponding writable Agents.
- Read-only explorer, official-reference research, web research, expert, and focused-review agents.
- Writable implementation, debugging, and prototype workers governed by a per-root single-writer lease.
Expand Down
6 changes: 3 additions & 3 deletions README.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

一套有明确纪律、可跨平台使用的 Codex 自定义子代理与独立 Worktree Root 编排系统。它不只提供一组 Agent,而是给每个根任务一套完整的工作方式:什么时候值得委派、每个子代理必须拿到哪些上下文、谁可以写入、并行 Worktree 工作线如何整合、如何验收结果,以及不同风险的改动需要多强的独立 Review。

Codex Orchestration 刻意不追求“Agent 越多越好”。简单任务仍由主代理直接完成;只读 Agent 可以按证据范围或独立观点并行调查,每个根任务内部则遵循本地单 Writer 租约。当用户明确要求使用 Codex 官方 Worktree,且任务可以安全拆分时,一个 Integration Root 最多可协调三个独立 Worktree Root 并行实现。每个 Worktree Root 都在分配的工作线内按普通根任务运行;全部声明工作线通过交接验收前,Integration Root 及其本地 Worker 均不得写仓库,之后它才串行合并整批结果并负责组合验证。只有整批结果准备并入主分支时,它才负责最终 Review。
Codex Orchestration 刻意不追求“Agent 越多越好”。简单任务仍由主代理直接完成;只读 Agent 可以按证据范围或独立观点并行调查,每个根任务内部则遵循本地单 Writer 租约。当用户明确要求使用 Codex 官方 Worktree,且任务可以安全拆分时,一个 Integration Root 最多可协调三个独立 Worktree Root 并行实现。每个 Worktree Root 都在分配的工作线内按普通根任务运行;全部声明工作线通过交接验收前,Integration Root 及其本地 Worker 均不得写仓库,之后它才串行合并整批结果并负责组合验证。处理集成 PR 时进行风险 Review;获准合并主分支时确认已有审查仍覆盖最终候选。

可选的 manager-only 模式只有在用户明确提出“开启编排模式”“主代理纯编排”或“全交给子代理”等请求时才启用,并且只对当前根任务生效。此时主代理自适应地拆解和协调:由 `explorer` 调查代码,由 `worker` 或方法 Worker 实现、测试和验证代码,再按当前风险交给合适的 Reviewer 做独立审查。主代理负责 Git/PR 与非代码工作,最终验收时才读取完整 diff、关键片段和验证输出。子代理失败时必须重拆、换代理或报告阻塞;三轮 Worker 不通过后只能只读重拆或报告阻塞,不得启动第四轮代码写入,新的代码写入必须等待用户新方向或明确退出模式。模式也不会持久化。

Expand Down Expand Up @@ -65,7 +65,7 @@ python3 scripts/install.py --uninstall --apply

## 鲜明特点

- **委派有门槛。** 只有并行证据、专业分工或边界清晰的 Worker 能实质改善结果时,才启动子代理;独立的主分支合并前门禁只授权它选中的只读 Reviewer。
- **委派有门槛。** 只有并行证据、专业分工或边界清晰的 Worker 能实质改善结果时,才启动子代理;独立的 PR Review 策略只授权它选中的只读 Reviewer。
- **manager-only 必须显式且临时。** 用户明确请求后,当前根任务才进入强委派管理模式:代码调查交给 `explorer`,实现、测试和验证交给带租约的 Worker;子代理失败时主代理不得静默接管,必须重拆、替换或报告阻塞。三轮不通过后只能只读重拆或报告阻塞,不得启动第四轮代码写入;新的代码写入要等用户新方向或明确退出模式。
- **交接保留有效压缩。** 委派使用自然语言简报,任务、必要上下文、交接重点和参考资料都只是可选结构,不自行发明固定字段或临时文档;调用方 Skill 或 Agent 角色提供机器可校验的回传 schema 时,仍遵循该专用合同。Agent 自行恢复普通仓库上下文并返回可追溯证据。
- **任务语言保留在本机。** 初始化可持久化选择英文或简体中文的委派措辞;角色名、路径和外部协议字面量保持稳定。
Expand All @@ -81,7 +81,7 @@ python3 scripts/install.py --uninstall --apply
- **协作方式有明确语义。** `coverage` 拆分证据范围,`panel` 让不同模型独立回答同一问题,
`hybrid` 则让同题 Panel 与彼此独立的专项工作流并行。`single` 只是普通单代理路径,不属于
多代理评估模式;任何模式都不会把多数票当作真相。
- **Review 是主分支集成门。** `codex-review-gate` 只在当前根任务准备把 PR、分支或已验收的 Worktree 集成分支并入 Git 仓库主分支时运行。普通任务完成、未合并交接、并不准备立即合并的 PR 创建或更新,以及没有 Git 历史的仓库只做正常验证,不进入 R0–R3。门生效时检查最新候选 diff:R0 覆盖已完整验证且不存在实质失败假设的改动;R1 对一个局部、已验证、可恢复的假设使用一名匹配 Reviewer;R2 覆盖多个独立风险、广泛或难恢复的合同、敏感边界及实质性不确定;R3 对信任边界变化或高影响失败追加专项整改与对抗式复核。只有新增实质失败假设才增加席位,不设人数配额。
- **PR 阶段审查,合并前确认覆盖。** 创建或更新 PR、受托审查现有 PR(含外部贡献),以及获准合并主分支前,加载 `codex-review-gate`。Review 不依赖 CI;有相关 CI 时并行推进,无 CI 时完成适用的本地验证。普通本地交付和仅分支交接不触发。R0 由主代理验证,R1 选择一名匹配 Reviewer,R2 覆盖更广或不确定的风险,R3 追加对抗复核。合并前复用覆盖最新候选的有效证据,仅补审受影响风险;修改贡献者分支和合并仍需对应授权。这些规则不会安装 GitHub 事件监听。
- **Review 结论保留证据类别。** Reviewer 留在指定变更边界和风险内;当结论依赖任务或 Spec 要求、仓库规范时,引用对应来源并标明证据类别,不因此启动通用 Standards/Spec 审查。判断性风险明确标注,当前通过的工具已能确定覆盖的检查不再重复报告,除非工具覆盖本身存在疑问。接受的 finding 修复后,由原 Reviewer 在同一线程做定向复核;这不等于为取得 clean 报告而重启整轮 Review。
- **测试必须值得其维护成本。** 可写 Agent 只在测试能通过正确的可观察 seam 提供独特信心时才补测试,并优先扩展成本最低的合适层级中的现有测试。测试可靠性 Reviewer 还会识别为覆盖率凑数、重复、绑定实现或文案、不稳定及只保留退役兼容性的测试,但只有在等价行为与故障保护仍然存在时才建议删除。
- **简化审查保持显式、只读且自包含。** 可选的 `simplicity-reviewer` 查找可删除代码、无必要抽象、重复防护和过度测试,同时不替代正确性、安全或性能审查。
Expand Down
9 changes: 4 additions & 5 deletions docs/adr/0009-coordinate-independent-worktree-roots.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,11 @@ worktree and returns its task/worktree identity, one candidate handoff branch, c
diff, validation evidence, and integration risks. The Integration Root waits for every declared
handoff to reach `accepted` before it serially merges lanes into a dedicated integration branch,
runs combined validation, and produces one accepted integration candidate. When the Integration
Root also owns the primary-branch merge, it applies the R0-R3 pre-merge gate to that candidate;
otherwise it hands off the validated integration branch and the future merge-owning root owns the
Review. Failed or canceled lanes block success; excluding one requires the user's explicit
Root handles an integration PR, it applies PR Review to that candidate; otherwise it hands off
the validated integration branch. The root authorized to merge confirms final Review coverage. Failed or canceled lanes block success; excluding one requires the user's explicit
rescoping. Prototype lanes additionally require explicit user acceptance. Lane consultation is
optional unless risk would otherwise compound; it never substitutes for a required pre-merge
Review.
optional unless risk would otherwise compound; its evidence can be reused for covered risks,
while combined behavior and remaining integration risks still need assessment.

While any lane is nonterminal, the Integration Root remains repository-read-only. It becomes the
repository writer for serial merge and integration fixes only after the complete batch is accepted.
Expand Down
Loading