maestro-flow 0.5.44 → 0.5.45

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  ---
2
- name: maestro-ralph-agent
3
- description: Agent-orchestrated lifecycle — compose, dispatch Agent, evaluate decision, loop
2
+ name: maestro-ralph-v2
3
+ description: Adaptive lifecycle orchestrator — compose, dispatch ralph-executor agent, evaluate decision, loop
4
4
  argument-hint: "<intent> [-y] [--amend [change]] [--roadmap] | status | continue"
5
5
  allowed-tools:
6
6
  - read_file
@@ -16,11 +16,9 @@ allowed-tools:
16
16
  <!-- Open-standard mirror generated by scripts/build-agents-standard.mjs — do not edit; re-run after editing .claude/ source. -->
17
17
 
18
18
  <purpose>
19
- Agent-orchestrated variant of maestro-ralph. Same chain-building logic but execution via Claude Agent instead of CLI delegation: compose prompt dispatch delegate_subagent(maestro-ralph-agent-execute) → agent runs step loopreturns on decision/complete/fail → evaluate decision inline via Agentre-dispatch → loop.
19
+ Adaptive lifecycle orchestrator: locate step resolve args load context dispatch delegate_subagent(ralph-executor) per step (agent `ralph next` + 执行) → extract signals drift check ralph complete → evaluate decision next step → loop.
20
20
 
21
- Session: `.workflow/.maestro/ralph-agent-{YYYYMMDD-HHmmss}/status.json`
22
-
23
- Chain building(A_RESOLVE_PHASE → A_INFER_POSITION → A_BUILD_STEPS)、session schema、decomposition(A_DECOMPOSE_TASKS)逻辑同 ralph。
21
+ Session: `.workflow/.maestro/ralph-v2-{YYYYMMDD-HHmmss}/status.json`
24
22
  </purpose>
25
23
 
26
24
  <deferred_reading>
@@ -42,25 +40,31 @@ Remaining → intent (amend_mode 时为 change_request)
42
40
 
43
41
  **State files**:
44
42
  - `.workflow/state.json` — artifact registry
45
- - `.workflow/.maestro/ralph-agent-*/status.json` — session state
43
+ - `.workflow/.maestro/ralph-v2-*/status.json` — session state
46
44
  </context>
47
45
 
48
46
  <invariants>
49
- All ralph invariants (1-16) apply, with the following overrides:
50
-
51
- - **Invariant 1 Agent 语义**: ralph-agent 不直接执行 step 内容;执行由 delegate_subagent(maestro-ralph-agent-execute) 完成
52
- - **Invariant 2 覆盖**: ralph-agent 不调用 `invoke_skill("maestro-ralph-execute")`;invariant 17-24 替代 handoff 机制,ralph-agent 持有完整循环
53
-
54
- Additionally:
55
-
56
- 17. **ralph-agent owns the loop** — dispatch Agent wait verify → decide → re-dispatch 全部在本命令内完成;execute Agent 是被委派的执行者
57
- 18. **Dispatch via delegate_subagent()** — 使用 `delegate_subagent({ name, description, prompt })` 启动执行 Agent,Agent 内部调用 `invoke_skill("maestro-ralph-agent-execute", "--session {session_id}")` 加载执行命令
58
- 19. **Synchronous dispatch**delegate_subagent() 调用是同步的(等待返回),不需要 STOP/callback 模式
59
- 20. **Execute Agent 自治执行** 执行 Agent 自主循环处理所有 pending 执行 step,遇到 decision 节点时停止并返回;执行 Agent 内部调用 `maestro ralph complete` 上报(agent 上报)
60
- 21. **Decision evaluation inline**decision 节点不 handoff,通过 `delegate_subagent()` 启动分析 Agent 在本循环内评估
61
- 22. **Agent return 解析** Agent 返回文本中解析执行结果(`---AGENT-STATUS---` 块),替代 `---RESULT---` 解析
62
- 23. **No CLI delegation** — 本命令不使用 `maestro delegate`;执行和评估均通过 delegate_subagent() 完成
63
- 24. **No inline skill execution** — 本命令不执行 skill 逻辑;执行由 delegate_subagent(maestro-ralph-agent-execute) 完成
47
+ 1. **Ralph-v2 owns the full loop** locate step → resolve args → load context → dispatch agent → extract signals → drift → complete,全部在本命令内完成
48
+ 2. **One agent per step** — 每个执行 step 派发一个 executor agent,agent 执行完返回,主流程解析结果后决定下一步
49
+ 3. **Agent is a thin wrapper** — executor agent `ralph next` 获取 skill prompt 并执行,返回输出;arg resolution、context loading、signal extraction、drift analysis、ralph complete 均由主流程完成
50
+ 4. **Synchronous dispatch** delegate_subagent() 调用是同步的(等待返回),不需要 STOP/callback 模式
51
+ 5. **主流程调 `ralph complete`** — 每个 step 完成后由主流程调 `maestro ralph complete`,非 agent 上报
52
+ 6. **Decision evaluation inline** — decision 节点不 handoff,通过 `delegate_subagent()` 启动分析 Agent 在本循环内评估
53
+ 7. **No CLI delegation** — 本命令不使用 `maestro delegate`;执行和评估均通过 delegate_subagent() 完成
54
+ 8. **Decision delegates read-only** — 评估 Agent 通过 prompt 中的 CONSTRAINTS 约束为只读
55
+ 9. **执行 step 通过 `maestro ralph next` CLI 加载并内联执行**(由 execute Agent 完成)
56
+ 10. **status.json 是唯一真源**不生成 markdown 清单或侧文件
57
+ 11. **每个 step 必须 `completion_confirmed: true`** `maestro ralph complete N --status DONE`(或 DONE_WITH_CONCERNS)写入;CLI 是唯一合法写入路径
58
+ 12. **command_path A_BUILD_STEPS 解析** 通过 `maestro ralph skills --platform agent --json --quiet` 预校验
59
+ 13. **执行 step 加载契约** `maestro ralph next` CLI 在执行期完成
60
+ 14. **Decomposition is outcome-oriented** — sub-goals 为可观测交付,禁止 lifecycle 复刻
61
+ 15. **planning_mode governs arg granularity** — `unified` skill args `{phase}`;`independent` → 含 `{phase}`
62
+ 16. **task_decomposition 驱动 steps[] 动态生长** — `post-goal-audit` 按 unmet 子目标插入 scoped mini-loop
63
+ 17. **Invariant violation = BLOCK** — 违反上述任一 invariant 即阻断当前操作
64
+ 18. **Evaluate fallback 必须标记** — 评估 Agent 解析 verdict 失败时 fallback 为 "fix",MUST 在 decisions.ndjson 记录 `"parse_failed": true, "confidence_score": 0`
65
+ 19. **auto_confirm 单一来源** — `auto_confirm` 仅由用户 `-y` 标志设定
66
+ 20. **分解契约单一所有者** — `boundary_contract` / `task_decomposition` 由 session 创建者拥有
67
+ 21. **控制权优先级(范式治理)** — FSM 独占 session 生命周期 + step 排序 + retry/fix/escalate + cross-step decision 节点
64
68
  </invariants>
