maestro-flow 0.5.44 → 0.5.46
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.
- package/.agents/agents/ralph-executor.md +93 -0
- package/.agents/skills/maestro-ralph-cli/SKILL.md +21 -16
- package/.agents/skills/maestro-ralph-v2/SKILL.md +923 -0
- package/.agents/skills/odyssey-debug/SKILL.md +338 -253
- package/.agents/skills/odyssey-improve/SKILL.md +367 -281
- package/.agents/skills/odyssey-planex/SKILL.md +490 -420
- package/.agents/skills/odyssey-review-test-fix/SKILL.md +336 -251
- package/.agents/skills/odyssey-ui/SKILL.md +332 -247
- package/.agy/agents/ralph-executor.md +91 -0
- package/.agy/skills/maestro-ralph-cli/SKILL.md +21 -16
- package/.agy/skills/maestro-ralph-v2/SKILL.md +935 -0
- package/.agy/skills/odyssey-debug/SKILL.md +338 -253
- package/.agy/skills/odyssey-improve/SKILL.md +367 -281
- package/.agy/skills/odyssey-planex/SKILL.md +490 -420
- package/.agy/skills/odyssey-review-test-fix/SKILL.md +336 -251
- package/.agy/skills/odyssey-ui/SKILL.md +332 -247
- package/.claude/agents/ralph-executor.md +91 -0
- package/.claude/commands/maestro-ralph-cli.md +21 -16
- package/.claude/commands/maestro-ralph-v2.md +921 -0
- package/.claude/commands/odyssey-debug.md +352 -267
- package/.claude/commands/odyssey-improve.md +381 -295
- package/.claude/commands/odyssey-planex.md +504 -434
- package/.claude/commands/odyssey-review-test-fix.md +350 -265
- package/.claude/commands/odyssey-ui.md +346 -261
- package/.codex/skills/maestro-next/SKILL.md +1 -1
- package/dashboard/dist-server/dashboard/src/server/wiki/embedding.js +3 -3
- package/dashboard/dist-server/dashboard/src/server/wiki/embedding.js.map +1 -1
- package/dashboard/dist-server/dashboard/src/server/wiki/wiki-indexer.js +4 -4
- package/dashboard/dist-server/dashboard/src/server/wiki/wiki-indexer.js.map +1 -1
- package/dashboard/dist-server/src/graph/kg/db/queries.d.ts +6 -0
- package/dashboard/dist-server/src/graph/kg/db/queries.js +141 -19
- package/dashboard/dist-server/src/graph/kg/db/queries.js.map +1 -1
- package/dashboard/dist-server/src/graph/kg/extraction/code/svelte-extractor.js +1 -1
- package/dashboard/dist-server/src/graph/kg/extraction/code/svelte-extractor.js.map +1 -1
- package/dashboard/dist-server/src/graph/kg/extraction/code/tree-sitter.js +2 -2
- package/dashboard/dist-server/src/graph/kg/extraction/code/tree-sitter.js.map +1 -1
- package/dashboard/dist-server/src/graph/kg/extraction/code/vue-extractor.js +1 -1
- package/dashboard/dist-server/src/graph/kg/extraction/code/vue-extractor.js.map +1 -1
- package/dashboard/dist-server/src/graph/kg/extraction/code/wasm-stability.js +1 -1
- package/dashboard/dist-server/src/graph/kg/extraction/code/wasm-stability.js.map +1 -1
- package/dashboard/dist-server/src/graph/kg/extraction/orchestrator.js +2 -2
- package/dashboard/dist-server/src/graph/kg/extraction/orchestrator.js.map +1 -1
- package/dashboard/dist-server/src/graph/kg/surface/hook-injector.js +1 -1
- package/dashboard/dist-server/src/graph/kg/surface/hook-injector.js.map +1 -1
- package/dashboard/dist-server/src/hooks/keyword-spec-injector.js +35 -0
- package/dashboard/dist-server/src/hooks/keyword-spec-injector.js.map +1 -1
- package/dashboard/dist-server/src/hooks/spec-analytics.d.ts +1 -0
- package/dashboard/dist-server/src/hooks/spec-analytics.js.map +1 -1
- package/dashboard/dist-server/src/hooks/wiki-search-bridge.d.ts +32 -0
- package/dashboard/dist-server/src/hooks/wiki-search-bridge.js +71 -0
- package/dashboard/dist-server/src/hooks/wiki-search-bridge.js.map +1 -0
- package/dist/src/agents/api-explore/agent-loop.d.ts +15 -2
- package/dist/src/agents/api-explore/agent-loop.d.ts.map +1 -1
- package/dist/src/agents/api-explore/agent-loop.js +6 -5
- package/dist/src/agents/api-explore/agent-loop.js.map +1 -1
- package/dist/src/agents/api-explore/config.d.ts +56 -0
- package/dist/src/agents/api-explore/config.d.ts.map +1 -1
- package/dist/src/agents/api-explore/config.js +34 -0
- package/dist/src/agents/api-explore/config.js.map +1 -1
- package/dist/src/agents/api-explore/llm.d.ts +5 -1
- package/dist/src/agents/api-explore/llm.d.ts.map +1 -1
- package/dist/src/agents/api-explore/llm.js +10 -8
- package/dist/src/agents/api-explore/llm.js.map +1 -1
- package/dist/src/agents/api-explore/moa-cache.d.ts +12 -0
- package/dist/src/agents/api-explore/moa-cache.d.ts.map +1 -0
- package/dist/src/agents/api-explore/moa-cache.js +50 -0
- package/dist/src/agents/api-explore/moa-cache.js.map +1 -0
- package/dist/src/agents/api-explore/moa-loop.d.ts +49 -0
- package/dist/src/agents/api-explore/moa-loop.d.ts.map +1 -0
- package/dist/src/agents/api-explore/moa-loop.js +43 -0
- package/dist/src/agents/api-explore/moa-loop.js.map +1 -0
- package/dist/src/agents/api-explore/moa-pipeline.d.ts +43 -0
- package/dist/src/agents/api-explore/moa-pipeline.d.ts.map +1 -0
- package/dist/src/agents/api-explore/moa-pipeline.js +276 -0
- package/dist/src/agents/api-explore/moa-pipeline.js.map +1 -0
- package/dist/src/agents/api-explore/runner.d.ts +3 -0
- package/dist/src/agents/api-explore/runner.d.ts.map +1 -1
- package/dist/src/agents/api-explore/runner.js +24 -7
- package/dist/src/agents/api-explore/runner.js.map +1 -1
- package/dist/src/agents/api-explore/session.d.ts +15 -0
- package/dist/src/agents/api-explore/session.d.ts.map +1 -1
- package/dist/src/agents/api-explore/session.js.map +1 -1
- package/dist/src/cli.js +1 -0
- package/dist/src/cli.js.map +1 -1
- package/dist/src/commands/explore.d.ts.map +1 -1
- package/dist/src/commands/explore.js +16 -1
- package/dist/src/commands/explore.js.map +1 -1
- package/dist/src/commands/moa.d.ts +3 -0
- package/dist/src/commands/moa.d.ts.map +1 -0
- package/dist/src/commands/moa.js +202 -0
- package/dist/src/commands/moa.js.map +1 -0
- package/dist/src/graph/kg/db/queries.d.ts +6 -0
- package/dist/src/graph/kg/db/queries.d.ts.map +1 -1
- package/dist/src/graph/kg/db/queries.js +141 -19
- package/dist/src/graph/kg/db/queries.js.map +1 -1
- package/dist/src/graph/kg/extraction/code/svelte-extractor.js +1 -1
- package/dist/src/graph/kg/extraction/code/svelte-extractor.js.map +1 -1
- package/dist/src/graph/kg/extraction/code/tree-sitter.js +2 -2
- package/dist/src/graph/kg/extraction/code/tree-sitter.js.map +1 -1
- package/dist/src/graph/kg/extraction/code/vue-extractor.js +1 -1
- package/dist/src/graph/kg/extraction/code/vue-extractor.js.map +1 -1
- package/dist/src/graph/kg/extraction/code/wasm-stability.js +1 -1
- package/dist/src/graph/kg/extraction/code/wasm-stability.js.map +1 -1
- package/dist/src/graph/kg/extraction/orchestrator.js +2 -2
- package/dist/src/graph/kg/extraction/orchestrator.js.map +1 -1
- package/dist/src/graph/kg/surface/hook-injector.js +1 -1
- package/dist/src/graph/kg/surface/hook-injector.js.map +1 -1
- package/dist/src/hooks/keyword-spec-injector.d.ts.map +1 -1
- package/dist/src/hooks/keyword-spec-injector.js +35 -0
- package/dist/src/hooks/keyword-spec-injector.js.map +1 -1
- package/dist/src/hooks/spec-analytics.d.ts +1 -0
- package/dist/src/hooks/spec-analytics.d.ts.map +1 -1
- package/dist/src/hooks/spec-analytics.js.map +1 -1
- package/dist/src/hooks/wiki-search-bridge.d.ts +33 -0
- package/dist/src/hooks/wiki-search-bridge.d.ts.map +1 -0
- package/dist/src/hooks/wiki-search-bridge.js +71 -0
- package/dist/src/hooks/wiki-search-bridge.js.map +1 -0
- package/dist/src/utils/update-notices.js +12 -0
- package/dist/src/utils/update-notices.js.map +1 -1
- package/package.json +1 -1
- package/.agents/skills/maestro-ralph-agent/SKILL.md +0 -697
- package/.agents/skills/maestro-ralph-agent-execute/SKILL.md +0 -461
- package/.agy/skills/maestro-ralph-agent/SKILL.md +0 -696
- package/.agy/skills/maestro-ralph-agent-execute/SKILL.md +0 -457
- package/.claude/commands/maestro-ralph-agent-execute.md +0 -459
- package/.claude/commands/maestro-ralph-agent.md +0 -695
|
@@ -0,0 +1,923 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: maestro-ralph-v2
|
|
3
|
+
description: Adaptive lifecycle orchestrator — compose, dispatch ralph-executor agent, evaluate decision, loop
|
|
4
|
+
argument-hint: "<intent> [-y] [--amend [change]] [--roadmap] | status | continue"
|
|
5
|
+
allowed-tools:
|
|
6
|
+
- read_file
|
|
7
|
+
- write_file
|
|
8
|
+
- edit_file
|
|
9
|
+
- shell
|
|
10
|
+
- find_files
|
|
11
|
+
- search
|
|
12
|
+
- invoke_skill
|
|
13
|
+
- ask_user
|
|
14
|
+
- delegate_subagent
|
|
15
|
+
- send_message
|
|
16
|
+
---
|
|
17
|
+
<!-- Open-standard mirror generated by scripts/build-agents-standard.mjs — do not edit; re-run after editing .claude/ source. -->
|
|
18
|
+
|
|
19
|
+
<purpose>
|
|
20
|
+
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.
|
|
21
|
+
|
|
22
|
+
Session: `.workflow/.maestro/ralph-v2-{YYYYMMDD-HHmmss}/status.json`
|
|
23
|
+
</purpose>
|
|
24
|
+
|
|
25
|
+
<deferred_reading>
|
|
26
|
+
- [ralph-amend-goal.md](~/.maestro/workflows/ralph-amend-goal.md) — read when `--amend` flag active for goal amendment flow
|
|
27
|
+
</deferred_reading>
|
|
28
|
+
|
|
29
|
+
<context>
|
|
30
|
+
$ARGUMENTS — intent text, flags, or keywords.
|
|
31
|
+
|
|
32
|
+
**Parse:**
|
|
33
|
+
```
|
|
34
|
+
-y flag → auto_confirm = true
|
|
35
|
+
--roadmap → wants_roadmap = true
|
|
36
|
+
--amend / -a → amend_mode = true
|
|
37
|
+
.md/.txt path → input_doc
|
|
38
|
+
status|continue → route keyword
|
|
39
|
+
Remaining → intent (amend_mode 时为 change_request)
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
**State files**:
|
|
43
|
+
- `.workflow/state.json` — artifact registry
|
|
44
|
+
- `.workflow/.maestro/ralph-v2-*/status.json` — session state
|
|
45
|
+
</context>
|
|
46
|
+
|
|
47
|
+
<invariants>
|
|
48
|
+
1. **Ralph-v2 owns the full loop** — locate step → resolve args → load context → dispatch agent → wait for send_message → receive → extract signals → drift → complete,全部在本命令内完成
|
|
49
|
+
2. **One agent per step** — 每个执行 step 派发一个 named executor agent,agent 通过 send_message 回传结果,主流程解析结果后决定下一步
|
|
50
|
+
3. **Agent is a thin wrapper** — executor agent 调 `ralph next` 获取 skill prompt 并执行,通过 send_message 回传输出;arg resolution、context loading、signal extraction、drift analysis、ralph complete 均由主流程完成
|
|
51
|
+
4. **Dual dispatch model** — 执行 Agent 与评估 Agent 使用不同派发模式:
|
|
52
|
+
- **执行 Agent**(A_STEP_DISPATCH):`delegate_subagent({name: "exe-xxx"})` — named mailbox teammate,支持内部多 agent 编排,通过 `send_message({to: "main"})` 回传结果
|
|
53
|
+
- **评估 Agent**(A_AGENT_EVALUATE / A_AGENT_GOAL_AUDIT / A_AGENT_REGROUND):`delegate_subagent()` 不传 `name` — 同步阻塞,直接返回结果(评估 agent 只读不需要多 agent)
|
|
54
|
+
- `agent_exec_name` 既用于 display/日志,也作为执行 Agent 的 `name` 参数
|
|
55
|
+
5. **主流程调 `ralph complete`** — 每个 step 完成后由主流程调 `maestro ralph complete`,非 agent 上报
|
|
56
|
+
6. **Decision evaluation inline** — decision 节点不 handoff,通过 Agent 或 CLI delegate 在本循环内评估
|
|
57
|
+
7. **CLI delegation for evaluation only** — CLI delegate(`maestro delegate --mode analysis`)仅限评估环节;执行仍通过 executor Agent 完成
|
|
58
|
+
8. **Decision delegates read-only** — 评估 Agent 通过 prompt 中的 CONSTRAINTS 约束为只读
|
|
59
|
+
9. **执行 step 通过 `maestro ralph next` CLI 加载并内联执行**(由 execute Agent 完成)
|
|
60
|
+
10. **status.json 是唯一真源** — 不生成 markdown 清单或侧文件
|
|
61
|
+
11. **每个 step 必须 `completion_confirmed: true`** — 由 `maestro ralph complete N --status DONE`(或 DONE_WITH_CONCERNS)写入;CLI 是唯一合法写入路径
|
|
62
|
+
12. **command_path 在 A_BUILD_STEPS 解析** — 通过 `maestro ralph skills --platform agent --json --quiet` 预校验
|
|
63
|
+
13. **执行 step 加载契约** — 由 `maestro ralph next` CLI 在执行期完成
|
|
64
|
+
14. **Decomposition is outcome-oriented** — sub-goals 为可观测交付,禁止 lifecycle 复刻
|
|
65
|
+
15. **planning_mode governs arg granularity** — `unified` → skill args 无 `{phase}`;`independent` → 含 `{phase}`
|
|
66
|
+
16. **task_decomposition 驱动 steps[] 动态生长** — `post-goal-audit` 按 unmet 子目标插入 scoped mini-loop
|
|
67
|
+
17. **Invariant violation = BLOCK** — 违反上述任一 invariant 即阻断当前操作
|
|
68
|
+
18. **Evaluate fallback 必须标记** — 评估 Agent 解析 verdict 失败时 fallback 为 "fix",MUST 在 decisions.ndjson 记录 `"parse_failed": true, "confidence_score": 0`
|
|
69
|
+
19. **auto_confirm 单一来源** — `auto_confirm` 仅由用户 `-y` 标志设定
|
|
70
|
+
20. **分解契约单一所有者** — `boundary_contract` / `task_decomposition` 由 session 创建者拥有
|
|
71
|
+
21. **控制权优先级(范式治理)** — FSM 独占 session 生命周期 + step 排序 + retry/fix/escalate + cross-step decision 节点
|
|
72
|
+
</invariants>
|
|
73
|
+
|
|
74
|
+
<state_machine>
|
|
75
|
+
|
|
76
|
+
Chain-building states + 执行循环 states:
|
|
77
|
+
|
|
78
|
+
<states>
|
|
79
|
+
S_PARSE_ROUTE — 解析参数、路由入口
|
|
80
|
+
S_STATUS — 显示 session 进度
|
|
81
|
+
S_CONTINUE — 恢复执行
|
|
82
|
+
S_RESOLVE_PHASE — 解析 phase + phase_is_new + milestone PERSIST: session.phase, session.phase_is_new, session.milestone
|
|
83
|
+
S_INFER — 推断 lifecycle_position PERSIST: session.lifecycle_position, session.wants_roadmap
|
|
84
|
+
S_RESOLVE_SCOPE — 读 macro analyze conclusions.scope_verdict PERSIST: session.scope_verdict, session.analyze_macro_id
|
|
85
|
+
S_QUALITY_MODE — 决定质量管线模式 PERSIST: session.quality_mode
|
|
86
|
+
S_PLANNING_MODE — 决定统一/独立规划模式 PERSIST: session.planning_mode
|
|
87
|
+
S_DECOMPOSE — 边界澄清 + 执行准则 + 子目标清单 PERSIST: session.boundary_contract, .execution_criteria, .task_decomposition
|
|
88
|
+
S_BUILD_CHAIN — 构建步骤链(build rules 0-14) PERSIST: session.steps[]
|
|
89
|
+
S_CREATE_SESSION — 写 status.json PERSIST: session (全量)
|
|
90
|
+
S_CONFIRM — 用户确认
|
|
91
|
+
|
|
92
|
+
S_STEP_LOCATE — 找下一个 pending step PERSIST: —
|
|
93
|
+
S_STEP_RESOLVE — 解析占位符 + 丰富参数 PERSIST: step.args (enriched)
|
|
94
|
+
S_STEP_DISPATCH — 组装上下文 + 派发 named executor agent PERSIST: step.agent_exec_name, step.status = "running"
|
|
95
|
+
S_STEP_WAIT_MSG — 等待 executor 的 send_message 回传 PERSIST: —
|
|
96
|
+
S_STEP_ANALYZE — 提取信号 + 组装 completion 参数 PERSIST: —
|
|
97
|
+
S_STEP_DRIFT — 产物 vs 目标偏离分析 PERSIST: step.drift_score
|
|
98
|
+
S_STEP_COMPLETE — 调 `ralph complete` 上报 PERSIST: step.completion_*
|
|
99
|
+
S_DECISION_EVAL — 启动分析 Agent 评估质量门 PERSIST: —
|
|
100
|
+
S_APPLY_VERDICT — 应用裁决 PERSIST: session.steps[]
|
|
101
|
+
S_SESSION_DONE — 所有 step 完成 PERSIST: session.status
|
|
102
|
+
S_HANDLE_FAIL — 处理失败 PERSIST: step.status
|
|
103
|
+
S_AMEND_GOAL — 修改 running session 目标 PERSIST: session.task_decomposition, .boundary_contract, .goal_changelog, .steps[]
|
|
104
|
+
S_FALLBACK — 请求用户输入 PERSIST: —
|
|
105
|
+
</states>
|
|
106
|
+
|
|
107
|
+
<transitions>
|
|
108
|
+
|
|
109
|
+
S_PARSE_ROUTE:
|
|
110
|
+
→ S_STATUS WHEN: intent == "status"
|
|
111
|
+
→ S_CONTINUE WHEN: intent == "continue"
|
|
112
|
+
→ S_AMEND_GOAL WHEN: amend_mode == true AND running session exists
|
|
113
|
+
→ S_FALLBACK WHEN: amend_mode == true AND no running session
|
|
114
|
+
→ S_DECISION_EVAL WHEN: running session with decision step in "running" status
|
|
115
|
+
→ S_RESOLVE_PHASE WHEN: intent is non-empty
|
|
116
|
+
→ S_FALLBACK WHEN: no intent AND no running session
|
|
117
|
+
|
|
118
|
+
S_STATUS:
|
|
119
|
+
→ END DO: A_SHOW_STATUS
|
|
120
|
+
|
|
121
|
+
S_CONTINUE:
|
|
122
|
+
→ S_STEP_LOCATE WHEN: running session found
|
|
123
|
+
→ S_FALLBACK WHEN: no running session
|
|
124
|
+
|
|
125
|
+
S_AMEND_GOAL:
|
|
126
|
+
→ S_STEP_LOCATE WHEN: change applied + user confirmed DO: A_AMEND_GOAL
|
|
127
|
+
→ END WHEN: user cancels
|
|
128
|
+
GUARD: RISK_LEVEL=high → auto_confirm 无效
|
|
129
|
+
|
|
130
|
+
S_CREATE_SESSION:
|
|
131
|
+
→ S_CONFIRM WHEN: not auto_confirm
|
|
132
|
+
→ S_STEP_LOCATE WHEN: auto_confirm
|
|
133
|
+
|
|
134
|
+
S_CONFIRM:
|
|
135
|
+
→ S_STEP_LOCATE WHEN: user confirms
|
|
136
|
+
→ S_BUILD_CHAIN WHEN: user edits
|
|
137
|
+
→ END WHEN: user cancels
|
|
138
|
+
|
|
139
|
+
S_STEP_LOCATE:
|
|
140
|
+
→ S_STEP_RESOLVE WHEN: pending execution step found (step.decision == null)
|
|
141
|
+
→ S_DECISION_EVAL WHEN: pending decision step found (step.decision != null)
|
|
142
|
+
→ S_SESSION_DONE WHEN: no pending steps (all completed/skipped)
|
|
143
|
+
→ S_HANDLE_FAIL WHEN: has failed step and no pending
|
|
144
|
+
→ S_FALLBACK WHEN: no running session
|
|
145
|
+
|
|
146
|
+
S_STEP_RESOLVE:
|
|
147
|
+
→ S_STEP_DISPATCH DO: A_STEP_RESOLVE_ARGS
|
|
148
|
+
|
|
149
|
+
S_STEP_DISPATCH:
|
|
150
|
+
→ S_STEP_WAIT_MSG WHEN: executor dispatched DO: A_STEP_DISPATCH
|
|
151
|
+
|
|
152
|
+
S_STEP_WAIT_MSG:
|
|
153
|
+
→ S_STEP_ANALYZE WHEN: received agent-message with EXECUTOR_OUTPUT DO: A_STEP_RECEIVE
|
|
154
|
+
→ S_HANDLE_FAIL WHEN: received agent-message with status=ERROR DO: A_STEP_RECEIVE
|
|
155
|
+
→ S_HANDLE_FAIL WHEN: executor idle without send_message(崩溃检测) DO: mark BLOCKED
|
|
156
|
+
|
|
157
|
+
S_STEP_ANALYZE:
|
|
158
|
+
→ S_STEP_DRIFT WHEN: STATUS == DONE|DONE_WITH_CONCERNS DO: A_STEP_EXTRACT
|
|
159
|
+
→ S_HANDLE_FAIL WHEN: STATUS == NEEDS_RETRY|BLOCKED DO: A_STEP_EXTRACT
|
|
160
|
+
|
|
161
|
+
S_STEP_DRIFT:
|
|
162
|
+
→ S_STEP_COMPLETE WHEN: ALIGNED|MINOR_DRIFT DO: A_STEP_DRIFT_ANALYZE
|
|
163
|
+
→ S_STEP_DISPATCH WHEN: MAJOR_DRIFT + not retried DO: A_STEP_DRIFT_ANALYZE (ralph retry + re-execute)
|
|
164
|
+
→ S_STEP_COMPLETE WHEN: MAJOR_DRIFT + retried DO: A_STEP_DRIFT_ANALYZE (DONE_WITH_CONCERNS)
|
|
165
|
+
|
|
166
|
+
S_STEP_COMPLETE:
|
|
167
|
+
→ S_STEP_LOCATE DO: A_STEP_COMPLETE (loop to next step)
|
|
168
|
+
|
|
169
|
+
S_DECISION_EVAL: (decision 节点 == `step.decision` 非空)
|
|
170
|
+
→ S_APPLY_VERDICT WHEN: quality-gate (post-execute, post-business-test, post-review, post-test, post-frontend-verify)
|
|
171
|
+
DO: A_AGENT_EVALUATE
|
|
172
|
+
→ S_APPLY_VERDICT WHEN: goal-gate (post-goal-audit)
|
|
173
|
+
DO: A_AGENT_GOAL_AUDIT
|
|
174
|
+
→ S_APPLY_VERDICT WHEN: scope-gate (post-analyze-scope)
|
|
175
|
+
DO: A_SCOPE_EVALUATE
|
|
176
|
+
→ S_APPLY_VERDICT WHEN: reground-gate (post-reground)
|
|
177
|
+
DO: A_AGENT_REGROUND
|
|
178
|
+
→ S_APPLY_VERDICT WHEN: structural (post-milestone, post-debug-escalate)
|
|
179
|
+
DO: A_STRUCTURAL_EVALUATE
|
|
180
|
+
|
|
181
|
+
S_APPLY_VERDICT:
|
|
182
|
+
→ S_STEP_LOCATE WHEN: verdict == "proceed" DO: A_APPLY_PROCEED
|
|
183
|
+
→ S_STEP_LOCATE WHEN: post-goal-audit + has_unmet DO: A_APPLY_GOAL_FIX
|
|
184
|
+
→ S_STEP_LOCATE WHEN: post-goal-audit + all_met + INTENT_ALIGNED=true DO: A_APPLY_GOAL_DONE
|
|
185
|
+
→ END WHEN: post-goal-audit + all_met + INTENT_ALIGNED=false DO: A_REGROUND_HALT
|
|
186
|
+
→ S_STEP_LOCATE WHEN: post-analyze-scope DO: A_APPLY_SCOPE_VERDICT
|
|
187
|
+
→ S_STEP_LOCATE WHEN: verdict == "fix" DO: A_APPLY_FIX
|
|
188
|
+
→ S_STEP_LOCATE WHEN: verdict == "escalate" DO: A_APPLY_ESCALATE
|
|
189
|
+
→ S_STEP_LOCATE WHEN: post-milestone + standard + next milestone DO: A_ADVANCE_MILESTONE
|
|
190
|
+
→ END WHEN: post-milestone + standard + no next milestone
|
|
191
|
+
→ END WHEN: post-milestone + adhoc DO: mark completed (set current_milestone = null)
|
|
192
|
+
→ END WHEN: post-debug-escalate DO: A_PAUSE_ESCALATE
|
|
193
|
+
→ END WHEN: post-reground + drifted + confidence >= 60 DO: A_REGROUND_HALT
|
|
194
|
+
→ S_STEP_LOCATE WHEN: post-reground + aligned DO: A_APPLY_PROCEED
|
|
195
|
+
→ S_STEP_LOCATE WHEN: post-reground + drifted + confidence < 60 DO: A_APPLY_PROCEED (标 LOW CONFIDENCE)
|
|
196
|
+
GUARD: retry_count >= max_retries → force escalate
|
|
197
|
+
GUARD: confidence_score < 60 AND proceed → override to fix
|
|
198
|
+
GUARD: confidence_score > 95 AND fix AND retry > 0 → suggest proceed
|
|
199
|
+
GUARD: auto_confirm → skip user prompt, apply adjusted verdict
|
|
200
|
+
GUARD: not auto_confirm → ask_user with override options
|
|
201
|
+
GUARD: post-reground + drifted + confidence >= 60 → A_REGROUND_HALT(auto_confirm 不跳过)
|
|
202
|
+
|
|
203
|
+
S_HANDLE_FAIL:
|
|
204
|
+
→ S_STEP_LOCATE WHEN: auto + not retried DO: A_RETRY
|
|
205
|
+
→ END WHEN: auto + retried DO: A_PAUSE_SESSION
|
|
206
|
+
→ S_STEP_LOCATE WHEN: interactive + retry
|
|
207
|
+
→ S_STEP_LOCATE WHEN: interactive + skip
|
|
208
|
+
→ END WHEN: interactive + abort
|
|
209
|
+
|
|
210
|
+
S_SESSION_DONE:
|
|
211
|
+
→ END DO: A_COMPLETE_SESSION
|
|
212
|
+
|
|
213
|
+
</transitions>
|
|
214
|
+
|
|
215
|
+
<actions>
|
|
216
|
+
|
|
217
|
+
### A_CREATE_SESSION
|
|
218
|
+
1. `session_id` format: `ralph-v2-{YYYYMMDD-HHmmss}`
|
|
219
|
+
2. Additional fields: `execution_mode: "agent"`,无 `cli_tool` 字段
|
|
220
|
+
3. Each step: `agent_exec_name: null`(执行 Agent 名称标识)
|
|
221
|
+
4. Step mode/role/rule assigned per stage (see Stage Mapping table)
|
|
222
|
+
|
|
223
|
+
### A_STEP_RESOLVE_ARGS
|
|
224
|
+
|
|
225
|
+
解析占位符 + 丰富参数。在 `ralph next` 之前执行。
|
|
226
|
+
|
|
227
|
+
**1. Placeholder substitution:**
|
|
228
|
+
|
|
229
|
+
| Placeholder | Source |
|
|
230
|
+
|-------------|--------|
|
|
231
|
+
| `{phase}` | session.phase |
|
|
232
|
+
| `{milestone}` | session.milestone |
|
|
233
|
+
| `{intent}` | session.intent |
|
|
234
|
+
| `{description}` | session.intent (alias) |
|
|
235
|
+
| `{scratch_dir}` | session.context.scratch_dir or latest artifact path |
|
|
236
|
+
| `{plan_dir}` | session.context.plan_dir |
|
|
237
|
+
| `{analysis_dir}` | session.context.analysis_dir |
|
|
238
|
+
| `{issue_id}` | session.context.issue_id |
|
|
239
|
+
| `{milestone_num}` | session.context.milestone_num |
|
|
240
|
+
|
|
241
|
+
**2. Per-skill enrichment** (when args empty or minimal):
|
|
242
|
+
|
|
243
|
+
| Skill | Required context | Source |
|
|
244
|
+
|-------|-----------------|--------|
|
|
245
|
+
| maestro-brainstorm | topic | `"{intent}"` |
|
|
246
|
+
| maestro-roadmap | description | `"{intent}"` |
|
|
247
|
+
| maestro-analyze | phase or topic | `{phase}` or `"{intent}"` |
|
|
248
|
+
| maestro-plan | phase, --from, or --dir | see --from auto-injection below |
|
|
249
|
+
| maestro-execute | phase or --dir | see --from auto-injection below |
|
|
250
|
+
| quality-debug | gap context | Read previous step's error/gap |
|
|
251
|
+
| quality-* | phase | `{phase}` |
|
|
252
|
+
|
|
253
|
+
**3. --from auto-injection (phase-level artifact chaining):**
|
|
254
|
+
|
|
255
|
+
```
|
|
256
|
+
Read state.json.artifacts(含 milestone_history 内归档 artifacts)
|
|
257
|
+
→ filter by milestone={session.milestone} + phase={session.phase} + status=="completed"
|
|
258
|
+
|
|
259
|
+
plan step(含 {phase} 占位符,args 无 --from 且无 --dir):
|
|
260
|
+
1. 查同 phase+milestone 最新 completed type=="analyze" artifact → id = ANL-xxx
|
|
261
|
+
2. 命中 → args 追加 --from analyze:{id}
|
|
262
|
+
3. 写 step.source_artifact_ref = "analyze:{id}"
|
|
263
|
+
|
|
264
|
+
execute step(含 {phase} 占位符,args 无 --dir):
|
|
265
|
+
1. 查同 phase+milestone 最新 completed type=="plan" artifact → id = PLN-xxx, path = scratch/...
|
|
266
|
+
2. 命中 → args 追加 --dir .workflow/scratch/{path}
|
|
267
|
+
3. 写 step.source_artifact_ref = "plan:{id}"
|
|
268
|
+
```
|
|
269
|
+
|
|
270
|
+
兜底:查询无结果 → 不注入,由命令自身 discovery 逻辑处理。已有 `--from` 或 `--dir` 的 step 不覆盖。
|
|
271
|
+
|
|
272
|
+
**4. Goal context injection:**
|
|
273
|
+
|
|
274
|
+
当 `step.goal_ref` 非空且 `session.task_decomposition` 存在时:
|
|
275
|
+
```
|
|
276
|
+
goal = session.task_decomposition.find(g => g.id == step.goal_ref)
|
|
277
|
+
if goal:
|
|
278
|
+
goal_snippet = { id: goal.id, goal: goal.goal, done_when: goal.done_when,
|
|
279
|
+
boundary: goal.boundary, evidence: goal.evidence }
|
|
280
|
+
→ 传递给 A_STEP_DISPATCH 注入 agent prompt
|
|
281
|
+
```
|
|
282
|
+
|
|
283
|
+
**5. Write** enriched args + source_artifact_ref back to status.json.
|
|
284
|
+
|
|
285
|
+
### A_STEP_DISPATCH
|
|
286
|
+
|
|
287
|
+
加载前序产出 + 组装上下文 + 派发 executor agent 执行单步。Agent 内部调 `maestro ralph next` 获取 skill prompt 并执行。
|
|
288
|
+
|
|
289
|
+
**1. Load previous step context:**
|
|
290
|
+
|
|
291
|
+
- 读前一 completed step 的 `completion_summary` + `completion_caveats` + `completion_decisions` + `completion_deferred`
|
|
292
|
+
- 按 `session.context` 中的路径逐个 Read,提取与当前 step 相关的内容:
|
|
293
|
+
|
|
294
|
+
| 当前 stage | 加载什么 | Source |
|
|
295
|
+
|-----------|---------|--------|
|
|
296
|
+
| plan | analysis conclusions + scope_verdict | `{context.analysis_dir}/conclusions.json` |
|
|
297
|
+
| execute | task list + wave assignments | `{context.plan_dir}/TASK-*.json` |
|
|
298
|
+
| review | changed files + verification results | `{context.scratch_dir}/verification.json` |
|
|
299
|
+
| test | review findings | `review.json` |
|
|
300
|
+
| debug | error traces + failing test details | 前一 step 的 `completion_evidence` |
|
|
301
|
+
| brainstorm | grill report | `{context.grill_id}` report |
|
|
302
|
+
|
|
303
|
+
- Explore if needed — 产物指向代码位置但缺少上下文 → `maestro explore` 补充(仅 execute/debug/test 且有文件路径引用时)
|
|
304
|
+
- Accumulated signals — 遍历 ALL completed steps → 聚合 caveats + deferred
|
|
305
|
+
|
|
306
|
+
**2. Goal context pre-injection:**
|
|
307
|
+
|
|
308
|
+
- GUARD: `ralph_protocol_version >= "2"` → skip(session_anchor 已含 goal context)
|
|
309
|
+
- WHEN `ralph_protocol_version < "2"` 或缺失 AND `step.goal_ref` 非空 → 组装 `<goal_context>` 块注入 prompt:
|
|
310
|
+
```
|
|
311
|
+
<goal_context>
|
|
312
|
+
Sub-goal: {goal.id} — {goal.goal}
|
|
313
|
+
Done when: {goal.done_when}
|
|
314
|
+
Boundary: {goal.boundary}
|
|
315
|
+
Evidence target: {goal.evidence}
|
|
316
|
+
Execution criteria: {session.execution_criteria joined by '; '}
|
|
317
|
+
</goal_context>
|
|
318
|
+
```
|
|
319
|
+
|
|
320
|
+
**3. Resolve agent name:** `{stage_prefix}-{session_id_short}-{HHmmss}`
|
|
321
|
+
|
|
322
|
+
| Stage | Prefix |
|
|
323
|
+
|-------|--------|
|
|
324
|
+
| grill | `grl` |
|
|
325
|
+
| brainstorm | `brn` |
|
|
326
|
+
| analyze-macro | `anm` |
|
|
327
|
+
| analyze | `ana` |
|
|
328
|
+
| plan | `pln` |
|
|
329
|
+
| execute | `exe` |
|
|
330
|
+
| review | `rev` |
|
|
331
|
+
| test | `tst` |
|
|
332
|
+
| debug | `dbg` |
|
|
333
|
+
| Other | `run` |
|
|
334
|
+
|
|
335
|
+
**4. Dispatch(named mailbox executor):**
|
|
336
|
+
|
|
337
|
+
> 执行 Agent 使用 `name` 参数派发为 named mailbox teammate,支持内部多 agent 编排。executor 通过 `send_message({to: "main"})` 回传执行结果。`resolved_agent_name` 同时用于 display 和 Agent `name` 参数。
|
|
338
|
+
|
|
339
|
+
```
|
|
340
|
+
delegate_subagent({
|
|
341
|
+
name: "{resolved_agent_name}",
|
|
342
|
+
subagent_type: "ralph-executor",
|
|
343
|
+
description: "执行 step {index}: {step.skill}",
|
|
344
|
+
prompt: `Session: {session_id}
|
|
345
|
+
Agent name: {resolved_agent_name}
|
|
346
|
+
|
|
347
|
+
{goal_context 块,仅 protocol < 2 时}
|
|
348
|
+
|
|
349
|
+
{loaded_step_context}
|
|
350
|
+
`
|
|
351
|
+
})
|
|
352
|
+
```
|
|
353
|
+
|
|
354
|
+
5. Write `step.agent_exec_name` to status.json
|
|
355
|
+
6. Display: `[{index}/{total}] ⟶ {step.skill} → {resolved_agent_name}`
|
|
356
|
+
7. delegate_subagent() 立即返回(named teammate 异步启动)→ 进入 S_STEP_WAIT_MSG 等待 executor 的 send_message
|
|
357
|
+
|
|
358
|
+
### A_STEP_RECEIVE
|
|
359
|
+
|
|
360
|
+
从 executor 的 `agent-message` 中提取执行输出。
|
|
361
|
+
|
|
362
|
+
1. 接收到 `<agent-message from="{resolved_agent_name}">` 后,提取 message 内容
|
|
363
|
+
2. 解析 `EXECUTOR_OUTPUT` 格式:
|
|
364
|
+
- `status: DONE` → agent_output = message 内容,继续 S_STEP_ANALYZE
|
|
365
|
+
- `status: DONE_WITH_CONCERNS` → agent_output = message 内容,继续 S_STEP_ANALYZE
|
|
366
|
+
- `status: ERROR` → STATUS=BLOCKED,转 S_HANDLE_FAIL
|
|
367
|
+
3. idle_notification 处理(区分正常等待与崩溃):
|
|
368
|
+
- 首次收到 `idle_notification`:executor 可能在等待 worker 回传,正常现象,继续等待
|
|
369
|
+
- 连续收到 2 次 `idle_notification` 且中间无 `agent-message`:向 executor 发送 `send_message({to: "{resolved_agent_name}", message: "请回报执行状态"})` 询问
|
|
370
|
+
- 询问后仍只收到 `idle_notification` 无 `agent-message`:STATUS=BLOCKED,转 S_HANDLE_FAIL
|
|
371
|
+
4. `agent_output` = 提取的 message 内容
|
|
372
|
+
|
|
373
|
+
### A_STEP_EXTRACT
|
|
374
|
+
|
|
375
|
+
从 agent 返回的执行输出中提取结构化信号,用于 completion 参数组装。
|
|
376
|
+
|
|
377
|
+
**1. Stage-specific signal extraction:**
|
|
378
|
+
|
|
379
|
+
| Stage | 提取什么 | 写入字段 |
|
|
380
|
+
|-------|---------|---------|
|
|
381
|
+
| analyze | `conclusions.json` scope_verdict + key_findings | `--summary`, context.analysis_dir |
|
|
382
|
+
| plan | TASK-*.json 数量 + 主要模块 + 波次 | `--summary`, context.plan_dir |
|
|
383
|
+
| execute | 修改文件数 + verification passed/failed | `--summary`, `--evidence`, context.scratch_dir |
|
|
384
|
+
| review | verdict + findings 数量 + severity | `--summary`, `--decisions` |
|
|
385
|
+
| test | pass/fail 统计 | `--summary`, `--evidence` |
|
|
386
|
+
| debug | root cause + 修复内容 | `--summary`, `--decisions` |
|
|
387
|
+
| grill | 核心质疑点数量 | `--summary`, `--caveats`, context.grill_id |
|
|
388
|
+
| brainstorm | 候选方案数 + 推荐方案 | `--summary`, `--decisions`, context.brainstorm_dir |
|
|
389
|
+
|
|
390
|
+
**2. Artifact scanning** — Use Glob 查找执行期间新增/修改的产物:
|
|
391
|
+
|
|
392
|
+
| Pattern | Signal |
|
|
393
|
+
|---------|--------|
|
|
394
|
+
| `conclusions.json` | `analysis_dir` |
|
|
395
|
+
| `TASK-*.json` | `plan_dir` |
|
|
396
|
+
| `verification.json` | `scratch_dir` |
|
|
397
|
+
| `review.json` | review stage |
|
|
398
|
+
| `test-results.json`, `uat.md` | test stage |
|
|
399
|
+
| `grill-report.md` | `grill_id` |
|
|
400
|
+
| `.brainstorming/*` | `brainstorm_dir` |
|
|
401
|
+
|
|
402
|
+
**3. Output text signal extraction** — 从执行输出文本中提取:
|
|
403
|
+
|
|
404
|
+
| Signal pattern | 写入 |
|
|
405
|
+
|----------------|------|
|
|
406
|
+
| `ANL-xxx` (artifact ID) | `session.analyze_macro_id` |
|
|
407
|
+
| `PLN-xxx` (artifact ID) | `context.plan_dir` |
|
|
408
|
+
| `BLP-xxx` (artifact ID) | `session.blueprint_id` |
|
|
409
|
+
| `scratch_dir:` 或 `.workflow/scratch/` 路径 | `context.scratch_dir` |
|
|
410
|
+
| `plan_dir:` 路径 | `context.plan_dir` |
|
|
411
|
+
| `PHASE: N` | `session.context.phase` |
|
|
412
|
+
|
|
413
|
+
**4. STATUS determination:**
|
|
414
|
+
|
|
415
|
+
| 条件 | STATUS |
|
|
416
|
+
|------|--------|
|
|
417
|
+
| Skill 正常完成 + 有产物 | `DONE` |
|
|
418
|
+
| 完成但有 warnings/concerns | `DONE_WITH_CONCERNS` |
|
|
419
|
+
| 执行出错但可重试(临时错误、网络问题) | `NEEDS_RETRY` |
|
|
420
|
+
| 执行出错且无法重试(schema 错误、command_path 不可达) | `BLOCKED` |
|
|
421
|
+
| Agent 返回 null(崩溃/超时) | `BLOCKED` |
|
|
422
|
+
|
|
423
|
+
**5. Compose completion params:**
|
|
424
|
+
|
|
425
|
+
| Param | 规则 | 组装方法 |
|
|
426
|
+
|-------|------|---------|
|
|
427
|
+
| `--summary` | MUST。动词开头,≤100 字 | `"<动词><做了什么>,<量化结果>"` |
|
|
428
|
+
| `--decisions` | SHOULD。每条一个架构/技术决策 | 从执行中做出的非显而易见的选择 |
|
|
429
|
+
| `--caveats` | SHOULD。后续 step 须知 | 发现但不属于本步解决的问题 |
|
|
430
|
+
| `--deferred` | SHOULD。推迟工作项 | 被主动推迟的项 |
|
|
431
|
+
| `--evidence` | SHOULD。验证产物路径 | 指向验证结果文件 |
|
|
432
|
+
| `--concerns` | COND。仅 DONE_WITH_CONCERNS 时 | CAVEATS 内容同时映射为 --concerns |
|
|
433
|
+
|
|
434
|
+
### A_STEP_DRIFT_ANALYZE
|
|
435
|
+
|
|
436
|
+
产物 vs 目标偏离分析。A_STEP_EXTRACT 后、A_STEP_COMPLETE 前执行。
|
|
437
|
+
|
|
438
|
+
**1. 收集对照基准:**
|
|
439
|
+
|
|
440
|
+
| 基准来源 | 取值 |
|
|
441
|
+
|---------|------|
|
|
442
|
+
| `step.goal_ref` → goal.done_when | 子目标完成条件 |
|
|
443
|
+
| `session.boundary_contract.definition_of_done` | 全局验收标准 |
|
|
444
|
+
| `session.execution_criteria` | 执行准则 |
|
|
445
|
+
| `session.intent` | 原始意图 |
|
|
446
|
+
|
|
447
|
+
**2. 对比评分:**
|
|
448
|
+
|
|
449
|
+
| 维度 | 检查 |
|
|
450
|
+
|------|------|
|
|
451
|
+
| 覆盖度 | 产物是否覆盖 goal.done_when 每个条件 |
|
|
452
|
+
| 方向性 | decisions 是否与 intent/boundary 一致 |
|
|
453
|
+
| 完整性 | 预期产物类型是否齐全 |
|
|
454
|
+
|
|
455
|
+
**drift_score:**
|
|
456
|
+
- `ALIGNED` — 全部维度通过
|
|
457
|
+
- `MINOR_DRIFT` — 小缺口,不影响后续
|
|
458
|
+
- `MAJOR_DRIFT` — 方向性偏离或关键产物缺失
|
|
459
|
+
|
|
460
|
+
**3. 修正动作:**
|
|
461
|
+
|
|
462
|
+
| drift_score | 动作 |
|
|
463
|
+
|-------------|------|
|
|
464
|
+
| ALIGNED | 正常进入 S_STEP_COMPLETE |
|
|
465
|
+
| MINOR_DRIFT | 偏离项追加到 caveats,正常 complete |
|
|
466
|
+
| MAJOR_DRIFT + 未重试 | `shell("maestro ralph retry {index}")` → 回到 S_STEP_DISPATCH 重执行(drift_correction 作修正上下文注入 prompt) |
|
|
467
|
+
| MAJOR_DRIFT + 已重试 | 以 DONE_WITH_CONCERNS complete |
|
|
468
|
+
|
|
469
|
+
**4. 写入:** `step.drift_score`, `step.drift_correction`
|
|
470
|
+
|
|
471
|
+
### A_STEP_COMPLETE
|
|
472
|
+
|
|
473
|
+
调 `ralph complete` 上报 + 传播上下文信号 + 循环。
|
|
474
|
+
|
|
475
|
+
1. 使用 A_STEP_EXTRACT 组装的参数调用 `ralph complete`:
|
|
476
|
+
```
|
|
477
|
+
shell("maestro ralph complete {index} --status DONE --summary \"{SUMMARY}\" [--evidence ...] [--decisions ...] [--caveats ...] [--deferred ...]")
|
|
478
|
+
```
|
|
479
|
+
DONE_WITH_CONCERNS 时 caveats 同时映射 `--concerns`。BLOCKED 时用 `--reason`。
|
|
480
|
+
|
|
481
|
+
2. **Context signals propagation** — 将关键信号写入 `status.json.context`:
|
|
482
|
+
|
|
483
|
+
| Signal | 写入字段 |
|
|
484
|
+
|--------|---------|
|
|
485
|
+
| `analysis_dir` | `context.analysis_dir` |
|
|
486
|
+
| `plan_dir` | `context.plan_dir` |
|
|
487
|
+
| `scratch_dir` | `context.scratch_dir` |
|
|
488
|
+
| `grill_id` | `context.grill_id` |
|
|
489
|
+
| `brainstorm_dir` | `context.brainstorm_dir` |
|
|
490
|
+
| `blueprint_dir` | `context.blueprint_dir` |
|
|
491
|
+
| `ANL-xxx` | `session.analyze_macro_id` |
|
|
492
|
+
| `BLP-xxx` | `session.blueprint_id` |
|
|
493
|
+
| `phase` | `session.context.phase` |
|
|
494
|
+
|
|
495
|
+
3. Display: `[{index}/{total}] ✓ {step.skill} → {SUMMARY}`
|
|
496
|
+
4. Loop back to S_STEP_LOCATE
|
|
497
|
+
|
|
498
|
+
### A_AGENT_EVALUATE
|
|
499
|
+
|
|
500
|
+
通过 Agent 和/或 CLI delegate 评估质量门。评估模式由 `step.evaluate_via` 决定。
|
|
501
|
+
|
|
502
|
+
**1. Common setup:**
|
|
503
|
+
|
|
504
|
+
1. Resolve artifact dir: `.workflow/scratch/{artifact.path}/` with fallback glob
|
|
505
|
+
2. Parse decision metadata: `{ decision, retry_count, max_retries, evaluate_via }`
|
|
506
|
+
3. Map result files:
|
|
507
|
+
|
|
508
|
+
| Decision | Files |
|
|
509
|
+
|----------|-------|
|
|
510
|
+
| post-execute | verification.json |
|
|
511
|
+
| post-business-test | .tests/auto-test/report.json |
|
|
512
|
+
| post-review | review.json |
|
|
513
|
+
| post-test | uat.md, .tests/test-results.json |
|
|
514
|
+
| post-frontend-verify | e2e-results.json |
|
|
515
|
+
|
|
516
|
+
4. `evaluate_via` 默认值:`"agent"`(未设置时)
|
|
517
|
+
|
|
518
|
+
**2. Dispatch by mode:**
|
|
519
|
+
|
|
520
|
+
**Mode: `agent`(默认)** — 同步 Agent 评估:
|
|
521
|
+
|
|
522
|
+
```
|
|
523
|
+
delegate_subagent({
|
|
524
|
+
description: "评估 {decision} 质量门(同步评估 Agent,不传 name)",
|
|
525
|
+
prompt: "PURPOSE: 评估 {decision} 质量门结果
|
|
526
|
+
TASK: 读取以下结果文件 | 分析状态 | 评估严重性 | 给出建议
|
|
527
|
+
FILES: {result_file_paths}
|
|
528
|
+
SESSION: {session_dir}/status.json
|
|
529
|
+
EXPECTED: 输出以下格式:
|
|
530
|
+
---VERDICT---
|
|
531
|
+
STATUS: PASS|FAIL|PARTIAL|BLOCKED
|
|
532
|
+
REASON: <一句话原因>
|
|
533
|
+
GAP_SUMMARY: <差距摘要>
|
|
534
|
+
CONFIDENCE: high|medium|low
|
|
535
|
+
CONFIDENCE_SCORE: 0-100
|
|
536
|
+
WEAKEST_DIMENSION: <最弱维度>
|
|
537
|
+
---END---
|
|
538
|
+
CONSTRAINTS: 只评估不修改文件 | 置信度<60%倾向 fix | retry {n}/{max} 达上限必须 escalate"
|
|
539
|
+
})
|
|
540
|
+
```
|
|
541
|
+
|
|
542
|
+
**Mode: `cli`** — CLI delegate 评估(异步后台):
|
|
543
|
+
|
|
544
|
+
```
|
|
545
|
+
shell({
|
|
546
|
+
command: `maestro delegate "PURPOSE: 评估 ${decision} 质量门结果\nTASK: 读取 ${result_file_paths} | 分析状态 | 评估严重性\nEXPECTED: ---VERDICT--- 格式(STATUS/REASON/GAP_SUMMARY/CONFIDENCE_SCORE)\nCONSTRAINTS: 只评估不修改文件" --mode analysis --rule analysis-review-code-quality`,
|
|
547
|
+
run_in_background: true
|
|
548
|
+
})
|
|
549
|
+
```
|
|
550
|
+
等待 delegate 完成 → `maestro delegate output {exec_id}` 获取结果 → 解析 `---VERDICT---`
|
|
551
|
+
|
|
552
|
+
**Mode: `dual`** — Agent + CLI 并行评估,交叉验证:
|
|
553
|
+
|
|
554
|
+
1. 先派发 CLI delegate(`run_in_background: true`)
|
|
555
|
+
2. 同时派发同步 Agent(阻塞等待)
|
|
556
|
+
3. Agent 返回后,检查 CLI delegate 状态(`maestro delegate status {exec_id}`)
|
|
557
|
+
4. 合并裁决:
|
|
558
|
+
|
|
559
|
+
| Agent 结果 | CLI 结果 | 合并策略 |
|
|
560
|
+
|-----------|---------|---------|
|
|
561
|
+
| 两者一致 | — | 采用共识,confidence_score 取较高值 |
|
|
562
|
+
| Agent=PASS, CLI=FAIL | — | 降级为 PARTIAL,confidence_score 取平均值 |
|
|
563
|
+
| Agent=FAIL, CLI=PASS | — | 维持 FAIL(保守策略) |
|
|
564
|
+
| CLI 未返回 | — | 使用 Agent 结果,标 `"cli_pending": true` |
|
|
565
|
+
|
|
566
|
+
**3. Verdict parse + adjustment(所有模式通用):**
|
|
567
|
+
|
|
568
|
+
5. 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)
|
|
569
|
+
6. Confidence adjustment: <60 + proceed → fix; >95 + fix + retry>0 → suggest proceed
|
|
570
|
+
7. **Decision log**: Append to `{session_dir}/decisions.ndjson`:
|
|
571
|
+
```json
|
|
572
|
+
{ "id": "DEC-{timestamp}", "timestamp": "{ISO}", "source": "ralph-v2",
|
|
573
|
+
"node_id": "{step.decision}", "type": "quality-gate",
|
|
574
|
+
"evaluate_via": "{mode}", "cli_exec_id": "{exec_id|null}",
|
|
575
|
+
"verdict": "{adjusted_verdict}", "confidence_score": {N},
|
|
576
|
+
"parse_failed": false,
|
|
577
|
+
"close_call": {N>=50 && N<=70}, "summary": "{REASON}" }
|
|
578
|
+
```
|
|
579
|
+
|
|
580
|
+
### A_AGENT_GOAL_AUDIT
|
|
581
|
+
|
|
582
|
+
通过 Agent 和/或 CLI delegate 审计子目标完成情况。支持 `evaluate_via` 三种模式(同 A_AGENT_EVALUATE)。
|
|
583
|
+
|
|
584
|
+
1. Read `session.task_decomposition` from status.json
|
|
585
|
+
2. Dispatch audit(按 `evaluate_via` 模式,默认 `agent`):
|
|
586
|
+
```
|
|
587
|
+
delegate_subagent({
|
|
588
|
+
description: "审计子目标完成情况(同步评估 Agent,不传 name)",
|
|
589
|
+
prompt: "PURPOSE: 审计未完成子目标,判定 met / unmet
|
|
590
|
+
TASK:
|
|
591
|
+
1. 读取 {session_dir}/status.json 中 task_decomposition 的 status!=done 子目标
|
|
592
|
+
2. 打开 evidence 产物,对照 done_when 严格判定
|
|
593
|
+
3. 输出 met / unmet,unmet 给出 gap + target_phase
|
|
594
|
+
4. 对照 intent + definition_of_done 判定意图保真
|
|
595
|
+
CONTEXT:
|
|
596
|
+
status.json = {session_dir}/status.json
|
|
597
|
+
intent = {session.intent}
|
|
598
|
+
definition_of_done = {boundary_contract.definition_of_done}
|
|
599
|
+
execution_criteria = {execution_criteria}
|
|
600
|
+
boundary_contract = {boundary_contract}
|
|
601
|
+
EXPECTED:
|
|
602
|
+
---VERDICT---
|
|
603
|
+
STATUS: all_met|has_unmet
|
|
604
|
+
INTENT_ALIGNED: true|false
|
|
605
|
+
UNMET: [{id:G2,gap:'...',target_phase:execute}, ...]
|
|
606
|
+
CONFIDENCE_SCORE: 0-100
|
|
607
|
+
---END---
|
|
608
|
+
CONSTRAINTS: 只评估不修改文件 | 严格按 done_when 判定 | evidence 缺失→unmet"
|
|
609
|
+
})
|
|
610
|
+
```
|
|
611
|
+
3. On return: parse verdict, update task_decomposition status
|
|
612
|
+
4. Append `{session_dir}/decisions.ndjson`:`{ "type": "goal-gate", "evaluate_via": "{mode}", "unmet_count": N, "unmet_ids": [...] }`
|
|
613
|
+
5. Verdict routing: `all_met` + `INTENT_ALIGNED=true` → A_APPLY_GOAL_DONE;`all_met` + `INTENT_ALIGNED=false` → A_REGROUND_HALT;`has_unmet` → A_APPLY_GOAL_FIX
|
|
614
|
+
GUARD: retry_count >= max_retries AND still unmet → A_APPLY_ESCALATE
|
|
615
|
+
|
|
616
|
+
### A_AGENT_REGROUND
|
|
617
|
+
|
|
618
|
+
通过 Agent 和/或 CLI delegate 执行意图保真检查。支持 `evaluate_via` 三种模式(同 A_AGENT_EVALUATE)。
|
|
619
|
+
|
|
620
|
+
1. Read status.json:intent, boundary_contract, completed steps, done goals
|
|
621
|
+
2. Dispatch reground(按 `evaluate_via` 模式,默认 `agent`):
|
|
622
|
+
```
|
|
623
|
+
delegate_subagent({
|
|
624
|
+
description: "意图保真检查(同步评估 Agent,不传 name)",
|
|
625
|
+
prompt: "PURPOSE: 意图保真检查 — 对照 intent 验证累积执行是否漂移
|
|
626
|
+
TASK:
|
|
627
|
+
1. 读取 intent + boundary_contract.definition_of_done
|
|
628
|
+
2. 读取已完成 steps 的 completion_evidence + 已 done 子目标
|
|
629
|
+
3. 判定累积产出是否仍服务 intent
|
|
630
|
+
4. 输出 aligned / drifted + drift_description + corrective_action
|
|
631
|
+
CONTEXT:
|
|
632
|
+
status.json = {session_dir}/status.json
|
|
633
|
+
intent = {session.intent}
|
|
634
|
+
definition_of_done = {boundary_contract.definition_of_done}
|
|
635
|
+
in_scope = {boundary_contract.in_scope}
|
|
636
|
+
out_of_scope = {boundary_contract.out_of_scope}
|
|
637
|
+
goal_changelog = {session.goal_changelog ?? []}
|
|
638
|
+
EXPECTED:
|
|
639
|
+
---VERDICT---
|
|
640
|
+
STATUS: aligned|drifted
|
|
641
|
+
DRIFT_DESCRIPTION: <空或具体描述>
|
|
642
|
+
CORRECTIVE_ACTION: <空或建议>
|
|
643
|
+
CONFIDENCE_SCORE: 0-100
|
|
644
|
+
---END---
|
|
645
|
+
CONSTRAINTS: 只评估不修改文件 | aligned 阈值≥80% | 单个 step 触碰 out_of_scope→直接 drifted"
|
|
646
|
+
})
|
|
647
|
+
```
|
|
648
|
+
3. On return: parse verdict
|
|
649
|
+
4. Append `{session_dir}/decisions.ndjson`
|
|
650
|
+
5. Verdict routing:aligned → A_APPLY_PROCEED;drifted + confidence >= 60 → A_REGROUND_HALT;drifted + confidence < 60 → A_APPLY_PROCEED (LOW CONFIDENCE)
|
|
651
|
+
|
|
652
|
+
### A_SCOPE_EVALUATE
|
|
653
|
+
|
|
654
|
+
仅由 `post-analyze-scope` 决策节点触发。
|
|
655
|
+
|
|
656
|
+
1. 定位刚完成的 macro analyze artifact → `analyze_macro_id`, `conclusions_path`
|
|
657
|
+
2. 读取 `conclusions.scope_verdict`(`large | medium | small`),缺失 → `unknown`
|
|
658
|
+
3. 写入 `session.scope_verdict` + `session.analyze_macro_id`
|
|
659
|
+
4. Append `{session_dir}/decisions.ndjson`:`{ "type": "scope-gate", "source": "ralph-v2", "verdict": "{scope_verdict}", "analyze_macro_id": "{ANL_ID}" }`
|
|
660
|
+
|
|
661
|
+
### A_STRUCTURAL_EVALUATE
|
|
662
|
+
|
|
663
|
+
**post-milestone:**
|
|
664
|
+
1. Read state.json → resolve milestone type(default `"standard"`)
|
|
665
|
+
2. Standard milestone:next milestone exists → insert lifecycle steps / complete
|
|
666
|
+
3. Adhoc milestone(`type == "adhoc"`):always END,set `current_milestone = null`
|
|
667
|
+
|
|
668
|
+
**post-debug-escalate:** always → A_PAUSE_ESCALATE
|
|
669
|
+
|
|
670
|
+
### A_SHOW_STATUS
|
|
671
|
+
|
|
672
|
+
1. Find latest `ralph-v2-*` session(by created_at)
|
|
673
|
+
2. Display: Session, Status, Position, Progress, Current step
|
|
674
|
+
3. List steps: [✓] confirmed, [▸] current, [ ] pending, [◆] decision;执行 step 附 `command_scope` + `command_path`
|
|
675
|
+
4. If `task_decomposition` present → 显示 sub-goals 进度(done/total)
|
|
676
|
+
|
|
677
|
+
### A_APPLY_PROCEED / A_APPLY_FIX / A_APPLY_ESCALATE
|
|
678
|
+
|
|
679
|
+
- **A_APPLY_PROCEED**: Mark decision completed, write status.json
|
|
680
|
+
- **A_APPLY_FIX**: Insert fix-loop steps after current step(见 Fix-Loop Templates),reindex,increment retry_count
|
|
681
|
+
- **A_APPLY_ESCALATE**: Insert `[quality-debug "{gap_summary}", decision:post-debug-escalate]`,reindex
|
|
682
|
+
|
|
683
|
+
### A_APPLY_SCOPE_VERDICT
|
|
684
|
+
|
|
685
|
+
依据 `session.scope_verdict` + `session.wants_roadmap` 重塑下游链路:
|
|
686
|
+
|
|
687
|
+
1. 路径 A(`large` 且 `wants_roadmap`):保持 roadmap+analyze,`plan` 选 phase 列
|
|
688
|
+
2. 路径 B(`medium`/`small`,或 `large` 非 `wants_roadmap`):删除未完成的 `roadmap` + `analyze` step,`plan` 改为 `--from analyze:{ANL_ID}`
|
|
689
|
+
3. 路径 C(`unknown`):非 auto_confirm → ask_user;auto_confirm → 默认路径 B
|
|
690
|
+
4. Reindex steps,标 decision completed
|
|
691
|
+
|
|
692
|
+
### A_APPLY_GOAL_FIX / A_APPLY_GOAL_DONE
|
|
693
|
+
|
|
694
|
+
- **A_APPLY_GOAL_FIX**: 对每个 unmet 子目标插入 scoped mini-loop(plan --gaps + execute),`goal_ref` 标注,重新追加 `decision:post-goal-audit {retry+1}`
|
|
695
|
+
- **A_APPLY_GOAL_DONE**: set `task_decomposition[*].status="done"`, `completion_confirmed=true`, `task_decomposition_all_done=true`
|
|
696
|
+
|
|
697
|
+
### A_ADVANCE_MILESTONE
|
|
698
|
+
|
|
699
|
+
1. Update session: milestone, phase, reset passed_gates
|
|
700
|
+
2. Insert full lifecycle steps for next milestone
|
|
701
|
+
3. Reindex, write status.json
|
|
702
|
+
|
|
703
|
+
### A_REGROUND_HALT / A_PAUSE_ESCALATE
|
|
704
|
+
|
|
705
|
+
- **A_REGROUND_HALT**: set `session.status = "paused"`,display drift warning + 恢复选项。auto_confirm 不跳过
|
|
706
|
+
- **A_PAUSE_ESCALATE**: set session paused,display "请人工介入",suggest continue
|
|
707
|
+
|
|
708
|
+
### A_AMEND_GOAL
|
|
709
|
+
|
|
710
|
+
运行中 session 的目标热修改。详细流程由 `<deferred_reading>` 加载 `ralph-amend-goal.md`。
|
|
711
|
+
|
|
712
|
+
| Phase | 行为 | 产出 |
|
|
713
|
+
|-------|------|------|
|
|
714
|
+
| 1. 快照 | 读 `task_decomposition` + `boundary_contract` + 已完成 steps 的 `completion_summary` | Display: 目标列表 + 进度 |
|
|
715
|
+
| 2. 解析 | `change_request` 非空 → 直接用;为空 → ask_user(修改/新增/移除/调整边界) | `change_type` + `change_request` |
|
|
716
|
+
| 3. Mini Grill | Agent 评估影响 | RISK_LEVEL + AFFECTED_GOALS + INVALIDATED_STEPS + NEW_GAPS |
|
|
717
|
+
| 4. 确认 | ask_user:应用并继续 / 仅改目标 / 取消 | 用户选择 |
|
|
718
|
+
| 5. 应用 | 归档旧目标(`superseded`)→ 写入新目标(`origin: CHG-xxx`)→ 重建链路 → write status.json | re-dispatch |
|
|
719
|
+
|
|
720
|
+
**Phase 3 Agent prompt:**
|
|
721
|
+
```
|
|
722
|
+
delegate_subagent({
|
|
723
|
+
description: "Amend impact analysis(同步评估 Agent,不传 name)",
|
|
724
|
+
prompt: "PURPOSE: 评估目标修改对 running session 的影响
|
|
725
|
+
TASK:
|
|
726
|
+
1. 读取 {session_dir}/status.json 的 task_decomposition + boundary_contract + 已完成 steps
|
|
727
|
+
2. 分析 change_request 对既有目标/步骤的影响
|
|
728
|
+
3. 判定 RISK_LEVEL (low/medium/high)
|
|
729
|
+
4. 列出 AFFECTED_GOALS / INVALIDATED_STEPS / NEW_GAPS
|
|
730
|
+
CONTEXT:
|
|
731
|
+
change_request = {change_request}
|
|
732
|
+
change_type = {change_type}
|
|
733
|
+
session = {session_dir}/status.json
|
|
734
|
+
EXPECTED:
|
|
735
|
+
---AMEND-VERDICT---
|
|
736
|
+
RISK_LEVEL: low|medium|high
|
|
737
|
+
AFFECTED_GOALS: [G1, G2, ...]
|
|
738
|
+
INVALIDATED_STEPS: [step indices]
|
|
739
|
+
NEW_GAPS: [gap descriptions]
|
|
740
|
+
RECOMMENDATION: <建议>
|
|
741
|
+
---END---
|
|
742
|
+
CONSTRAINTS: 只评估不修改文件"
|
|
743
|
+
})
|
|
744
|
+
```
|
|
745
|
+
|
|
746
|
+
GUARD: `RISK_LEVEL == high` → ask_user 不跳过(auto_confirm 无效)
|
|
747
|
+
GUARD: 已完成(`status: "done"`)的目标不可 supersede(skip + warn)
|
|
748
|
+
旧目标标 `superseded`(`superseded_by` + `superseded_at`),新目标标 `origin: "CHG-xxx"`。`goal_changelog` 含完整 `before/after` + `impact_assessment`。
|
|
749
|
+
|
|
750
|
+
### A_RETRY / A_PAUSE_SESSION / A_COMPLETE_SESSION
|
|
751
|
+
|
|
752
|
+
- **A_RETRY**: `shell("maestro ralph retry {index}")` — CLI 设 `step.retried = true`, `step.status = "pending"`, 清 `active_step_index`
|
|
753
|
+
- **A_PAUSE_SESSION**: `ralph complete N --status BLOCKED --reason "..."` — CLI 写 `session.status = "paused"`
|
|
754
|
+
- **A_COMPLETE_SESSION**: 校验所有 step `completion_confirmed == true` + `task_decomposition_all_done == true`(若存在),通过后写 `session.status = "completed"`。完成后向所有 idle executor 发送 shutdown_request 清理:
|
|
755
|
+
```
|
|
756
|
+
遍历 steps[].agent_exec_name → send_message({to: name, message: {type: "shutdown_request"}})
|
|
757
|
+
```
|
|
758
|
+
|
|
759
|
+
</actions>
|
|
760
|
+
|
|
761
|
+
</state_machine>
|
|
762
|
+
|
|
763
|
+
<appendix>
|
|
764
|
+
|
|
765
|
+
### Stage Mapping
|
|
766
|
+
|
|
767
|
+
执行 Agent 始终拥有完整工具集(read + write),由 skill 自身约束行为。Decision 评估 Agent 通过 prompt 中的 CONSTRAINTS 约束为只读。
|
|
768
|
+
|
|
769
|
+
| Stage | invoke_skill(independent) | invoke_skill(unified) | Decision after | quality_mode |
|
|
770
|
+
|-------|---------------------|-----------------|----------------|--------------|
|
|
771
|
+
| grill | `maestro-grill "{intent}"` | *(same)* | — | all |
|
|
772
|
+
| brainstorm | `maestro-brainstorm "{intent}"` | *(same)* | — | all |
|
|
773
|
+
| blueprint | `maestro-blueprint "{intent}"` | *(same)* | — | all |
|
|
774
|
+
| init | `maestro-init` | *(same)* | — | all |
|
|
775
|
+
| spec-setup | `spec-setup` | *(same)* | — | all |
|
|
776
|
+
| analyze-macro | `maestro-analyze "{intent}"` | *(same)* | `post-analyze-scope` | all |
|
|
777
|
+
| roadmap | `maestro-roadmap --from analyze:{id}` | *(same)* | — | all |
|
|
778
|
+
| analyze | `maestro-analyze {phase}` | `maestro-analyze` | — | all |
|
|
779
|
+
| plan | `maestro-plan {phase}` | `maestro-plan` | — | all |
|
|
780
|
+
| execute | `maestro-execute {phase}` | `maestro-execute` | `post-execute` | all |
|
|
781
|
+
| business-test | `quality-auto-test {phase}` | `quality-auto-test` | `post-business-test` | full only |
|
|
782
|
+
| review | `quality-review {phase}` | `quality-review` | `post-review` | all |
|
|
783
|
+
| test-gen | `quality-auto-test {phase}` | `quality-auto-test` | — | full / standard |
|
|
784
|
+
| test | `quality-test {phase}` | `quality-test` | `post-test` | full, standard |
|
|
785
|
+
| frontend-verify | `quality-test {phase} --frontend-verify` | `quality-test --frontend-verify` | `post-frontend-verify` | all (UI only) |
|
|
786
|
+
| milestone-audit | `maestro-milestone-audit` | *(same)* | — | all |
|
|
787
|
+
| goal-audit | *(decision-only)* | *(same)* | `post-goal-audit` | all |
|
|
788
|
+
| milestone-complete | `maestro-milestone-complete` | *(same)* | `post-milestone` | all |
|
|
789
|
+
|
|
790
|
+
Build rules 0-14 全部适用,包括 spec-setup 预检(rule 0.5)、grill auto_confirm 透传(rule 3.5)、frontend-verify UI 门控(rule 3.6)、re-grounding 插入(rule 5.5)等。
|
|
791
|
+
|
|
792
|
+
### Session Schema
|
|
793
|
+
|
|
794
|
+
```json
|
|
795
|
+
{
|
|
796
|
+
"session_id": "ralph-v2-{YYYYMMDD-HHmmss}",
|
|
797
|
+
"source": "ralph", "status": "running",
|
|
798
|
+
"execution_mode": "agent",
|
|
799
|
+
"ralph_protocol_version": "2",
|
|
800
|
+
"active_step_index": null,
|
|
801
|
+
"active_agent_name": null,
|
|
802
|
+
"intent": "", "lifecycle_position": "",
|
|
803
|
+
"phase": null, "phase_is_new": false,
|
|
804
|
+
"milestone": "",
|
|
805
|
+
"auto_mode": false,
|
|
806
|
+
"decomposition_owner": "ralph",
|
|
807
|
+
|
|
808
|
+
"quality_mode": "standard",
|
|
809
|
+
"planning_mode": "independent",
|
|
810
|
+
"scope_verdict": null,
|
|
811
|
+
"wants_roadmap": false,
|
|
812
|
+
"analyze_macro_id": null,
|
|
813
|
+
"blueprint_id": null,
|
|
814
|
+
"passed_gates": [],
|
|
815
|
+
"context": { "issue_id": null, "scratch_dir": null, "plan_dir": null,
|
|
816
|
+
"analysis_dir": null, "brainstorm_dir": null, "blueprint_dir": null },
|
|
817
|
+
"steps": [{
|
|
818
|
+
"index": 0,
|
|
819
|
+
"skill": "",
|
|
820
|
+
"args": "",
|
|
821
|
+
"stage": "",
|
|
822
|
+
"scope": null,
|
|
823
|
+
"decision": null,
|
|
824
|
+
"evaluate_via": "agent|cli|dual",
|
|
825
|
+
"retry_count": 0,
|
|
826
|
+
"max_retries": 2,
|
|
827
|
+
"command_scope": "global|project|missing|null",
|
|
828
|
+
"command_path": "<absolute path> | null",
|
|
829
|
+
"milestone_id": null,
|
|
830
|
+
"source_artifact_ref": null,
|
|
831
|
+
"status": "pending|running|completed|skipped|failed",
|
|
832
|
+
"goal_ref": null,
|
|
833
|
+
"completion_confirmed": false,
|
|
834
|
+
"completion_status": null,
|
|
835
|
+
"completion_evidence": null,
|
|
836
|
+
"completion_summary": null,
|
|
837
|
+
"completion_decisions": null,
|
|
838
|
+
"completion_caveats": null,
|
|
839
|
+
"completion_deferred": null,
|
|
840
|
+
"completed_at": null,
|
|
841
|
+
"deferred_reads": [],
|
|
842
|
+
"load": null,
|
|
843
|
+
"agent_exec_name": null,
|
|
844
|
+
"artifacts_produced": [],
|
|
845
|
+
"drift_score": null,
|
|
846
|
+
"drift_correction": null
|
|
847
|
+
}],
|
|
848
|
+
"waves": [], "current_step": 0,
|
|
849
|
+
|
|
850
|
+
"boundary_contract": {
|
|
851
|
+
"in_scope": [], "out_of_scope": [], "constraints": [], "definition_of_done": ""
|
|
852
|
+
},
|
|
853
|
+
"execution_criteria": [],
|
|
854
|
+
"task_decomposition": [
|
|
855
|
+
{ "id": "G1", "goal": "", "boundary": "", "done_when": "",
|
|
856
|
+
"evidence": "", "lifecycle": [], "status": "pending|done|superseded",
|
|
857
|
+
"completion_confirmed": false, "completed_at": null,
|
|
858
|
+
"superseded_by": null, "superseded_at": null, "origin": null }
|
|
859
|
+
],
|
|
860
|
+
"task_decomposition_all_done": false,
|
|
861
|
+
|
|
862
|
+
"goal_changelog": [
|
|
863
|
+
{ "id": "CHG-001", "timestamp": "{ISO}",
|
|
864
|
+
"change_type": "modify|add|remove|boundary",
|
|
865
|
+
"reason": "",
|
|
866
|
+
"impact_assessment": { "risk_level": "low|medium|high",
|
|
867
|
+
"invalidated_steps": [], "new_steps_inserted": 0 },
|
|
868
|
+
"before": { "goals": [{"id":"G1","goal":"...","done_when":"..."}] },
|
|
869
|
+
"after": { "goals": [{"id":"G1v2","goal":"...","done_when":"..."}] } }
|
|
870
|
+
]
|
|
871
|
+
}
|
|
872
|
+
```
|
|
873
|
+
|
|
874
|
+
### Fix-Loop Templates
|
|
875
|
+
|
|
876
|
+
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` 上报。
|
|
877
|
+
|
|
878
|
+
### Error Codes
|
|
879
|
+
|
|
880
|
+
E001–E006, W001–W004 适用。Agent 新增:
|
|
881
|
+
|
|
882
|
+
| Code | Severity | Description | Recovery |
|
|
883
|
+
|------|----------|-------------|----------|
|
|
884
|
+
| E014 | error | Agent execution failed (Agent returned null) | Retry once, then BLOCKED |
|
|
885
|
+
| E016 | error | Evaluation Agent verdict parse failed | Fallback fix + parse_failed: true |
|
|
886
|
+
|
|
887
|
+
### Success Criteria
|
|
888
|
+
|
|
889
|
+
- [ ] ralph-v2 owns full step loop: locate → resolve → dispatch → wait → receive → extract → drift → complete → next
|
|
890
|
+
- [ ] One agent per step — `delegate_subagent({ name, subagent_type: "ralph-executor" })` 每步派发一个 named executor
|
|
891
|
+
- [ ] Executor 内调 `maestro ralph next` 获取 skill prompt 并执行,支持内部多 agent 编排
|
|
892
|
+
- [ ] Executor 通过 `send_message({to: "main"})` 回传 `EXECUTOR_OUTPUT` 格式结果
|
|
893
|
+
- [ ] 主流程调 `maestro ralph complete` 上报(非 agent 上报)
|
|
894
|
+
- [ ] 主流程负责 arg resolution、context loading、signal extraction、drift analysis
|
|
895
|
+
- [ ] A_STEP_RECEIVE 从 executor 的 agent-message 中提取执行输出
|
|
896
|
+
- [ ] Executor 崩溃(idle 无 send_message)→ 询问 2 次后 STATUS=BLOCKED,转 S_HANDLE_FAIL
|
|
897
|
+
- [ ] Dual dispatch: 执行 Agent 传 `name`(async + send_message),评估 Agent 不传 `name`(sync)或 CLI delegate
|
|
898
|
+
- [ ] Decision evaluation 支持三种模式:agent(同步)、cli(CLI delegate)、dual(并行交叉验证)
|
|
899
|
+
- [ ] `evaluate_via` 字段控制评估模式,默认 `"agent"`
|
|
900
|
+
- [ ] dual 模式合并策略:一致取共识、分歧保守降级、CLI 未返回用 Agent 结果
|
|
901
|
+
- [ ] Verdict 解析保持 `---VERDICT---` 格式,parse 失败 → fallback fix + parse_failed: true
|
|
902
|
+
- [ ] decisions.ndjson 追加:source 字段为 `"ralph-v2"`
|
|
903
|
+
- [ ] Session schema: `execution_mode: "agent"`,`agent_exec_name`(执行 Agent name + display),含 `artifacts_produced`
|
|
904
|
+
- [ ] Chain building(S_RESOLVE_PHASE through S_BUILD_CHAIN)自包含执行
|
|
905
|
+
- [ ] A_STEP_DISPATCH 含前序产出加载(滑动窗口 5 step + accumulated signals + stage-specific artifacts)
|
|
906
|
+
- [ ] `agent_exec_name` 含 stage prefix(grl/brn/anm/ana/pln/exe/rev/tst/dbg)——同时用于 Agent name 参数和 display
|
|
907
|
+
- [ ] `--summary` 在 DONE/DONE_WITH_CONCERNS 时为 MUST(动词开头,≤100 字)
|
|
908
|
+
- [ ] CAVEATS 在 DONE_WITH_CONCERNS 时同时映射 --concerns
|
|
909
|
+
- [ ] A_STEP_EXTRACT 从 executor 输出提取 artifact IDs、path signals、phase signals
|
|
910
|
+
- [ ] A_STEP_DRIFT_ANALYZE:ALIGNED/MINOR_DRIFT → complete;MAJOR_DRIFT+未重试 → retry;MAJOR_DRIFT+已重试 → DONE_WITH_CONCERNS
|
|
911
|
+
- [ ] A_STEP_COMPLETE 将 context signals 写入 status.json.context
|
|
912
|
+
- [ ] A_AMEND_GOAL:完整 5 步流程 + deferred_reading ralph-amend-goal.md + Agent mini grill 含完整 prompt
|
|
913
|
+
- [ ] 旧目标标 superseded(superseded_by + superseded_at),新目标 origin: "CHG-xxx"
|
|
914
|
+
- [ ] goal_changelog 含完整 before/after + impact_assessment
|
|
915
|
+
- [ ] blueprint_id session 字段支持 --from blueprint:{BLP_ID} 路径
|
|
916
|
+
- [ ] spec-setup 预检(build rule 0.5)
|
|
917
|
+
- [ ] post-milestone adhoc 分支:mark completed + set current_milestone = null
|
|
918
|
+
- [ ] post-reground + drifted + confidence < 60 → A_APPLY_PROCEED (LOW CONFIDENCE)
|
|
919
|
+
- [ ] Fix-loop 插入的 step 通过 A_STEP_DISPATCH 逐步执行
|
|
920
|
+
- [ ] re-grounding 3-step 插入规则(build rule 5.5)不变
|
|
921
|
+
- [ ] A_REGROUND_HALT 漂移熔断(auto_confirm 不跳过)不变
|
|
922
|
+
|
|
923
|
+
</appendix>
|