re-verify-logic
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseLogic Verification — Reverse Engineering Phase 2 Critic
逻辑验证 — 逆向工程第二阶段Critic
Verify logic diagrams produced by against actual source code. Runs as an independent Critic in a separate agent context.
re-visualize-logicGate rule: Phase 3 () shall not proceed until verification produces a or verdict for all components.
re-extract-requirementsPASSWARN将生成的逻辑图与实际源代码进行比对验证。作为独立的Critic在单独的Agent上下文运行。
re-visualize-logic准入规则:所有组件的验证结果为或之前,不得进入第三阶段()。
PASSWARNre-extract-requirementsThree Principles (Critic Perspective)
三大原则(Critic视角)
1. Code is Truth
1. 代码即真相
- The source code is the sole authority. If the logic diagram says something the code does not confirm, the diagram is wrong.
- 源代码是唯一权威。如果逻辑图的内容无法被代码证实,则逻辑图存在错误。
2. Traceability to Line
2. 可追溯到行
- Every line number in the diagram must resolve to actual code. Unresolvable references are hallucinations.
- 逻辑图中的每一个行号都必须对应到实际代码中。无法解析的引用属于幻觉内容。
3. Behavior over Intent
3. 行为优先于意图
- Verify what the diagram claims against what the code shows. Do not interpret or justify discrepancies.
- 将逻辑图的声明与代码实际表现进行比对。不要解释或合理化差异。
Execution
执行步骤
Step 1: Load Artifacts
步骤1:加载工件
Read .
docs/reverse/{analysis}/manifest.jsonDetermine which components to verify:
- If argument is provided, verify only that component
component - If omitted, verify all entries in that have
phase2.completedverification: null
For each component, read the logic diagram:
docs/reverse/{analysis}/02-logic-{component}.md读取文件。
docs/reverse/{analysis}/manifest.json确定需要验证的组件:
- 如果提供了参数,仅验证该组件
component - 如果未提供,则验证中所有
phase2.completed的条目verification: null
针对每个组件,读取逻辑图文件:
docs/reverse/{analysis}/02-logic-{component}.mdStep 2: Line Number Verification
步骤2:行号验证
For each node in the Mermaid diagram and each row in the node-to-line mapping table:
- Extract the cited line number
- Read the source file at that line
- Compare the code at that line with the claim
Classify:
- ✅ MATCH: Code at cited line matches the description
- ⚠️ OFFSET: Code found within ±5 lines
- ❌ MISMATCH: Code at cited line does not match
- 🚫 HALLUCINATION: Described behavior not found in source at any location
针对Mermaid图中的每个节点以及节点-行号映射表中的每一行:
- 提取引用的行号
- 读取对应行的源代码
- 将该行代码与逻辑图中的声明进行比对
分类结果:
- ✅ 匹配:引用行的代码与描述一致
- ⚠️ 偏移:在±5行范围内找到对应代码
- ❌ 不匹配:引用行的代码与描述不符
- 🚫 幻觉:在源代码的任何位置都找不到描述的行为
Step 3: Mermaid Syntax Validation
步骤3:Mermaid语法验证
Check each Mermaid code block for:
- Valid node definitions and arrow syntax
- No prohibited characters (,
!=,>=,[]in text)() - Parseable structure (matching brackets, valid subgraphs)
检查每个Mermaid代码块:
- 有效的节点定义和箭头语法
- 无禁用字符(文本中不得包含、
!=、>=、[])() - 可解析的结构(括号匹配、有效的子图)
Step 4: Completeness Check
步骤4:完整性检查
Compare the logic diagram against the source method:
- Count control flow branches in source (if/else, switch cases, loops)
- Count corresponding nodes in the diagram
- Flag missing branches
Check side effects documentation:
- Grep source for database operations, network calls, file I/O, logging
- Verify each is documented in the side effects summary
将逻辑图与源代码方法进行比对:
- 统计源代码中的控制流分支(if/else、switch分支、循环)
- 统计逻辑图中对应的节点数量
- 标记缺失的分支
检查副作用文档:
- 用Grep工具搜索源代码中的数据库操作、网络调用、文件I/O、日志记录
- 验证每一项都在副作用摘要中有记录
Step 5: Generate Verification Report
步骤5:生成验证报告
Write to :
docs/reverse/{analysis}/verification/v2-logic-{component}.mdmarkdown
undefined写入文件:
docs/reverse/{analysis}/verification/v2-logic-{component}.mdmarkdown
undefinedLogic Diagram Verification: {component}
Logic Diagram Verification: {component}
Verification Date: {YYYY-MM-DD}
Target Document: 02-logic-{component}.md
Verdict: {PASS / WARN / FAIL}
Verification Date: {YYYY-MM-DD}
Target Document: 02-logic-{component}.md
Verdict: {PASS / WARN / FAIL}
Summary
Summary
| Check | Result | Details |
|---|---|---|
| Line Number Accuracy | {✅/⚠️/❌} | {match}/{total} nodes ({%}) |
| Mermaid Syntax | {✅/⚠️/❌} | {error_count} errors |
| Branch Coverage | {✅/⚠️/❌} | {covered}/{total} branches ({%}) |
| Side Effects | {✅/⚠️/❌} | {documented}/{total} side effects ({%}) |
| Check | Result | Details |
|---|---|---|
| Line Number Accuracy | {✅/⚠️/❌} | {match}/{total} nodes ({%}) |
| Mermaid Syntax | {✅/⚠️/❌} | {error_count} errors |
| Branch Coverage | {✅/⚠️/❌} | {covered}/{total} branches ({%}) |
| Side Effects | {✅/⚠️/❌} | {documented}/{total} side effects ({%}) |
Verdict
Verdict
{PASS/WARN/FAIL}: {explanation}
{PASS/WARN/FAIL}: {explanation}
Details
Details
Line Number Issues
Line Number Issues
| Node | Claimed Line | Actual Line | Issue |
|---|
| Node | Claimed Line | Actual Line | Issue |
|---|
Missing Branches
Missing Branches
- {description of missing branch at file:line}
- {description of missing branch at file:line}
Missing Side Effects
Missing Side Effects
- {description of undocumented side effect at file:line}
- {description of undocumented side effect at file:line}
Recommendations
Recommendations
- [{severity}] {fix description}
undefined- [{severity}] {fix description}
undefinedStep 6: Update Manifest
步骤6:更新清单
For each verified component:
- Update to
phase2.completed[].verification"verification/v2-logic-{component}.md"
After all components are verified:
- If all verdicts are PASS or WARN: set to
phase2.status"verified" - If any verdict is FAIL: leave as
phase2.status"completed" - Update timestamp
updated
针对每个已验证的组件:
- 将更新为
phase2.completed[].verification"verification/v2-logic-{component}.md"
所有组件验证完成后:
- 如果所有结果均为PASS或WARN:将设置为
phase2.status"verified" - 如果存在任何FAIL结果:保持为
phase2.status"completed" - 更新时间戳
updated
Verdict Criteria
结果判定标准
| Criterion | PASS | WARN | FAIL |
|---|---|---|---|
| Line number accuracy | >= 95% match | 80-94% | < 80% |
| Mermaid syntax errors | 0 | 1-2 | >= 3 |
| Branch coverage | >= 90% | 75-89% | < 75% |
| Side effect documentation | 100% | >= 80% | < 80% |
| Hallucinations | 0 | 0 | >= 1 |
Any single FAIL criterion results in overall FAIL.
| 判定项 | PASS | WARN | FAIL |
|---|---|---|---|
| 行号准确率 | >= 95%匹配 | 80-94% | < 80% |
| Mermaid语法错误数 | 0 | 1-2 | >=3 |
| 分支覆盖率 | >=90% | 75-89% | <75% |
| 副作用文档覆盖率 | 100% | >=80% | <80% |
| 幻觉内容数 | 0 | 0 | >=1 |
任何单项判定为FAIL则整体结果为FAIL。
Prohibited Actions
禁止操作
- Do NOT modify logic diagram documents
- Do NOT modify source code files
- Do NOT approve documents with FAIL status
- Do NOT access the Doer's conversation context
- 不得修改逻辑图文档
- 不得修改源代码文件
- 不得批准结果为FAIL的文档
- 不得访问Doer的对话上下文