65
69
 
66
70
  <state_machine>
@@ -81,8 +85,12 @@ S_BUILD_CHAIN — 构建步骤链(build rules 0-14)
81
85
  S_CREATE_SESSION — 写 status.json PERSIST: session (全量)
82
86
  S_CONFIRM — 用户确认
83
87
 
84
- S_AGENT_DISPATCH 启动执行 Agent PERSIST: session.active_agent_name
85
- S_AGENT_RECEIVE 接收 Agent 返回、解析状态 PERSIST:
88
+ S_STEP_LOCATE 找下一个 pending step PERSIST:
89
+ S_STEP_RESOLVE 解析占位符 + 丰富参数 PERSIST: step.args (enriched)
90
+ S_STEP_DISPATCH — 组装上下文 + 派发 executor agent 执行单步 PERSIST: step.agent_exec_name, step.status = "running"
91
+ S_STEP_ANALYZE — 提取信号 + 组装 completion 参数 PERSIST: —
92
+ S_STEP_DRIFT — 产物 vs 目标偏离分析 PERSIST: step.drift_score
93
+ S_STEP_COMPLETE — 调 `ralph complete` 上报 PERSIST: step.completion_*
86
94
  S_DECISION_EVAL — 启动分析 Agent 评估质量门 PERSIST: —
87
95
  S_APPLY_VERDICT — 应用裁决 PERSIST: session.steps[]
88
96
  S_SESSION_DONE — 所有 step 完成 PERSIST: session.status
@@ -106,31 +114,48 @@ S_STATUS:
106
114
  → END DO: A_SHOW_STATUS
107
115
 
108
116
  S_CONTINUE:
109
- S_AGENT_DISPATCH WHEN: running session found
117
+ S_STEP_LOCATE WHEN: running session found
110
118
  → S_FALLBACK WHEN: no running session
111
119
 
112
120
  S_AMEND_GOAL:
113
- S_AGENT_DISPATCH WHEN: change applied + user confirmed DO: A_AMEND_GOAL
121
+ S_STEP_LOCATE WHEN: change applied + user confirmed DO: A_AMEND_GOAL
114
122
  → END WHEN: user cancels
115
123
  GUARD: RISK_LEVEL=high → auto_confirm 无效
116
124
 
117
125
  S_CREATE_SESSION:
118
- → S_CONFIRM WHEN: not auto_confirm
119
- S_AGENT_DISPATCH WHEN: auto_confirm
126
+ → S_CONFIRM WHEN: not auto_confirm
127
+ S_STEP_LOCATE WHEN: auto_confirm
120
128
 
121
129
  S_CONFIRM:
122
- S_AGENT_DISPATCH WHEN: user confirms
123
- → S_BUILD_CHAIN WHEN: user edits
124
- → END WHEN: user cancels
130
+ S_STEP_LOCATE WHEN: user confirms
131
+ → S_BUILD_CHAIN WHEN: user edits
132
+ → END WHEN: user cancels
133
+
134
+ S_STEP_LOCATE:
135
+ → S_STEP_RESOLVE WHEN: pending execution step found (step.decision == null)
136
+ → S_DECISION_EVAL WHEN: pending decision step found (step.decision != null)
137
+ → S_SESSION_DONE WHEN: no pending steps (all completed/skipped)
138
+ → S_HANDLE_FAIL WHEN: has failed step and no pending
139
+ → S_FALLBACK WHEN: no running session
140
+
141
+ S_STEP_RESOLVE:
142
+ → S_STEP_DISPATCH DO: A_STEP_RESOLVE_ARGS
125
143
 
126
- S_AGENT_DISPATCH:
127
- S_AGENT_RECEIVE DO: A_DISPATCH_EXECUTE_AGENT
144
+ S_STEP_DISPATCH:
145
+ S_STEP_ANALYZE WHEN: agent returned output DO: A_STEP_DISPATCH
146
+ → S_HANDLE_FAIL WHEN: agent returned error/null DO: A_STEP_DISPATCH
128
147
 
129
- S_AGENT_RECEIVE:
130
- S_DECISION_EVAL WHEN: Agent returned "decision_pending" DO: A_PARSE_AGENT_RETURN
131
- S_SESSION_DONE WHEN: Agent returned "session_complete" DO: A_PARSE_AGENT_RETURN
132
- → S_HANDLE_FAIL WHEN: Agent returned "step_failed" DO: A_PARSE_AGENT_RETURN
133
- → S_HANDLE_FAIL WHEN: Agent returned null (agent error) DO: A_PARSE_AGENT_RETURN
148
+ S_STEP_ANALYZE:
149
+ S_STEP_DRIFT WHEN: STATUS == DONE|DONE_WITH_CONCERNS DO: A_STEP_EXTRACT
150
+ S_HANDLE_FAIL WHEN: STATUS == NEEDS_RETRY|BLOCKED DO: A_STEP_EXTRACT
151
+
152
+ S_STEP_DRIFT:
153
+ → S_STEP_COMPLETE WHEN: ALIGNED|MINOR_DRIFT DO: A_STEP_DRIFT_ANALYZE
154
+ → S_STEP_DISPATCH WHEN: MAJOR_DRIFT + not retried DO: A_STEP_DRIFT_ANALYZE (ralph retry + re-execute)
155
+ → S_STEP_COMPLETE WHEN: MAJOR_DRIFT + retried DO: A_STEP_DRIFT_ANALYZE (DONE_WITH_CONCERNS)
156
+
157
+ S_STEP_COMPLETE:
158
+ → S_STEP_LOCATE DO: A_STEP_COMPLETE (loop to next step)
134
159
 
135
160
  S_DECISION_EVAL: (decision 节点 == `step.decision` 非空)
136
161
  → S_APPLY_VERDICT WHEN: quality-gate (post-execute, post-business-test, post-review, post-test, post-frontend-verify)
@@ -145,20 +170,20 @@ S_DECISION_EVAL: (decision 节点 == `step.decision` 非空)
145
170
  DO: A_STRUCTURAL_EVALUATE
146
171
 
147
172
  S_APPLY_VERDICT:
