merge-orchestrator
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseMerge Orchestrator Skill
Merge Orchestrator 技能
Local Git, Not Remote VCS
本地Git操作,非远程版本控制系统操作
This skill performs local of a subagent's worktree branch into the integration branch, recording a rollback SHA so a can undo the merge on any failure. It does not call the VCS provider (GitHub / GitLab / Azure DevOps) and does not require a PR id. For remote PR merging during the synthesize phase, see ( action).
git mergegit reset --hard@skills/synthesis/SKILL.mdmerge_prThe mental model and the rationale for why these are two separate concerns are documented in .
references/local-git-semantics.md该技能执行子代理(subagent)工作树分支到集成分支的本地操作,记录回滚SHA,以便在任何失败时通过撤销合并。它不会调用版本控制系统提供商(GitHub / GitLab / Azure DevOps)的接口,也不需要PR编号。若要在合成阶段执行远程PR合并,请查看中的操作。
git mergegit reset --hard@skills/synthesis/SKILL.mdmerge_pr关于这两个操作为何分为独立功能的思路和原理,记录在中。
references/local-git-semantics.mdOverview
概述
Closes the loop between (which spawns subagents into worktrees) and the integration branch that needs their work. After a delegated task completes inside a worktree, this skill:
/delegate- Composes preflight guards (ancestry, current-branch protection, main-worktree assertion, working-tree drift).
- Records pre-merge of the integration branch as a rollback anchor.
HEAD - Performs a local of the source (subagent) branch into the target (integration) branch.
git merge - On any failure, runs and surfaces a categorized failure reason.
git reset --hard <rollbackSha> - Emits dedicated event types so the merge timeline is reconstructable from the event log alone.
Resumable: terminal phases ( / / ) short-circuit on re-entry without re-emitting events. Idempotent: re-dispatch with the same collapses via the idempotency key.
completedrolled-backabortedtaskIdnext_actions该技能打通了(将子代理分配到工作树)与需要接收其工作成果的集成分支之间的闭环。当委托任务在工作树内完成后,该技能会执行以下步骤:
/delegate- 组合预检防护规则(祖先校验、当前分支保护、主工作树断言、工作树漂移检测)。
- 将集成分支合并前的记录为回滚锚点。
HEAD - 执行源分支(子代理分支)到目标分支(集成分支)的本地操作。
git merge - 若出现任何失败,执行并返回分类后的失败原因。
git reset --hard <rollbackSha> - 发送专属事件类型,以便仅通过事件日志即可重构合并时间线。
可恢复性:终端阶段( / / )在重新触发时会直接短路,不会重新发送事件。幂等性:使用相同重新调度时,会通过的幂等键合并请求。
completedrolled-backabortedtaskIdnext_actionsTriggers
触发条件
Activate this skill when:
- The HSM is parked in (entry guard fires when the most recent
feature/merge-pendingcarries a worktree association).task.completed - The envelope surfaces a
next_actionsverb with idempotency keymerge_orchestrate.${streamId}:merge_orchestrate:${taskId} - The user runs (CLI) or invokes
exarchos merge-orchestrate ...directly.mcp__exarchos__exarchos_orchestrate({ action: "merge_orchestrate", ... })
Do not activate this skill:
- During the synthesize phase to merge a remote PR — that is .
merge_pr - When the workflow's is already terminal — the resume short-circuit runs but no fresh dispatch is needed.
mergeOrchestrator.phase
在以下场景激活该技能:
- HSM处于状态(当最近的
feature/merge-pending事件带有工作树关联时,进入防护规则触发)。task.completed - 消息包中出现带有幂等键
next_actions的${streamId}:merge_orchestrate:${taskId}动词。merge_orchestrate - 用户运行(CLI命令)或直接调用
exarchos merge-orchestrate ...。mcp__exarchos__exarchos_orchestrate({ action: "merge_orchestrate", ... })
请勿在以下场景激活该技能:
- 在合成阶段合并远程PR——这属于的功能范畴。
merge_pr - 工作流的已处于终端状态——恢复逻辑会短路,但无需重新调度。
mergeOrchestrator.phase
Process
流程
Schema: discover the action's argument schema with. Strategy is required (no schema-level default) — pickmcp__exarchos__exarchos_orchestrate({ action: "describe", actions: ["merge_orchestrate"] })/squash/mergedeliberately.rebase
Schema( schema ): 可通过查看该操作的参数 schema 。合并策略为必填项(无默认值)——需明确选择mcp__exarchos__exarchos_orchestrate({ action: "describe", actions: ["merge_orchestrate"] })/squash/merge。rebase
Step 1: Pick the merge strategy
步骤1:选择合并策略
| Strategy | Local git operation | When to choose |
|---|---|---|
| | Preserves the subagent's commit history with a visible merge boundary. |
| | Subagent commit history is noise; one logical change should land as one commit. |
| rebases an ephemeral copy of source onto target then ff-merges target — linear history | No merge commit; integration branch stays linear. The original source ref is preserved (the rebase runs on a temporary branch that is deleted afterward), so an executor rollback only needs to reset target. |
Strategy is required at the schema layer (#1127 collision check, #1109 §2 user-visible parity). There is no implicit default — operator intent is always explicit in the event log.
| 策略 | 本地Git操作 | 适用场景 |
|---|---|---|
| | 保留子代理的提交历史,带有清晰的合并边界。 |
| | 子代理的提交历史无意义;一个逻辑变更应作为单个提交落地。 |
| 将源分支的临时副本变基到目标分支,然后快进合并目标分支 — 线性历史 | 无合并提交;集成分支保持线性。原始源引用会被保留(变基操作在临时分支上执行,之后会被删除),因此执行回滚只需重置目标分支。 |
合并策略在 schema 层为必填项(#1127冲突检查、#1109 §2用户可见一致性)。无隐式默认值——操作意图会始终明确记录在事件日志中。
Step 2: Invoke
步骤2:调用方式
Via MCP:
typescript
mcp__exarchos__exarchos_orchestrate({
action: "merge_orchestrate",
featureId: "<id>",
sourceBranch: "<subagent-branch>",
targetBranch: "<integration-branch>",
taskId: "<task-id>", // present when auto-dispatched from next_actions
strategy: "squash", // required
dryRun: false, // optional — preflight only, no executor invocation
resume: false, // optional — short-circuit on terminal phases
})Via CLI:
bash
exarchos merge-orchestrate \
--feature-id <id> \
--source-branch <subagent-branch> \
--target-branch <integration-branch> \
--task-id <task-id> \
--strategy squash
# add --dry-run for preflight-only, --resume for terminal-phase short-circuitCLI exit codes: 0 = success, 1 = invalid input, 2 = merge failed (preflight blocked or rollback executed), 3 = uncaught exception.
通过MCP调用:
typescript
mcp__exarchos__exarchos_orchestrate({
action: "merge_orchestrate",
featureId: "<id>",
sourceBranch: "<subagent-branch>",
targetBranch: "<integration-branch>",
taskId: "<task-id>", // 自动调度自next_actions时会携带该参数
strategy: "squash", // 必填
dryRun: false, // 可选——仅执行预检,不调用执行器
resume: false, // 可选——在终端阶段触发短路逻辑
})通过CLI调用:
bash
exarchos merge-orchestrate \
--feature-id <id> \
--source-branch <subagent-branch> \
--target-branch <integration-branch> \
--task-id <task-id> \
--strategy squash
# 添加--dry-run仅执行预检,--resume开启终端阶段短路逻辑CLI退出码:0 = 成功,1 = 输入无效,2 = 合并失败(预检拦截或执行回滚),3 = 未捕获异常。
Step 3: Interpret the result
步骤3:结果解读
The handler returns a whose discriminates the outcome:
ToolResultdata.phase | Meaning | Operator action |
|---|---|---|
| Local merge landed; | None — workflow exits |
| Preflight failed; no merge attempted. | Inspect |
| Merge was attempted, failed ( | Inspect |
For the full recovery flow per outcome, see .
references/recovery-runbook.md处理器会返回一个,其中字段用于区分结果类型:
ToolResultdata.phase | 含义 | 操作人员操作建议 |
|---|---|---|
| 本地合并完成; | 无需操作——工作流从 |
| 预检失败;未尝试合并。 | 检查 |
| 尝试合并但失败( | 检查 |
关于每种结果的完整恢复流程,请查看。
references/recovery-runbook.mdStep 4: Confirm event emissions
步骤4:确认事件发送
Three events are emitted directly to the workflow's event stream (stream id = ) — not wrapped in :
featureIdgate.executed| Event type | When | Carries |
|---|---|---|
| Always (after preflight runs, before any merge attempt) | Full structured guard sub-results + |
| On successful local merge | |
| On post-merge failure followed by reset | |
These events are auto-emitted by the handler — do not manually append them via during normal operation. Manual emission is only sanctioned during the documented manual-recovery flow in when a merge has been completed out-of-band (e.g., conflict resolution) and the event log must be brought back in sync — follow that runbook's event-first sequencing.
mcp__exarchos__exarchos_eventrecovery-runbook.mdDiscover the event payload schemas via.mcp__exarchos__exarchos_event({ action: "describe", eventTypes: ["merge.preflight", "merge.executed", "merge.rollback"] })
三个事件会直接发送到工作流的事件流(流ID = )——不会被包裹在中:
featureIdgate.executed| 事件类型 | 发送时机 | 携带内容 |
|---|---|---|
| 始终发送(预检完成后,合并尝试前) | 完整的结构化防护规则子结果;若 |
| 本地合并成功时 | |
| 合并失败后执行回滚时 | |
这些事件由处理器自动发送——正常操作流程中请勿通过手动添加。仅在中记录的手动恢复流程中允许手动发送:当合并操作已通过外部方式完成(如冲突解决),需要同步事件日志时,请遵循该手册中的事件优先顺序。
mcp__exarchos__exarchos_eventrecovery-runbook.md可通过查看事件负载的 schema 。mcp__exarchos__exarchos_event({ action: "describe", eventTypes: ["merge.preflight", "merge.executed", "merge.rollback"] })
Disambiguation: merge_orchestrate
vs merge_pr
merge_orchestratemerge_pr区分:merge_orchestrate
vs merge_pr
merge_orchestratemerge_prTwo related actions, two distinct concerns:
| Aspect | | |
|---|---|---|
| Layer | Local SDLC handoff | Remote PR primitive |
| Phase affinity | | |
| What it merges | A subagent worktree branch into the integration branch | A user-facing PR via the VCS provider API |
| Identifier required | | |
| Underlying operation | | |
| Rollback | | None — the VCS provider owns merge state |
| Events | | |
If you reach for thinking "I want to merge a PR," you want instead.
merge_orchestratemerge_pr两个相关操作,对应不同的功能范畴:
| 维度 | | |
|---|---|---|
| 层级 | 本地SDLC交接 | 远程PR基础操作 |
| 阶段关联 | | |
| 合并对象 | 子代理工作树分支到集成分支 | 通过版本控制系统提供商API合并面向用户的PR |
| 必填标识 | | |
| 底层操作 | | |
| 回滚机制 | | 无——版本控制系统提供商管理合并状态 |
| 事件 | | |
如果您想用来实现“合并PR”的需求,那么您应该使用。
merge_orchestratemerge_prResume Semantics
恢复语义
When invoked with , the handler reads existing state. Terminal phases ( / / , members of ) short-circuit and return the recorded result with no new events and no executor call. Non-terminal phases ( / ) fall through to a fresh preflight + executor run, which is safe because the underlying git operations are idempotent on already-merged branches.
resume: truemergeOrchestratorcompletedrolled-backabortedEXCLUDED_MERGE_PHASESpendingexecutingWhen invoked without , prior state is deliberately ignored — fresh-dispatch semantics.
resume当以调用时,处理器会读取已有的状态。终端阶段( / / ,属于)会触发短路逻辑,返回已记录的结果,不会发送新事件或调用执行器。非终端阶段( / )会执行完整的预检和执行器调用,这是安全的,因为底层Git操作在已合并的分支上具备幂等性。
resume: truemergeOrchestratorcompletedrolled-backabortedEXCLUDED_MERGE_PHASESpendingexecuting当未携带参数调用时,会刻意忽略之前的状态——采用全新调度语义。
resumeDry-Run
试运行(Dry-Run)
dryRun: truemerge.preflight{ dryRun: true, preflight, phase: 'pending' | 'aborted' }dryRun: truemerge.preflight{ dryRun: true, preflight, phase: 'pending' | 'aborted' }Anti-Patterns
反模式
| Don't | Do Instead |
|---|---|
| Use this skill to merge a remote PR | Use |
Manually emit | Let the handler auto-emit; manual emission causes duplicates (one exception: documented manual-recovery flow in |
Wrap merge events under | Direct stream append with the dedicated event type — these are state transitions, not gate executions |
Re-dispatch after a | Read |
Omit | Strategy is required; supply |
| Invoke from a subagent worktree | Preflight refuses (main-worktree assertion); invoke from the main worktree |
| 禁止操作 | 正确做法 |
|---|---|
| 使用本技能合并远程PR | 在合成阶段使用 |
在正常流程中手动发送 | 由处理器自动发送;手动发送会导致重复事件(唯一例外: |
将合并事件包裹在 | 使用专属事件类型直接写入事件流——这些是状态转换事件,而非网关执行事件 |
在 | 查看 |
省略 | 合并策略为必填项;需明确指定 |
| 从子代理工作树中调用 | 预检会拒绝(主工作树断言);从主工作树中调用 |
Phase Transitions and Guards
阶段转换与防护规则
For the full transition table, consult .
@skills/workflow-state/references/phase-transitions.mdQuick reference:
- →
delegaterequires guardmerge-pending— fires when the most recentmerge-pending-entrycarries a worktree association ANDtask.completedis not inmergeOrchestrator.phase.EXCLUDED_MERGE_PHASES - →
merge-pendingrequires guarddelegate— fires whenmerge-pending-exitenters a terminal value (mergeOrchestrator.phase/completed/rolled-back).aborted
The HSM exits back to regardless of merge outcome — then re-evaluates whether more worktree-bearing tasks remain and either re-enters for the next, or transitions on to when all delegation is complete.
merge-pendingdelegatedelegatemerge-pendingreview完整的转换表请查看。
@skills/workflow-state/references/phase-transitions.md快速参考:
- →
delegate需要merge-pending防护规则——当最近的merge-pending-entry事件带有工作树关联,且task.completed不属于mergeOrchestrator.phase时触发。EXCLUDED_MERGE_PHASES - →
merge-pending需要delegate防护规则——当merge-pending-exit进入终端状态(mergeOrchestrator.phase/completed/rolled-back)时触发。aborted
无论合并结果如何,HSM都会从状态退出,回到状态——会重新评估是否还有带工作树的任务未完成,若有则再次进入状态处理下一个任务,若所有委托任务都已完成则转换到状态。
merge-pendingdelegatedelegatemerge-pendingreviewSchema Discovery
Schema 发现
For the argument schema, call . The full feature-workflow phase playbook (which includes ) is available via . Event payload shapes come from .
mcp__exarchos__exarchos_orchestrate({ action: "describe", actions: ["merge_orchestrate"] })merge-pendingmcp__exarchos__exarchos_workflow({ action: "describe", playbook: "feature" })mcp__exarchos__exarchos_event({ action: "describe", eventTypes: ["merge.preflight", "merge.executed", "merge.rollback"] })可通过查看参数 schema 。包含的完整功能工作流阶段手册可通过获取。事件负载结构可通过查看。
mcp__exarchos__exarchos_orchestrate({ action: "describe", actions: ["merge_orchestrate"] })merge-pendingmcp__exarchos__exarchos_workflow({ action: "describe", playbook: "feature" })mcp__exarchos__exarchos_event({ action: "describe", eventTypes: ["merge.preflight", "merge.executed", "merge.rollback"] })Completion Criteria
完成标准
- Preflight result (or operator has decided to proceed despite a documented preflight gap)
passed: true - in workflow state
mergeOrchestrator.phase === 'completed' - event present in the stream with the recorded
merge.executedandmergeSharollbackSha - HSM has exited back to
merge-pendingdelegate - Integration branch's HEAD matches the recorded
mergeSha
If any criterion fails, consult before re-dispatching.
references/recovery-runbook.md- 预检结果(或操作人员已决定忽略已记录的预检间隙)
passed: true - 工作流状态中
mergeOrchestrator.phase === 'completed' - 事件流中存在带有记录的和
mergeSha的rollbackSha事件merge.executed - HSM已从状态退出,回到
merge-pending状态delegate - 集成分支的HEAD与记录的一致
mergeSha
若任何标准未满足,请在重新调度前查看。
references/recovery-runbook.md