delegate
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseDelegation Skill
任务委派Skill
Dispatch implementation tasks to subagents with proper context, worktree isolation, and TDD requirements. This skill follows a three-step flow: Prepare, Dispatch, Monitor.
在具备合适上下文、工作树隔离和TDD要求的前提下,将实现任务分派给子Agent。该Skill遵循三步流程:准备、分派、监控。
Triggers
触发条件
Activate this skill when:
- User runs command
/delegate - Implementation plan is ready with extractable tasks
- User wants to parallelize work across subagents
Exception — oneshot workflows skip delegation entirely. The oneshot playbook runs an in-session TDD loop in the main agent's context, with no subagent dispatch or review phase. If , do not call this skill — see for the lightweight path.
workflowType === "oneshot"@skills/oneshot/SKILL.md在以下场景激活本Skill:
- 用户执行命令
/delegate - 实现计划已准备就绪,可提取出具体任务
- 用户希望通过子Agent并行处理工作
例外情况 —— 单次执行工作流完全跳过委派流程。单次执行剧本会在主Agent的上下文中运行会话内TDD循环,无需子Agent分派或审查阶段。若,请勿调用本Skill —— 请查看了解轻量级流程。
workflowType === "oneshot"@skills/oneshot/SKILL.mdCore Principles
核心原则
Fresh Context Per Task (MANDATORY)
任务专属独立上下文(强制要求)
Each subagent MUST start with a clean, self-contained context. As established in the Anthropic best practices for multi-agent coordination:
- No shared state assumptions. Every subagent prompt must contain the full task description, file paths, TDD requirements, and acceptance criteria. Never say "see the plan" or "as discussed earlier."
- No cross-agent references. Subagent A must not depend on output from Subagent B unless explicitly sequenced with a dependency edge in the plan.
- Isolated worktrees. Each subagent operates in its own . Parallel agents in the same worktree will corrupt branch state.
git worktree
Rationalization patterns that violate this principle are catalogued in .
references/rationalization-refutation.md每个子Agent必须从干净、独立的上下文启动。根据Anthropic多Agent协作最佳实践:
- 无共享状态假设。每个子Agent的提示必须包含完整的任务描述、文件路径、TDD要求和验收标准。绝不能说“查看计划”或“如之前讨论”。
- 无跨Agent引用。子Agent A不得依赖子Agent B的输出,除非计划中明确设置了依赖顺序。
- 隔离工作树。每个子Agent在独立的中运行。同一工作树中的并行Agent会破坏分支状态。
git worktree
违反此原则的常见合理化借口已整理在中。
references/rationalization-refutation.mdDelegation Modes
委派模式
The default mode dispatches each task using the runtime's spawn primitive: .
subagenttaskUse the from task classifications when available. If no classification exists (e.g., fixer dispatch), omit to inherit the session default.
recommendedModelprepare_delegationmodel默认的模式使用运行时的生成原语分派每个任务。
subagenttask若任务分类中提供了,请使用该模型。若无分类信息(例如修复任务分派),则省略参数,继承会话默认模型。
prepare_delegationrecommendedModelmodelPre-Dispatch Schema Discovery
分派前模式发现
Before dispatching, query decision runbooks to classify the work and select the right strategy:
- Task complexity: to get the cognitive complexity classification tree. Low-complexity tasks can use the scaffolder agent spec for faster execution.
exarchos_orchestrate({ action: "runbook", id: "task-classification" }) - Dispatch strategy: for dispatch strategy (parallel vs sequential, team sizing, isolation mode).
exarchos_orchestrate({ action: "runbook", id: "dispatch-decision" })
分派前,查询决策手册对工作进行分类并选择合适策略:
- 任务复杂度:调用获取认知复杂度分类树。低复杂度任务可使用脚手架Agent规范以提升执行速度。
exarchos_orchestrate({ action: "runbook", id: "task-classification" }) - 分派策略:调用获取分派策略(并行/串行、团队规模、隔离模式)。
exarchos_orchestrate({ action: "runbook", id: "dispatch-decision" })
Step 1: Prepare
步骤1:准备
Use the composite action to validate readiness in a single call. This replaces manual script invocations and individual checks.
prepare_delegationAuthoritative spec: the canonical list of preconditions, blockers, and arguments forlives in the runtime — query it withprepare_delegationif anything in this skill drifts from observed behavior. Treat the runtimeexarchos_orchestrate({ action: "describe", actions: ["prepare_delegation"] })output as the source of truth.describe
使用复合操作一次性验证就绪状态。这替代了手动脚本调用和单独检查。
prepare_delegation权威规范:的前提条件、阻塞因素和参数的标准列表存储在运行时中 —— 若本Skill内容与实际行为不符,请调用prepare_delegation查询。请将运行时的exarchos_orchestrate({ action: "describe", actions: ["prepare_delegation"] })输出视为唯一可信来源。describe
Step 0 — Pre-emit (required before prepare_delegation
)
prepare_delegation步骤0 —— 预发送(调用prepare_delegation
前必须执行)
prepare_delegationBefore calling , the workflow stream must contain a event for each task. The readiness view counts these events to populate ; without them, returns .
prepare_delegationtask.assignedtaskCountprepare_delegation{ ready: false, blockers: ["no task.assigned events found ..."] }typescript
exarchos_event({
action: "batch_append",
stream: "<featureId>",
events: tasks.map((t) => ({
type: "task.assigned",
data: { taskId: t.id, title: t.title, branch: t.branch },
})),
})调用前,工作流流必须包含每个任务的事件。就绪视图会统计这些事件以填充;若无这些事件,会返回。
prepare_delegationtask.assignedtaskCountprepare_delegation{ ready: false, blockers: ["未找到task.assigned事件..."] }typescript
exarchos_event({
action: "batch_append",
stream: "<featureId>",
events: tasks.map((t) => ({
type: "task.assigned",
data: { taskId: t.id, title: t.title, branch: t.branch },
})),
})Step 1 — Prepare (readiness check)
步骤1 —— 准备(就绪检查)
typescript
exarchos_orchestrate({
action: "prepare_delegation",
featureId: "<featureId>",
planPath: "docs/specs/<the-decomposition-spec>.md",
tasks: [{ id: "task-001", title: "...", modules: [...] }, ...]
})Pass . It points at the decomposition markdown so it lifts each task's / stamp automatically (deterministic parse — no hand-transcription). The stamp is what selects the per-task verification depth below; without (and without an explicit / on a task) every task falls back to a keyword/glob heuristic that under-provisions planner-/boundary tasks (#1636). You may still set / explicitly on a entry to override the plan for one task; an explicit value always wins.
planPathprepare_delegation**Risk Tier:****Boundary Touching:**planPathriskTierboundaryTouchinghighriskTierboundaryTouchingtasks[]The composite action is read-only — it queries delegation readiness and
assembles quality hints. It does not create worktrees and does not run
(its authoritative description is "Query delegation readiness and
prepare quality hints for subagent dispatch"). Worktree materialization is the
host's responsibility under native isolation, or an explicit
call — which lays out the canonical path. The
action performs:
npm installsetup_worktree.worktrees/<taskId>-<taskName>- State validation — verifies workflow state is in phase, plan exists, plan approved
delegate - Quality signal assembly — queries view; if
code_quality, returns quality hints to embed in prompts. EmitsgatePassRate < 0.80on success (no pre-query needed)gate.executed('plan-coverage') - Benchmark detection — sets if any task has benchmark criteria
verification.hasBenchmarks - Readiness verdict — returns (the
{ ready: true, worktrees: [...], qualityHints: [...] }array reports the expected paths, not created ones) orworktrees{ ready: false, reason: "..." }
If with : the response includes a field (e.g. "checkout the feature/phase branch before dispatching delegation"). Apply the hint, then re-call.
blocked: truereason: "current-branch-protected"hintIf : Stop. Report the reason to the user. Do not proceed.
ready: falseIf : Extract the paths and for prompt construction.
ready: trueworktreesqualityHintsNative isolation — verify worktrees before agents edit. Under native isolation (), returns even when the host has not yet materialized worktrees (), because isolation is the host's responsibility — readiness cannot be confirmed at prepare-time. When and none are confirmed ready, the response carries a warning: "native isolation requested; N worktree(s) expected but 0 confirmed ready — verify the host materializes worktrees or dispatch may land in the shared checkout." Do not ignore it. After dispatching, and before any agent edits files, confirm each agent's working directory is under (e.g. the agent's first reported ). If an agent is NOT in a worktree it has landed in the shared checkout — stop it, create the worktree manually with (the same layout uses, so a manually-created worktree is recognized without a second-path retry), redirect the agent to that path, and only then allow edits. Skipping this check risks silent shared-tree corruption across parallel agents.
nativeIsolation: trueprepare_delegationready: trueworktrees.ready: 0worktrees.expected > 0.worktrees/pwdgit worktree add -b <task-branch> .worktrees/<taskId>-<taskName> <integration-tip><taskId>-<taskName>setup_worktreetypescript
exarchos_orchestrate({
action: "prepare_delegation",
featureId: "<featureId>",
planPath: "docs/specs/<the-decomposition-spec>.md",
tasks: [{ id: "task-001", title: "...", modules: [...] }, ...]
})传入。它指引找到分解文档,以便自动提取每个任务的 / 标记(确定性解析 —— 无需手动转录)。该标记用于选择下文的任务验证深度;若无(且任务未显式设置/),所有任务会回退到关键词/通配符启发式规则,这会导致规划师标记为/边界任务的验证资源不足(#1636)。你仍可在条目中显式设置/以覆盖计划中的单个任务值;显式设置的值始终优先。
planPathprepare_delegation**Risk Tier:****Boundary Touching:**planPathriskTierboundaryTouchinghightasks[]riskTierboundaryTouching复合操作是只读的 —— 它查询委派就绪状态并收集质量提示。它不会创建工作树,也不会运行(其权威描述为“查询委派就绪状态并为子Agent分派准备质量提示”)。工作树实例化是原生隔离下宿主的责任,或需显式调用 —— 该操作会创建标准路径。此操作执行以下内容:
npm installsetup_worktree.worktrees/<taskId>-<taskName>- 状态验证 —— 验证工作流状态处于阶段、计划存在且已获批
delegate - 质量信号收集 —— 查询视图;若
code_quality,则返回质量提示以嵌入到提示词中。成功时会发送gatePassRate < 0.80事件(无需预查询)gate.executed('plan-coverage') - 基准检测 —— 若任何任务包含基准标准,则设置
verification.hasBenchmarks - 就绪判定 —— 返回(
{ ready: true, worktrees: [...], qualityHints: [...] }数组报告预期路径,而非已创建路径)或worktrees{ ready: false, reason: "..." }
若返回且:响应包含字段(例如“分派前切换到feature/phase分支”)。应用该提示后重新调用。
blocked: truereason: "current-branch-protected"hint若:停止操作。向用户报告原因。请勿继续。
ready: false若:提取路径和用于提示词构建。
ready: trueworktreesqualityHints原生隔离 —— Agent编辑前验证工作树。在原生隔离模式下(),即使宿主尚未实例化工作树(),仍会返回,因为隔离是宿主的责任 —— 准备阶段无法确认就绪状态。当且无已确认就绪的工作树时,响应会携带警告:*“请求原生隔离;预计N个工作树,但0个已确认就绪 —— 请验证宿主已实例化工作树,否则分派可能会进入共享检出目录。”*请勿忽略该警告。分派后,在任何Agent编辑文件前,确认每个Agent的工作目录位于下(例如Agent首次报告的)。若Agent不在工作树中,则它已进入共享检出目录 —— 停止该Agent,手动创建工作树:(使用与相同的结构,以便手动创建的工作树无需二次路径重试即可被识别),将Agent重定向到该路径,然后才允许编辑。跳过此检查可能导致并行Agent之间的共享树静默损坏。
nativeIsolation: trueworktrees.ready: 0prepare_delegationready: trueworktrees.expected > 0.worktrees/pwdgit worktree add -b <task-branch> .worktrees/<taskId>-<taskName> <integration-tip>setup_worktree<taskId>-<taskName>Task Extraction
任务提取
From the implementation plan, extract for each task:
- Full task description (paste inline; never reference external files)
- The /
**Risk Tier:**stamps are lifted automatically when you pass**Boundary Touching:**(above) — you do NOT need to re-transcribe them intoplanPath; pass them explicitly only to override the plan for a specific tasktasks[] - Files to create/modify as worktree-relative paths rooted inside the worktree (e.g. ) — never an absolute parent-repo path, and never a
src/foo.tssequence that escapes the worktree root. Either form resolves outside the agent's worktree cwd and silently writes into the main worktree. This is the platform-agnostic line of defense — it must hold on every runtime... - Test file paths (worktree-relative) and expected test names
- Dependencies on other tasks (for sequencing)
- Property-based testing flag ()
testingStrategy.propertyTests
For a complete worked example of this flow, see .
references/worked-example.md从实现计划中为每个任务提取以下内容:
- 完整任务描述(直接粘贴;绝不要引用外部文件)
- 传入后,
planPath/**Risk Tier:**标记会自动提取(上文已说明)—— 你无需将其重新转录到**Boundary Touching:**中;仅需为特定任务显式传入以覆盖计划值tasks[] - 要创建/修改的文件路径(工作树内的相对路径,例如)—— 绝不要使用绝对父仓库路径,也不要使用
src/foo.ts序列跳出工作树根目录。这两种形式都会解析到Agent工作树当前工作目录之外,并静默写入主工作树。这是平台无关的防御线 —— 必须在所有运行时中严格遵守。.. - 测试文件路径(工作树相对路径)和预期测试名称
- 对其他任务的依赖(用于排序)
- 属性测试标记()
testingStrategy.propertyTests
有关此流程的完整示例,请查看。
references/worked-example.mdStep 2: Dispatch
步骤2:分派
Build subagent prompts using as the template. Each prompt MUST include the full task context — this is the fresh-context principle in action.
references/implementer-prompt.md使用作为模板构建子Agent提示词。每个提示词必须包含完整的任务上下文 —— 这是独立上下文原则的具体体现。
references/implementer-prompt.mdPrompt Construction
提示词构建
On runtimes with native agent definitions:
The implementer agent definition already includes the system prompt, model, isolation, skills, hooks, and memory. The dispatch prompt should contain ONLY task-specific context:
- Full task description (requirements, acceptance criteria)
- Working directory (worktree path from Step 1)
- File paths to create/modify and test file paths
- Quality hints (if any)
- PBT flag when
propertyTests: true
Full prompt template (default):
For each task:
- Fill the implementer prompt template with task-specific details
- Set the to the worktree path from Step 1
Working Directory - Include quality hints (if any) in the Quality Signals section
- Include PBT section from when
references/pbt-patterns.mdpropertyTests: true - Include testing patterns from
references/testing-patterns.md
在具备原生Agent定义的运行时中:
实现者Agent定义已包含系统提示词、模型、隔离设置、Skill、钩子和内存。分派提示词应仅包含任务特定上下文:
- 完整任务描述(需求、验收标准)
- 工作目录(步骤1中的工作树路径)
- 要创建/修改的文件路径和测试文件路径
- 质量提示(若有)
- 当时的PBT标记
propertyTests: true
完整提示词模板(默认):
针对每个任务:
- 使用任务特定细节填充实现者提示词模板
- 将设置为步骤1中的工作树路径
Working Directory - 在Quality Signals部分包含质量提示(若有)
- 当时,包含
propertyTests: true中的PBT部分references/pbt-patterns.md - 包含中的测试模式
references/testing-patterns.md
Tier-selected verification note — dispatch the rendered prompt
按层级选择的验证说明 —— 分派渲染后的提示词
prepare_delegationplanPathstamp:warningsimplementerPromptTemplateverificationNoteverificationNotes"<riskTier>|<boundaryTouching>"taskClassifications[i].verificationNoteKeyverificationNotes[taskClassifications[i].verificationNoteKey]detail: trueoutputFormat: "prompt-only"taskClassifications[i].implementerPromptDispatch THAT reconstructed prompt — not the static agent default. The shipped bakes a fixed medium-tier note (a self-contained fallback for runtimes that pre-bind a named agent). Use it verbatim only when no classification exists (e.g. a fixer dispatch). Otherwise, the orchestrator's dispatch payload must be built from with the task's note spliced in, then fill its / / placeholders (the same template slots in ) with the task-specific context above. Dispatching the static default instead re-imposes medium-RGR ceremony on every task regardless of tier — the exact gap this seam closes. The tier is pure data from the classification stamp; no workflow-type branching is involved.
agents/implementer.mdimplementerPromptTemplateverificationNoteKeytaskDescriptionrequirementsfilePathsreferences/implementer-prompt.mdprepare_delegationplanPathwarningsstamp:implementerPromptTemplateverificationNoteverificationNotes"<riskTier>|<boundaryTouching>"taskClassifications[i].verificationNoteKeyverificationNotes[taskClassifications[i].verificationNoteKey]detail: trueoutputFormat: "prompt-only"taskClassifications[i].implementerPrompt分派重构后的提示词 —— 而非静态Agent默认提示词。发布的包含固定的中等级别说明(为预绑定命名Agent的运行时提供独立 fallback)。仅当无分类信息时(例如修复任务分派),才直接使用该默认提示词。否则,编排器的分派负载必须基于,将任务的对应的说明插入其中,然后用上述任务特定上下文填充 / / 占位符(与中的模板插槽一致)。若分派静态默认提示词,会导致所有任务无论层级如何都强制执行中等RGR流程 —— 这正是此机制要解决的问题。层级直接来自分类标记的纯数据;无需基于工作流类型进行分支处理。
agents/implementer.mdimplementerPromptTemplateverificationNoteKeytaskDescriptionrequirementsfilePathsreferences/implementer-prompt.mdDecision Runbooks
决策手册
For dispatch strategy decisions, query the decision runbook:
exarchos_orchestrate({ action: "runbook", id: "dispatch-decision" })This runbook provides structured criteria for parallel vs sequential dispatch, team sizing, and failure escalation.
有关分派策略决策,请查询决策手册:
exarchos_orchestrate({ action: "runbook", id: "dispatch-decision" })该手册提供了并行/串行分派、团队规模和故障升级的结构化标准。
Parallel Dispatch
并行分派
Dispatch all independent tasks using the runtime's native spawn primitive in a single message so the dispatches run in parallel.
typescript
task --agent implementer 'Implement task-001: [title]: Task-specific context: requirements, file paths, acceptance criteria'Note: Include the full implementer prompt template fromin the dispatch payload so the spawned agent has a self-contained context — runtimes that pre-bind the implementer prompt to a named agent will discard the redundant content automatically.references/implementer-prompt.md
For parallel grouping strategy and model selection, see .
references/parallel-strategy.md使用运行时的原生生成原语,在单个消息中分派所有独立任务,以便任务并行运行。
typescript
task --agent implementer 'Implement task-001: [title]: Task-specific context: requirements, file paths, acceptance criteria'注意: 在分派负载中包含中的完整实现者提示词模板,以便生成的Agent具备独立上下文 —— 预绑定实现者提示词到命名Agent的运行时会自动丢弃冗余内容。references/implementer-prompt.md
有关并行分组策略和模型选择,请查看。
references/parallel-strategy.mdVerification Ownership Contract (ONE owner per claim)
验证所有权契约(每个声明仅一个所有者)
Every verification claim has exactly one owner. Re-verifying a claim you do
not own is duplicated work, not defense in depth — it inflates the wave's cost
and hides which run is authoritative when the two disagree.
| Claim | Owner | Where it runs | Everyone else |
|---|---|---|---|
| "This task's behavior is covered and its tests can fail" | Implementer subagent | Its own worktree, via the per-task gates in the task-completion runbook | Lead consumes the recorded evidence; it does not re-run the gates |
| "This task's diff is clean (types, lint, contracts, mocks)" | Implementer subagent | Same per-task gate sequence | Lead consumes the evidence |
| "The wave as a whole did not cascade" | Lead | Once at the wave boundary — | Implementers never run the cumulative suite |
| "The wave is complete (all tasks done, branches exist)" | Lead | | — |
Two consequences bind the runbooks:
- is the terminal step of the task-completion runbook. No blocking gate may run after it — a task that is marked complete has already passed every gate that could block it.
task_complete - is a wave-boundary backstop, not a per-task gate. It runs exactly once per wave, after the merges, matching its own action description. Per-task cascade risk is covered by the task's own scoped gates.
check_integration_suite
The lead's only independent verification is a spot check — reading the
recorded evidence and, at most, sampling one claim it has concrete reason to
doubt. A blanket re-run of the per-task chain is a contract violation.
每个验证声明有且仅有一个所有者。重新验证非你所有的声明属于重复工作,而非深度防御 —— 这会增加批量成本,且当两个结果不一致时难以确定哪个运行结果是权威的。
| 声明 | 所有者 | 运行位置 | 其他角色 |
|---|---|---|---|
| "此任务的行为已覆盖,测试可失败" | 实现者子Agent | 自身工作树中,通过任务完成手册中的每任务验证门 | 主导者消费记录的证据;不会重新运行验证门 |
| "此任务的差异干净(类型、 lint、契约、模拟)" | 实现者子Agent | 同一每任务验证门序列 | 主导者消费证据 |
| "整体批量未产生连锁故障" | 主导者 | 一次在批量边界处 —— 每次批量合并完成后运行 | 实现者从不运行累积套件 |
| "批量已完成(所有任务完成,分支存在)" | 主导者 | | — |
此契约对手册有两个约束:
- 是任务完成手册的终端步骤。不得在其之后运行阻塞性验证门 —— 标记为完成的任务已通过所有可能阻塞它的验证门。
task_complete - 是批量边界的后备检查,而非每任务验证门。它在每个批量中仅运行一次,在合并完成后,与其自身的操作描述一致。每任务连锁风险由任务自身的范围验证门覆盖。
check_integration_suite
主导者仅需进行抽查 —— 读取记录的证据,最多对有具体怀疑理由的声明进行抽样验证。 blanket重新运行每任务验证链属于契约违规。
Step 3: Monitor and Collect
步骤3:监控与收集
Subagent Monitoring
子Agent监控
Collect background task results using the runtime's result-collection primitive (this may be a poll/await per task or inline replies, depending on the runtime):
text
inline reply from task --agent (no separate collection API)After each subagent reports completion:
Runbook: For each completed task, execute the task-completion runbook:Execute the returned steps in order. Stop on gate failure. If the runbook action is unavailable, useexarchos_orchestrate({ action: "runbook", id: "task-completion" })to retrieve gate schemas and run manually:describeexarchos_orchestrate({ action: "describe", actions: ["check_test_adequacy", "check_static_analysis", "task_complete"] })
-
Extract provenance from subagent report — parse the subagent's completion output and extract structured provenance fields (,
implements,tests). These fields are reported by the subagent following the Provenance Reporting section of the implementer prompt.files -
Verify worktree state — confirm each worktree has cleanand passing tests
git status -
Run blocking gates — therunbook (referenced above) defines the exact gate sequence (test adequacy, static analysis, then task_complete). On any gate failure, keep the task in-progress and report findings. All gate handlers auto-emit
task-completionevents, so manualgate.executedcalls are not needed.exarchos_event -
Pass provenance in task completion — when marking a task complete, pass the extracted provenance fields in theparameter so they flow into the
resultevent:task.completed
typescript
exarchos_orchestrate({
action: "task_complete",
taskId: "<taskId>",
streamId: "<featureId>",
result: {
summary: "<task summary>",
implements: ["DR-1", "DR-3"],
tests: [{ name: "testName", file: "path/to/test.ts" }],
files: ["path/to/impl.ts", "path/to/test.ts"]
}
})- Update workflow state — set each passing to
tasks[].statusvia"complete"exarchos_workflow update - Delegation completion gate (D4, advisory) — after ALL tasks pass, run an operational resilience check on the full branch diff before transitioning to review:
typescript
exarchos_orchestrate({
action: "check_operational_resilience",
featureId: "<featureId>",
repoRoot: ".",
baseBranch: "main"
})This is advisory — findings are recorded for the convergence view but do not block the delegation→review transition. Include findings in the delegation summary for review-phase attention.
- Schema sync — if any task modified API files (,
*Endpoints.cs), runModels/*.csnpm run sync:schemas
使用运行时的结果收集原语收集后台任务结果(根据运行时不同,可能是每个任务的轮询/等待或内回复):
text
inline reply from task --agent (no separate collection API)每个子Agent报告完成后:
手册: 针对每个已完成任务,执行任务完成手册:按顺序执行返回的步骤。验证门失败时停止。 若手册操作不可用,使用exarchos_orchestrate({ action: "runbook", id: "task-completion" })获取验证门模式并手动运行:describeexarchos_orchestrate({ action: "describe", actions: ["check_test_adequacy", "check_static_analysis", "task_complete"] })
-
从子Agent报告中提取来源信息 —— 解析子Agent的完成输出并提取结构化来源字段(、
implements、tests)。这些字段由子Agent根据实现者提示词中的来源报告部分进行报告。files -
验证工作树状态 —— 确认每个工作树的干净且测试通过
git status -
运行阻塞性验证门 ——手册(上文提及)定义了确切的验证门序列(测试充分性、静态分析,然后是task_complete)。任何验证门失败时,保持任务进行中并报告结果。所有验证门处理程序会自动发送
task-completion事件,因此无需手动调用gate.executed。exarchos_event -
在任务完成时传入来源信息 —— 标记任务完成时,在参数中传入提取的来源字段,使其流入
result事件:task.completed
typescript
exarchos_orchestrate({
action: "task_complete",
taskId: "<taskId>",
streamId: "<featureId>",
result: {
summary: "<task summary>",
implements: ["DR-1", "DR-3"],
tests: [{ name: "testName", file: "path/to/test.ts" }],
files: ["path/to/impl.ts", "path/to/test.ts"]
}
})- 更新工作流状态 —— 通过将每个通过的
exarchos_workflow update设置为tasks[].status"complete" - 委派完成验证门(D4,建议性) —— 所有任务通过后,在过渡到审查阶段前,对完整分支差异运行操作弹性检查:
typescript
exarchos_orchestrate({
action: "check_operational_resilience",
featureId: "<featureId>",
repoRoot: ".",
baseBranch: "main"
})这是建议性检查 —— 结果会记录到收敛视图中,但不会阻止委派→审查的过渡。请在委派总结中包含检查结果,以供审查阶段关注。
- 模式同步 —— 若任何任务修改了API文件(、
*Endpoints.cs),运行Models/*.csnpm run sync:schemas
Failure Recovery
故障恢复
When a task fails:
- Read the failure output from the runtime's result-collection primitive ()
inline reply from task --agent (no separate collection API) - Diagnose root cause — do NOT trust the implementer's self-assessment (see R3 adversarial posture)
- Fix the task using the fixer flow below
- Run the runbook gate chain after the fix completes
task-fix
For the full recovery flow with a concrete example, see .
references/worked-example.md任务失败时:
- 从运行时的结果收集原语读取失败输出()
inline reply from task --agent (no separate collection API) - 诊断根本原因 —— 不要信任实现者的自我评估(请参考R3对抗性姿态)
- 使用以下修复流程修复任务
- 修复完成后运行手册验证门链
task-fix
有关包含具体示例的完整恢复流程,请查看。
references/worked-example.mdFix Failed Tasks
修复失败任务
Dispatch a fresh fixer agent using the runtime's native spawn primitive, carrying the full failure context and the original task description:
typescript
task --agent fixer 'Fix failed task-001: Your implementation failed. [failure context from test output]. Apply adversarial verification: do NOT trust your previous self-assessment, re-read actual test output, identify root cause not symptoms. [Original task context].'After fix completes, run the runbook gate chain:
If runbook unavailable, use to retrieve gate schemas:
task-fixexarchos_orchestrate({ action: "runbook", id: "task-fix" })describeexarchos_orchestrate({ action: "describe", actions: ["check_test_adequacy", "check_static_analysis", "task_complete"] })使用运行时的原生生成原语分派新的修复Agent,携带完整的故障上下文和原始任务描述:
typescript
task --agent fixer 'Fix failed task-001: Your implementation failed. [failure context from test output]. Apply adversarial verification: do NOT trust your previous self-assessment, re-read actual test output, identify root cause not symptoms. [Original task context].'修复完成后,运行手册验证门链:
若手册不可用,使用获取验证门模式:
task-fixexarchos_orchestrate({ action: "runbook", id: "task-fix" })describeexarchos_orchestrate({ action: "describe", actions: ["check_test_adequacy", "check_static_analysis", "task_complete"] })Fix Mode (--fixes)
修复模式(--fixes)
Handles review failures instead of initial implementation. Uses template with adversarial verification posture, dispatches fix tasks per issue, then re-invokes review to re-integrate fixes.
references/fixer-prompt.mdArguments: — state JSON containing review results in or .
--fixes <state-file-path>.reviews.<taskId>.specReview.reviews.<taskId>.qualityReviewFor detailed fix-mode process, see .
references/fix-mode.mdDeprecated:has been superseded by--pr-fixes. Use the shepherd skill for PR feedback workflows./exarchos:shepherd
处理审查失败,而非初始实现。使用模板,采用对抗性验证姿态,针对每个问题分派修复任务,然后重新调用审查以整合修复内容。
references/fixer-prompt.md参数: —— 包含审查结果的状态JSON,位于或中。
--fixes <state-file-path>.reviews.<taskId>.specReview.reviews.<taskId>.qualityReview有关修复模式的详细流程,请查看。
references/fix-mode.md已弃用:已被--pr-fixes取代。PR反馈工作流请使用shepherd Skill。/exarchos:shepherd
Context Compaction Recovery
上下文压缩恢复
If context compaction occurs during delegation:
- Query workflow state: with
exarchos_workflow getfields: ["tasks"] - Check active worktrees: and verify branch state
ls .worktrees/ - Reconcile: replays the event stream and patches stale task state (CAS-protected)
exarchos_workflow reconcile - Do NOT re-create branches or re-dispatch agents until confirmed lost
若委派过程中发生上下文压缩:
- 查询工作流状态:并传入
exarchos_workflow getfields: ["tasks"] - 检查活动工作树:并验证分支状态
ls .worktrees/ - 协调:重放事件流并修补过期任务状态(受CAS保护)
exarchos_workflow reconcile - 确认任务丢失前,请勿重新创建分支或重新分派Agent
Worktree State Schema
工作树状态模式
Worktree entries are stored as in workflow state. Each entry requires:
worktrees["<wt-id>"]| Field | Type | Required | Notes |
|---|---|---|---|
| string | Yes | Git branch name |
| string | Conditional | Single task ID (use for 1-task worktrees) |
| string[] | Conditional | Multiple task IDs (use for multi-task worktrees) |
| | Yes | Worktree lifecycle status |
Either or (non-empty array) is required — at least one must be present.
taskIdtasksSingle-task example:
json
{ "branch": "feat/task-001", "taskId": "task-001", "status": "active" }Multi-task example:
json
{ "branch": "feat/integration", "tasks": ["task-001", "task-002"], "status": "active" }工作树条目存储在工作流状态的中。每个条目需要:
worktrees["<wt-id>"]| 字段 | 类型 | 必填 | 说明 |
|---|---|---|---|
| string | 是 | Git分支名称 |
| string | 可选 | 单个任务ID(用于单任务工作树) |
| string[] | 可选 | 多个任务ID(用于多任务工作树) |
| | 是 | 工作树生命周期状态 |
必须提供或(非空数组)中的至少一个。
taskIdtasks单任务示例:
json
{ "branch": "feat/task-001", "taskId": "task-001", "status": "active" }多任务示例:
json
{ "branch": "feat/integration", "tasks": ["task-001", "task-002"], "status": "active" }Phase Transitions and Guards
阶段过渡与守卫
For the full transition table, consult .
@skills/checkpoint/references/phase-transitions.mdQuick reference: The → transition requires guard — all must be in workflow state.
delegatereviewall-tasks-completetasks[].status"complete"Before transitioning to review: You MUST first update all task statuses tovia"complete"with the tasks array. The phase transition will be rejected by the guard if any task is still pending/in_progress/failed. Update tasks first, then set the phase in a separate call.exarchos_workflow update
完整的过渡表请参考。
@skills/checkpoint/references/phase-transitions.md快速参考: → 过渡需要守卫 —— 工作流状态中所有必须为。
delegatereviewall-tasks-completetasks[].status"complete"过渡到审查前: 必须先通过传入tasks数组,将所有任务状态更新为exarchos_workflow update。若任何任务仍处于pending/in_progress/failed状态,阶段过渡会被守卫拒绝。请先更新任务状态,再通过单独调用设置阶段。"complete"
Worktree-Bearing Tasks: Auto-Detour to merge-pending
merge-pending关联工作树的任务:自动转向merge-pending
merge-pendingWhen a event carries a worktree association ( or ), the HSM auto-transitions through before reaching . The projection surfaces the merge verb (idempotency-keyed by ) so a runtime that consumes will dispatch the merge automatically.
task.completeddata.worktreedata.worktreePathfeature/merge-pendingreviewnext_actions${streamId}:merge_orchestrate:${taskId}next_actionsLand it through . The integration branch is shared — sibling worktree merges within the same wave (or a concurrent operator) can race for it. is THE integration-merge path: it holds an optimistic per- single-writer lease, then composes unchanged to do the local with a recorded recovery-point SHA — see . Do not dispatch raw to land onto the integration branch — a live foreign lease makes it fail closed (, naming ). Raw is for a non-integration merge (a private / scratch branch no sibling will touch) or a crash-resumed caller re-presenting its original lease.
serialize_mergeserialize_mergeintegrationRefmerge_orchestrategit merge@skills/merge-orchestrator/SKILL.mdmerge_orchestrateMERGE_LEASE_HELDserialize_mergemerge_orchestrateThe HSM exits back to once the merge terminates ( / / ), at which point either re-enters for the next worktree-bearing task or transitions on to when all delegation is complete.
merge-pendingdelegatecompletedrolled-backaborteddelegatemerge-pendingreviewThis detour is invisible to the delegation skill itself — the all-tasks-complete guard still gates the transition. The merge-pending substate just sits between task completion and the next dispatch decision.
delegate → review当事件携带工作树关联信息(或)时,HSM会自动通过子状态,然后进入阶段。投影会显示合并动词(由生成幂等键),因此消费的运行时会自动分派合并操作。
task.completeddata.worktreedata.worktreePathfeature/merge-pendingreviewnext_actions${streamId}:merge_orchestrate:${taskId}next_actions通过完成合并。集成分支是共享的 —— 同一批量内的兄弟工作树合并(或并发操作)可能会产生竞争。是唯一的集成合并路径:它持有每个的乐观单写入者租约,然后调用未修改的执行本地并记录恢复点SHA —— 请查看。请勿直接分派原始以合并到集成分支 —— 若存在外部活动租约,操作会失败(,提示使用)。原始适用于非集成合并(兄弟分支不会触及的私有/临时分支),或崩溃恢复的调用者重新提交其原始租约。
serialize_mergeserialize_mergeintegrationRefmerge_orchestrategit merge@skills/merge-orchestrator/SKILL.mdmerge_orchestrateMERGE_LEASE_HELDserialize_mergemerge_orchestrate合并终止后( / / ),HSM会从回到阶段,此时要么为下一个关联工作树的任务重新进入,要么在所有委派完成后过渡到。
completedrolled-backabortedmerge-pendingdelegatedelegatemerge-pendingreview此转向对委派Skill本身不可见 —— all-tasks-complete守卫仍会控制过渡。merge-pending子状态仅存在于任务完成与下一个分派决策之间。
delegate → reviewTask Status Values
任务状态值
| Status | When to use |
|---|---|
| Task not yet started |
| Task actively being worked on |
| Task finished successfully |
| Task encountered an error (requires fix cycle) |
| 状态 | 使用场景 |
|---|---|
| 任务尚未开始 |
| 任务正在进行中 |
| 任务成功完成 |
| 任务遇到错误(需要修复循环) |
Schema Discovery
模式发现
Use for
parameter schemas and
for phase transitions, guards, and playbook guidance. Use
for orchestrate action schemas.
exarchos_workflow({ action: "describe", actions: ["update", "init"] })exarchos_workflow({ action: "describe", playbook: "feature" })exarchos_orchestrate({ action: "describe", actions: ["check_test_adequacy", "task_complete"] })参数模式请使用查询;阶段过渡、守卫和剧本指引请使用查询;编排操作模式请使用查询。
exarchos_workflow({ action: "describe", actions: ["update", "init"] })exarchos_workflow({ action: "describe", playbook: "feature" })exarchos_orchestrate({ action: "describe", actions: ["check_test_adequacy", "task_complete"] })When integration advances mid-wave
批量进行中时集成分支更新
Runbook for recovering when a subagent worktree's branch has diverged from the
integration branch. Triggered by the integration merge's ancestry preflight
(run by the composed inside ): the
failure message links here verbatim and includes the manual
command. Auto-rebase is not wired today — operators
must drive recovery by hand.
merge_orchestrateserialize_mergegit rebase当子Agent工作树的分支与集成分支发生分歧时的恢复手册。由内部调用的执行的集成合并祖先预检触发:失败消息会直接链接到此处,并包含手动命令。目前未支持自动变基 —— 必须由操作人员手动驱动恢复。
serialize_mergemerge_orchestrategit rebaseSymptom
症状
The merge-orchestrator reports an ancestry failure of the form:
text
source branch <feature-branch> is not a descendant of <integration-branch>.
Rebase manually with: git rebase <integration-branch> (run from the <feature-branch> worktree).
Runbook: skills-src/delegate/SKILL.md#when-integration-advances-mid-waveThis means the integration branch advanced (typically because an earlier
worktree merge landed) while the failing worktree was still in flight.
Fast-forward merge is no longer safe — the working branch must catch up
first.
合并编排器报告以下形式的祖先失败:
text
source branch <feature-branch> is not a descendant of <integration-branch>.
Rebase manually with: git rebase <integration-branch> (run from the <feature-branch> worktree).
Runbook: skills-src/delegate/SKILL.md#when-integration-advances-mid-wave这意味着集成分支已更新(通常是因为较早的工作树合并已完成),而失败的工作树仍在运行中。此时快速前向合并已不安全 —— 工作分支必须先追上集成分支。
Why this happens
原因
With the worktree base pinned to local HEAD (see prerequisite below), each
subagent worktree is created at the integration branch's tip at dispatch time.
When the orchestrator merges sibling worktrees serially, each merge moves the
integration branch forward. A worktree that was dispatched against an older
integration tip will fail the ancestry preflight when its turn comes.
This is expected behavior under the current single-writer merge contract —
preflight is fail-only on purpose so the operator stays in control.
工作树基础固定到本地HEAD(请参考下文前提条件),每个子Agent工作树在分派时创建于集成分支的最新提交。当编排器串行合并兄弟工作树时,每次合并都会推进集成分支。针对较旧集成分支提交分派的工作树,轮到它合并时会失败祖先预检。
这是当前单写入者合并契约下的预期行为 —— 预检故意仅失败不自动处理,以便操作人员保持控制权。
Recovery procedure
恢复流程
Before each step, verify you are in the main worktree (not the failing
subagent worktree) and that is clean.
git status-
Capture the rollback SHA before doing anything destructive:bash
git rev-parse <feature-branch> > /tmp/rollback.shaKeep this until the merge has been verified. If anything goes wrong,on the feature branch restores the pre-rebase state. The filename is intentionally branch-name-free so slash-delimited branches likegit reset --hard "$(cat /tmp/rollback.sha)"don't break the path with embeddedfeature/dr-6characters./ -
Rebase the feature branch onto the current integration tip:bash
cd <feature-worktree-path> git fetch origin git rebase <integration-branch>Resolve any conflicts that surface. The conflicts are real — they reflect genuine drift between the two branches, not preflight noise. Do not passblindly; that drops the subagent's work.--strategy-option=theirs -
Re-run the integration merge from the main worktree — through, which re-composes
serialize_merge's ancestry preflight under the single-writer lease:merge_orchestratetypescriptexarchos_orchestrate({ action: "serialize_merge", featureId: "<featureId>", integrationRef: "<integration-branch>", sourceBranch: "<feature-branch>", strategy: "squash", // squash | rebase | merge taskId: "<taskId>", dryRun: false, // REQUIRED to execute — the action DEFAULTS to dry-run })defaults to a dry-run (preflight only, no lease claimed): omitserialize_mergeand it reports whether the merge would apply without mutating anything. PassdryRunto actually claim the single-writer lease and perform the merge. The action is declared shared-mutating, so a read-only caller (a session without write capability) is denied even the apply path; in that case fall back to a local-git merge from the main worktree (dryRun: falsethen commit) and record the equivalent merge state/events yourself, since that merge sits outside the serialized lease.git merge --squash <feature-branch>The preflight should now pass. Proceed with the orchestrator's normal merge flow. (Re-run rawdirectly only for a non-integration merge, or as the crash-resumed caller re-presenting its originalmerge_orchestrate.)leaseOperationId
每个步骤前,请确认你处于主工作树(而非失败的子Agent工作树)且干净。
git status-
捕获回滚SHA,然后再执行任何破坏性操作:bash
git rev-parse <feature-branch> > /tmp/rollback.sha保留此SHA直到合并验证完成。若出现任何问题,在功能分支上执行可恢复变基前的状态。文件名故意不包含分支名称,因此像git reset --hard "$(cat /tmp/rollback.sha)"这样包含斜杠的分支不会破坏路径。feature/dr-6 -
将功能分支变基到当前集成分支最新提交:bash
cd <feature-worktree-path> git fetch origin git rebase <integration-branch>解决出现的任何冲突。这些冲突是真实的 —— 反映了两个分支之间的实际差异,而非预检噪声。请勿盲目使用;这会丢弃子Agent的工作成果。--strategy-option=theirs -
从主工作树重新运行集成合并 —— 通过,它会在单写入者租约下重新调用
serialize_merge的祖先预检:merge_orchestratetypescriptexarchos_orchestrate({ action: "serialize_merge", featureId: "<featureId>", integrationRef: "<integration-branch>", sourceBranch: "<feature-branch>", strategy: "squash", // squash | rebase | merge taskId: "<taskId>", dryRun: false, // 必须设为false才能执行 —— 操作默认是试运行 })默认是试运行(仅预检,不获取租约):省略serialize_merge时,它会报告合并是否可应用,但不会修改任何内容。传入dryRun以实际获取单写入者租约并执行合并。该操作被标记为共享修改,因此只读调用者(无写入权限的会话)即使在应用路径下也会被拒绝;在这种情况下,回退到主工作树的本地git合并(dryRun: false然后提交)并自行记录等效的合并状态/事件,因为该合并在序列化租约之外。git merge --squash <feature-branch>此时预检应会通过。继续执行编排器的正常合并流程。(仅针对非集成合并,或崩溃恢复的调用者重新提交其原始时,才直接调用原始leaseOperationId。)merge_orchestrate
Rollback procedure
回滚流程
If the rebase produces conflicts you cannot resolve safely, or the merge
still fails after rebase:
-
Reset the feature branch to the captured rollback SHA:bash
cd <feature-worktree-path> git rebase --abort # if mid-rebase git reset --hard "$(cat /tmp/rollback.sha)" -
Mark the taskin workflow state and dispatch a fixer (see the Failure Recovery section above). Do not delete the worktree — the fixer needs the original branch state to diagnose the conflict.
failed -
Record the incident by emitting aevent with
merge.abortedand the failing branch's pre-rebase SHA so the convergence view captures the rollback.reason: "ancestry-rebase-conflict"
若变基产生无法安全解决的冲突,或变基后合并仍失败:
-
将功能分支重置到捕获的回滚SHA:bash
cd <feature-worktree-path> git rebase --abort # 若正在变基中 git reset --hard "$(cat /tmp/rollback.sha)" -
**在工作流状态中标记任务为**并分派修复Agent(请参考上文故障恢复部分)。请勿删除工作树 —— 修复Agent需要原始分支状态来诊断冲突。
failed -
记录事件,发送事件,包含
merge.aborted和失败分支变基前的SHA,以便收敛视图捕获回滚操作。reason: "ancestry-rebase-conflict"
Why no auto-rebase yet
为何暂不支持自动变基
Auto-rebase is not yet wired. Today the orchestrator stops at
the ancestry preflight on purpose: a botched auto-rebase across diverged
worktrees risks silently dropping subagent work, and the recovery path
above is short enough that operator-driven rebase is preferable to
clever-but-fragile automation.
暂未支持自动变基。目前编排器在祖先预检处停止是有意为之:在分歧工作树之间进行自动变基可能会静默丢弃子Agent的工作成果,而上述恢复流程足够简短,操作人员手动变基比复杂但脆弱的自动化更可靠。
Transition
过渡
After all tasks complete, auto-continue immediately (no user confirmation):
- Verify all in workflow state
tasks[].status === "complete" - Update state: with
exarchos_workflow updatephase: "review" - Invoke:
[Invoke the exarchos:review skill with args: <plan-path>]
This is NOT a human checkpoint — the workflow continues autonomously.
所有任务完成后,立即自动继续(无需用户确认):
- 验证工作流状态中所有
tasks[].status === "complete" - 更新状态:并传入
exarchos_workflow updatephase: "review" - 调用:
[Invoke the exarchos:review skill with args: <plan-path>]
这不是人工检查点 —— 工作流会自主继续。
References
参考文档
| Document | Purpose |
|---|---|
| Full prompt template for implementation tasks |
| Fix agent prompt with adversarial verification posture |
| Complete delegation trace with recovery path (R1) |
| Common rationalizations and counter-arguments (R2) |
| Parallel grouping and model selection |
| Arrange/Act/Assert, naming, mocking conventions |
| Property-based testing patterns |
| Detailed fix-mode process |
| State patterns and benchmark labeling |
| Common failure modes and resolutions |
| Adaptive team composition |
| Cross-platform step-by-step delegation reference |
| Worktree isolation rules |
| 文档 | 用途 |
|---|---|
| 实现任务的完整提示词模板 |
| 具备对抗性验证姿态的修复Agent提示词 |
| 包含恢复路径的完整委派跟踪示例(R1) |
| 常见合理化借口及反驳(R2) |
| 并行分组和模型选择 |
| Arrange/Act/Assert、命名、模拟约定 |
| 属性测试模式 |
| 修复模式详细流程 |
| 状态模式和基准标记 |
| 常见故障模式及解决方案 |
| 自适应团队组成 |
| 跨平台分步委派参考 |
| 工作树隔离规则 |