148
- S_AGENT_DISPATCH WHEN: verdict == "proceed" DO: A_APPLY_PROCEED
149
- S_AGENT_DISPATCH WHEN: post-goal-audit + has_unmet DO: A_APPLY_GOAL_FIX
150
- S_AGENT_DISPATCH WHEN: post-goal-audit + all_met + INTENT_ALIGNED=true DO: A_APPLY_GOAL_DONE
173
+ S_STEP_LOCATE WHEN: verdict == "proceed" DO: A_APPLY_PROCEED
174
+ S_STEP_LOCATE WHEN: post-goal-audit + has_unmet DO: A_APPLY_GOAL_FIX
175
+ S_STEP_LOCATE WHEN: post-goal-audit + all_met + INTENT_ALIGNED=true DO: A_APPLY_GOAL_DONE
151
176
  → END WHEN: post-goal-audit + all_met + INTENT_ALIGNED=false DO: A_REGROUND_HALT
152
- S_AGENT_DISPATCH WHEN: post-analyze-scope DO: A_APPLY_SCOPE_VERDICT
153
- S_AGENT_DISPATCH WHEN: verdict == "fix" DO: A_APPLY_FIX
154
- S_AGENT_DISPATCH WHEN: verdict == "escalate" DO: A_APPLY_ESCALATE
155
- S_AGENT_DISPATCH WHEN: post-milestone + standard + next milestone DO: A_ADVANCE_MILESTONE
177
+ S_STEP_LOCATE WHEN: post-analyze-scope DO: A_APPLY_SCOPE_VERDICT
178
+ S_STEP_LOCATE WHEN: verdict == "fix" DO: A_APPLY_FIX
179
+ S_STEP_LOCATE WHEN: verdict == "escalate" DO: A_APPLY_ESCALATE
180
+ S_STEP_LOCATE WHEN: post-milestone + standard + next milestone DO: A_ADVANCE_MILESTONE
156
181
  → END WHEN: post-milestone + standard + no next milestone
157
182
  → END WHEN: post-milestone + adhoc DO: mark completed (set current_milestone = null)
158
183
  → END WHEN: post-debug-escalate DO: A_PAUSE_ESCALATE
159
184
  → END WHEN: post-reground + drifted + confidence >= 60 DO: A_REGROUND_HALT
160
- S_AGENT_DISPATCH WHEN: post-reground + aligned DO: A_APPLY_PROCEED
161
- S_AGENT_DISPATCH WHEN: post-reground + drifted + confidence < 60 DO: A_APPLY_PROCEED (标 LOW CONFIDENCE)
185
+ S_STEP_LOCATE WHEN: post-reground + aligned DO: A_APPLY_PROCEED
186
+ S_STEP_LOCATE WHEN: post-reground + drifted + confidence < 60 DO: A_APPLY_PROCEED (标 LOW CONFIDENCE)
162
187
  GUARD: retry_count >= max_retries → force escalate
163
188
  GUARD: confidence_score < 60 AND proceed → override to fix
164
189
  GUARD: confidence_score > 95 AND fix AND retry > 0 → suggest proceed
@@ -167,10 +192,10 @@ S_APPLY_VERDICT:
167
192
  GUARD: post-reground + drifted + confidence >= 60 → A_REGROUND_HALT(auto_confirm 不跳过)
168
193
 
169
194
  S_HANDLE_FAIL:
170
- S_AGENT_DISPATCH WHEN: auto + not retried DO: A_RETRY
195
+ S_STEP_LOCATE WHEN: auto + not retried DO: A_RETRY
171
196
  → END WHEN: auto + retried DO: A_PAUSE_SESSION
172
- S_AGENT_DISPATCH WHEN: interactive + retry
173
- S_AGENT_DISPATCH WHEN: interactive + skip
197
+ S_STEP_LOCATE WHEN: interactive + retry
198
+ S_STEP_LOCATE WHEN: interactive + skip
174
199
  → END WHEN: interactive + abort
175
200
 
176
201
  S_SESSION_DONE:
@@ -181,19 +206,109 @@ S_SESSION_DONE:
181
206
  <actions>
182
207
 
183
208
  ### A_CREATE_SESSION
184
- 1. `session_id` format: `ralph-agent-{YYYYMMDD-HHmmss}`
209
+ 1. `session_id` format: `ralph-v2-{YYYYMMDD-HHmmss}`
185
210
  2. Additional fields: `execution_mode: "agent"`,无 `cli_tool` 字段
186
- 3. Each step: `agent_exec_name: null`(替代 `delegate_exec_id`)
211
+ 3. Each step: `agent_exec_name: null`(执行 Agent 名称标识)
187
212
  4. Step mode/role/rule assigned per stage (see Stage Mapping table)
188
213
 
189
- ### A_DISPATCH_EXECUTE_AGENT
214
+ ### A_STEP_RESOLVE_ARGS
215
+
216
+ 解析占位符 + 丰富参数。在 `ralph next` 之前执行。
217
+
218
+ **1. Placeholder substitution:**
190
219
 
191
- 启动执行 Agent 处理 pending 执行 step。Agent 自主循环直到遇到 decision/完成/失败。
220
+ | Placeholder | Source |
221
+ |-------------|--------|
222
+ | `{phase}` | session.phase |
223
+ | `{milestone}` | session.milestone |
224
+ | `{intent}` | session.intent |
225
+ | `{description}` | session.intent (alias) |
226
+ | `{scratch_dir}` | session.context.scratch_dir or latest artifact path |
227
+ | `{plan_dir}` | session.context.plan_dir |
228
+ | `{analysis_dir}` | session.context.analysis_dir |
229
+ | `{issue_id}` | session.context.issue_id |
230
+ | `{milestone_num}` | session.context.milestone_num |
192
231
 
193
- 1. Read status.json 确认有 pending step
194
- 2. Resolve agent name: `{stage_prefix}-{session_id_short}-{HHmmss}`
232
+ **2. Per-skill enrichment** (when args empty or minimal):
195
233
 
