pi-maestro-flow 0.2.0
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/README.md +124 -0
- package/agents/aggregator.md +27 -0
- package/agents/cli-explore-agent.md +188 -0
- package/agents/cross-role-reviewer.md +171 -0
- package/agents/delegate.md +19 -0
- package/agents/explorer.md +23 -0
- package/agents/impeccable-agent.md +99 -0
- package/agents/ralph-executor.md +81 -0
- package/agents/reference.md +24 -0
- package/agents/role-design-author.md +220 -0
- package/agents/team-supervisor.md +143 -0
- package/agents/team-worker.md +237 -0
- package/agents/ui-design-agent.md +270 -0
- package/agents/workflow-analyzer.md +116 -0
- package/agents/workflow-codebase-mapper.md +77 -0
- package/agents/workflow-collab-planner.md +147 -0
- package/agents/workflow-debugger.md +104 -0
- package/agents/workflow-executor.md +133 -0
- package/agents/workflow-external-researcher.md +86 -0
- package/agents/workflow-integration-checker.md +83 -0
- package/agents/workflow-nyquist-auditor.md +85 -0
- package/agents/workflow-phase-researcher.md +85 -0
- package/agents/workflow-plan-checker.md +100 -0
- package/agents/workflow-planner.md +200 -0
- package/agents/workflow-project-researcher.md +74 -0
- package/agents/workflow-research-synthesizer.md +70 -0
- package/agents/workflow-reviewer.md +82 -0
- package/agents/workflow-roadmapper.md +81 -0
- package/agents/workflow-verifier.md +120 -0
- package/package.json +58 -0
- package/skills/codify-to-knowhow/SKILL.md +167 -0
- package/skills/delegation-check/SKILL.md +297 -0
- package/skills/domain-add/SKILL.md +75 -0
- package/skills/insight-challenge/SKILL.md +226 -0
- package/skills/learn-decompose/SKILL.md +124 -0
- package/skills/learn-follow/SKILL.md +163 -0
- package/skills/learn-investigate/SKILL.md +160 -0
- package/skills/learn-second-opinion/SKILL.md +128 -0
- package/skills/maestro/SKILL.md +239 -0
- package/skills/maestro-amend/SKILL.md +169 -0
- package/skills/maestro-analyze/SKILL.md +173 -0
- package/skills/maestro-blueprint/SKILL.md +159 -0
- package/skills/maestro-brainstorm/SKILL.md +193 -0
- package/skills/maestro-collab/SKILL.md +181 -0
- package/skills/maestro-companion/SKILL.md +536 -0
- package/skills/maestro-composer/SKILL.md +192 -0
- package/skills/maestro-execute/SKILL.md +193 -0
- package/skills/maestro-fork/SKILL.md +104 -0
- package/skills/maestro-grill/SKILL.md +151 -0
- package/skills/maestro-guard/SKILL.md +124 -0
- package/skills/maestro-help/SKILL.md +328 -0
- package/skills/maestro-impeccable/SKILL.md +302 -0
- package/skills/maestro-init/SKILL.md +151 -0
- package/skills/maestro-merge/SKILL.md +90 -0
- package/skills/maestro-milestone-audit/SKILL.md +117 -0
- package/skills/maestro-milestone-complete/SKILL.md +133 -0
- package/skills/maestro-milestone-release/SKILL.md +131 -0
- package/skills/maestro-next/SKILL.md +269 -0
- package/skills/maestro-overlay/SKILL.md +203 -0
- package/skills/maestro-plan/SKILL.md +194 -0
- package/skills/maestro-player/SKILL.md +184 -0
- package/skills/maestro-quick/SKILL.md +117 -0
- package/skills/maestro-ralph/SKILL.md +905 -0
- package/skills/maestro-ralph-cli/SKILL.md +976 -0
- package/skills/maestro-ralph-cli-execute/SKILL.md +229 -0
- package/skills/maestro-ralph-execute/SKILL.md +409 -0
- package/skills/maestro-ralph-v2/SKILL.md +1198 -0
- package/skills/maestro-roadmap/SKILL.md +157 -0
- package/skills/maestro-swarm-workflow/SKILL.md +272 -0
- package/skills/maestro-tools-execute/SKILL.md +143 -0
- package/skills/maestro-tools-register/SKILL.md +192 -0
- package/skills/maestro-ui-codify/SKILL.md +127 -0
- package/skills/maestro-universal-workflow/SKILL.md +622 -0
- package/skills/maestro-update/SKILL.md +156 -0
- package/skills/manage-codebase-rebuild/SKILL.md +111 -0
- package/skills/manage-drift-realign/SKILL.md +159 -0
- package/skills/manage-harvest/SKILL.md +121 -0
- package/skills/manage-issue/SKILL.md +88 -0
- package/skills/manage-issue-discover/SKILL.md +104 -0
- package/skills/manage-kg-extractors/SKILL.md +147 -0
- package/skills/manage-knowhow/SKILL.md +102 -0
- package/skills/manage-knowhow-capture/SKILL.md +109 -0
- package/skills/manage-knowledge-audit/SKILL.md +147 -0
- package/skills/manage-status/SKILL.md +80 -0
- package/skills/manage-wiki/SKILL.md +104 -0
- package/skills/odyssey-debug/SKILL.md +344 -0
- package/skills/odyssey-improve/SKILL.md +423 -0
- package/skills/odyssey-planex/SKILL.md +542 -0
- package/skills/odyssey-review-test-fix/SKILL.md +392 -0
- package/skills/odyssey-ui/SKILL.md +388 -0
- package/skills/prompt-generator/SKILL.md +470 -0
- package/skills/quality-auto-test/SKILL.md +168 -0
- package/skills/quality-debug/SKILL.md +176 -0
- package/skills/quality-refactor/SKILL.md +108 -0
- package/skills/quality-retrospective/SKILL.md +134 -0
- package/skills/quality-review/SKILL.md +169 -0
- package/skills/quality-sync/SKILL.md +90 -0
- package/skills/quality-test/SKILL.md +183 -0
- package/skills/scholar-anti-ai-writing/SKILL.md +173 -0
- package/skills/scholar-anti-ai-writing/references/patterns-chinese.md +242 -0
- package/skills/scholar-anti-ai-writing/references/patterns-english.md +242 -0
- package/skills/scholar-citation-verify/SKILL.md +166 -0
- package/skills/scholar-citation-verify/references/api-usage.md +372 -0
- package/skills/scholar-citation-verify/references/common-errors.md +384 -0
- package/skills/scholar-citation-verify/references/verification-rules.md +399 -0
- package/skills/scholar-experiment/SKILL.md +321 -0
- package/skills/scholar-ideation/SKILL.md +288 -0
- package/skills/scholar-latex-organizer/SKILL.md +186 -0
- package/skills/scholar-publish/SKILL.md +220 -0
- package/skills/scholar-rebuttal-pro/README.md +313 -0
- package/skills/scholar-rebuttal-pro/SKILL.md +511 -0
- package/skills/scholar-review/SKILL.md +227 -0
- package/skills/scholar-thesis-docx/README.md +111 -0
- package/skills/scholar-thesis-docx/README_EN.md +108 -0
- package/skills/scholar-thesis-docx/SKILL.md +212 -0
- package/skills/scholar-thesis-docx/references/failure-patterns-and-quality-gates.md +178 -0
- package/skills/scholar-thesis-docx/references/figure-and-code-rules.md +33 -0
- package/skills/scholar-thesis-docx/references/paper-format-workflow.md +68 -0
- package/skills/scholar-thesis-docx/references/script-usage.md +157 -0
- package/skills/scholar-thesis-docx/scripts/audit_docx_ooxml.py +429 -0
- package/skills/scholar-thesis-docx/scripts/check_word_com.ps1 +50 -0
- package/skills/scholar-thesis-docx/scripts/export_word_pdf.ps1 +62 -0
- package/skills/scholar-thesis-docx/scripts/normalize_word_styles.ps1 +498 -0
- package/skills/scholar-thesis-docx/scripts/render_mermaid_figure.ps1 +148 -0
- package/skills/scholar-writing/SKILL.md +296 -0
- package/skills/security-audit/SKILL.md +244 -0
- package/skills/skill-generator/SKILL.md +472 -0
- package/skills/skill-iter-tune/SKILL.md +382 -0
- package/skills/skill-simplify/SKILL.md +63 -0
- package/skills/skill-tuning/SKILL.md +174 -0
- package/skills/spec-add/SKILL.md +105 -0
- package/skills/spec-load/SKILL.md +98 -0
- package/skills/spec-remove/SKILL.md +74 -0
- package/skills/spec-setup/SKILL.md +75 -0
- package/skills/team-adversarial-swarm/SKILL.md +233 -0
- package/skills/team-adversarial-swarm/scripts/__pycache__/pheromone.cpython-313.pyc +0 -0
- package/skills/team-adversarial-swarm/scripts/__pycache__/scoring.cpython-313.pyc +0 -0
- package/skills/team-adversarial-swarm/scripts/aco.py +473 -0
- package/skills/team-adversarial-swarm/scripts/pheromone.py +144 -0
- package/skills/team-adversarial-swarm/scripts/scoring.py +92 -0
- package/skills/team-adversarial-swarm/scripts/test_aco.py +475 -0
- package/skills/team-arch-opt/SKILL.md +158 -0
- package/skills/team-brainstorm/SKILL.md +171 -0
- package/skills/team-coordinate/SKILL.md +266 -0
- package/skills/team-designer/SKILL.md +160 -0
- package/skills/team-executor/SKILL.md +189 -0
- package/skills/team-frontend/SKILL.md +136 -0
- package/skills/team-frontend-debug/SKILL.md +198 -0
- package/skills/team-interactive-craft/SKILL.md +141 -0
- package/skills/team-issue/SKILL.md +171 -0
- package/skills/team-lifecycle-v4/SKILL.md +209 -0
- package/skills/team-motion-design/SKILL.md +142 -0
- package/skills/team-perf-opt/SKILL.md +175 -0
- package/skills/team-planex/SKILL.md +137 -0
- package/skills/team-quality-assurance/SKILL.md +147 -0
- package/skills/team-review/SKILL.md +147 -0
- package/skills/team-roadmap-dev/SKILL.md +169 -0
- package/skills/team-swarm/SKILL.md +178 -0
- package/skills/team-swarm/scripts/aco.py +473 -0
- package/skills/team-swarm/scripts/pheromone.py +144 -0
- package/skills/team-swarm/scripts/scoring.py +92 -0
- package/skills/team-swarm/scripts/test_aco.py +475 -0
- package/skills/team-tech-debt/SKILL.md +128 -0
- package/skills/team-testing/SKILL.md +143 -0
- package/skills/team-ui-polish/SKILL.md +141 -0
- package/skills/team-uidesign/SKILL.md +144 -0
- package/skills/team-ultra-analyze/SKILL.md +173 -0
- package/skills/team-ux-improve/SKILL.md +151 -0
- package/skills/team-visual-a11y/SKILL.md +156 -0
- package/skills/workflow-skill-designer/SKILL.md +496 -0
- package/src/extension/index.ts +222 -0
- package/src/extension/schemas.ts +131 -0
- package/src/providers/cli-tools-loader.ts +74 -0
- package/src/providers/provider-registry.ts +130 -0
- package/src/tools/delegate.ts +85 -0
- package/src/tools/explore.ts +134 -0
- package/src/tools/moa.ts +213 -0
- package/src/tools/status.ts +99 -0
- package/src/tools/wait.ts +166 -0
|
@@ -0,0 +1,1198 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: maestro-ralph-v2
|
|
3
|
+
description: "[RECOMMENDED] Adaptive lifecycle orchestrator — compose, dispatch ralph-executor agent, evaluate decision, loop Arguments: <intent> [-y] [--amend [change]] [--roadmap] | status | continue"
|
|
4
|
+
allowed-tools: Read Write Edit Bash Glob Grep Skill AskUserQuestion Agent SendMessage
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
<purpose>
|
|
8
|
+
Adaptive lifecycle orchestrator: locate step → resolve args → load context → dispatch Agent(ralph-executor) per step (agent 调 `ralph next` + 执行) → extract signals → drift check → ralph complete → evaluate decision → next step → loop.
|
|
9
|
+
|
|
10
|
+
Session: `.workflow/.maestro/ralph-v2-{YYYYMMDD-HHmmss}/status.json`
|
|
11
|
+
</purpose>
|
|
12
|
+
|
|
13
|
+
<deferred_reading>
|
|
14
|
+
- [ralph-amend-goal.md](~/.maestro/workflows/ralph-amend-goal.md) — read when `--amend` flag active for goal amendment flow
|
|
15
|
+
</deferred_reading>
|
|
16
|
+
|
|
17
|
+
<context>
|
|
18
|
+
$ARGUMENTS — intent text, flags, or keywords.
|
|
19
|
+
|
|
20
|
+
**Parse:**
|
|
21
|
+
```
|
|
22
|
+
-y flag → auto_confirm = true
|
|
23
|
+
--roadmap → wants_roadmap = true
|
|
24
|
+
--amend / -a → amend_mode = true
|
|
25
|
+
.md/.txt path → input_doc
|
|
26
|
+
status|continue → route keyword
|
|
27
|
+
Remaining → intent (amend_mode 时为 change_request)
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
**State files**:
|
|
31
|
+
- `.workflow/state.json` — artifact registry
|
|
32
|
+
- `.workflow/.maestro/ralph-v2-*/status.json` — session state
|
|
33
|
+
</context>
|
|
34
|
+
|
|
35
|
+
<invariants>
|
|
36
|
+
1. **Ralph-v2 owns the full loop** — locate step → resolve args → load context → dispatch agent → wait for task-notification → extract signals → drift → complete,全部在本命令内完成
|
|
37
|
+
2. **One agent per step** — 每个执行 step 派发一个 unnamed executor agent,结果通过 task-notification `<result>` 回传,主流程解析结果后决定下一步
|
|
38
|
+
3. **Agent is a thin wrapper** — executor agent 调 `ralph next` 获取 skill prompt 并执行,返回输出文本;arg resolution、context loading、signal extraction、drift analysis、ralph complete 均由主流程完成
|
|
39
|
+
4. **Unified unnamed dispatch** — 执行 Agent 和评估 Agent 均使用 unnamed Agent(),结果通过 task-notification `<result>` 回传:
|
|
40
|
+
- **执行 Agent**(A_STEP_DISPATCH):`Agent()` 不传 name — executor 内部编排也用 unnamed Agent(子结果自动回流 executor,嵌套套娃模型)
|
|
41
|
+
- **评估 Agent**(A_AGENT_EVALUATE / A_AGENT_GOAL_AUDIT / A_AGENT_REGROUND):同样 `Agent()` 不传 name
|
|
42
|
+
- `agent_exec_name` 仅用于 display/日志标识,不作为 Agent name 参数
|
|
43
|
+
5. **主流程调 `ralph complete`** — 每个 step 完成后由主流程调 `maestro ralph complete`,非 agent 上报
|
|
44
|
+
6. **Decision evaluation inline** — decision 节点不 handoff,通过 Agent 或 CLI delegate 在本循环内评估
|
|
45
|
+
7. **CLI delegation for evaluation only** — CLI delegate(`maestro delegate --mode analysis`)仅限评估环节;执行仍通过 executor Agent 完成
|
|
46
|
+
8. **Decision delegates read-only** — 评估 Agent 通过 prompt 中的 CONSTRAINTS 约束为只读
|
|
47
|
+
9. **执行 step 通过 `maestro ralph next` CLI 加载并内联执行**(由 execute Agent 完成)
|
|
48
|
+
10. **status.json 是唯一真源** — 不生成 markdown 清单或侧文件
|
|
49
|
+
11. **每个 step 必须 `completion_confirmed: true`** — 由 `maestro ralph complete N --status DONE`(或 DONE_WITH_CONCERNS)写入;CLI 是唯一合法写入路径
|
|
50
|
+
12. **command_path 在 A_BUILD_STEPS 解析** — 通过 `maestro ralph skills --platform claude --json --quiet` 预校验
|
|
51
|
+
13. **执行 step 加载契约** — 由 `maestro ralph next` CLI 在执行期完成
|
|
52
|
+
14. **Decomposition is outcome-oriented** — sub-goals 为可观测交付,禁止 lifecycle 复刻
|
|
53
|
+
15. **planning_mode governs arg granularity** — `unified` → skill args 无 `{phase}`;`independent` → 含 `{phase}`
|
|
54
|
+
16. **task_decomposition 驱动 steps[] 动态生长** — `post-goal-audit` 按 unmet 子目标插入 scoped mini-loop
|
|
55
|
+
17. **Invariant violation = BLOCK** — 违反上述任一 invariant 即阻断当前操作
|
|
56
|
+
18. **Evaluate fallback 必须标记** — 评估 Agent 解析 verdict 失败时 fallback 为 "fix",MUST 在 decisions.ndjson 记录 `"parse_failed": true, "confidence_score": 0`
|
|
57
|
+
19. **auto_confirm 单一来源** — `auto_confirm` 仅由用户 `-y` 标志设定
|
|
58
|
+
20. **分解契约单一所有者** — `boundary_contract` / `task_decomposition` 由 session 创建者拥有
|
|
59
|
+
21. **控制权优先级(范式治理)** — FSM 独占 session 生命周期 + step 排序 + retry/fix/escalate + cross-step decision 节点
|
|
60
|
+
</invariants>
|
|
61
|
+
|
|
62
|
+
<state_machine>
|
|
63
|
+
|
|
64
|
+
Chain-building states + 执行循环 states:
|
|
65
|
+
|
|
66
|
+
<states>
|
|
67
|
+
S_PARSE_ROUTE — 解析参数、路由入口
|
|
68
|
+
S_STATUS — 显示 session 进度
|
|
69
|
+
S_CONTINUE — 恢复执行
|
|
70
|
+
S_RESOLVE_PHASE — 解析 phase + phase_is_new + milestone PERSIST: session.phase, session.phase_is_new, session.milestone
|
|
71
|
+
S_INFER — 推断 lifecycle_position PERSIST: session.lifecycle_position, session.wants_roadmap
|
|
72
|
+
S_RESOLVE_SCOPE — 读 macro analyze conclusions.scope_verdict PERSIST: session.scope_verdict, session.analyze_macro_id
|
|
73
|
+
S_QUALITY_MODE — 决定质量管线模式 PERSIST: session.quality_mode
|
|
74
|
+
S_PLANNING_MODE — 决定统一/独立规划模式 PERSIST: session.planning_mode
|
|
75
|
+
S_DECOMPOSE — 边界澄清 + 执行准则 + 子目标清单 PERSIST: session.boundary_contract, .execution_criteria, .task_decomposition
|
|
76
|
+
S_BUILD_CHAIN — 构建步骤链(build rules 0-14) PERSIST: session.steps[]
|
|
77
|
+
S_CREATE_SESSION — 写 status.json PERSIST: session (全量)
|
|
78
|
+
S_CONFIRM — 用户确认
|
|
79
|
+
|
|
80
|
+
S_STEP_LOCATE — 找下一个 pending step PERSIST: —
|
|
81
|
+
S_STEP_RESOLVE — 解析占位符 + 丰富参数 PERSIST: step.args (enriched)
|
|
82
|
+
S_STEP_DISPATCH — 组装上下文 + 派发 unnamed executor agent PERSIST: step.agent_exec_name, step.status = "running"
|
|
83
|
+
S_STEP_ANALYZE — 提取信号 + 组装 completion 参数 PERSIST: —
|
|
84
|
+
S_STEP_DRIFT — 产物 vs 目标偏离分析 PERSIST: step.drift_score
|
|
85
|
+
S_STEP_COMPLETE — 调 `ralph complete` 上报 PERSIST: step.completion_*
|
|
86
|
+
S_DECISION_EVAL — 启动分析 Agent 评估质量门 PERSIST: —
|
|
87
|
+
S_APPLY_VERDICT — 应用裁决 PERSIST: session.steps[]
|
|
88
|
+
S_SESSION_DONE — 所有 step 完成 PERSIST: session.status
|
|
89
|
+
S_HANDLE_FAIL — 处理失败 PERSIST: step.status
|
|
90
|
+
S_AMEND_GOAL — 修改 running session 目标 PERSIST: session.task_decomposition, .boundary_contract, .goal_changelog, .steps[]
|
|
91
|
+
S_FALLBACK — 请求用户输入 PERSIST: —
|
|
92
|
+
</states>
|
|
93
|
+
|
|
94
|
+
<transitions>
|
|
95
|
+
|
|
96
|
+
S_PARSE_ROUTE:
|
|
97
|
+
→ S_STATUS WHEN: intent == "status"
|
|
98
|
+
→ S_CONTINUE WHEN: intent == "continue"
|
|
99
|
+
→ S_AMEND_GOAL WHEN: amend_mode == true AND running session exists
|
|
100
|
+
→ S_FALLBACK WHEN: amend_mode == true AND no running session
|
|
101
|
+
→ S_DECISION_EVAL WHEN: running session with decision step in "running" status
|
|
102
|
+
→ S_RESOLVE_PHASE WHEN: intent is non-empty
|
|
103
|
+
→ S_FALLBACK WHEN: no intent AND no running session
|
|
104
|
+
|
|
105
|
+
S_STATUS:
|
|
106
|
+
→ END DO: A_SHOW_STATUS
|
|
107
|
+
|
|
108
|
+
S_CONTINUE:
|
|
109
|
+
→ S_STEP_LOCATE WHEN: running session found
|
|
110
|
+
→ S_FALLBACK WHEN: no running session
|
|
111
|
+
|
|
112
|
+
S_AMEND_GOAL:
|
|
113
|
+
→ S_STEP_LOCATE WHEN: change applied + user confirmed DO: A_AMEND_GOAL
|
|
114
|
+
→ END WHEN: user cancels
|
|
115
|
+
GUARD: RISK_LEVEL=high → auto_confirm 无效
|
|
116
|
+
|
|
117
|
+
S_CREATE_SESSION:
|
|
118
|
+
→ S_CONFIRM WHEN: not auto_confirm
|
|
119
|
+
→ S_STEP_LOCATE WHEN: auto_confirm
|
|
120
|
+
|
|
121
|
+
S_CONFIRM:
|
|
122
|
+
→ S_STEP_LOCATE WHEN: user confirms
|
|
123
|
+
→ S_BUILD_CHAIN WHEN: user edits
|
|
124
|
+
→ END WHEN: user cancels
|
|
125
|
+
|
|
126
|
+
S_STEP_LOCATE:
|
|
127
|
+
→ S_STEP_RESOLVE WHEN: pending execution step found (step.decision == null)
|
|
128
|
+
→ S_DECISION_EVAL WHEN: pending decision step found (step.decision != null)
|
|
129
|
+
→ S_SESSION_DONE WHEN: no pending steps (all completed/skipped)
|
|
130
|
+
→ S_HANDLE_FAIL WHEN: has failed step and no pending
|
|
131
|
+
→ S_FALLBACK WHEN: no running session
|
|
132
|
+
|
|
133
|
+
S_STEP_RESOLVE:
|
|
134
|
+
→ S_STEP_DISPATCH DO: A_STEP_RESOLVE_ARGS
|
|
135
|
+
|
|
136
|
+
S_STEP_DISPATCH:
|
|
137
|
+
→ S_STEP_ANALYZE WHEN: task-notification status=completed DO: A_STEP_DISPATCH
|
|
138
|
+
→ S_HANDLE_FAIL WHEN: task-notification status=failed DO: mark BLOCKED
|
|
139
|
+
|
|
140
|
+
S_STEP_ANALYZE:
|
|
141
|
+
→ S_STEP_DRIFT WHEN: STATUS == DONE|DONE_WITH_CONCERNS DO: A_STEP_EXTRACT
|
|
142
|
+
→ S_HANDLE_FAIL WHEN: STATUS == NEEDS_RETRY|BLOCKED DO: A_STEP_EXTRACT
|
|
143
|
+
|
|
144
|
+
S_STEP_DRIFT:
|
|
145
|
+
→ S_STEP_COMPLETE WHEN: ALIGNED|MINOR_DRIFT DO: A_STEP_DRIFT_ANALYZE
|
|
146
|
+
→ S_STEP_DISPATCH WHEN: MAJOR_DRIFT + not retried DO: A_STEP_DRIFT_ANALYZE (ralph retry + re-execute)
|
|
147
|
+
→ S_STEP_COMPLETE WHEN: MAJOR_DRIFT + retried DO: A_STEP_DRIFT_ANALYZE (DONE_WITH_CONCERNS)
|
|
148
|
+
|
|
149
|
+
S_STEP_COMPLETE:
|
|
150
|
+
→ S_STEP_LOCATE DO: A_STEP_COMPLETE (loop to next step)
|
|
151
|
+
|
|
152
|
+
S_DECISION_EVAL: (decision 节点 == `step.decision` 非空)
|
|
153
|
+
→ S_APPLY_VERDICT WHEN: quality-gate (post-execute, post-business-test, post-review, post-test, post-frontend-verify)
|
|
154
|
+
DO: A_AGENT_EVALUATE
|
|
155
|
+
→ S_APPLY_VERDICT WHEN: goal-gate (post-goal-audit)
|
|
156
|
+
DO: A_AGENT_GOAL_AUDIT
|
|
157
|
+
→ S_APPLY_VERDICT WHEN: scope-gate (post-analyze-scope)
|
|
158
|
+
DO: A_SCOPE_EVALUATE
|
|
159
|
+
→ S_APPLY_VERDICT WHEN: reground-gate (post-reground)
|
|
160
|
+
DO: A_AGENT_REGROUND
|
|
161
|
+
→ S_APPLY_VERDICT WHEN: structural (post-milestone, post-debug-escalate)
|
|
162
|
+
DO: A_STRUCTURAL_EVALUATE
|
|
163
|
+
|
|
164
|
+
S_APPLY_VERDICT:
|
|
165
|
+
→ S_STEP_LOCATE WHEN: verdict == "proceed" DO: A_APPLY_PROCEED
|
|
166
|
+
→ S_STEP_LOCATE WHEN: post-goal-audit + has_unmet DO: A_APPLY_GOAL_FIX
|
|
167
|
+
→ S_STEP_LOCATE WHEN: post-goal-audit + all_met + INTENT_ALIGNED=true DO: A_APPLY_GOAL_DONE
|
|
168
|
+
→ END WHEN: post-goal-audit + all_met + INTENT_ALIGNED=false DO: A_REGROUND_HALT
|
|
169
|
+
→ S_STEP_LOCATE WHEN: post-analyze-scope DO: A_APPLY_SCOPE_VERDICT
|
|
170
|
+
→ S_STEP_LOCATE WHEN: verdict == "fix" DO: A_APPLY_FIX
|
|
171
|
+
→ S_STEP_LOCATE WHEN: verdict == "escalate" DO: A_APPLY_ESCALATE
|
|
172
|
+
→ S_STEP_LOCATE WHEN: post-milestone + standard + next milestone DO: A_ADVANCE_MILESTONE
|
|
173
|
+
→ END WHEN: post-milestone + standard + no next milestone
|
|
174
|
+
→ END WHEN: post-milestone + adhoc DO: mark completed (set current_milestone = null)
|
|
175
|
+
→ END WHEN: post-debug-escalate DO: A_PAUSE_ESCALATE
|
|
176
|
+
→ END WHEN: post-reground + drifted + confidence >= 60 DO: A_REGROUND_HALT
|
|
177
|
+
→ S_STEP_LOCATE WHEN: post-reground + aligned DO: A_APPLY_PROCEED
|
|
178
|
+
→ S_STEP_LOCATE WHEN: post-reground + drifted + confidence < 60 DO: A_APPLY_PROCEED (标 LOW CONFIDENCE)
|
|
179
|
+
GUARD: retry_count >= max_retries → force escalate
|
|
180
|
+
GUARD: confidence_score < 60 AND proceed → override to fix
|
|
181
|
+
GUARD: confidence_score > 95 AND fix AND retry > 0 → suggest proceed
|
|
182
|
+
GUARD: auto_confirm → skip user prompt, apply adjusted verdict
|
|
183
|
+
GUARD: not auto_confirm → AskUserQuestion with override options
|
|
184
|
+
GUARD: post-reground + drifted + confidence >= 60 → A_REGROUND_HALT(auto_confirm 不跳过)
|
|
185
|
+
|
|
186
|
+
S_HANDLE_FAIL:
|
|
187
|
+
→ S_STEP_LOCATE WHEN: auto + not retried DO: A_RETRY
|
|
188
|
+
→ END WHEN: auto + retried DO: A_PAUSE_SESSION
|
|
189
|
+
→ S_STEP_LOCATE WHEN: interactive + retry
|
|
190
|
+
→ S_STEP_LOCATE WHEN: interactive + skip
|
|
191
|
+
→ END WHEN: interactive + abort
|
|
192
|
+
|
|
193
|
+
S_SESSION_DONE:
|
|
194
|
+
→ END DO: A_COMPLETE_SESSION
|
|
195
|
+
|
|
196
|
+
</transitions>
|
|
197
|
+
|
|
198
|
+
<actions>
|
|
199
|
+
|
|
200
|
+
### A_RESOLVE_PHASE
|
|
201
|
+
|
|
202
|
+
前置于 A_INFER_POSITION。产出 `phase` + `phase_is_new` + `milestone`(D-007 反查)三元组。
|
|
203
|
+
|
|
204
|
+
**Priority:**
|
|
205
|
+
|
|
206
|
+
| Step | 行为 | phase_is_new |
|
|
207
|
+
|------|------|--------------|
|
|
208
|
+
| 1 | intent 匹配 `phase\s*(\d+)` → 取 state.json 对应 phase | false |
|
|
209
|
+
| 2 | intent 派生短语 → 在 `state.json.milestones[*].phase_slugs` / `artifacts[*].path` 查找 | false (匹配) / true (无匹配) |
|
|
210
|
+
| 3 | 未派生 → 取最新 in-progress artifact 的 phase | false |
|
|
211
|
+
| 4 | 仍无 → state.json 首个 incomplete phase | false |
|
|
212
|
+
| 5 | position 将是 brainstorm/blueprint/init/roadmap/analyze-macro → phase = null | n/a |
|
|
213
|
+
| 6 | 仍模糊 → `AskUserQuestion` | 由用户回答确定 |
|
|
214
|
+
|
|
215
|
+
**D-007 Phase→Milestone 反查**(数字 phase 已解析时):
|
|
216
|
+
```
|
|
217
|
+
resolve_milestone(phase_number):
|
|
218
|
+
for ms in state.json.milestones:
|
|
219
|
+
if str(phase_number) in ms.phase_slugs: return ms.id
|
|
220
|
+
return state.json.current_milestone # fallback
|
|
221
|
+
```
|
|
222
|
+
写入 `session.milestone`;禁止直接使用 `current_milestone` 当做 phase 所属 milestone。
|
|
223
|
+
|
|
224
|
+
**写入 session**: `phase`, `phase_is_new`, `milestone`。
|
|
225
|
+
|
|
226
|
+
**新派生 phase 时 milestone 处理**:
|
|
227
|
+
- state.json 当前 milestone 仍 active → 沿用,新增 phase
|
|
228
|
+
- intent 派生新 milestone 名 → 写入 session 仅作标签;`state.json.milestones` 由 `maestro-roadmap` / `maestro-milestone-release` 创建
|
|
229
|
+
|
|
230
|
+
### A_INFER_POSITION
|
|
231
|
+
|
|
232
|
+
**Intent-based overrides** (按顺序匹配,先命中先用):
|
|
233
|
+
|
|
234
|
+
| Pattern | Position |
|
|
235
|
+
|---------|----------|
|
|
236
|
+
| 压力测试 / 拷问 / 验证假设 / grill / stress-test | `grill`(**auto_confirm=true 时透传 `-y`,grill 以 Auto mode 代码代答,不跳过**) |
|
|
237
|
+
| brainstorm / 头脑风暴 / 探索 / ideate / 设计思路 | `brainstorm` |
|
|
238
|
+
| blueprint / 规格 / 正式文档 / spec-generate / 7-phase | `blueprint` |
|
|
239
|
+
| broad/medium intent 无数字 phase (重构/全面/重写/迁移/新功能 X) | `analyze-macro` |
|
|
240
|
+
|
|
241
|
+
**Roadmap opt-in detection** (设 `session.wants_roadmap`,缺省 `false`):
|
|
242
|
+
```
|
|
243
|
+
wants_roadmap = (--roadmap flag)
|
|
244
|
+
OR (intent 含多发布信号: 多发布|多版本|分阶段交付|按里程碑发布|v1.*v2|multi-release|roadmap)
|
|
245
|
+
OR (.workflow/roadmap.md 已存在) ← 向后兼容:既有 roadmap 项目行为不变
|
|
246
|
+
```
|
|
247
|
+
默认 `false` → large 项目走单一多波次 `plan --from analyze`,不引入 roadmap 横切层;roadmap 仅多发布场景 opt-in。
|
|
248
|
+
|
|
249
|
+
**Bootstrap detection:**
|
|
250
|
+
|
|
251
|
+
| Condition | Position |
|
|
252
|
+
|-----------|----------|
|
|
253
|
+
| No `.workflow/` + no source files | `brainstorm` |
|
|
254
|
+
| No `.workflow/` + has source files | `init` |
|
|
255
|
+
| Has `.workflow/` but no state.json | `init` |
|
|
256
|
+
| Has state.json | → phase-aware artifact inference |
|
|
257
|
+
|
|
258
|
+
**Phase-aware artifact inference** (使用 A_RESOLVE_PHASE 已写入的 `session.phase` + `session.phase_is_new`):
|
|
259
|
+
|
|
260
|
+
| Condition | Position |
|
|
261
|
+
|-----------|----------|
|
|
262
|
+
| `phase_is_new == true` (新 phase) | `analyze` |
|
|
263
|
+
| no milestones AND no roadmap.md AND has analyze macro artifact | `roadmap` if `wants_roadmap` else `plan` (--from analyze) |
|
|
264
|
+
| no milestones AND no roadmap.md AND no analyze artifact | `analyze-macro` |
|
|
265
|
+
| `phase == null` (grill/brainstorm/blueprint/init/roadmap/analyze-macro override 已定) | n/a |
|
|
266
|
+
| phase 已存在 + 无任何 artifact | `analyze` |
|
|
267
|
+
| phase 已存在 + 最新 artifact = analyze | `plan` |
|
|
268
|
+
| phase 已存在 + 最新 artifact = plan | `execute` |
|
|
269
|
+
| phase 已存在 + 最新 artifact = execute | → refine from post-execute results |
|
|
270
|
+
|
|
271
|
+
**关键不变量**:artifact 过滤按 `session.phase`,不读 `state.json.current_phase`。`phase_is_new` → 直接 `analyze`。
|
|
272
|
+
|
|
273
|
+
### A_RESOLVE_SCOPE_VERDICT
|
|
274
|
+
|
|
275
|
+
仅当 `lifecycle_position ∈ {analyze-macro, roadmap, plan}` 且存在最新 analyze artifact 时执行。
|
|
276
|
+
|
|
277
|
+
1. 定位最新 macro analyze artifact(`type=="analyze"` 且 `scope=="macro"`,按 created_at DESC)→ 记 `session.analyze_macro_id = ANL-xxx`
|
|
278
|
+
2. 读 `{artifact_path}/conclusions.json` 的 `scope_verdict` 字段(`large | medium | small`)
|
|
279
|
+
3. 写入 `session.scope_verdict`;缺失时设 `unknown`
|
|
280
|
+
4. 路由建议(A_BUILD_STEPS 据此决定是否插入 roadmap、plan 是否走 `--from`):
|
|
281
|
+
|
|
282
|
+
| scope_verdict | 链路 |
|
|
283
|
+
|---------------|------|
|
|
284
|
+
| `large` + `wants_roadmap` | analyze-macro → roadmap → analyze → plan → execute → ...(多发布 opt-in) |
|
|
285
|
+
| `large`(默认)/ `medium` / `small` | analyze-macro → plan --from analyze:{ANL_ID} → execute → ...(跳过 roadmap + analyze-phase;单一多波次计划) |
|
|
286
|
+
| `unknown` | 默认走 standalone(plan --from analyze)路径,post-analyze-scope 决策节点再纠正 |
|
|
287
|
+
|
|
288
|
+
**Refine from post-execute results:**
|
|
289
|
+
|
|
290
|
+
在 execute artifact 的 scratch dir 中检查结果文件(verification.json 由 execute 内置 gate 产出):
|
|
291
|
+
|
|
292
|
+
| Condition | Position |
|
|
293
|
+
|-----------|----------|
|
|
294
|
+
| 无 verification.json 或 passed==false 或 gaps[] | `execute` (触发 post-execute fix loop) |
|
|
295
|
+
| passed==true, no review.json | `business-test` |
|
|
296
|
+
| review.json: verdict=="BLOCK" | `review-failed` |
|
|
297
|
+
| review.json: verdict!="BLOCK" | `test` |
|
|
298
|
+
| uat.md: all passed + `session.milestone` 存在 | `milestone-audit` |
|
|
299
|
+
| uat.md: all passed + `session.milestone=null` (standalone) | 标记 session completed(无 milestone 可审计) |
|
|
300
|
+
| uat.md: has failures | `test-failed` |
|
|
301
|
+
|
|
302
|
+
### A_DETERMINE_QUALITY_MODE
|
|
303
|
+
|
|
304
|
+
决定下游质量管线长度。读 `session.quality_mode_override`(CLI 标志 `--quality`),无则按规则推断:
|
|
305
|
+
|
|
306
|
+
| Condition | Mode | Pipeline (execute 之后) |
|
|
307
|
+
|-----------|------|-------------------------|
|
|
308
|
+
| Has `specs/REQ-*.md` + 当前 phase 业务范围明确 | `full` | business-test → review → test-gen → test |
|
|
309
|
+
| Default | `standard` | review → test-gen (当 coverage<80%) → test |
|
|
310
|
+
| `--quality quick` | `quick` | review --tier quick |
|
|
311
|
+
|
|
312
|
+
写入 `session.quality_mode`。A_BUILD_STEPS 据此过滤 stage(见下)。
|
|
313
|
+
|
|
314
|
+
### A_DETERMINE_PLANNING_MODE
|
|
315
|
+
|
|
316
|
+
决定里程碑的规划粒度:一次性规划整个里程碑(统一)还是逐 phase 走完整生命周期(独立)。
|
|
317
|
+
|
|
318
|
+
**Auto-resolve rules (按优先级):**
|
|
319
|
+
|
|
320
|
+
| Condition | Mode | Reason |
|
|
321
|
+
|-----------|------|--------|
|
|
322
|
+
| lifecycle_position ∈ {grill, brainstorm, init, roadmap} | `independent` | 前期阶段不涉及多 phase 规划 |
|
|
323
|
+
| `phase_is_new == true` | `independent` | 新 phase 尚无里程碑上下文 |
|
|
324
|
+
| intent 显式指定 phase 编号(如 "phase 2"、"P3") | `independent` | 用户明确针对单个 phase |
|
|
325
|
+
| milestone 仅含 1 个 phase(读 state.json) | `independent` | 统一无意义 |
|
|
326
|
+
| milestone 含多个 phase + `auto_confirm` | `unified` | 自动模式倾向高效 |
|
|
327
|
+
| milestone 含多个 phase + 非 `auto_confirm` | → AskUserQuestion | 征询用户选择 |
|
|
328
|
+
|
|
329
|
+
**AskUserQuestion** (仅当 milestone 含 ≥2 phase 且非 auto_confirm):
|
|
330
|
+
|
|
331
|
+
```
|
|
332
|
+
question: "当前里程碑含 {N} 个 phase,选择规划模式?"
|
|
333
|
+
options:
|
|
334
|
+
- label: "统一规划 (Recommended)"
|
|
335
|
+
description: "一次性分析+规划整个里程碑所有 phase,analyze/plan 走里程碑级,适合 phase 间关联紧密"
|
|
336
|
+
- label: "独立规划"
|
|
337
|
+
description: "逐个 phase 走完整生命周期(analyze→plan→execute→...),适合 phase 间独立性高"
|
|
338
|
+
```
|
|
339
|
+
|
|
340
|
+
写入 `session.planning_mode`(`"unified"` 或 `"independent"`)。`A_BUILD_STEPS` 据此决定 skill args 是否携带 `{phase}` 占位符。
|
|
341
|
+
|
|
342
|
+
### A_DECOMPOSE_TASKS
|
|
343
|
+
|
|
344
|
+
Runs once before chain build; additive to status.json. 设 `session.decomposition_owner = "ralph"`。
|
|
345
|
+
|
|
346
|
+
**0. Ownership guard** (invariant 20): 若 `session.boundary_contract` 或 `session.task_decomposition` 已非空(上游 maestro 已写入,`decomposition_owner == "maestro"`)→ MUST 跳过下述提问,仅做 shape 校验 + 缺省字段补齐,直接进入步骤 6。
|
|
347
|
+
|
|
348
|
+
**1. Classify intent breadth:**
|
|
349
|
+
|
|
350
|
+
| Pattern | Breadth | Clarify? |
|
|
351
|
+
|---------|---------|----------|
|
|
352
|
+
| 重构/全面/重写/重做/整体/迁移 · overhaul/migrate/rewrite/revamp | broad | MUST (ignores auto_confirm) |
|
|
353
|
+
| named single file/function/bug, "fix X", "add Y to Z" | narrow | skip — auto-derive |
|
|
354
|
+
| otherwise | medium | clarify unless auto_confirm |
|
|
355
|
+
|
|
356
|
+
**2. Clarify boundary** (broad/medium) — `AskUserQuestion`, ≤3 rounds, options pre-filled from intent + a quick Glob/Grep scan of the target module:
|
|
357
|
+
|
|
358
|
+
| Round | Question | Drives |
|
|
359
|
+
|-------|----------|--------|
|
|
360
|
+
| Scope | 哪些目录/文件/层在范围内?明确排除什么? | boundary_contract.in_scope / out_of_scope |
|
|
361
|
+
| Constraints | 必须向后兼容?公共 API 冻结?行为/性能预算?测试门槛? | boundary_contract.constraints + execution_criteria |
|
|
362
|
+
| Done | 什么可观测结果算"完成"?(如:测试全绿 + 行为零变更 + X 指标) | boundary_contract.definition_of_done |
|
|
363
|
+
|
|
364
|
+
narrow → derive defaults from intent + codebase, skip questions.
|
|
365
|
+
|
|
366
|
+
**3. Derive `execution_criteria`**: backward-compat、scope-freeze、test/coverage bar、fix-don't-hide、incremental commit。
|
|
367
|
+
|
|
368
|
+
**4. Derive `task_decomposition`** (子目标清单 — outcome-oriented, NOT lifecycle stages). Each entry:
|
|
369
|
+
```json
|
|
370
|
+
{ "id": "G1", "goal": "<deliverable>", "boundary": "<in/out note>",
|
|
371
|
+
"done_when": "<objectively checkable condition>",
|
|
372
|
+
"evidence": "verification.json|review.json|uat.md|e2e-results.json|<test path>",
|
|
373
|
+
"lifecycle": ["analyze","execute"], "status": "pending" }
|
|
374
|
+
```
|
|
375
|
+
`done_when` 必须客观可验证,且引用 ralph 已产出的 artifact;`lifecycle` 字段映射到产出 evidence 的生命周期 stage。涉及前端可用性的子目标,`done_when` 应引用 `e2e-results.json`(frontend-verify 门产出),不得仅以后端 API/build 证据判定可用。
|
|
376
|
+
|
|
377
|
+
**5. Persist** (additive): `boundary_contract`, `execution_criteria`, `task_decomposition`。每个 sub-goal 含 `status: "pending"` + `completion_confirmed: false`。
|
|
378
|
+
|
|
379
|
+
**6. Stage** the Goal Prompt (Appendix) for A_CREATE_SESSION to emit.
|
|
380
|
+
|
|
381
|
+
### A_BUILD_STEPS
|
|
382
|
+
|
|
383
|
+
Generate steps from `session.lifecycle_position` to `milestone-complete`(`session.milestone` 存在时)或最后一个质量门(standalone 时)。
|
|
384
|
+
|
|
385
|
+
> **v2 执行模型**:每个 step 由 Agent(ralph-executor) 派发执行,非主会话内联。Agent 内部调 `maestro ralph next` 获取 skill prompt 并执行,结果通过 task-notification 回传主流程。
|
|
386
|
+
|
|
387
|
+
| Stage | Skill (independent) | Skill (unified) | Decision after | quality_mode |
|
|
388
|
+
|-------|---------------------|-----------------|----------------|--------------|
|
|
389
|
+
| grill | `maestro-grill "{intent}"` | *(same)* | — | all (**auto_confirm → 透传 `-y` 到 grill args,不删除 stage**) |
|
|
390
|
+
| brainstorm | `maestro-brainstorm "{intent}" --from grill:{grill_id}` *(if grill ran)* / `maestro-brainstorm "{intent}"` *(otherwise)* | *(same)* | — | all |
|
|
391
|
+
| blueprint | `maestro-blueprint "{intent}"` | *(same)* | — | all |
|
|
392
|
+
| init | `maestro-init` | *(same)* | — | all |
|
|
393
|
+
| spec-setup | `spec-setup` | *(same)* | — | all (**仅当 `.workflow/specs/` 不存在时插入**) |
|
|
394
|
+
| analyze-macro | `maestro-analyze "{intent}"` | *(same)* | `post-analyze-scope` | all |
|
|
395
|
+
| roadmap | `maestro-roadmap --from analyze:{analyze_macro_id}` | *(same)* | — | all |
|
|
396
|
+
| analyze | `maestro-analyze {phase}` | `maestro-analyze` | — | all |
|
|
397
|
+
| plan | `maestro-plan {phase}` *(scope=phase)* / `maestro-plan --from analyze:{analyze_macro_id}` *(scope=standalone)* / `maestro-plan --from blueprint:{blueprint_id}` *(scope=standalone)* | `maestro-plan` | — | all |
|
|
398
|
+
| execute | `maestro-execute {phase}` | `maestro-execute` | `post-execute` | all |
|
|
399
|
+
| business-test | `quality-auto-test {phase}` | `quality-auto-test` | `post-business-test` | full only |
|
|
400
|
+
| review | `quality-review {phase}` | `quality-review` | `post-review` | all (quick: append `--tier quick`) |
|
|
401
|
+
| test-gen | `quality-auto-test {phase}` | `quality-auto-test` | — | full / standard if coverage<80% |
|
|
402
|
+
| test | `quality-test {phase}` | `quality-test` | `post-test` | full, standard |
|
|
403
|
+
| frontend-verify | `quality-test {phase} --frontend-verify` | `quality-test --frontend-verify` | `post-frontend-verify` | all(**仅当 phase 交付 UI 时插入**:检出 `dashboard/` 或 UI 关键词 `landing\|page\|dashboard\|frontend\|UI\|component\|界面`) |
|
|
404
|
+
| milestone-audit | `maestro-milestone-audit` | *(same)* | — | all |
|
|
405
|
+
| goal-audit | *(decision-only)* | *(same)* | `post-goal-audit` | all (only if decomposed) |
|
|
406
|
+
| milestone-complete | `maestro-milestone-complete` | *(same)* | `post-milestone` | all |
|
|
407
|
+
|
|
408
|
+
**Build rules (按顺序应用):**
|
|
409
|
+
|
|
410
|
+
0. **planning_mode 选列**:`unified` → Skill (unified) 列;`independent` → Skill (independent) 列
|
|
411
|
+
0.5. **specs 预检**:当 `lifecycle_position ∉ {grill, brainstorm, blueprint, init}` 且 `.workflow/specs/` 目录不存在时,在链路最前面插入 `spec-setup` 步骤(stage=`spec-setup`,无 decision)。确保下游 analyze/plan/execute 可获得项目约束规则注入
|
|
412
|
+
1. **起点**:从 `session.lifecycle_position` 开始
|
|
413
|
+
2. **跳过已完成**:跳过当前 milestone+phase 下已有 completed artifact 的 stage(按 `session.phase` 过滤);unified 按 milestone 过滤
|
|
414
|
+
3. **quality_mode 过滤**:按 `session.quality_mode` 排除不匹配 stage
|
|
415
|
+
3.5. **grill auto_confirm 透传**:`auto_confirm == true` 时为 `grill` step args 追加 `-y`(grill 自身 Auto mode 用代码代答,见 maestro-grill `<context>` Mode selection);保留 `grill` stage 与 brainstorm 的 `--from grill:*`(grill 仍产出 grill-report/terminology/context-package)
|
|
416
|
+
3.6. **frontend-verify UI 门控**:仅当当前 phase 交付前端(检出 `dashboard/` 目录,或 phase 目标/计划含 UI 关键词 `landing|page|dashboard|frontend|UI|component|界面`)时保留 `frontend-verify` stage + `post-frontend-verify` decision;纯后端 phase 删除该 stage
|
|
417
|
+
4. **决策节点**:每个 Decision after 非空的 stage 之后插入 `{ decision: "<gate>", retry_count: 0, max_retries: 2, command_scope: null, command_path: null }`
|
|
418
|
+
5. **goal-audit 插入**:`task_decomposition` 存在时,在最后一个 evidence-producing stage(execute/review/test)之后、`milestone-complete` 之前插入 `decision:post-goal-audit`
|
|
419
|
+
5.5. **re-grounding 插入**:WHEN `task_decomposition` 存在 AND 执行 step(不含 decision)≥3
|
|
420
|
+
- 从第 3 个执行 step 起每隔 3 个插入 `{ decision: "post-reground", retry_count: 0, max_retries: 0, command_scope: null, command_path: null }`
|
|
421
|
+
- 不在最后一个执行 step 后插入(由 goal-audit 覆盖)
|
|
422
|
+
- 不与已有 quality-gate decision 节点相邻(顺延到下一个 3-step 边界)
|
|
423
|
+
- fix-loop 动态插入的 step **纳入**计数(从插入点起重新计算 3-step 间隔)
|
|
424
|
+
6. **终点硬约束**:`session.milestone` 存在时 chain 以 `milestone-complete` 结尾;`session.milestone=null`(standalone)时跳过 `milestone-audit` + `milestone-complete` stage,chain 以最后一个质量门 stage 结尾
|
|
425
|
+
7. **goal_ref 传播**:`task_decomposition` 存在时,每个 step 按 `step.stage ∈ g.lifecycle` 匹配 `step.goal_ref = g.id`(多匹配取字典序最小);decision 节点不打 goal_ref
|
|
426
|
+
8. **占位符**:independent 保留 `{phase}` `{intent}`;unified 不带 `{phase}`
|
|
427
|
+
9. **command_path 解析**(每个执行 step,decision 节点跳过):
|
|
428
|
+
- 取 skill 名(args 前的第一个 token)
|
|
429
|
+
- **预校验通过 `Bash("maestro ralph skills --platform claude --json --quiet")`** 一次性拉取 claude 平台可用 commands + skills(global + project,project 覆盖 global),匹配 skill 名得到:
|
|
430
|
+
- 命中 commands → `command_scope = "global" | "project"`,`command_path = <绝对路径>`
|
|
431
|
+
- 命中 skills → 同上(type=skill)
|
|
432
|
+
- 未命中 → `command_scope = "missing"`, `command_path = null`,A_CREATE_SESSION 报错 E006
|
|
433
|
+
- **不在 build 阶段读取 .md 内容**;`<required_reading>` / `<deferred_reading>` 解析与加载由 `maestro ralph next` CLI 在执行期完成
|
|
434
|
+
10. **每个 step 初始化** `completion_confirmed: false`, `completion_status: null`, `completion_evidence: null`, `completion_summary: null`, `completion_decisions: null`, `completion_caveats: null`, `completion_deferred: null`, `deferred_reads: []`, `load: null`(由 `ralph next` 写入)
|
|
435
|
+
11. **scope_verdict gating**(仅当 chain 起点 = `analyze-macro`):
|
|
436
|
+
- `scope_verdict == large` **且** `wants_roadmap` → 保留 `roadmap` + `analyze`;`plan` 选 phase 列(`{phase}`)
|
|
437
|
+
- 其余(`medium` / `small`,或 `large` 但非 `wants_roadmap`)→ 跳过 `roadmap` + `analyze` 两 stage;`plan` 选 standalone 列(`--from analyze:{analyze_macro_id}`),不带 `{phase}`
|
|
438
|
+
- `scope_verdict == unknown` → 默认 standalone(非 roadmap)路径;由 `post-analyze-scope` 决策节点在 macro analyze 完成后纠正(A_APPLY_SCOPE_VERDICT)
|
|
439
|
+
12. **--from 自动注入**:
|
|
440
|
+
- `analyze_macro_id` 存在且当前 step 是 `roadmap` → args 改为 `--from analyze:{analyze_macro_id}`
|
|
441
|
+
- `analyze_macro_id` 存在且当前 `plan` step 处于 standalone 列(即非 wants_roadmap 路径:`medium`/`small`,或 `large` 但非 `wants_roadmap`)→ args 改为 `--from analyze:{analyze_macro_id}`
|
|
442
|
+
- `blueprint_id` 存在 → 当前 step 是 `plan` → args 改为 `--from blueprint:{blueprint_id}`(优先级低于 phase 数字参数)
|
|
443
|
+
- **phase-level deferred chaining**(独立模式,step 含 `{phase}` 占位符):build 阶段前序 artifact 尚未产出,由 A_STEP_RESOLVE_ARGS 运行时从 state.json 查找同 phase+milestone 最新 completed artifact 注入:
|
|
444
|
+
- `plan` step → `--from analyze:{phase_analyze_id}`,写 `source_artifact_ref`
|
|
445
|
+
- `execute` step → `--dir {plan_path}`(现有逻辑),写 `source_artifact_ref = "plan:{id}"`
|
|
446
|
+
- 写入 `step.source_artifact_ref` 以便审计
|
|
447
|
+
13. **D-007 Milestone-ref 标注**:每个含 `{phase}` 占位符的 step → `step.milestone_id = session.milestone`(由 A_RESOLVE_PHASE 反查得出),禁止读 `current_milestone`
|
|
448
|
+
14. **动态插入步骤**(A_APPLY_*)同样应用规则 7-13
|
|
449
|
+
|
|
450
|
+
### A_CREATE_SESSION
|
|
451
|
+
1. `session_id` format: `ralph-v2-{YYYYMMDD-HHmmss}`
|
|
452
|
+
2. Validate: 所有 step 的 `command_scope != "missing"`;否则 raise E006 + 列出缺失 skill
|
|
453
|
+
3. Additional fields: `execution_mode: "agent"`,无 `cli_tool` 字段
|
|
454
|
+
4. Each step: `agent_exec_name: null`(执行 Agent 名称标识)
|
|
455
|
+
5. Step mode/role/rule assigned per stage (see Stage Mapping table)
|
|
456
|
+
|
|
457
|
+
### A_STEP_RESOLVE_ARGS
|
|
458
|
+
|
|
459
|
+
解析占位符 + 丰富参数。在 `ralph next` 之前执行。
|
|
460
|
+
|
|
461
|
+
**1. Placeholder substitution:**
|
|
462
|
+
|
|
463
|
+
| Placeholder | Source |
|
|
464
|
+
|-------------|--------|
|
|
465
|
+
| `{phase}` | session.phase |
|
|
466
|
+
| `{milestone}` | session.milestone |
|
|
467
|
+
| `{intent}` | session.intent |
|
|
468
|
+
| `{description}` | session.intent (alias) |
|
|
469
|
+
| `{scratch_dir}` | session.context.scratch_dir or latest artifact path |
|
|
470
|
+
| `{plan_dir}` | session.context.plan_dir |
|
|
471
|
+
| `{analysis_dir}` | session.context.analysis_dir |
|
|
472
|
+
| `{issue_id}` | session.context.issue_id |
|
|
473
|
+
| `{milestone_num}` | session.context.milestone_num |
|
|
474
|
+
|
|
475
|
+
**2. Per-skill enrichment** (when args empty or minimal):
|
|
476
|
+
|
|
477
|
+
| Skill | Required context | Source |
|
|
478
|
+
|-------|-----------------|--------|
|
|
479
|
+
| maestro-brainstorm | topic | `"{intent}"` |
|
|
480
|
+
| maestro-roadmap | description | `"{intent}"` |
|
|
481
|
+
| maestro-analyze | phase or topic | `{phase}` or `"{intent}"` |
|
|
482
|
+
| maestro-plan | phase, --from, or --dir | see --from auto-injection below |
|
|
483
|
+
| maestro-execute | phase or --dir | see --from auto-injection below |
|
|
484
|
+
| quality-debug | gap context | Read previous step's error/gap |
|
|
485
|
+
| quality-* | phase | `{phase}` |
|
|
486
|
+
|
|
487
|
+
**3. --from auto-injection (phase-level artifact chaining):**
|
|
488
|
+
|
|
489
|
+
```
|
|
490
|
+
Read state.json.artifacts(含 milestone_history 内归档 artifacts)
|
|
491
|
+
→ filter by milestone={session.milestone} + phase={session.phase} + status=="completed"
|
|
492
|
+
|
|
493
|
+
plan step(含 {phase} 占位符,args 无 --from 且无 --dir):
|
|
494
|
+
1. 查同 phase+milestone 最新 completed type=="analyze" artifact → id = ANL-xxx
|
|
495
|
+
2. 命中 → args 追加 --from analyze:{id}
|
|
496
|
+
3. 写 step.source_artifact_ref = "analyze:{id}"
|
|
497
|
+
|
|
498
|
+
execute step(含 {phase} 占位符,args 无 --dir):
|
|
499
|
+
1. 查同 phase+milestone 最新 completed type=="plan" artifact → id = PLN-xxx, path = scratch/...
|
|
500
|
+
2. 命中 → args 追加 --dir .workflow/scratch/{path}
|
|
501
|
+
3. 写 step.source_artifact_ref = "plan:{id}"
|
|
502
|
+
```
|
|
503
|
+
|
|
504
|
+
兜底:查询无结果 → 不注入,由命令自身 discovery 逻辑处理。已有 `--from` 或 `--dir` 的 step 不覆盖。
|
|
505
|
+
|
|
506
|
+
**4. Goal context injection:**
|
|
507
|
+
|
|
508
|
+
当 `step.goal_ref` 非空且 `session.task_decomposition` 存在时:
|
|
509
|
+
```
|
|
510
|
+
goal = session.task_decomposition.find(g => g.id == step.goal_ref)
|
|
511
|
+
if goal:
|
|
512
|
+
goal_snippet = { id: goal.id, goal: goal.goal, done_when: goal.done_when,
|
|
513
|
+
boundary: goal.boundary, evidence: goal.evidence }
|
|
514
|
+
→ 传递给 A_STEP_DISPATCH 注入 agent prompt
|
|
515
|
+
```
|
|
516
|
+
|
|
517
|
+
**5. Write** enriched args + source_artifact_ref back to status.json.
|
|
518
|
+
|
|
519
|
+
### A_STEP_DISPATCH
|
|
520
|
+
|
|
521
|
+
加载前序产出 + 组装上下文 + 派发 executor agent 执行单步。Agent 内部调 `maestro ralph next` 获取 skill prompt 并执行。
|
|
522
|
+
|
|
523
|
+
**1. Load previous step context:**
|
|
524
|
+
|
|
525
|
+
- 读前一 completed step 的 `completion_summary` + `completion_caveats` + `completion_decisions` + `completion_deferred`
|
|
526
|
+
- 按 `session.context` 中的路径逐个 Read,提取与当前 step 相关的内容:
|
|
527
|
+
|
|
528
|
+
| 当前 stage | 加载什么 | Source |
|
|
529
|
+
|-----------|---------|--------|
|
|
530
|
+
| plan | analysis conclusions + scope_verdict | `{context.analysis_dir}/conclusions.json` |
|
|
531
|
+
| execute | task list + wave assignments | `{context.plan_dir}/TASK-*.json` |
|
|
532
|
+
| review | changed files + verification results | `{context.scratch_dir}/verification.json` |
|
|
533
|
+
| test | review findings | `review.json` |
|
|
534
|
+
| debug | error traces + failing test details | 前一 step 的 `completion_evidence` |
|
|
535
|
+
| brainstorm | grill report | `{context.grill_id}` report |
|
|
536
|
+
|
|
537
|
+
- Explore if needed — 产物指向代码位置但缺少上下文 → `maestro explore` 补充(仅 execute/debug/test 且有文件路径引用时)
|
|
538
|
+
- Accumulated signals — 遍历 ALL completed steps → 聚合 caveats + deferred
|
|
539
|
+
|
|
540
|
+
**2. Goal context pre-injection:**
|
|
541
|
+
|
|
542
|
+
- GUARD: `ralph_protocol_version >= "2"` → skip(session_anchor 已含 goal context)
|
|
543
|
+
- WHEN `ralph_protocol_version < "2"` 或缺失 AND `step.goal_ref` 非空 → 组装 `<goal_context>` 块注入 prompt:
|
|
544
|
+
```
|
|
545
|
+
<goal_context>
|
|
546
|
+
Sub-goal: {goal.id} — {goal.goal}
|
|
547
|
+
Done when: {goal.done_when}
|
|
548
|
+
Boundary: {goal.boundary}
|
|
549
|
+
Evidence target: {goal.evidence}
|
|
550
|
+
Execution criteria: {session.execution_criteria joined by '; '}
|
|
551
|
+
</goal_context>
|
|
552
|
+
```
|
|
553
|
+
|
|
554
|
+
**3. Resolve agent name:** `{stage_prefix}-{session_id_short}-{HHmmss}`
|
|
555
|
+
|
|
556
|
+
| Stage | Prefix |
|
|
557
|
+
|-------|--------|
|
|
558
|
+
| grill | `grl` |
|
|
559
|
+
| brainstorm | `brn` |
|
|
560
|
+
| analyze-macro | `anm` |
|
|
561
|
+
| analyze | `ana` |
|
|
562
|
+
| plan | `pln` |
|
|
563
|
+
| execute | `exe` |
|
|
564
|
+
| review | `rev` |
|
|
565
|
+
| test | `tst` |
|
|
566
|
+
| debug | `dbg` |
|
|
567
|
+
| Other | `run` |
|
|
568
|
+
|
|
569
|
+
**4. Dispatch(unnamed executor):**
|
|
570
|
+
|
|
571
|
+
> 执行 Agent 不传 name,结果通过 task-notification `<result>` 自动回传主流程。executor 内部编排也用 unnamed Agent(子结果自动回流 executor,嵌套套娃模型)。
|
|
572
|
+
|
|
573
|
+
```
|
|
574
|
+
Agent({
|
|
575
|
+
subagent_type: "ralph-executor",
|
|
576
|
+
description: "执行 step {index}: {step.skill} [{resolved_agent_name}]",
|
|
577
|
+
prompt: `Session: {session_id}
|
|
578
|
+
|
|
579
|
+
{goal_context 块,仅 protocol < 2 时}
|
|
580
|
+
|
|
581
|
+
{loaded_step_context}
|
|
582
|
+
`
|
|
583
|
+
})
|
|
584
|
+
```
|
|
585
|
+
|
|
586
|
+
5. Write `step.agent_exec_name` to status.json(仅日志标识)
|
|
587
|
+
6. Display: `[{index}/{total}] ⟶ {step.skill} → {resolved_agent_name}`
|
|
588
|
+
7. Agent() 返回 agentId → 等待 task-notification(status=completed 时 `<result>` 含 executor 输出)
|
|
589
|
+
8. task-notification 到达后,`agent_output` = `<result>` 内容 → 进入 S_STEP_ANALYZE
|
|
590
|
+
9. task-notification status=failed → STATUS=BLOCKED,转 S_HANDLE_FAIL
|
|
591
|
+
|
|
592
|
+
### A_STEP_EXTRACT
|
|
593
|
+
|
|
594
|
+
从 agent 返回的执行输出中提取结构化信号,用于 completion 参数组装。
|
|
595
|
+
|
|
596
|
+
**1. Stage-specific signal extraction:**
|
|
597
|
+
|
|
598
|
+
| Stage | 提取什么 | 写入字段 |
|
|
599
|
+
|-------|---------|---------|
|
|
600
|
+
| analyze | `conclusions.json` scope_verdict + key_findings | `--summary`, context.analysis_dir |
|
|
601
|
+
| plan | TASK-*.json 数量 + 主要模块 + 波次 | `--summary`, context.plan_dir |
|
|
602
|
+
| execute | 修改文件数 + verification passed/failed | `--summary`, `--evidence`, context.scratch_dir |
|
|
603
|
+
| review | verdict + findings 数量 + severity | `--summary`, `--decisions` |
|
|
604
|
+
| test | pass/fail 统计 | `--summary`, `--evidence` |
|
|
605
|
+
| debug | root cause + 修复内容 | `--summary`, `--decisions` |
|
|
606
|
+
| grill | 核心质疑点数量 | `--summary`, `--caveats`, context.grill_id |
|
|
607
|
+
| brainstorm | 候选方案数 + 推荐方案 | `--summary`, `--decisions`, context.brainstorm_dir |
|
|
608
|
+
|
|
609
|
+
**2. Artifact scanning** — Use Glob 查找执行期间新增/修改的产物:
|
|
610
|
+
|
|
611
|
+
| Pattern | Signal |
|
|
612
|
+
|---------|--------|
|
|
613
|
+
| `conclusions.json` | `analysis_dir` |
|
|
614
|
+
| `TASK-*.json` | `plan_dir` |
|
|
615
|
+
| `verification.json` | `scratch_dir` |
|
|
616
|
+
| `review.json` | review stage |
|
|
617
|
+
| `test-results.json`, `uat.md` | test stage |
|
|
618
|
+
| `grill-report.md` | `grill_id` |
|
|
619
|
+
| `.brainstorming/*` | `brainstorm_dir` |
|
|
620
|
+
|
|
621
|
+
**3. Output text signal extraction** — 从执行输出文本中提取:
|
|
622
|
+
|
|
623
|
+
| Signal pattern | 写入 |
|
|
624
|
+
|----------------|------|
|
|
625
|
+
| `ANL-xxx` (artifact ID) | `session.analyze_macro_id` |
|
|
626
|
+
| `PLN-xxx` (artifact ID) | `context.plan_dir` |
|
|
627
|
+
| `BLP-xxx` (artifact ID) | `session.blueprint_id` |
|
|
628
|
+
| `scratch_dir:` 或 `.workflow/scratch/` 路径 | `context.scratch_dir` |
|
|
629
|
+
| `plan_dir:` 路径 | `context.plan_dir` |
|
|
630
|
+
| `PHASE: N` | `session.context.phase` |
|
|
631
|
+
|
|
632
|
+
**4. STATUS determination:**
|
|
633
|
+
|
|
634
|
+
| 条件 | STATUS |
|
|
635
|
+
|------|--------|
|
|
636
|
+
| Skill 正常完成 + 有产物 | `DONE` |
|
|
637
|
+
| 完成但有 warnings/concerns | `DONE_WITH_CONCERNS` |
|
|
638
|
+
| 执行出错但可重试(临时错误、网络问题) | `NEEDS_RETRY` |
|
|
639
|
+
| 执行出错且无法重试(schema 错误、command_path 不可达) | `BLOCKED` |
|
|
640
|
+
| Agent 返回 null(崩溃/超时) | `BLOCKED` |
|
|
641
|
+
|
|
642
|
+
**5. Compose completion params:**
|
|
643
|
+
|
|
644
|
+
| Param | 规则 | 组装方法 |
|
|
645
|
+
|-------|------|---------|
|
|
646
|
+
| `--summary` | MUST。动词开头,≤100 字 | `"<动词><做了什么>,<量化结果>"` |
|
|
647
|
+
| `--decisions` | SHOULD。每条一个架构/技术决策 | 从执行中做出的非显而易见的选择 |
|
|
648
|
+
| `--caveats` | SHOULD。后续 step 须知 | 发现但不属于本步解决的问题 |
|
|
649
|
+
| `--deferred` | SHOULD。推迟工作项 | 被主动推迟的项 |
|
|
650
|
+
| `--evidence` | SHOULD。验证产物路径 | 指向验证结果文件 |
|
|
651
|
+
| `--concerns` | COND。仅 DONE_WITH_CONCERNS 时 | CAVEATS 内容同时映射为 --concerns |
|
|
652
|
+
|
|
653
|
+
### A_STEP_DRIFT_ANALYZE
|
|
654
|
+
|
|
655
|
+
产物 vs 目标偏离分析。A_STEP_EXTRACT 后、A_STEP_COMPLETE 前执行。
|
|
656
|
+
|
|
657
|
+
**1. 收集对照基准:**
|
|
658
|
+
|
|
659
|
+
| 基准来源 | 取值 |
|
|
660
|
+
|---------|------|
|
|
661
|
+
| `step.goal_ref` → goal.done_when | 子目标完成条件 |
|
|
662
|
+
| `session.boundary_contract.definition_of_done` | 全局验收标准 |
|
|
663
|
+
| `session.execution_criteria` | 执行准则 |
|
|
664
|
+
| `session.intent` | 原始意图 |
|
|
665
|
+
|
|
666
|
+
**2. 对比评分:**
|
|
667
|
+
|
|
668
|
+
| 维度 | 检查 |
|
|
669
|
+
|------|------|
|
|
670
|
+
| 覆盖度 | 产物是否覆盖 goal.done_when 每个条件 |
|
|
671
|
+
| 方向性 | decisions 是否与 intent/boundary 一致 |
|
|
672
|
+
| 完整性 | 预期产物类型是否齐全 |
|
|
673
|
+
|
|
674
|
+
**drift_score:**
|
|
675
|
+
- `ALIGNED` — 全部维度通过
|
|
676
|
+
- `MINOR_DRIFT` — 小缺口,不影响后续
|
|
677
|
+
- `MAJOR_DRIFT` — 方向性偏离或关键产物缺失
|
|
678
|
+
|
|
679
|
+
**3. 修正动作:**
|
|
680
|
+
|
|
681
|
+
| drift_score | 动作 |
|
|
682
|
+
|-------------|------|
|
|
683
|
+
| ALIGNED | 正常进入 S_STEP_COMPLETE |
|
|
684
|
+
| MINOR_DRIFT | 偏离项追加到 caveats,正常 complete |
|
|
685
|
+
| MAJOR_DRIFT + 未重试 | `Bash("maestro ralph retry {index}")` → 回到 S_STEP_DISPATCH 重执行(drift_correction 作修正上下文注入 prompt) |
|
|
686
|
+
| MAJOR_DRIFT + 已重试 | 以 DONE_WITH_CONCERNS complete |
|
|
687
|
+
|
|
688
|
+
**4. 写入:** `step.drift_score`, `step.drift_correction`
|
|
689
|
+
|
|
690
|
+
### A_STEP_COMPLETE
|
|
691
|
+
|
|
692
|
+
调 `ralph complete` 上报 + 传播上下文信号 + 循环。
|
|
693
|
+
|
|
694
|
+
1. 使用 A_STEP_EXTRACT 组装的参数调用 `ralph complete`:
|
|
695
|
+
```
|
|
696
|
+
Bash("maestro ralph complete {index} --status DONE --summary \"{SUMMARY}\" [--evidence ...] [--decisions ...] [--caveats ...] [--deferred ...]")
|
|
697
|
+
```
|
|
698
|
+
DONE_WITH_CONCERNS 时 caveats 同时映射 `--concerns`。BLOCKED 时用 `--reason`。
|
|
699
|
+
|
|
700
|
+
2. **Context signals propagation** — 将关键信号写入 `status.json.context`:
|
|
701
|
+
|
|
702
|
+
| Signal | 写入字段 |
|
|
703
|
+
|--------|---------|
|
|
704
|
+
| `analysis_dir` | `context.analysis_dir` |
|
|
705
|
+
| `plan_dir` | `context.plan_dir` |
|
|
706
|
+
| `scratch_dir` | `context.scratch_dir` |
|
|
707
|
+
| `grill_id` | `context.grill_id` |
|
|
708
|
+
| `brainstorm_dir` | `context.brainstorm_dir` |
|
|
709
|
+
| `blueprint_dir` | `context.blueprint_dir` |
|
|
710
|
+
| `ANL-xxx` | `session.analyze_macro_id` |
|
|
711
|
+
| `BLP-xxx` | `session.blueprint_id` |
|
|
712
|
+
| `phase` | `session.context.phase` |
|
|
713
|
+
|
|
714
|
+
3. Display: `[{index}/{total}] ✓ {step.skill} → {SUMMARY}`
|
|
715
|
+
4. Loop back to S_STEP_LOCATE
|
|
716
|
+
|
|
717
|
+
### A_AGENT_EVALUATE
|
|
718
|
+
|
|
719
|
+
通过 Agent 和/或 CLI delegate 评估质量门。评估模式由 `step.evaluate_via` 决定。
|
|
720
|
+
|
|
721
|
+
**1. Common setup:**
|
|
722
|
+
|
|
723
|
+
1. Resolve artifact dir: `.workflow/scratch/{artifact.path}/` with fallback glob
|
|
724
|
+
2. Parse decision metadata: `{ decision, retry_count, max_retries, evaluate_via }`
|
|
725
|
+
3. Map result files:
|
|
726
|
+
|
|
727
|
+
| Decision | Files |
|
|
728
|
+
|----------|-------|
|
|
729
|
+
| post-execute | verification.json |
|
|
730
|
+
| post-business-test | .tests/auto-test/report.json |
|
|
731
|
+
| post-review | review.json |
|
|
732
|
+
| post-test | uat.md, .tests/test-results.json |
|
|
733
|
+
| post-frontend-verify | e2e-results.json |
|
|
734
|
+
|
|
735
|
+
4. `evaluate_via` 默认值:`"agent"`(未设置时)
|
|
736
|
+
|
|
737
|
+
**2. Dispatch by mode:**
|
|
738
|
+
|
|
739
|
+
**Mode: `agent`(默认)** — 同步 Agent 评估:
|
|
740
|
+
|
|
741
|
+
```
|
|
742
|
+
Agent({
|
|
743
|
+
description: "评估 {decision} 质量门(同步评估 Agent,不传 name)",
|
|
744
|
+
prompt: "PURPOSE: 评估 {decision} 质量门结果
|
|
745
|
+
TASK: 读取以下结果文件 | 分析状态 | 评估严重性 | 给出建议
|
|
746
|
+
FILES: {result_file_paths}
|
|
747
|
+
SESSION: {session_dir}/status.json
|
|
748
|
+
EXPECTED: 输出以下格式:
|
|
749
|
+
---VERDICT---
|
|
750
|
+
STATUS: PASS|FAIL|PARTIAL|BLOCKED
|
|
751
|
+
REASON: <一句话原因>
|
|
752
|
+
GAP_SUMMARY: <差距摘要>
|
|
753
|
+
CONFIDENCE: high|medium|low
|
|
754
|
+
CONFIDENCE_SCORE: 0-100
|
|
755
|
+
WEAKEST_DIMENSION: <最弱维度>
|
|
756
|
+
---END---
|
|
757
|
+
CONSTRAINTS: 只评估不修改文件 | 置信度<60%倾向 fix | retry {n}/{max} 达上限必须 escalate"
|
|
758
|
+
})
|
|
759
|
+
```
|
|
760
|
+
|
|
761
|
+
**Mode: `cli`** — CLI delegate 评估(异步后台):
|
|
762
|
+
|
|
763
|
+
```
|
|
764
|
+
Bash({
|
|
765
|
+
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`,
|
|
766
|
+
run_in_background: true
|
|
767
|
+
})
|
|
768
|
+
```
|
|
769
|
+
等待 delegate 完成 → `maestro delegate output {exec_id}` 获取结果 → 解析 `---VERDICT---`
|
|
770
|
+
|
|
771
|
+
**Mode: `dual`** — Agent + CLI 并行评估,交叉验证:
|
|
772
|
+
|
|
773
|
+
1. 先派发 CLI delegate(`run_in_background: true`)
|
|
774
|
+
2. 同时派发同步 Agent(阻塞等待)
|
|
775
|
+
3. Agent 返回后,检查 CLI delegate 状态(`maestro delegate status {exec_id}`)
|
|
776
|
+
4. 合并裁决:
|
|
777
|
+
|
|
778
|
+
| Agent 结果 | CLI 结果 | 合并策略 |
|
|
779
|
+
|-----------|---------|---------|
|
|
780
|
+
| 两者一致 | — | 采用共识,confidence_score 取较高值 |
|
|
781
|
+
| Agent=PASS, CLI=FAIL | — | 降级为 PARTIAL,confidence_score 取平均值 |
|
|
782
|
+
| Agent=FAIL, CLI=PASS | — | 维持 FAIL(保守策略) |
|
|
783
|
+
| CLI 未返回 | — | 使用 Agent 结果,标 `"cli_pending": true` |
|
|
784
|
+
|
|
785
|
+
**3. Verdict parse + adjustment(所有模式通用):**
|
|
786
|
+
|
|
787
|
+
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)
|
|
788
|
+
6. Confidence adjustment: <60 + proceed → fix; >95 + fix + retry>0 → suggest proceed
|
|
789
|
+
7. **Decision log**: Append to `{session_dir}/decisions.ndjson`:
|
|
790
|
+
```json
|
|
791
|
+
{ "id": "DEC-{timestamp}", "timestamp": "{ISO}", "source": "ralph-v2",
|
|
792
|
+
"node_id": "{step.decision}", "type": "quality-gate",
|
|
793
|
+
"evaluate_via": "{mode}", "cli_exec_id": "{exec_id|null}",
|
|
794
|
+
"verdict": "{adjusted_verdict}", "confidence_score": {N},
|
|
795
|
+
"parse_failed": false,
|
|
796
|
+
"close_call": {N>=50 && N<=70}, "summary": "{REASON}" }
|
|
797
|
+
```
|
|
798
|
+
|
|
799
|
+
### A_AGENT_GOAL_AUDIT
|
|
800
|
+
|
|
801
|
+
通过 Agent 和/或 CLI delegate 审计子目标完成情况。支持 `evaluate_via` 三种模式(同 A_AGENT_EVALUATE)。
|
|
802
|
+
|
|
803
|
+
1. Read `session.task_decomposition` from status.json
|
|
804
|
+
2. Dispatch audit(按 `evaluate_via` 模式,默认 `agent`):
|
|
805
|
+
```
|
|
806
|
+
Agent({
|
|
807
|
+
description: "审计子目标完成情况(同步评估 Agent,不传 name)",
|
|
808
|
+
prompt: "PURPOSE: 审计未完成子目标,判定 met / unmet
|
|
809
|
+
TASK:
|
|
810
|
+
1. 读取 {session_dir}/status.json 中 task_decomposition 的 status!=done 子目标
|
|
811
|
+
2. 打开 evidence 产物,对照 done_when 严格判定
|
|
812
|
+
3. 输出 met / unmet,unmet 给出 gap + target_phase
|
|
813
|
+
4. 对照 intent + definition_of_done 判定意图保真
|
|
814
|
+
CONTEXT:
|
|
815
|
+
status.json = {session_dir}/status.json
|
|
816
|
+
intent = {session.intent}
|
|
817
|
+
definition_of_done = {boundary_contract.definition_of_done}
|
|
818
|
+
execution_criteria = {execution_criteria}
|
|
819
|
+
boundary_contract = {boundary_contract}
|
|
820
|
+
EXPECTED:
|
|
821
|
+
---VERDICT---
|
|
822
|
+
STATUS: all_met|has_unmet
|
|
823
|
+
INTENT_ALIGNED: true|false
|
|
824
|
+
UNMET: [{id:G2,gap:'...',target_phase:execute}, ...]
|
|
825
|
+
CONFIDENCE_SCORE: 0-100
|
|
826
|
+
---END---
|
|
827
|
+
CONSTRAINTS: 只评估不修改文件 | 严格按 done_when 判定 | evidence 缺失→unmet"
|
|
828
|
+
})
|
|
829
|
+
```
|
|
830
|
+
3. On return: parse verdict, update task_decomposition status
|
|
831
|
+
4. Append `{session_dir}/decisions.ndjson`:`{ "type": "goal-gate", "evaluate_via": "{mode}", "unmet_count": N, "unmet_ids": [...] }`
|
|
832
|
+
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
|
|
833
|
+
GUARD: retry_count >= max_retries AND still unmet → A_APPLY_ESCALATE
|
|
834
|
+
|
|
835
|
+
### A_AGENT_REGROUND
|
|
836
|
+
|
|
837
|
+
通过 Agent 和/或 CLI delegate 执行意图保真检查。支持 `evaluate_via` 三种模式(同 A_AGENT_EVALUATE)。
|
|
838
|
+
|
|
839
|
+
1. Read status.json:intent, boundary_contract, completed steps, done goals
|
|
840
|
+
2. Dispatch reground(按 `evaluate_via` 模式,默认 `agent`):
|
|
841
|
+
```
|
|
842
|
+
Agent({
|
|
843
|
+
description: "意图保真检查(同步评估 Agent,不传 name)",
|
|
844
|
+
prompt: "PURPOSE: 意图保真检查 — 对照 intent 验证累积执行是否漂移
|
|
845
|
+
TASK:
|
|
846
|
+
1. 读取 intent + boundary_contract.definition_of_done
|
|
847
|
+
2. 读取已完成 steps 的 completion_evidence + 已 done 子目标
|
|
848
|
+
3. 判定累积产出是否仍服务 intent
|
|
849
|
+
4. 输出 aligned / drifted + drift_description + corrective_action
|
|
850
|
+
CONTEXT:
|
|
851
|
+
status.json = {session_dir}/status.json
|
|
852
|
+
intent = {session.intent}
|
|
853
|
+
definition_of_done = {boundary_contract.definition_of_done}
|
|
854
|
+
in_scope = {boundary_contract.in_scope}
|
|
855
|
+
out_of_scope = {boundary_contract.out_of_scope}
|
|
856
|
+
goal_changelog = {session.goal_changelog ?? []}
|
|
857
|
+
EXPECTED:
|
|
858
|
+
---VERDICT---
|
|
859
|
+
STATUS: aligned|drifted
|
|
860
|
+
DRIFT_DESCRIPTION: <空或具体描述>
|
|
861
|
+
CORRECTIVE_ACTION: <空或建议>
|
|
862
|
+
CONFIDENCE_SCORE: 0-100
|
|
863
|
+
---END---
|
|
864
|
+
CONSTRAINTS: 只评估不修改文件 | aligned 阈值≥80% | 单个 step 触碰 out_of_scope→直接 drifted"
|
|
865
|
+
})
|
|
866
|
+
```
|
|
867
|
+
3. On return: parse verdict
|
|
868
|
+
4. Append `{session_dir}/decisions.ndjson`
|
|
869
|
+
5. Verdict routing:aligned → A_APPLY_PROCEED;drifted + confidence >= 60 → A_REGROUND_HALT;drifted + confidence < 60 → A_APPLY_PROCEED (LOW CONFIDENCE)
|
|
870
|
+
|
|
871
|
+
### A_SCOPE_EVALUATE
|
|
872
|
+
|
|
873
|
+
仅由 `post-analyze-scope` 决策节点触发。
|
|
874
|
+
|
|
875
|
+
1. 定位刚完成的 macro analyze artifact → `analyze_macro_id`, `conclusions_path`
|
|
876
|
+
2. 读取 `conclusions.scope_verdict`(`large | medium | small`),缺失 → `unknown`
|
|
877
|
+
3. 写入 `session.scope_verdict` + `session.analyze_macro_id`
|
|
878
|
+
4. Append `{session_dir}/decisions.ndjson`:`{ "type": "scope-gate", "source": "ralph-v2", "verdict": "{scope_verdict}", "analyze_macro_id": "{ANL_ID}" }`
|
|
879
|
+
|
|
880
|
+
### A_STRUCTURAL_EVALUATE
|
|
881
|
+
|
|
882
|
+
**post-milestone:**
|
|
883
|
+
1. Read state.json → resolve milestone type(default `"standard"`)
|
|
884
|
+
2. Standard milestone:next milestone exists → insert lifecycle steps / complete
|
|
885
|
+
3. Adhoc milestone(`type == "adhoc"`):always END,set `current_milestone = null`
|
|
886
|
+
|
|
887
|
+
**post-debug-escalate:** always → A_PAUSE_ESCALATE
|
|
888
|
+
|
|
889
|
+
### A_SHOW_STATUS
|
|
890
|
+
|
|
891
|
+
1. Find latest `ralph-v2-*` session(by created_at)
|
|
892
|
+
2. Display: Session, Status, Position, Progress, Current step
|
|
893
|
+
3. List steps: [✓] confirmed, [▸] current, [ ] pending, [◆] decision;执行 step 附 `command_scope` + `command_path`
|
|
894
|
+
4. If `task_decomposition` present → 显示 sub-goals 进度(done/total)
|
|
895
|
+
|
|
896
|
+
### A_APPLY_PROCEED / A_APPLY_FIX / A_APPLY_ESCALATE
|
|
897
|
+
|
|
898
|
+
- **A_APPLY_PROCEED**: Mark decision completed, write status.json
|
|
899
|
+
- **A_APPLY_FIX**: Insert fix-loop steps after current step(见 Fix-Loop Templates),reindex,increment retry_count
|
|
900
|
+
- **A_APPLY_ESCALATE**: Insert `[quality-debug "{gap_summary}", decision:post-debug-escalate]`,reindex
|
|
901
|
+
|
|
902
|
+
### A_APPLY_SCOPE_VERDICT
|
|
903
|
+
|
|
904
|
+
依据 `session.scope_verdict` + `session.wants_roadmap` 重塑下游链路:
|
|
905
|
+
|
|
906
|
+
1. 路径 A(`large` 且 `wants_roadmap`):保持 roadmap+analyze,`plan` 选 phase 列
|
|
907
|
+
2. 路径 B(`medium`/`small`,或 `large` 非 `wants_roadmap`):删除未完成的 `roadmap` + `analyze` step,`plan` 改为 `--from analyze:{ANL_ID}`
|
|
908
|
+
3. 路径 C(`unknown`):非 auto_confirm → AskUserQuestion;auto_confirm → 默认路径 B
|
|
909
|
+
4. Reindex steps,标 decision completed
|
|
910
|
+
|
|
911
|
+
### A_APPLY_GOAL_FIX / A_APPLY_GOAL_DONE
|
|
912
|
+
|
|
913
|
+
- **A_APPLY_GOAL_FIX**: 对每个 unmet 子目标插入 scoped mini-loop(plan --gaps + execute),`goal_ref` 标注,重新追加 `decision:post-goal-audit {retry+1}`
|
|
914
|
+
- **A_APPLY_GOAL_DONE**: set `task_decomposition[*].status="done"`, `completion_confirmed=true`, `task_decomposition_all_done=true`
|
|
915
|
+
|
|
916
|
+
### A_ADVANCE_MILESTONE
|
|
917
|
+
|
|
918
|
+
1. Update session: milestone, phase, reset passed_gates
|
|
919
|
+
2. Insert full lifecycle steps for next milestone
|
|
920
|
+
3. Reindex, write status.json
|
|
921
|
+
|
|
922
|
+
### A_REGROUND_HALT / A_PAUSE_ESCALATE
|
|
923
|
+
|
|
924
|
+
- **A_REGROUND_HALT**: set `session.status = "paused"`,display drift warning + 恢复选项。auto_confirm 不跳过
|
|
925
|
+
- **A_PAUSE_ESCALATE**: set session paused,display "请人工介入",suggest continue
|
|
926
|
+
|
|
927
|
+
### A_AMEND_GOAL
|
|
928
|
+
|
|
929
|
+
运行中 session 的目标热修改。详细流程由 `<deferred_reading>` 加载 `ralph-amend-goal.md`。
|
|
930
|
+
|
|
931
|
+
| Phase | 行为 | 产出 |
|
|
932
|
+
|-------|------|------|
|
|
933
|
+
| 1. 快照 | 读 `task_decomposition` + `boundary_contract` + 已完成 steps 的 `completion_summary` | Display: 目标列表 + 进度 |
|
|
934
|
+
| 2. 解析 | `change_request` 非空 → 直接用;为空 → AskUserQuestion(修改/新增/移除/调整边界) | `change_type` + `change_request` |
|
|
935
|
+
| 3. Mini Grill | Agent 评估影响 | RISK_LEVEL + AFFECTED_GOALS + INVALIDATED_STEPS + NEW_GAPS |
|
|
936
|
+
| 4. 确认 | AskUserQuestion:应用并继续 / 仅改目标 / 取消 | 用户选择 |
|
|
937
|
+
| 5. 应用 | 归档旧目标(`superseded`)→ 写入新目标(`origin: CHG-xxx`)→ 重建链路 → write status.json | re-dispatch |
|
|
938
|
+
|
|
939
|
+
**Phase 3 Agent prompt:**
|
|
940
|
+
```
|
|
941
|
+
Agent({
|
|
942
|
+
description: "Amend impact analysis(同步评估 Agent,不传 name)",
|
|
943
|
+
prompt: "PURPOSE: 评估目标修改对 running session 的影响
|
|
944
|
+
TASK:
|
|
945
|
+
1. 读取 {session_dir}/status.json 的 task_decomposition + boundary_contract + 已完成 steps
|
|
946
|
+
2. 分析 change_request 对既有目标/步骤的影响
|
|
947
|
+
3. 判定 RISK_LEVEL (low/medium/high)
|
|
948
|
+
4. 列出 AFFECTED_GOALS / INVALIDATED_STEPS / NEW_GAPS
|
|
949
|
+
CONTEXT:
|
|
950
|
+
change_request = {change_request}
|
|
951
|
+
change_type = {change_type}
|
|
952
|
+
session = {session_dir}/status.json
|
|
953
|
+
EXPECTED:
|
|
954
|
+
---AMEND-VERDICT---
|
|
955
|
+
RISK_LEVEL: low|medium|high
|
|
956
|
+
AFFECTED_GOALS: [G1, G2, ...]
|
|
957
|
+
INVALIDATED_STEPS: [step indices]
|
|
958
|
+
NEW_GAPS: [gap descriptions]
|
|
959
|
+
RECOMMENDATION: <建议>
|
|
960
|
+
---END---
|
|
961
|
+
CONSTRAINTS: 只评估不修改文件"
|
|
962
|
+
})
|
|
963
|
+
```
|
|
964
|
+
|
|
965
|
+
GUARD: `RISK_LEVEL == high` → AskUserQuestion 不跳过(auto_confirm 无效)
|
|
966
|
+
GUARD: 已完成(`status: "done"`)的目标不可 supersede(skip + warn)
|
|
967
|
+
旧目标标 `superseded`(`superseded_by` + `superseded_at`),新目标标 `origin: "CHG-xxx"`。`goal_changelog` 含完整 `before/after` + `impact_assessment`。
|
|
968
|
+
|
|
969
|
+
### A_RETRY / A_PAUSE_SESSION / A_COMPLETE_SESSION
|
|
970
|
+
|
|
971
|
+
- **A_RETRY**: `Bash("maestro ralph retry {index}")` — CLI 设 `step.retried = true`, `step.status = "pending"`, 清 `active_step_index`
|
|
972
|
+
- **A_PAUSE_SESSION**: `ralph complete N --status BLOCKED --reason "..."` — CLI 写 `session.status = "paused"`
|
|
973
|
+
- **A_COMPLETE_SESSION**: 校验所有 step `completion_confirmed == true` + `task_decomposition_all_done == true`(若存在),通过后写 `session.status = "completed"`。unnamed executor 执行完自动终止,无需 shutdown 清理
|
|
974
|
+
|
|
975
|
+
</actions>
|
|
976
|
+
|
|
977
|
+
</state_machine>
|
|
978
|
+
|
|
979
|
+
<appendix>
|
|
980
|
+
|
|
981
|
+
### Stage Mapping
|
|
982
|
+
|
|
983
|
+
执行 Agent 始终拥有完整工具集(read + write),由 skill 自身约束行为。Decision 评估 Agent 通过 prompt 中的 CONSTRAINTS 约束为只读。
|
|
984
|
+
|
|
985
|
+
| Stage | Skill (independent) | Skill (unified) | Decision after | quality_mode |
|
|
986
|
+
|-------|---------------------|-----------------|----------------|--------------|
|
|
987
|
+
| grill | `maestro-grill "{intent}"` | *(same)* | — | all |
|
|
988
|
+
| brainstorm | `maestro-brainstorm "{intent}"` | *(same)* | — | all |
|
|
989
|
+
| blueprint | `maestro-blueprint "{intent}"` | *(same)* | — | all |
|
|
990
|
+
| init | `maestro-init` | *(same)* | — | all |
|
|
991
|
+
| spec-setup | `spec-setup` | *(same)* | — | all |
|
|
992
|
+
| analyze-macro | `maestro-analyze "{intent}"` | *(same)* | `post-analyze-scope` | all |
|
|
993
|
+
| roadmap | `maestro-roadmap --from analyze:{id}` | *(same)* | — | all |
|
|
994
|
+
| analyze | `maestro-analyze {phase}` | `maestro-analyze` | — | all |
|
|
995
|
+
| plan | `maestro-plan {phase}` | `maestro-plan` | — | all |
|
|
996
|
+
| execute | `maestro-execute {phase}` | `maestro-execute` | `post-execute` | all |
|
|
997
|
+
| business-test | `quality-auto-test {phase}` | `quality-auto-test` | `post-business-test` | full only |
|
|
998
|
+
| review | `quality-review {phase}` | `quality-review` | `post-review` | all |
|
|
999
|
+
| test-gen | `quality-auto-test {phase}` | `quality-auto-test` | — | full / standard |
|
|
1000
|
+
| test | `quality-test {phase}` | `quality-test` | `post-test` | full, standard |
|
|
1001
|
+
| frontend-verify | `quality-test {phase} --frontend-verify` | `quality-test --frontend-verify` | `post-frontend-verify` | all (UI only) |
|
|
1002
|
+
| milestone-audit | `maestro-milestone-audit` | *(same)* | — | all |
|
|
1003
|
+
| goal-audit | *(decision-only)* | *(same)* | `post-goal-audit` | all |
|
|
1004
|
+
| milestone-complete | `maestro-milestone-complete` | *(same)* | `post-milestone` | all |
|
|
1005
|
+
|
|
1006
|
+
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)等。
|
|
1007
|
+
|
|
1008
|
+
### Session Schema
|
|
1009
|
+
|
|
1010
|
+
```json
|
|
1011
|
+
{
|
|
1012
|
+
"session_id": "ralph-v2-{YYYYMMDD-HHmmss}",
|
|
1013
|
+
"source": "ralph", "status": "running",
|
|
1014
|
+
"execution_mode": "agent",
|
|
1015
|
+
"ralph_protocol_version": "2",
|
|
1016
|
+
"active_step_index": null,
|
|
1017
|
+
"active_agent_name": null,
|
|
1018
|
+
"intent": "", "lifecycle_position": "",
|
|
1019
|
+
"phase": null, "phase_is_new": false,
|
|
1020
|
+
"milestone": "",
|
|
1021
|
+
"auto_mode": false,
|
|
1022
|
+
"decomposition_owner": "ralph",
|
|
1023
|
+
|
|
1024
|
+
"quality_mode": "standard",
|
|
1025
|
+
"planning_mode": "independent",
|
|
1026
|
+
"scope_verdict": null,
|
|
1027
|
+
"wants_roadmap": false,
|
|
1028
|
+
"analyze_macro_id": null,
|
|
1029
|
+
"blueprint_id": null,
|
|
1030
|
+
"passed_gates": [],
|
|
1031
|
+
"context": { "issue_id": null, "scratch_dir": null, "plan_dir": null,
|
|
1032
|
+
"analysis_dir": null, "brainstorm_dir": null, "blueprint_dir": null },
|
|
1033
|
+
"steps": [{
|
|
1034
|
+
"index": 0,
|
|
1035
|
+
"skill": "",
|
|
1036
|
+
"args": "",
|
|
1037
|
+
"stage": "",
|
|
1038
|
+
"scope": null,
|
|
1039
|
+
"decision": null,
|
|
1040
|
+
"evaluate_via": "agent|cli|dual",
|
|
1041
|
+
"retry_count": 0,
|
|
1042
|
+
"max_retries": 2,
|
|
1043
|
+
"command_scope": "global|project|missing|null",
|
|
1044
|
+
"command_path": "<absolute path> | null",
|
|
1045
|
+
"milestone_id": null,
|
|
1046
|
+
"source_artifact_ref": null,
|
|
1047
|
+
"status": "pending|running|completed|skipped|failed",
|
|
1048
|
+
"goal_ref": null,
|
|
1049
|
+
"completion_confirmed": false,
|
|
1050
|
+
"completion_status": null,
|
|
1051
|
+
"completion_evidence": null,
|
|
1052
|
+
"completion_summary": null,
|
|
1053
|
+
"completion_decisions": null,
|
|
1054
|
+
"completion_caveats": null,
|
|
1055
|
+
"completion_deferred": null,
|
|
1056
|
+
"completed_at": null,
|
|
1057
|
+
"deferred_reads": [],
|
|
1058
|
+
"load": null,
|
|
1059
|
+
"agent_exec_name": null,
|
|
1060
|
+
"artifacts_produced": [],
|
|
1061
|
+
"drift_score": null,
|
|
1062
|
+
"drift_correction": null
|
|
1063
|
+
}],
|
|
1064
|
+
"waves": [], "current_step": 0,
|
|
1065
|
+
|
|
1066
|
+
"boundary_contract": {
|
|
1067
|
+
"in_scope": [], "out_of_scope": [], "constraints": [], "definition_of_done": ""
|
|
1068
|
+
},
|
|
1069
|
+
"execution_criteria": [],
|
|
1070
|
+
"task_decomposition": [
|
|
1071
|
+
{ "id": "G1", "goal": "", "boundary": "", "done_when": "",
|
|
1072
|
+
"evidence": "", "lifecycle": [], "status": "pending|done|superseded",
|
|
1073
|
+
"completion_confirmed": false, "completed_at": null,
|
|
1074
|
+
"superseded_by": null, "superseded_at": null, "origin": null }
|
|
1075
|
+
],
|
|
1076
|
+
"task_decomposition_all_done": false,
|
|
1077
|
+
|
|
1078
|
+
"goal_changelog": [
|
|
1079
|
+
{ "id": "CHG-001", "timestamp": "{ISO}",
|
|
1080
|
+
"change_type": "modify|add|remove|boundary",
|
|
1081
|
+
"reason": "",
|
|
1082
|
+
"impact_assessment": { "risk_level": "low|medium|high",
|
|
1083
|
+
"invalidated_steps": [], "new_steps_inserted": 0 },
|
|
1084
|
+
"before": { "goals": [{"id":"G1","goal":"...","done_when":"..."}] },
|
|
1085
|
+
"after": { "goals": [{"id":"G1v2","goal":"...","done_when":"..."}] } }
|
|
1086
|
+
]
|
|
1087
|
+
}
|
|
1088
|
+
```
|
|
1089
|
+
|
|
1090
|
+
### Fix-Loop Templates
|
|
1091
|
+
|
|
1092
|
+
所有插入的执行 step 按 A_BUILD_STEPS 规则 9 解析 `command_path` + `command_scope`;`decision:*` 条目为 decision 节点(`step.decision` 字段)。插入的 step 通过 A_STEP_DISPATCH 派发 executor agent 逐步执行,由主流程调 `ralph complete` 上报。
|
|
1093
|
+
|
|
1094
|
+
**post-execute:**
|
|
1095
|
+
```
|
|
1096
|
+
quality-debug "{gap_summary}"
|
|
1097
|
+
maestro-plan --gaps {phase}
|
|
1098
|
+
maestro-execute {phase}
|
|
1099
|
+
decision:post-execute {retry+1}
|
|
1100
|
+
```
|
|
1101
|
+
|
|
1102
|
+
**post-business-test:**
|
|
1103
|
+
```
|
|
1104
|
+
quality-debug --from-business-test "{gap_summary}"
|
|
1105
|
+
maestro-plan --gaps {phase}
|
|
1106
|
+
maestro-execute {phase}
|
|
1107
|
+
decision:post-execute {retry: 0}
|
|
1108
|
+
quality-auto-test {phase}
|
|
1109
|
+
decision:post-business-test {retry+1}
|
|
1110
|
+
```
|
|
1111
|
+
|
|
1112
|
+
**post-review:**
|
|
1113
|
+
```
|
|
1114
|
+
quality-debug "{gap_summary}"
|
|
1115
|
+
maestro-plan --gaps {phase}
|
|
1116
|
+
maestro-execute {phase}
|
|
1117
|
+
quality-review {phase}
|
|
1118
|
+
decision:post-review {retry+1}
|
|
1119
|
+
```
|
|
1120
|
+
|
|
1121
|
+
**post-test:**
|
|
1122
|
+
```
|
|
1123
|
+
quality-debug --from-uat "{gap_summary}"
|
|
1124
|
+
maestro-plan --gaps {phase}
|
|
1125
|
+
maestro-execute {phase}
|
|
1126
|
+
decision:post-execute {retry: 0}
|
|
1127
|
+
quality-auto-test {phase}
|
|
1128
|
+
decision:post-business-test {retry: 0}
|
|
1129
|
+
quality-review {phase}
|
|
1130
|
+
decision:post-review {retry: 0}
|
|
1131
|
+
quality-auto-test {phase}
|
|
1132
|
+
quality-test {phase}
|
|
1133
|
+
decision:post-test {retry+1}
|
|
1134
|
+
```
|
|
1135
|
+
|
|
1136
|
+
**post-frontend-verify:** (UI 写端点未接线/不可用时)
|
|
1137
|
+
```
|
|
1138
|
+
quality-debug --from-frontend-verify "{gap_summary}"
|
|
1139
|
+
maestro-plan --gaps {phase}
|
|
1140
|
+
maestro-execute {phase}
|
|
1141
|
+
quality-test {phase} --frontend-verify
|
|
1142
|
+
decision:post-frontend-verify {retry+1}
|
|
1143
|
+
```
|
|
1144
|
+
|
|
1145
|
+
**post-goal-audit:** (per unmet sub-goal group)
|
|
1146
|
+
```
|
|
1147
|
+
# for each unmet sub-goal G{n}, scoped to target_phase:
|
|
1148
|
+
maestro-plan --gaps {target_phase} "G{n}: {gap}" [goal_ref: G{n}]
|
|
1149
|
+
maestro-execute {target_phase} [goal_ref: G{n}]
|
|
1150
|
+
# after all unmet groups inserted:
|
|
1151
|
+
decision:post-goal-audit {retry+1}
|
|
1152
|
+
```
|
|
1153
|
+
|
|
1154
|
+
### Error Codes
|
|
1155
|
+
|
|
1156
|
+
E001–E006, W001–W004 适用。Agent 新增:
|
|
1157
|
+
|
|
1158
|
+
| Code | Severity | Description | Recovery |
|
|
1159
|
+
|------|----------|-------------|----------|
|
|
1160
|
+
| E014 | error | Agent execution failed (Agent returned null) | Retry once, then BLOCKED |
|
|
1161
|
+
| E016 | error | Evaluation Agent verdict parse failed | Fallback fix + parse_failed: true |
|
|
1162
|
+
|
|
1163
|
+
### Success Criteria
|
|
1164
|
+
|
|
1165
|
+
- [ ] ralph-v2 owns full step loop: locate → resolve → dispatch → wait task-notification → extract → drift → complete → next
|
|
1166
|
+
- [ ] One agent per step — `Agent({ subagent_type: "ralph-executor" })` 每步派发一个 unnamed executor
|
|
1167
|
+
- [ ] Executor 内调 `maestro ralph next` 获取 skill prompt 并执行,内部编排用 unnamed Agent(子结果回流 executor)
|
|
1168
|
+
- [ ] Executor 结果通过 task-notification `<result>` 自动回传主流程
|
|
1169
|
+
- [ ] 主流程调 `maestro ralph complete` 上报(非 agent 上报)
|
|
1170
|
+
- [ ] 主流程负责 arg resolution、context loading、signal extraction、drift analysis
|
|
1171
|
+
- [ ] task-notification status=failed → STATUS=BLOCKED,转 S_HANDLE_FAIL
|
|
1172
|
+
- [ ] Unified unnamed dispatch: 执行 Agent 和评估 Agent 均不传 name,结果通过 task-notification 回传。CLI delegate 仅限评估环节
|
|
1173
|
+
- [ ] Decision evaluation 支持三种模式:agent(同步)、cli(CLI delegate)、dual(并行交叉验证)
|
|
1174
|
+
- [ ] `evaluate_via` 字段控制评估模式,默认 `"agent"`
|
|
1175
|
+
- [ ] dual 模式合并策略:一致取共识、分歧保守降级、CLI 未返回用 Agent 结果
|
|
1176
|
+
- [ ] Verdict 解析保持 `---VERDICT---` 格式,parse 失败 → fallback fix + parse_failed: true
|
|
1177
|
+
- [ ] decisions.ndjson 追加:source 字段为 `"ralph-v2"`
|
|
1178
|
+
- [ ] Session schema: `execution_mode: "agent"`,`agent_exec_name`(display 标识),含 `artifacts_produced`
|
|
1179
|
+
- [ ] Chain building(S_RESOLVE_PHASE through S_BUILD_CHAIN)自包含执行
|
|
1180
|
+
- [ ] A_STEP_DISPATCH 含前序产出加载(滑动窗口 5 step + accumulated signals + stage-specific artifacts)
|
|
1181
|
+
- [ ] `agent_exec_name` 含 stage prefix(grl/brn/anm/ana/pln/exe/rev/tst/dbg)——仅用于 display/日志标识
|
|
1182
|
+
- [ ] `--summary` 在 DONE/DONE_WITH_CONCERNS 时为 MUST(动词开头,≤100 字)
|
|
1183
|
+
- [ ] CAVEATS 在 DONE_WITH_CONCERNS 时同时映射 --concerns
|
|
1184
|
+
- [ ] A_STEP_EXTRACT 从 executor 输出提取 artifact IDs、path signals、phase signals
|
|
1185
|
+
- [ ] A_STEP_DRIFT_ANALYZE:ALIGNED/MINOR_DRIFT → complete;MAJOR_DRIFT+未重试 → retry;MAJOR_DRIFT+已重试 → DONE_WITH_CONCERNS
|
|
1186
|
+
- [ ] A_STEP_COMPLETE 将 context signals 写入 status.json.context
|
|
1187
|
+
- [ ] A_AMEND_GOAL:完整 5 步流程 + deferred_reading ralph-amend-goal.md + Agent mini grill 含完整 prompt
|
|
1188
|
+
- [ ] 旧目标标 superseded(superseded_by + superseded_at),新目标 origin: "CHG-xxx"
|
|
1189
|
+
- [ ] goal_changelog 含完整 before/after + impact_assessment
|
|
1190
|
+
- [ ] blueprint_id session 字段支持 --from blueprint:{BLP_ID} 路径
|
|
1191
|
+
- [ ] spec-setup 预检(build rule 0.5)
|
|
1192
|
+
- [ ] post-milestone adhoc 分支:mark completed + set current_milestone = null
|
|
1193
|
+
- [ ] post-reground + drifted + confidence < 60 → A_APPLY_PROCEED (LOW CONFIDENCE)
|
|
1194
|
+
- [ ] Fix-loop 插入的 step 通过 A_STEP_DISPATCH 逐步执行
|
|
1195
|
+
- [ ] re-grounding 3-step 插入规则(build rule 5.5)不变
|
|
1196
|
+
- [ ] A_REGROUND_HALT 漂移熔断(auto_confirm 不跳过)不变
|
|
1197
|
+
|
|
1198
|
+
</appendix>
|