re-verify-structure
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseStructure Verification — Reverse Engineering Phase 1 Critic
结构验证 — 逆向工程第一阶段Critic
Verify the structure map produced by against the actual source code. This skill runs as an independent Critic in a separate agent context. It has no access to the Doer's reasoning — only the artifacts.
re-structure-analysisGate rule: Phase 2 () shall not proceed until this verification produces a or verdict.
re-visualize-logicPASSWARN对照实际源代码验证生成的结构映射。该技能作为独立的Critic在单独的Agent环境中运行,无法访问执行者(Doer)的推理过程——仅能访问工件。
re-structure-analysis准入规则:第二阶段()必须在本验证得出或结论后才能启动。
re-visualize-logicPASSWARNThree Principles (Critic Perspective)
三大原则(Critic视角)
1. Code is Truth
1. 代码即真理
- The source code is the sole authority. If the structure map says something the code does not confirm, the structure map is wrong.
- 源代码是唯一权威。如果结构映射中的内容无法得到代码的证实,则结构映射存在错误。
2. Traceability to Line
2. 可追溯到行
- Every reference in the structure map must resolve to actual code. Unresolvable references are hallucinations.
file:line
- 结构映射中的每一处引用都必须能对应到实际代码。无法解析的引用属于幻觉内容(hallucinations)。
file:line
3. Behavior over Intent
3. 行为优先于意图
- Verify what the structure map claims against what the code shows. Do not interpret or justify discrepancies.
- 对照代码实际内容验证结构映射的声明。不要解读或为差异找借口。
Execution
执行步骤
Step 1: Load Artifacts
步骤1:加载工件
Determine the manifest path:
- If argument is provided, use it directly
manifest - If argument is provided, derive path as
analysisdocs/reverse/{analysis}/manifest.json - At least one of or
manifestmust be providedanalysis
Read the manifest and structure map:
{manifest-path}
{analysis-dir}/01-structure-map.mdExtract from the manifest:
- — original user-specified targets
targets.entry_points - — must be
phase1.statusto proceed"completed" - — for tool strategy
language
If is not , report error and stop.
phase1.status"completed"确定清单路径:
- 如果提供了参数,直接使用该路径
manifest - 如果提供了参数,路径推导为
analysisdocs/reverse/{analysis}/manifest.json - 必须至少提供或
manifest中的一个analysis
读取清单和结构映射:
{manifest-path}
{analysis-dir}/01-structure-map.md从清单中提取以下信息:
- — 用户最初指定的目标
targets.entry_points - — 必须为
phase1.status才能继续执行"completed" - — 用于确定工具策略
language
如果不是,则报告错误并停止执行。
phase1.status"completed"Step 2: Reference Verification
步骤2:引用验证
Extract all references from the structure map.
file:lineFor each reference:
- File existence: Verify the file exists at the specified path.
- Line validity: Read the file and verify the line number is within range.
- Content match: Verify the content at the cited line matches the claim in the structure map.
Classify each reference:
| Category | Criteria |
|---|---|
| ✅ VALID | File exists, line exists, content matches claim |
| ⚠️ INACCURATE | File exists, content found within ±10 lines of cited line |
| ❌ INVALID | File does not exist, or line number grossly wrong |
| 🚫 HALLUCINATION | Component described in structure map cannot be found in source code at any location |
从结构映射中提取所有引用。
file:line对每个引用执行以下检查:
- 文件存在性:验证指定路径下的文件是否存在。
- 行号有效性:读取文件并验证行号是否在有效范围内。
- 内容匹配:验证引用行的内容是否与结构映射中的声明一致。
将每个引用分类:
| 分类 | 判定标准 |
|---|---|
| ✅ VALID | 文件存在,行号有效,内容与声明匹配 |
| ⚠️ INACCURATE | 文件存在,在引用行的±10行范围内找到对应内容 |
| ❌ INVALID | 文件不存在,或行号严重错误 |
| 🚫 HALLUCINATION | 结构映射中描述的组件在源代码的任何位置都无法找到 |
Step 3: Completeness Verification
步骤3:完整性验证
Count actual components in the target scope and compare with the structure map.
With Serena:
mcp__serena__search_for_pattern(
substring_pattern="class |interface |def |function ",
restrict_search_to_code_files=true
)Without Serena:
- Use Grep to count class/function definitions in the target scope
- Compare with the number listed in the structure map
Calculate coverage:
(listed_in_map / actual_in_source) * 100| Coverage | Verdict |
|---|---|
| >= 95% | PASS |
| 90% - 94% | WARN |
| < 90% | FAIL |
List any components found in source but missing from the structure map.
统计目标范围内的实际组件数量,并与结构映射中的数量进行对比。
使用Serena工具时:
mcp__serena__search_for_pattern(
substring_pattern="class |interface |def |function ",
restrict_search_to_code_files=true
)不使用Serena工具时:
- 使用Grep统计目标范围内的类/函数定义数量
- 与结构映射中列出的数量进行对比
计算覆盖率:
(结构映射中列出的数量 / 源代码中的实际数量) * 100| 覆盖率 | 结论 |
|---|---|
| >= 95% | PASS |
| 90% - 94% | WARN |
| < 90% | FAIL |
列出所有在源代码中存在但未被结构映射收录的组件。
Step 4: Mermaid Diagram Validation
步骤4:Mermaid图验证
For each Mermaid code block in the structure map:
- Check syntax validity (matching brackets, valid node definitions, valid arrow syntax)
- Spot-check 3 nodes/relationships against source code
- Document any syntax errors or content inaccuracies
对结构映射中的每个Mermaid代码块执行以下检查:
- 检查语法有效性(括号匹配、节点定义合法、箭头语法有效)
- 随机抽查3个节点/关系,与源代码进行对比
- 记录所有语法错误或内容不准确的问题
Step 5: Internal Consistency Check
步骤5:内部一致性检查
Verify that:
- Components in dependency diagrams are also listed in component tables
- Entry points in diagrams match the entry point section
- File paths are consistent throughout the document
- in the manifest references components that exist in the structure map
targets_for_phase2
验证以下内容:
- 依赖图中的组件也在组件列表中列出
- 图中的入口点与入口点章节的内容一致
- 整个文档中的文件路径保持一致
- 清单中的引用的组件在结构映射中存在
targets_for_phase2
Step 6: Generate Verification Report
步骤6:生成验证报告
Write to :
docs/reverse/{analysis}/verification/v1-structure.mdmarkdown
undefined将报告写入:
docs/reverse/{analysis}/verification/v1-structure.mdmarkdown
undefinedStructure Map Verification Report
结构映射验证报告
Verification Date: {YYYY-MM-DD}
Target Document: docs/reverse/{analysis}/01-structure-map.md
Verdict: {PASS / WARN / FAIL}
验证日期:{YYYY-MM-DD}
目标文档:docs/reverse/{analysis}/01-structure-map.md
结论:{PASS / WARN / FAIL}
Summary
摘要
| Check | Result | Details |
|---|---|---|
| Reference Accuracy | {✅/⚠️/❌} | {valid}/{total} references ({%}) |
| Component Coverage | {✅/⚠️/❌} | {listed}/{actual} components ({%}) |
| Mermaid Syntax | {✅/⚠️/❌} | {error_count} errors |
| Internal Consistency | {✅/⚠️/❌} | {inconsistency_count} issues |
| 检查项 | 结果 | 详情 |
|---|---|---|
| 引用准确性 | {✅/⚠️/❌} | {有效数量}/{总数量} 引用 (占比{百分比}%) |
| 组件覆盖率 | {✅/⚠️/❌} | {列出数量}/{实际数量} 组件 (占比{百分比}%) |
| Mermaid语法 | {✅/⚠️/❌} | {错误数量} 个错误 |
| 内部一致性 | {✅/⚠️/❌} | {不一致问题数量} 个问题 |
Verdict
结论说明
{PASS}: Phase 2 may proceed.
{WARN}: Minor issues found. Phase 2 may proceed. Corrections recommended.
{FAIL}: Critical issues found. Phase 2 must not proceed. Corrections required.
{PASS}:第二阶段可以启动。
{WARN}:发现轻微问题。第二阶段可以启动,建议进行修正。
{FAIL}:发现严重问题。第二阶段不得启动,必须进行修正。
Reference Verification Details
引用验证详情
Invalid References
无效引用
| Claim | File:Line | Issue | Expected |
|---|---|---|---|
| {claim} | {reference} | {issue description} | {correct reference or "not found"} |
| 声明 | 文件:行 | 问题 | 预期 |
|---|---|---|---|
| {声明内容} | {引用} | {问题描述} | {正确引用或“未找到”} |
Hallucinations
幻觉内容
- {component}: {reason it is considered hallucinated}
- {组件名称}:{被判定为幻觉内容的原因}
Completeness Details
完整性详情
Missing Components
缺失组件
| Component | File | Type |
|---|---|---|
| {name} | {file path} | {class/function/interface} |
| 组件 | 文件 | 类型 |
|---|---|---|
| {名称} | {文件路径} | {类/函数/接口} |
Mermaid Validation
Mermaid图验证
Syntax Errors
语法错误
- Block {N}: {error description}
- 代码块{N}:{错误描述}
Content Inaccuracies
内容不准确
- Node "{node}": {discrepancy}
- 节点“{节点名称}”:{差异描述}
Internal Consistency Issues
内部一致性问题
- {description of inconsistency}
- {不一致问题描述}
Recommendations
建议
- [CRITICAL] {fix description}
- [HIGH] {fix description}
- [MEDIUM] {fix description}
undefined- [CRITICAL] {修复描述}
- [HIGH] {修复描述}
- [MEDIUM] {修复描述}
undefinedStep 7: Update Manifest
步骤7:更新清单
Read the current manifest, then update:
- Set to
phase1.verification"verification/v1-structure.md" - If verdict is or
PASS: setWARNtophase1.status"verified" - If verdict is : leave
FAILasphase1.status(do not promote)"completed" - Update timestamp
updated
读取当前清单,然后更新以下内容:
- 将设置为
phase1.verification"verification/v1-structure.md" - 如果结论为或
PASS:将WARN设置为phase1.status"verified" - 如果结论为:保持
FAIL为phase1.status(不推进阶段)"completed" - 更新时间戳
updated
Verdict Criteria
结论判定标准
| Criterion | PASS | WARN | FAIL |
|---|---|---|---|
| Reference accuracy | >= 95% | 80-94% | < 80% |
| Component coverage | >= 95% | 90-94% | < 90% |
| Mermaid errors | 0 | 1-2 | >= 3 |
| Hallucinations | 0 | 0 | >= 1 |
Any single FAIL criterion results in an overall FAIL verdict.
| 判定项 | PASS | WARN | FAIL |
|---|---|---|---|
| 引用准确性 | >= 95% | 80-94% | < 80% |
| 组件覆盖率 | >= 95% | 90-94% | < 90% |
| Mermaid图错误 | 0 | 1-2 | >= 3 |
| 幻觉内容 | 0 | 0 | >= 1 |
任何一项判定为FAIL都会导致整体结论为FAIL。
Prohibited Actions
禁止操作
- Do NOT modify the structure map document
- Do NOT modify source code files
- Do NOT assume missing information — flag it as an issue
- Do NOT approve documents with FAIL status
- Do NOT access the Doer's conversation context or reasoning
- 不得修改结构映射文档
- 不得修改源代码文件
- 不得自行补充缺失信息 — 需将其标记为问题
- 不得批准结论为FAIL的文档
- 不得访问执行者(Doer)的对话上下文或推理过程 ",