196
- **Agent Name Prefix (by stage):**
234
+ | Skill | Required context | Source |
235
+ |-------|-----------------|--------|
236
+ | maestro-brainstorm | topic | `"{intent}"` |
237
+ | maestro-roadmap | description | `"{intent}"` |
238
+ | maestro-analyze | phase or topic | `{phase}` or `"{intent}"` |
239
+ | maestro-plan | phase, --from, or --dir | see --from auto-injection below |
240
+ | maestro-execute | phase or --dir | see --from auto-injection below |
241
+ | quality-debug | gap context | Read previous step's error/gap |
242
+ | quality-* | phase | `{phase}` |
243
+
244
+ **3. --from auto-injection (phase-level artifact chaining):**
245
+
246
+ ```
247
+ Read state.json.artifacts(含 milestone_history 内归档 artifacts)
248
+ → filter by milestone={session.milestone} + phase={session.phase} + status=="completed"
249
+
250
+ plan step(含 {phase} 占位符,args 无 --from 且无 --dir):
251
+ 1. 查同 phase+milestone 最新 completed type=="analyze" artifact → id = ANL-xxx
252
+ 2. 命中 → args 追加 --from analyze:{id}
253
+ 3. 写 step.source_artifact_ref = "analyze:{id}"
254
+
255
+ execute step(含 {phase} 占位符,args 无 --dir):
256
+ 1. 查同 phase+milestone 最新 completed type=="plan" artifact → id = PLN-xxx, path = scratch/...
257
+ 2. 命中 → args 追加 --dir .workflow/scratch/{path}
258
+ 3. 写 step.source_artifact_ref = "plan:{id}"
259
+ ```
260
+
261
+ 兜底:查询无结果 → 不注入,由命令自身 discovery 逻辑处理。已有 `--from` 或 `--dir` 的 step 不覆盖。
262
+
263
+ **4. Goal context injection:**
264
+
265
+ 当 `step.goal_ref` 非空且 `session.task_decomposition` 存在时:
266
+ ```
267
+ goal = session.task_decomposition.find(g => g.id == step.goal_ref)
268
+ if goal:
269
+ goal_snippet = { id: goal.id, goal: goal.goal, done_when: goal.done_when,
270
+ boundary: goal.boundary, evidence: goal.evidence }
271
+ → 传递给 A_STEP_DISPATCH 注入 agent prompt
272
+ ```
273
+
274
+ **5. Write** enriched args + source_artifact_ref back to status.json.
275
+
276
+ ### A_STEP_DISPATCH
277
+
278
+ 加载前序产出 + 组装上下文 + 派发 executor agent 执行单步。Agent 内部调 `maestro ralph next` 获取 skill prompt 并执行。
279
+
280
+ **1. Load previous step context:**
281
+
282
+ - 读前一 completed step 的 `completion_summary` + `completion_caveats` + `completion_decisions` + `completion_deferred`
283
+ - 按 `session.context` 中的路径逐个 Read,提取与当前 step 相关的内容:
284
+
285
+ | 当前 stage | 加载什么 | Source |
286
+ |-----------|---------|--------|
287
+ | plan | analysis conclusions + scope_verdict | `{context.analysis_dir}/conclusions.json` |
288
+ | execute | task list + wave assignments | `{context.plan_dir}/TASK-*.json` |
289
+ | review | changed files + verification results | `{context.scratch_dir}/verification.json` |
290
+ | test | review findings | `review.json` |
291
+ | debug | error traces + failing test details | 前一 step 的 `completion_evidence` |
292
+ | brainstorm | grill report | `{context.grill_id}` report |
293
+
294
+ - Explore if needed — 产物指向代码位置但缺少上下文 → `maestro explore` 补充(仅 execute/debug/test 且有文件路径引用时)
295
+ - Accumulated signals — 遍历 ALL completed steps → 聚合 caveats + deferred
296
+
297
+ **2. Goal context pre-injection:**
298
+
299
+ - GUARD: `ralph_protocol_version >= "2"` → skip(session_anchor 已含 goal context)
300
+ - WHEN `ralph_protocol_version < "2"` 或缺失 AND `step.goal_ref` 非空 → 组装 `<goal_context>` 块注入 prompt:
301
+ ```
302
+ <goal_context>
303
+ Sub-goal: {goal.id} — {goal.goal}
304
+ Done when: {goal.done_when}
305
+ Boundary: {goal.boundary}
306
+ Evidence target: {goal.evidence}
307
+ Execution criteria: {session.execution_criteria joined by '; '}
308
+ </goal_context>
309
+ ```
310
+
311
+ **3. Resolve agent name:** `{stage_prefix}-{session_id_short}-{HHmmss}`
197
312
 
198
313
  | Stage | Prefix |
199
314
  |-------|--------|
@@ -208,97 +323,160 @@ S_SESSION_DONE:
208
323
  | debug | `dbg` |
209
324
  | Other | `run` |
210
325
 
211
- 3. Compose `<execution_context>` block:
212
-
213
- ```xml
214
- <execution_context>
215
- <intent>{session.intent}</intent>
216
- <phase>{session.phase}</phase>
217
- <milestone>{session.milestone}</milestone>
218
- <boundary_contract>
219
- <in_scope>{boundary_contract.in_scope}</in_scope>
220
- <out_of_scope>{boundary_contract.out_of_scope}</out_of_scope>
221
- <definition_of_done>{boundary_contract.definition_of_done}</definition_of_done>
222
- </boundary_contract>
223
- <execution_criteria>{session.execution_criteria}</execution_criteria>
224
- <active_goals>{task_decomposition WHERE status != "superseded"; superseded 目标仅一行标注}</active_goals>
225
- <prior_step_context>
226
- {最近 5 个已完成 step 的 completion_summary + completion_caveats}
227
- </prior_step_context>
228
- <accumulated_signals>
229
- {聚合所有已完成 step 的 caveats + deferred}
230
- </accumulated_signals>
231
- <stage_context>
232
- {按下一个 pending step 的目标 skill 类型选择性注入,见下表;仅在有实际内容时加入}
233
- </stage_context>
234
- </execution_context>
326
+ **4. Dispatch:**
327
+
235
328
  ```
