ln-813-optimization-plan-validator
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChinesePaths: File paths (,shared/,references/) are relative to skills repo root. If not found at CWD, locate this SKILL.md directory and go up one level for repo root.../ln-*
路径: 文件路径(、shared/、references/)是相对于技能仓库根目录的。如果在当前工作目录(CWD)未找到,找到此SKILL.md所在目录并向上一级即为仓库根目录。../ln-*
ln-813-optimization-plan-validator
ln-813-optimization-plan-validator
Type: L3 Worker
Category: 8XX Optimization
Validates optimization plan (performance_map + hypotheses + context) via parallel agent review before committing to code changes. Catches feasibility issues, missing hypotheses, and incorrect conflict mappings before the strike.
类型: L3 Worker
分类: 8XX 优化
在提交代码变更前,通过多Agent并行审核验证优化方案(performance_map + 假设 + 上下文),在执行前发现可行性问题、缺失的假设以及错误的冲突映射。
Overview
概述
| Aspect | Details |
|---|---|
| Input | |
| Output | Verdict (GO / GO_WITH_CONCERNS / NO_GO), corrected context.md, agent feedback summary |
| Pattern | Parallel agent review (Codex + Gemini) + own feasibility check → merge → verdict |
| 方面 | 详情 |
|---|---|
| 输入 | |
| 输出 | 结论(GO / GO_WITH_CONCERNS / NO_GO)、修正后的context.md、Agent反馈摘要 |
| 模式 | 多Agent并行审核(Codex + Gemini)+ 自主可行性检查 → 合并结果 → 给出结论 |
Workflow
工作流
Phases: Load Context + Health Check → Materialize for Agents → Launch Agents → Feasibility Check → Merge + Debate → Verdict
阶段: 加载上下文 + 健康检查 → 为Agent准备上下文 → 启动Agent → 可行性检查 → 合并反馈 + 研讨 → 给出结论
Phase 0: Load Context + Health Check
阶段0:加载上下文 + 健康检查
MANDATORY READ: Load
MANDATORY READ: Load
shared/references/agent_review_workflow.mdshared/references/agent_delegation_pattern.md必读内容: 加载
必读内容: 加载
shared/references/agent_review_workflow.mdshared/references/agent_delegation_pattern.mdSlug Resolution
Slug解析
- If invoked via Agent with contextStore containing — use directly.
slug - If invoked standalone — ask user for target directory or scan for single slug.
.optimization/
- 如果由包含的contextStore的Agent调用 — 直接使用该slug。
slug - 如果独立调用 — 询问用户目标目录或扫描单个slug。
.optimization/
Step 1: Load Context
步骤1:加载上下文
Read from project root. Verify required sections present:
.optimization/{slug}/context.md| Section | Required | Verify |
|---|---|---|
| Performance Map | Yes | |
| Hypotheses | Yes | At least 1 hypothesis with |
| Suspicion Stack | Yes | At least 1 confirmed suspicion |
| Test Command | Yes | Non-empty |
If missing → Block: "context.md incomplete — run profiler and researcher first."
从项目根目录读取,验证是否存在所需章节:
.optimization/{slug}/context.md| 章节 | 是否必填 | 验证内容 |
|---|---|---|
| 性能地图 | 是 | |
| 假设 | 是 | 至少1个带有 |
| 疑点栈 | 是 | 至少1个已确认的疑点 |
| 测试命令 | 是 | |
若缺失 → 拦截:"context.md不完整 — 请先运行分析器和调研工具。"
Step 2: Agent Health Check
步骤2:Agent健康检查
python shared/agents/agent_runner.py --health-check- 0 agents available → , proceed with own feasibility check only
agents_launched = SKIPPED - Agents available → continue to Phase 1
python shared/agents/agent_runner.py --health-check- 无可用Agent → ,仅执行自主可行性检查
agents_launched = SKIPPED - 有可用Agent → 继续阶段1
Phase 1: Materialize Context for Agents
阶段1:为Agent准备上下文
Prepare context for external agents (they cannot read directly):
.optimization/- Ensure directory exists (with
.agent-review/containing.gitignore)* - Copy →
.optimization/{slug}/context.md.agent-review/context/{id}_optimization_plan.md - Build per-agent prompts per Step: Build Prompt (steps 1-9). Use
agent_review_workflow.md+review_base.mdmodes/plan_review.md
为外部Agent准备上下文(它们无法直接读取):
.optimization/- 确保目录存在(包含
.agent-review/的*文件).gitignore - 复制→
.optimization/{slug}/context.md.agent-review/context/{id}_optimization_plan.md - 根据的“构建提示”步骤(步骤1-9)为每个Agent构建提示。使用
agent_review_workflow.md+review_base.mdmodes/plan_review.md
Optimization-Specific Focus Areas
优化专项关注点
Replace default in prompt with:
{focus_areas}MANDATORY READ: Load optimization_review_focus.md
- Save per-agent prompts to
.agent-review/{agent}/{id}_optimization_review_prompt.md
将提示中的默认替换为:
{focus_areas}必读内容: 加载 optimization_review_focus.md
- 将每个Agent的提示保存至
.agent-review/{agent}/{id}_optimization_review_prompt.md
Phase 2: Launch Agents (Background)
阶段2:启动Agent(后台运行)
Launch BOTH agents as background Bash tasks:
bash
python shared/agents/agent_runner.py \
--agent codex-review \
--prompt-file .agent-review/codex/{id}_optimization_review_prompt.md \
--output-file .agent-review/codex/{id}_optimization_review.md \
--cwd {project_root}
python shared/agents/agent_runner.py \
--agent gemini-review \
--prompt-file .agent-review/gemini/{id}_optimization_review_prompt.md \
--output-file .agent-review/gemini/{id}_optimization_review.md \
--cwd {project_root}Both run in background (). Proceed to Phase 3 while agents work.
run_in_background=true以后台Bash任务启动两个Agent:
bash
python shared/agents/agent_runner.py \
--agent codex-review \
--prompt-file .agent-review/codex/{id}_optimization_review_prompt.md \
--output-file .agent-review/codex/{id}_optimization_review.md \
--cwd {project_root}
python shared/agents/agent_runner.py \
--agent gemini-review \
--prompt-file .agent-review/gemini/{id}_optimization_review_prompt.md \
--output-file .agent-review/gemini/{id}_optimization_review.md \
--cwd {project_root}两者均后台运行(),在Agent运行期间继续阶段3。
run_in_background=truePhase 3: Own Feasibility Check (while agents run)
阶段3:自主可行性检查(Agent运行期间)
Perform independent validation of the optimization plan:
| Check | How | Fail Action |
|---|---|---|
| Files exist | For each hypothesis: verify every file in | Flag hypothesis as INVALID |
| No file conflicts | Check uncontested hypotheses don't modify same file lines | Flag overlap as CONCERN |
| Suspicion coverage | Cross-reference | Flag uncovered suspicions as MISSING_HYPOTHESIS |
| Evidence backing | Each hypothesis should trace to a profiler finding or research source | Flag unsupported as WEAK_EVIDENCE |
| Conflicts correct | Verify | Flag incorrect as BAD_CONFLICT |
| Fix Hierarchy | Verify hypotheses ordered Configuration→...→Removal. Flag if top hypothesis is level 4-5 | CONCERN: "config-level fix may be available" |
| Removal guard | Any "remove feature" hypothesis MUST have paired "optimize feature" alternative | CONCERN: "removal without optimization alternative" |
| Assumption verification | Each hypothesis's premises — verified by profiler data or just assumed? | Flag: "assumption not verified: {premise}" |
| Depth check | Did profiler go inside all accessible slow services? Check performance_map for surface-level entries | CONCERN: "service X profiled at surface level only" |
对优化方案执行独立验证:
| 检查项 | 检查方式 | 失败处理 |
|---|---|---|
| 文件存在性 | 针对每个假设:验证 | 将假设标记为INVALID |
| 无文件冲突 | 检查无争议的假设是否修改同一文件的相同行 | 将重叠标记为CONCERN |
| 疑点覆盖 | 交叉对比已确认的 | 将未覆盖的疑点标记为MISSING_HYPOTHESIS |
| 证据支持 | 每个假设应能追溯到分析器结果或调研来源 | 将无支持的假设标记为WEAK_EVIDENCE |
| 冲突映射正确性 | 验证 | 将错误映射标记为BAD_CONFLICT |
| 修复层级 | 验证假设是否按“配置→...→移除”排序。若顶级假设为4-5级则标记 | 关注点:"可能存在配置级修复方案" |
| 移除防护 | 任何“移除功能”的假设必须配有“优化功能”的替代方案 | 关注点:"仅移除未提供优化替代方案" |
| 假设验证 | 每个假设的前提 — 是由分析器数据验证还是仅为假设? | 标记:"假设未验证:{premise}" |
| 深度检查 | 分析器是否深入了所有可访问的慢服务?检查performance_map是否仅为表层条目 | 关注点:"仅对服务X进行了表层分析" |
Output
输出
feasibility_result:
valid_hypotheses: [H1, H2, H4]
invalid_hypotheses: [{id: H3, reason: "file not found: src/cache.py"}]
concerns: [{type: "file_overlap", detail: "H1 and H2 both modify src/api.py"}]
missing: [{suspicion: "N+1 in loop at handler.py:45", note: "no hypothesis addresses this"}]feasibility_result:
valid_hypotheses: [H1, H2, H4]
invalid_hypotheses: [{id: H3, reason: "file not found: src/cache.py"}]
concerns: [{type: "file_overlap", detail: "H1 and H2 both modify src/api.py"}]
missing: [{suspicion: "N+1 in loop at handler.py:45", note: "no hypothesis addresses this"}]Phase 4: Merge Agent Feedback + Debate
阶段4:合并Agent反馈 + 研讨
Wait for agent results, then merge per :
shared/references/agent_review_workflow.md- Parse agent suggestions from both result files
- Merge with own feasibility findings (Phase 3)
- For EACH suggestion: dedup → evaluate → AGREE or DISAGREE (debate per shared workflow)
- Apply accepted corrections directly to :
.optimization/{slug}/context.md- Remove invalid hypotheses
- Add warnings to concerns
- Adjust if agents found errors
conflicts_with - Add missing hypotheses if agents identified gaps
Save review summary →
.agent-review/review_history.mdDisplay:
"Agent Review: codex ({accepted}/{total}), gemini ({accepted}/{total}), {N} corrections applied"等待Agent结果,然后根据合并:
shared/references/agent_review_workflow.md- 解析两个结果文件中的Agent建议
- 与阶段3的自主可行性检查结果合并
- 对每个建议:去重 → 评估 → 同意或不同意(按照共享工作流研讨)
- 将已接受的修正直接应用到:
.optimization/{slug}/context.md- 移除无效假设
- 为关注点添加警告
- 若Agent发现错误则调整
conflicts_with - 若Agent发现缺口则添加缺失的假设
将审核摘要保存至 →
.agent-review/review_history.md显示:
"Agent审核:codex({已接受}/{总数}),gemini({已接受}/{总数}),已应用{N}项修正"Phase 5: Verdict
阶段5:结论
| Verdict | Condition |
|---|---|
| GO | All hypotheses valid, no critical issues, agents agree plan is feasible |
| GO_WITH_CONCERNS | Minor issues found and documented as warnings in context.md. Safe to proceed |
| NO_GO | Critical feasibility issue (files missing, fundamental approach flaw, both agents reject) |
| 结论 | 条件 |
|---|---|
| GO(执行) | 所有假设有效,无关键问题,Agents一致认为方案可行 |
| GO_WITH_CONCERNS(带关注点执行) | 发现轻微问题并在context.md中记录为警告,可安全执行 |
| NO_GO(不执行) | 存在严重可行性问题(文件缺失、核心方法缺陷、两个Agent均拒绝) |
Output
输出
validation_result:
verdict: "GO" | "GO_WITH_CONCERNS" | "NO_GO"
corrections_applied: <number>
hypotheses_removed: [<ids>]
hypotheses_added: [<ids>]
concerns: [<list>]
agent_summary: "codex: PLAN_ACCEPTABLE, gemini: SUGGESTIONS (2 accepted)"Return verdict to coordinator. On NO_GO: coordinator presents issues to user.
validation_result:
verdict: "GO" | "GO_WITH_CONCERNS" | "NO_GO"
corrections_applied: <number>
hypotheses_removed: [<ids>]
hypotheses_added: [<ids>]
concerns: [<list>]
agent_summary: "codex: PLAN_ACCEPTABLE, gemini: SUGGESTIONS (2 accepted)"将结论返回给协调器。若为NO_GO:协调器向用户展示问题。
Error Handling
错误处理
| Error | Recovery |
|---|---|
| Context file missing | Block: "run profiler and researcher first" |
| Both agents unavailable | Proceed with own feasibility check only (reduced confidence) |
| Agent timeout | Use results from available agent + own check |
| Context file malformed | Block: "context.md missing required sections" |
| 错误 | 恢复方式 |
|---|---|
| 上下文文件缺失 | 拦截:"请先运行分析器和调研工具" |
| 两个Agent均不可用 | 仅执行自主可行性检查(置信度降低) |
| Agent超时 | 使用可用Agent的结果 + 自主检查结果 |
| 上下文文件格式错误 | 拦截:"context.md缺失所需章节" |
References
参考文档
- — merge + debate protocol
shared/references/agent_review_workflow.md - — agent invocation pattern
shared/references/agent_delegation_pattern.md - — plan review template
shared/agents/prompt_templates/modes/plan_review.md - optimization_review_focus.md — optimization-specific focus areas
- — 合并 + 研讨协议
shared/references/agent_review_workflow.md - — Agent调用模式
shared/references/agent_delegation_pattern.md - — 方案审核模板
shared/agents/prompt_templates/modes/plan_review.md - optimization_review_focus.md — 优化专项关注点
Definition of Done
完成标准
- Context file loaded and validated (all required sections present)
- Agent health check performed
- Context materialized to for agents
.agent-review/ - Both agents launched (or SKIPPED if unavailable)
- Own feasibility check completed (files exist, no conflicts, evidence backing)
- Agent results merged and debated
- Corrections applied to context.md
- Verdict issued (GO / GO_WITH_CONCERNS / NO_GO)
- Review summary saved to
.agent-review/review_history.md
Version: 1.0.0
Last Updated: 2026-03-15
- 上下文文件已加载并验证(所有必填章节存在)
- 已执行Agent健康检查
- 已为Agent准备好上下文并存储至
.agent-review/ - 已启动两个Agent(或不可用时标记为SKIPPED)
- 已完成自主可行性检查(文件存在性、无冲突、证据支持等)
- 已合并Agent反馈并完成研讨
- 已将修正应用到context.md
- 已给出结论(GO / GO_WITH_CONCERNS / NO_GO)
- 已将审核摘要保存至
.agent-review/review_history.md
版本: 1.0.0
最后更新: 2026-03-15