329
+ delegate_subagent({
330
+ subagent_type: "ralph-executor",
331
+ name: "{resolved_agent_name}",
332
+ description: "执行 step {index}: {step.skill}",
333
+ prompt: `Session: {session_id}
236
334
 
237
- **Stage-specific `<stage_context>` injection:**
335
+ {goal_context 块,仅 protocol < 2 时}
238
336
 
239
- | 目标 skill 类型 | 注入重点 |
240
- |----------------|---------|
241
- | analyze | intent + scope + boundary |
242
- | plan | analysis findings + scope_verdict + recommendations |
243
- | execute | task list + dependencies + wave + caveats from plan |
244
- | review | changed files + verification results + execution decisions |
245
- | test | review findings + execution artifacts + coverage data |
246
- | debug | error details + failing tests + execution trace |
247
- | brainstorm/grill | challenged assumptions + risks + prior findings |
337
+ {loaded_step_context}
338
+ `
339
+ })
340
+ ```
248
341
 
249
- 4. Dispatch Agent:
342
+ Agent 内部调 `maestro ralph next --session {session_id}` 获取 skill prompt 并执行。
343
+
344
+ 5. Write `step.agent_exec_name` to status.json
345
+ 6. Display: `[{index}/{total}] ⟶ {step.skill} → Agent:{name}`
346
+ 7. Agent 同步返回 → `agent_output` = 返回文本;返回 null → STATUS=BLOCKED
250
347
 
251
- ```
252
- delegate_subagent({
253
- name: "{resolved_agent_name}",
254
- description: "执行 ralph session steps",
255
- prompt: `执行 ralph-agent session {session_id} 的 pending steps。
348
+ ### A_STEP_EXTRACT
256
349
 
257
- 调用 invoke_skill("maestro-ralph-agent-execute", "--session {session_id}") 执行步骤。
258
- maestro-ralph-agent-execute 会自动循环执行 pending 执行 step,遇到 decision/完成/失败时返回。
350
+ agent 返回的执行输出中提取结构化信号,用于 completion 参数组装。
259
351
 
260
- {execution_context}
352
+ **1. Stage-specific signal extraction:**
261
353
 
262
- 执行 Agent 内部调用 maestro ralph complete 上报。你只需确保 Skill 调用完成后输出 ---AGENT-STATUS--- 块。
354
+ | Stage | 提取什么 | 写入字段 |
355
+ |-------|---------|---------|
356
+ | analyze | `conclusions.json` scope_verdict + key_findings | `--summary`, context.analysis_dir |
357
+ | plan | TASK-*.json 数量 + 主要模块 + 波次 | `--summary`, context.plan_dir |
358
+ | execute | 修改文件数 + verification passed/failed | `--summary`, `--evidence`, context.scratch_dir |
359
+ | review | verdict + findings 数量 + severity | `--summary`, `--decisions` |
360
+ | test | pass/fail 统计 | `--summary`, `--evidence` |
361
+ | debug | root cause + 修复内容 | `--summary`, `--decisions` |
362
+ | grill | 核心质疑点数量 | `--summary`, `--caveats`, context.grill_id |
363
+ | brainstorm | 候选方案数 + 推荐方案 | `--summary`, `--decisions`, context.brainstorm_dir |
263
364
 
264
- 最后必须输出以下状态块:
365
+ **2. Artifact scanning** — Use Glob 查找执行期间新增/修改的产物:
265
366
 
266
- ---AGENT-STATUS---
267
- RESULT: decision_pending|session_complete|step_failed|steps_completed
268
- LAST_STEP_INDEX: {N}
269
- DECISION_NODE: {gate name, decision_pending 时}
270
- COMPLETED_STEPS: {本次完成的 step 数量}
271
- FAILURE_REASON: {仅 step_failed 时}
272
- ---END---`
273
- })
274
- ```
367
+ | Pattern | Signal |
368
+ |---------|--------|
369
+ | `conclusions.json` | `analysis_dir` |
370
+ | `TASK-*.json` | `plan_dir` |
371
+ | `verification.json` | `scratch_dir` |
372
+ | `review.json` | review stage |
373
+ | `test-results.json`, `uat.md` | test stage |
374
+ | `grill-report.md` | `grill_id` |
375
+ | `.brainstorming/*` | `brainstorm_dir` |
376
+
377
+ **3. Output text signal extraction** — 从执行输出文本中提取:
378
+
379
+ | Signal pattern | 写入 |
380
+ |----------------|------|
381
+ | `ANL-xxx` (artifact ID) | `session.analyze_macro_id` |
382
+ | `PLN-xxx` (artifact ID) | `context.plan_dir` |
383
+ | `BLP-xxx` (artifact ID) | `session.blueprint_id` |
384
+ | `scratch_dir:` 或 `.workflow/scratch/` 路径 | `context.scratch_dir` |
385
+ | `plan_dir:` 路径 | `context.plan_dir` |
386
+ | `PHASE: N` | `session.context.phase` |
387
+
388
+ **4. STATUS determination:**
275
389
 
276
- 5. Write `session.active_agent_name` to status.json
277
- 6. Display: `⟶ Agent:{name} dispatched for session {session_id}`
390
+ | 条件 | STATUS |
391
+ |------|--------|
392
+ | Skill 正常完成 + 有产物 | `DONE` |
393
+ | 完成但有 warnings/concerns | `DONE_WITH_CONCERNS` |
394
+ | 执行出错但可重试(临时错误、网络问题) | `NEEDS_RETRY` |
395
+ | 执行出错且无法重试(schema 错误、command_path 不可达) | `BLOCKED` |
396
+ | Agent 返回 null(崩溃/超时) | `BLOCKED` |
278
397
 
279
- ### A_PARSE_AGENT_RETURN
398
+ **5. Compose completion params:**
280
399
 
281
- Agent 返回文本中解析 `---AGENT-STATUS---` 块,并验证 session 状态一致性。
400
+ | Param | 规则 | 组装方法 |
401
+ |-------|------|---------|
402
+ | `--summary` | MUST。动词开头,≤100 字 | `"<动词><做了什么>,<量化结果>"` |
403
+ | `--decisions` | SHOULD。每条一个架构/技术决策 | 从执行中做出的非显而易见的选择 |
404
+ | `--caveats` | SHOULD。后续 step 须知 | 发现但不属于本步解决的问题 |
405
+ | `--deferred` | SHOULD。推迟工作项 | 被主动推迟的项 |
406
+ | `--evidence` | SHOULD。验证产物路径 | 指向验证结果文件 |
407
+ | `--concerns` | COND。仅 DONE_WITH_CONCERNS 时 | CAVEATS 内容同时映射为 --concerns |
282
408
 
283
- 1. Extract RESULT field → route to next state
284
- 2. Extract metadata: LAST_STEP_INDEX, DECISION_NODE, COMPLETED_STEPS, FAILURE_REASON
285
- 3. If no `---AGENT-STATUS---` block → fallback: re-read status.json 推断状态
286
- - 有 pending decision step → `decision_pending`
287
- - 全部 completed → `session_complete`
288
- - 有 failed step → `step_failed`
289
- 4. **Verify agent reporting** — re-read status.json 验证 agent 上报是否成功写入:
290
- - 检查 LAST_STEP_INDEX 对应的 step 是否 `completion_confirmed == true`
291
- - 若 Agent 返回 COMPLETED_STEPS > 0 但 status.json 中对应 step 未 completed 标记 `agent_report_mismatch = true`,RESULT 降级为 `step_failed`,FAILURE_REASON = "agent 上报未写入 status.json"
292
- - 检查 `session.status` 是否仍为 "running"(agent 崩溃可能导致 paused)
293
- 5. Display: `[Agent返回] {RESULT} 完成 {COMPLETED_STEPS} 步`
409
+ ### A_STEP_DRIFT_ANALYZE
410
+
411
+ 产物 vs 目标偏离分析。A_STEP_EXTRACT 后、A_STEP_COMPLETE 前执行。
412
+
413
+ **1. 收集对照基准:**
414
+
415
+ | 基准来源 | 取值 |
416
+ |---------|------|
417
+ | `step.goal_ref`goal.done_when | 子目标完成条件 |
418
+ | `session.boundary_contract.definition_of_done` | 全局验收标准 |
419
+ | `session.execution_criteria` | 执行准则 |
420
+ | `session.intent` | 原始意图 |
421
+
422
+ **2. 对比评分:**
423
+
424
+ | 维度 | 检查 |
425
+ |------|------|
426
+ | 覆盖度 | 产物是否覆盖 goal.done_when 每个条件 |
427
+ | 方向性 | decisions 是否与 intent/boundary 一致 |
428
+ | 完整性 | 预期产物类型是否齐全 |
429
+
430
+ **drift_score:**
431
+ - `ALIGNED` — 全部维度通过
432
+ - `MINOR_DRIFT` — 小缺口,不影响后续
433
+ - `MAJOR_DRIFT` — 方向性偏离或关键产物缺失
434
+
435
+ **3. 修正动作:**
436
+
437
+ | drift_score | 动作 |
438
+ |-------------|------|
439
+ | ALIGNED | 正常进入 S_STEP_COMPLETE |
440
+ | MINOR_DRIFT | 偏离项追加到 caveats,正常 complete |
441
+ | MAJOR_DRIFT + 未重试 | `shell("maestro ralph retry {index}")` → 回到 S_STEP_DISPATCH 重执行(drift_correction 作修正上下文注入 prompt) |
442
+ | MAJOR_DRIFT + 已重试 | 以 DONE_WITH_CONCERNS complete |
443
+
444
+ **4. 写入:** `step.drift_score`, `step.drift_correction`
445
+
446
+ ### A_STEP_COMPLETE
447
+
448
+ 调 `ralph complete` 上报 + 传播上下文信号 + 循环。
449
+
450
+ 1. 使用 A_STEP_EXTRACT 组装的参数调用 `ralph complete`:
451
+ ```
452
+ shell("maestro ralph complete {index} --status DONE --summary \"{SUMMARY}\" [--evidence ...] [--decisions ...] [--caveats ...] [--deferred ...]")
453
+ ```
454
+ DONE_WITH_CONCERNS 时 caveats 同时映射 `--concerns`。BLOCKED 时用 `--reason`。
455
+
456
+ 2. **Context signals propagation** — 将关键信号写入 `status.json.context`:
457
+
458
+ | Signal | 写入字段 |
459
+ |--------|---------|
460
+ | `analysis_dir` | `context.analysis_dir` |
461
+ | `plan_dir` | `context.plan_dir` |
462
+ | `scratch_dir` | `context.scratch_dir` |
463
+ | `grill_id` | `context.grill_id` |
464
+ | `brainstorm_dir` | `context.brainstorm_dir` |
465
+ | `blueprint_dir` | `context.blueprint_dir` |
466
+ | `ANL-xxx` | `session.analyze_macro_id` |
467
+ | `BLP-xxx` | `session.blueprint_id` |
468
+ | `phase` | `session.context.phase` |
469
+
470
+ 3. Display: `[{index}/{total}] ✓ {step.skill} → {SUMMARY}`
471
+ 4. Loop back to S_STEP_LOCATE
294
472
 
295
473
  ### A_AGENT_EVALUATE
296
474
 
297
- 通过 Agent 在本循环内评估质量门。替代 `maestro delegate --mode analysis`。
475
+ 通过 Agent 在本循环内评估质量门。
298
476
 
299
477
  1. Resolve artifact dir: `.workflow/scratch/{artifact.path}/` with fallback glob
300
478
  2. Parse decision metadata: `{ decision, retry_count, max_retries }`
301
- 3. Map result files(同 ralph A_DELEGATE_EVALUATE):
479
+ 3. Map result files:
302
480
 
303
481
  | Decision | Files |
304
482
  |----------|-------|
@@ -329,11 +507,11 @@ FAILURE_REASON: {仅 step_failed 时}
329
507
  CONSTRAINTS: 只评估不修改文件 | 置信度<60%倾向 fix | retry {n}/{max} 达上限必须 escalate"
330
508
  })
331
509
  ```
332
- 5. On return: parse `---VERDICT---` block — STATUS must match strict enum `PASS|FAIL|PARTIAL|BLOCKED`; parse failure → fallback STATUS="fix", `parse_failed: true`, `confidence_score: 0` (invariant 13)
510
+ 5. On return: parse `---VERDICT---` block — STATUS must match strict enum `PASS|FAIL|PARTIAL|BLOCKED`; parse failure → fallback STATUS="fix", `parse_failed: true`, `confidence_score: 0` (invariant 18)
333
511
  6. Confidence adjustment: <60 + proceed → fix; >95 + fix + retry>0 → suggest proceed
334
512
  7. **Decision log**: Append to `{session_dir}/decisions.ndjson`:
335
513
  ```json
336
- { "id": "DEC-{timestamp}", "timestamp": "{ISO}", "source": "ralph-agent",
514
+ { "id": "DEC-{timestamp}", "timestamp": "{ISO}", "source": "ralph-v2",
337
515
  "node_id": "{step.decision}", "type": "quality-gate",
338
516
  "verdict": "{adjusted_verdict}", "confidence_score": {N},
339
517
  "parse_failed": false,
@@ -342,7 +520,7 @@ FAILURE_REASON: {仅 step_failed 时}
342
520
 
343
521
  ### A_AGENT_GOAL_AUDIT
344
522
 
345
- 通过 Agent 审计子目标完成情况。替代 `maestro delegate --mode analysis` 的 goal audit。
523
+ 通过 Agent 审计子目标完成情况。
346
524
 
347
525
  1. Read `session.task_decomposition` from status.json
348
526
  2. Dispatch audit Agent:
@@ -379,7 +557,7 @@ FAILURE_REASON: {仅 step_failed 时}
379
557
 
380
558
  ### A_AGENT_REGROUND
381
559
 
382
- 通过 Agent 执行意图保真检查。替代 `maestro delegate --mode analysis` 的 reground。
560
+ 通过 Agent 执行意图保真检查。
383
561
 
384
562
  1. Read status.json:intent, boundary_contract, completed steps, done goals
385
563
  2. Dispatch reground Agent:
@@ -421,7 +599,7 @@ FAILURE_REASON: {仅 step_failed 时}
421
599
  1. 定位刚完成的 macro analyze artifact → `analyze_macro_id`, `conclusions_path`
422
600
  2. 读取 `conclusions.scope_verdict`(`large | medium | small`),缺失 → `unknown`
423
601
  3. 写入 `session.scope_verdict` + `session.analyze_macro_id`
424
- 4. Append `{session_dir}/decisions.ndjson`:`{ "type": "scope-gate", "source": "ralph-agent", "verdict": "{scope_verdict}", "analyze_macro_id": "{ANL_ID}" }`
602
+ 4. Append `{session_dir}/decisions.ndjson`:`{ "type": "scope-gate", "source": "ralph-v2", "verdict": "{scope_verdict}", "analyze_macro_id": "{ANL_ID}" }`
425
603
 
426
604
  ### A_STRUCTURAL_EVALUATE
427
605
 
@@ -434,7 +612,7 @@ FAILURE_REASON: {仅 step_failed 时}
434
612
 
435
613
  ### A_SHOW_STATUS
436
614
 
437
- 1. Find latest `ralph-agent-*` session(by created_at)
615
+ 1. Find latest `ralph-v2-*` session(by created_at)
438
616
  2. Display: Session, Status, Position, Progress, Current step
439
617
  3. List steps: [✓] confirmed, [▸] current, [ ] pending, [◆] decision;执行 step 附 `command_scope` + `command_path`
440
618
  4. If `task_decomposition` present → 显示 sub-goals 进度(done/total)
@@ -478,7 +656,7 @@ FAILURE_REASON: {仅 step_failed 时}
478
656
  |-------|------|------|
479
657
  | 1. 快照 | 读 `task_decomposition` + `boundary_contract` + 已完成 steps 的 `completion_summary` | Display: 目标列表 + 进度 |
480
658
  | 2. 解析 | `change_request` 非空 → 直接用;为空 → ask_user(修改/新增/移除/调整边界) | `change_type` + `change_request` |
481
- | 3. Mini Grill | Agent 评估影响(替代 maestro delegate) | RISK_LEVEL + AFFECTED_GOALS + INVALIDATED_STEPS + NEW_GAPS |
659
+ | 3. Mini Grill | Agent 评估影响 | RISK_LEVEL + AFFECTED_GOALS + INVALIDATED_STEPS + NEW_GAPS |
482
660
  | 4. 确认 | ask_user:应用并继续 / 仅改目标 / 取消 | 用户选择 |
483
661
  | 5. 应用 | 归档旧目标(`superseded`)→ 写入新目标(`origin: CHG-xxx`)→ 重建链路 → write status.json | re-dispatch |
484
662
 
@@ -515,9 +693,9 @@ GUARD: 已完成(`status: "done"`)的目标不可 supersede(skip + warn)
515
693
 
516
694
  ### A_RETRY / A_PAUSE_SESSION / A_COMPLETE_SESSION
517
695
 
518
- - **A_RETRY**: `shell("maestro ralph retry {index}")` — ralph
519
- - **A_PAUSE_SESSION**: `ralph complete N --status BLOCKED --reason "..."` — ralph
520
- - **A_COMPLETE_SESSION**: 校验所有 step `completion_confirmed == true` + `task_decomposition_all_done == true`,写 `session.status = "completed"` — 同 ralph
696
+ - **A_RETRY**: `shell("maestro ralph retry {index}")` — CLI 设 `step.retried = true`, `step.status = "pending"`, 清 `active_step_index`
697
+ - **A_PAUSE_SESSION**: `ralph complete N --status BLOCKED --reason "..."` — CLI 写 `session.status = "paused"`
698
+ - **A_COMPLETE_SESSION**: 校验所有 step `completion_confirmed == true` + `task_decomposition_all_done == true`(若存在),通过后写 `session.status = "completed"`
521
699
 
522
700
  </actions>
523
701
 
@@ -525,21 +703,9 @@ GUARD: 已完成(`status: "done"`)的目标不可 supersede(skip + warn)
525
703
 
526
704
  <appendix>
527
705
 
528
- ### Agent vs CLI-Delegate 对照
529
-
530
- | 维度 | ralph-cli (CLI-delegate) | ralph-agent (Agent) |
531
- |------|-------------------------|---------------------|
532
- | 执行分发 | `maestro delegate` (Bash bg) | `delegate_subagent()` (同步) |
533
- | 执行包装器 | `maestro-ralph-cli-execute` (delegate 加载) | `maestro-ralph-agent-execute` (Agent 内 Skill 加载) |
534
- | 结果通信 | `---RESULT---` 文本块 (从 delegate output 解析) | Agent 返回文本 + `---AGENT-STATUS---` 块 |
535
- | 回调模式 | STOP → re-invocation callback | 同步等待 Agent 返回(无 STOP) |
536
- | 决策评估 | `maestro delegate --mode analysis` (Bash bg + STOP) | `delegate_subagent()` 同步分析(无 STOP) |
537
- | 完成上报 | 编排器调 `ralph complete`(解析 RESULT 后) | 执行 Agent 内调 `ralph complete`(agent 上报) |
538
- | session 字段 | `execution_mode: "cli-delegate"`, `cli_tool`, `delegate_exec_id` | `execution_mode: "agent"`, `agent_exec_name` |
539
-
540
706
  ### Stage Mapping
541
707
 
542
- Agent 版无 `delegate_mode`/`delegate_rule` 字段。执行 Agent 始终拥有完整工具集(read + write),由 skill 自身约束行为。Decision 评估 Agent 通过 prompt 中的 CONSTRAINTS 约束为只读。
708
+ 执行 Agent 始终拥有完整工具集(read + write),由 skill 自身约束行为。Decision 评估 Agent 通过 prompt 中的 CONSTRAINTS 约束为只读。
543
709
 
544
710
  | Stage | invoke_skill(independent) | invoke_skill(unified) | Decision after | quality_mode |
545
711
  |-------|---------------------|-----------------|----------------|--------------|
@@ -568,7 +734,7 @@ Build rules 0-14 全部适用,包括 spec-setup 预检(rule 0.5)、grill a
568
734
 
569
735
  ```json
570
736
  {
571
- "session_id": "ralph-agent-{YYYYMMDD-HHmmss}",
737
+ "session_id": "ralph-v2-{YYYYMMDD-HHmmss}",
572
738
  "source": "ralph", "status": "running",
573
739
  "execution_mode": "agent",
574
740
  "ralph_protocol_version": "2",
@@ -647,7 +813,7 @@ Build rules 0-14 全部适用,包括 spec-setup 预检(rule 0.5)、grill a
647
813
 
648
814
  ### Fix-Loop Templates
649
815
 
650
- 6 套 fix-loop templates(post-execute / post-business-test / post-review / post-test / post-frontend-verify / post-goal-audit),结构同 ralph。插入的 step 通过 Agent dispatch 执行,由 execute Agent 内调 `ralph complete` 上报。
816
+ 6 套 fix-loop templates(post-execute / post-business-test / post-review / post-test / post-frontend-verify / post-goal-audit)。插入的 step 通过 A_STEP_DISPATCH 派发 executor agent 逐步执行,由主流程调 `ralph complete` 上报。
651
817
 
652
818
  ### Error Codes
653
819
 
@@ -656,29 +822,30 @@ E001–E006, W001–W004 适用。Agent 新增:
656
822
  | Code | Severity | Description | Recovery |
657
823
  |------|----------|-------------|----------|
658
824
  | E014 | error | Agent execution failed (Agent returned null) | Retry once, then BLOCKED |
659
- | E015 | error | `---AGENT-STATUS---` block not found | Fallback: re-read status.json 推断 |
660
825
  | E016 | error | Evaluation Agent verdict parse failed | Fallback fix + parse_failed: true |
661
826
 
662
827
  ### Success Criteria
663
828
 
664
- - [ ] ralph-agent owns full loop: dispatch Agentwaitverifydecidere-dispatch
665
- - [ ] 执行通过 `delegate_subagent()` 分发,Agent 内调 `invoke_skill("maestro-ralph-agent-execute", "--session {id}")` 执行
666
- - [ ] Agent 返回文本含 `---AGENT-STATUS---` 块(RESULT/LAST_STEP_INDEX/DECISION_NODE/COMPLETED_STEPS/FAILURE_REASON)
829
+ - [ ] ralph-v2 owns full step loop: locate resolve dispatchextractdriftcomplete → next
830
+ - [ ] One agent per step — `delegate_subagent({ subagent_type: "ralph-executor" })` 每步派发一个
831
+ - [ ] Agent 内调 `maestro ralph next` 获取 skill prompt 并执行,返回执行输出
832
+ - [ ] 主流程调 `maestro ralph complete` 上报(非 agent 上报)
833
+ - [ ] 主流程负责 arg resolution、context loading、signal extraction、drift analysis
834
+ - [ ] Agent 返回执行输出文本,主流程从中提取信号和状态
835
+ - [ ] Agent 崩溃(返回 null)→ STATUS=BLOCKED,转 S_HANDLE_FAIL
667
836
  - [ ] 无 STOP/callback 模式 — delegate_subagent() 同步等待返回
668
- - [ ] 执行 Agent 自主循环执行 step,遇 decision 停止返回
669
- - [ ] 执行 Agent 内部调 `maestro ralph complete` 上报(agent 上报,非编排器上报)
670
- - [ ] A_PARSE_AGENT_RETURN 验证 status.json:agent 上报写入确认 + session.status 一致性
671
- - [ ] Decision evaluation 通过 delegate_subagent() 同步完成(非 maestro delegate)
837
+ - [ ] Decision evaluation 通过 delegate_subagent() 同步完成
672
838
  - [ ] Verdict 解析保持 `---VERDICT---` 格式,parse 失败 → fallback fix + parse_failed: true
673
- - [ ] decisions.ndjson 追加:source 字段为 `"ralph-agent"`
674
- - [ ] Session schema: `execution_mode: "agent"`,`agent_exec_name` 替代 `delegate_exec_id`,含 `artifacts_produced`
675
- - [ ] Chain building(S_RESOLVE_PHASE through S_BUILD_CHAIN)逻辑同 ralph,本文件自包含执行
676
- - [ ] execution_context 块含 prior_step_context(滑动窗口 5 step)+ accumulated_signals + stage_context
677
- - [ ] execution_context 中 boundary_contract 不截断;superseded 目标仅一行标注
839
+ - [ ] decisions.ndjson 追加:source 字段为 `"ralph-v2"`
840
+ - [ ] Session schema: `execution_mode: "agent"`,`agent_exec_name`(执行 Agent 名称标识),含 `artifacts_produced`
841
+ - [ ] Chain building(S_RESOLVE_PHASE through S_BUILD_CHAIN)自包含执行
842
+ - [ ] A_STEP_DISPATCH 含前序产出加载(滑动窗口 5 step + accumulated signals + stage-specific artifacts)
678
843
  - [ ] Agent name 含 stage prefix(grl/brn/anm/ana/pln/exe/rev/tst/dbg)
679
- - [ ] Stage Mapping 表内联适配(无 delegate_mode/delegate_rule,Agent 始终 read+write,评估 Agent prompt 约束只读)
680
- - [ ] completion_summaryDONE/DONE_WITH_CONCERNS 时为 MUST(由 execute Agent 的 ralph complete --summary 写入)
681
- - [ ] CAVEATS DONE_WITH_CONCERNS 时同时映射 --concerns(execute Agent 负责)
844
+ - [ ] `--summary` DONE/DONE_WITH_CONCERNS 时为 MUST(动词开头,≤100 字)
845
+ - [ ] CAVEATS 在 DONE_WITH_CONCERNS 时同时映射 --concerns
846
+ - [ ] A_STEP_EXTRACT agent 输出提取 artifact IDs、path signals、phase signals
847
+ - [ ] A_STEP_DRIFT_ANALYZE:ALIGNED/MINOR_DRIFT → complete;MAJOR_DRIFT+未重试 → retry;MAJOR_DRIFT+已重试 → DONE_WITH_CONCERNS
848
+ - [ ] A_STEP_COMPLETE 将 context signals 写入 status.json.context
682
849
  - [ ] A_AMEND_GOAL:完整 5 步流程 + deferred_reading ralph-amend-goal.md + Agent mini grill 含完整 prompt
683
850
  - [ ] 旧目标标 superseded(superseded_by + superseded_at),新目标 origin: "CHG-xxx"
684
851
  - [ ] goal_changelog 含完整 before/after + impact_assessment
@@ -686,12 +853,8 @@ E001–E006, W001–W004 适用。Agent 新增:
686
853
  - [ ] spec-setup 预检(build rule 0.5)
687
854
  - [ ] post-milestone adhoc 分支:mark completed + set current_milestone = null
688
855
  - [ ] post-reground + drifted + confidence < 60 → A_APPLY_PROCEED (LOW CONFIDENCE)
689
- - [ ] Fix-loop 插入的 step 通过 Agent dispatch 执行,`agent_exec_name` 初始化为 null
856
+ - [ ] Fix-loop 插入的 step 通过 A_STEP_DISPATCH 逐步执行
690
857
  - [ ] re-grounding 3-step 插入规则(build rule 5.5)不变
691
858
  - [ ] A_REGROUND_HALT 漂移熔断(auto_confirm 不跳过)不变
692
- - [ ] `---AGENT-STATUS---` 块缺失时 fallback:re-read status.json 推断状态
693
- - [ ] Agent 超时/崩溃 → A_PARSE_AGENT_RETURN fallback 推断 + S_HANDLE_FAIL 路径
694
859
 
695
860
  </appendix>
696
- </output>
697
- </output>