@veewo/gitnexus 1.5.0 → 1.5.2

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.
Files changed (137) hide show
  1. package/dist/benchmark/agent-context/runner.js +3 -0
  2. package/dist/benchmark/agent-context/runner.test.js +22 -0
  3. package/dist/benchmark/agent-context/tool-runner.d.ts +7 -6
  4. package/dist/benchmark/agent-safe-query-context/io.d.ts +2 -0
  5. package/dist/benchmark/agent-safe-query-context/io.js +86 -0
  6. package/dist/benchmark/agent-safe-query-context/io.test.d.ts +1 -0
  7. package/dist/benchmark/agent-safe-query-context/io.test.js +13 -0
  8. package/dist/benchmark/agent-safe-query-context/report.d.ts +57 -0
  9. package/dist/benchmark/agent-safe-query-context/report.js +159 -0
  10. package/dist/benchmark/agent-safe-query-context/report.test.d.ts +1 -0
  11. package/dist/benchmark/agent-safe-query-context/report.test.js +362 -0
  12. package/dist/benchmark/agent-safe-query-context/runner.d.ts +44 -0
  13. package/dist/benchmark/agent-safe-query-context/runner.js +406 -0
  14. package/dist/benchmark/agent-safe-query-context/runner.test.d.ts +1 -0
  15. package/dist/benchmark/agent-safe-query-context/runner.test.js +290 -0
  16. package/dist/benchmark/agent-safe-query-context/semantic-tuple.d.ts +20 -0
  17. package/dist/benchmark/agent-safe-query-context/semantic-tuple.js +225 -0
  18. package/dist/benchmark/agent-safe-query-context/semantic-tuple.test.d.ts +1 -0
  19. package/dist/benchmark/agent-safe-query-context/semantic-tuple.test.js +122 -0
  20. package/dist/benchmark/agent-safe-query-context/subagent-live.d.ts +47 -0
  21. package/dist/benchmark/agent-safe-query-context/subagent-live.js +128 -0
  22. package/dist/benchmark/agent-safe-query-context/subagent-live.test.d.ts +1 -0
  23. package/dist/benchmark/agent-safe-query-context/subagent-live.test.js +155 -0
  24. package/dist/benchmark/agent-safe-query-context/telemetry-tool.d.ts +9 -0
  25. package/dist/benchmark/agent-safe-query-context/telemetry-tool.js +77 -0
  26. package/dist/benchmark/agent-safe-query-context/types.d.ts +61 -0
  27. package/dist/benchmark/agent-safe-query-context/types.js +8 -0
  28. package/dist/benchmark/runtime-poc/provenance-artifact.d.ts +47 -0
  29. package/dist/benchmark/runtime-poc/provenance-artifact.js +89 -0
  30. package/dist/benchmark/runtime-poc/runner.d.ts +31 -0
  31. package/dist/benchmark/runtime-poc/runner.js +163 -0
  32. package/dist/benchmark/u2-e2e/hydration-policy-repeatability-runner.d.ts +8 -0
  33. package/dist/benchmark/u2-e2e/hydration-policy-repeatability-runner.js +21 -0
  34. package/dist/benchmark/u2-e2e/phase2-runtime-claim-acceptance-runner.d.ts +0 -1
  35. package/dist/benchmark/u2-e2e/phase2-runtime-claim-acceptance-runner.js +53 -51
  36. package/dist/benchmark/u2-e2e/phase2-runtime-claim-acceptance-runner.test.js +0 -1
  37. package/dist/benchmark/u2-e2e/phase5-rule-lab-acceptance-runner.d.ts +1 -1
  38. package/dist/benchmark/u2-e2e/phase5-rule-lab-acceptance-runner.js +82 -18
  39. package/dist/benchmark/u2-e2e/phase5-rule-lab-acceptance-runner.test.js +1 -2
  40. package/dist/benchmark/u2-e2e/retrieval-runner.js +15 -7
  41. package/dist/benchmark/u2-e2e/retrieval-runner.test.js +46 -0
  42. package/dist/cli/ai-context.js +2 -12
  43. package/dist/cli/ai-context.test.js +8 -0
  44. package/dist/cli/analyze-runtime-summary.js +1 -0
  45. package/dist/cli/analyze-runtime-summary.test.js +2 -0
  46. package/dist/cli/analyze-summary.d.ts +2 -0
  47. package/dist/cli/analyze-summary.js +24 -0
  48. package/dist/cli/analyze-summary.test.js +65 -1
  49. package/dist/cli/analyze.js +5 -1
  50. package/dist/cli/benchmark-agent-safe-query-context.d.ts +20 -0
  51. package/dist/cli/benchmark-agent-safe-query-context.js +39 -0
  52. package/dist/cli/benchmark-agent-safe-query-context.test.d.ts +1 -0
  53. package/dist/cli/benchmark-agent-safe-query-context.test.js +271 -0
  54. package/dist/cli/benchmark.d.ts +29 -0
  55. package/dist/cli/benchmark.js +55 -0
  56. package/dist/cli/index.js +23 -0
  57. package/dist/cli/rule-lab.d.ts +3 -7
  58. package/dist/cli/rule-lab.js +13 -22
  59. package/dist/cli/rule-lab.test.js +23 -3
  60. package/dist/cli/tool.d.ts +2 -0
  61. package/dist/cli/tool.js +2 -0
  62. package/dist/core/config/unity-config.d.ts +0 -1
  63. package/dist/core/config/unity-config.js +0 -1
  64. package/dist/core/ingestion/pipeline.js +35 -6
  65. package/dist/core/ingestion/unity-lifecycle-synthetic-calls.test.js +18 -20
  66. package/dist/core/ingestion/unity-parity-seed.d.ts +2 -1
  67. package/dist/core/ingestion/unity-parity-seed.js +8 -0
  68. package/dist/core/ingestion/unity-resource-processor.d.ts +11 -0
  69. package/dist/core/ingestion/unity-resource-processor.js +102 -0
  70. package/dist/core/ingestion/unity-resource-processor.test.js +449 -0
  71. package/dist/core/ingestion/unity-runtime-binding-rules.d.ts +15 -0
  72. package/dist/core/ingestion/unity-runtime-binding-rules.js +178 -30
  73. package/dist/core/lbug/csv-generator.test.js +2 -2
  74. package/dist/core/unity/doc-contract.test.d.ts +1 -0
  75. package/dist/core/unity/doc-contract.test.js +30 -0
  76. package/dist/core/unity/prefab-source-scan.d.ts +25 -0
  77. package/dist/core/unity/prefab-source-scan.js +152 -0
  78. package/dist/core/unity/prefab-source-scan.test.d.ts +1 -0
  79. package/dist/core/unity/prefab-source-scan.test.js +70 -0
  80. package/dist/core/unity/scan-context.d.ts +12 -0
  81. package/dist/core/unity/scan-context.js +50 -2
  82. package/dist/core/unity/scan-context.test.js +74 -0
  83. package/dist/mcp/local/agent-safe-response.d.ts +10 -0
  84. package/dist/mcp/local/agent-safe-response.js +639 -0
  85. package/dist/mcp/local/derived-process-reader.js +1 -1
  86. package/dist/mcp/local/local-backend.d.ts +18 -1
  87. package/dist/mcp/local/local-backend.js +319 -125
  88. package/dist/mcp/local/process-confidence.d.ts +1 -2
  89. package/dist/mcp/local/process-confidence.js +0 -3
  90. package/dist/mcp/local/process-confidence.test.js +4 -2
  91. package/dist/mcp/local/process-evidence.d.ts +1 -8
  92. package/dist/mcp/local/process-evidence.js +1 -23
  93. package/dist/mcp/local/process-evidence.test.js +2 -16
  94. package/dist/mcp/local/process-ref.d.ts +1 -1
  95. package/dist/mcp/local/runtime-chain-closure-evaluator.d.ts +33 -0
  96. package/dist/mcp/local/runtime-chain-closure-evaluator.js +273 -0
  97. package/dist/mcp/local/runtime-chain-graph-candidates.d.ts +23 -0
  98. package/dist/mcp/local/runtime-chain-graph-candidates.js +131 -0
  99. package/dist/mcp/local/runtime-chain-verify.d.ts +1 -1
  100. package/dist/mcp/local/runtime-chain-verify.js +149 -138
  101. package/dist/mcp/local/runtime-chain-verify.test.js +126 -68
  102. package/dist/mcp/local/runtime-claim-rule-registry.d.ts +4 -0
  103. package/dist/mcp/local/runtime-claim-rule-registry.js +4 -0
  104. package/dist/mcp/local/runtime-claim-rule-registry.test.js +37 -4
  105. package/dist/mcp/local/runtime-claim.d.ts +11 -0
  106. package/dist/mcp/local/runtime-claim.js +28 -0
  107. package/dist/mcp/local/unity-evidence-view.d.ts +1 -1
  108. package/dist/mcp/local/unity-evidence-view.js +1 -1
  109. package/dist/mcp/local/unity-evidence-view.test.js +22 -0
  110. package/dist/mcp/tools.js +51 -21
  111. package/dist/rule-lab/analyze.d.ts +2 -1
  112. package/dist/rule-lab/analyze.js +94 -59
  113. package/dist/rule-lab/analyze.test.js +238 -20
  114. package/dist/rule-lab/curate.d.ts +2 -1
  115. package/dist/rule-lab/curate.js +24 -3
  116. package/dist/rule-lab/curate.test.js +65 -0
  117. package/dist/rule-lab/curation-input-builder.d.ts +45 -0
  118. package/dist/rule-lab/curation-input-builder.js +133 -0
  119. package/dist/rule-lab/promote.js +80 -7
  120. package/dist/rule-lab/promote.test.js +150 -0
  121. package/dist/rule-lab/review-pack.d.ts +3 -0
  122. package/dist/rule-lab/review-pack.js +41 -1
  123. package/dist/rule-lab/review-pack.test.js +67 -0
  124. package/dist/rule-lab/types.d.ts +29 -0
  125. package/dist/types/pipeline.d.ts +3 -0
  126. package/package.json +4 -3
  127. package/scripts/run-node-tests.mjs +61 -0
  128. package/skills/_shared/unity-rule-authoring-contract.md +64 -0
  129. package/skills/_shared/unity-runtime-process-contract.md +16 -0
  130. package/skills/gitnexus-cli.md +8 -0
  131. package/skills/gitnexus-debugging.md +9 -0
  132. package/skills/gitnexus-exploring.md +66 -18
  133. package/skills/gitnexus-guide.md +42 -3
  134. package/skills/gitnexus-impact-analysis.md +8 -0
  135. package/skills/gitnexus-pr-review.md +8 -0
  136. package/skills/gitnexus-refactoring.md +8 -0
  137. package/skills/gitnexus-unity-rule-gen.md +66 -312
@@ -1,353 +1,107 @@
1
1
  ---
2
2
  name: gitnexus-unity-rule-gen
3
- description: "Interactive workflow for generating Unity analyze_rules: collect chain clues from user, explore graph to fill parameters, generate rule YAML, compile to bundle, analyze, and verify. Use when: 'create unity rules', 'generate analyze rules', 'add resource binding rules', 'unity rule gen'."
3
+ description: "Reduced rule-lab workflow for Unity analyze_rules authoring from exact source/target gaps. Use when: 'create unity rules', 'generate analyze rules', 'fill sparse runtime gap'."
4
4
  ---
5
5
 
6
- # Unity Analyze Rules 交互式生成工作流
6
+ # Unity Reduced Rule-Lab Authoring
7
7
 
8
- 本技能引导 agent 从用户描述的自然语言调用链路线索出发,通过图谱探索补全参数,交互式生成 `analyze_rules` 规则。支持一次录入多条规则,一次性 analyze 后逐一验证。
8
+ This skill is the post-rollback workflow.
9
9
 
10
- ## Phase 0: 初始化
10
+ Primary path:
11
11
 
12
- ```
13
- 1. 确认 gitnexus CLI 可用(gitnexus --version)
14
- 2. 确认目标仓库路径(询问用户或从 cwd 推断)
15
- 3. 确认仓库已索引(gitnexus status),未索引则先 analyze
16
- 4. 确认 UNITY_ASSET_GUID_REF 和 UNITY_COMPONENT_INSTANCE 边存在:
17
- ```
18
-
19
- ```
20
- mcp__gitnexus__cypher:
21
- query: |
22
- MATCH ()-[r:CodeRelation]->()
23
- WHERE r.type IN ['UNITY_ASSET_GUID_REF', 'UNITY_COMPONENT_INSTANCE']
24
- RETURN r.type AS edgeType, count(*) AS cnt
25
- repo: <repo-name>
26
- ```
27
-
28
- 如果这两种边不存在,说明索引时未启用 Unity 资源解析,需要重新 analyze,**必须加 Unity 参数**:
29
-
30
- ```bash
31
- gitnexus analyze --force --extensions ".cs,.meta"
32
- # 如果所有代码都在 Assets/ 下,可加 --scope-prefix Assets/ 缩短分析时间
33
- ```
34
-
35
- ---
36
-
37
- ## Phase 1: 规则录入循环
38
-
39
- ```
40
- loop:
41
- 1.1 收集用户链路线索
42
- 1.2 图谱探索补全
43
- 1.3 多路径确认
44
- 1.4 binding 类型判定
45
- 1.5 生成规则 YAML 并暂存
46
- 1.6 询问用户:是否继续录入下一条规则?
47
- - 是 → 回到 1.1
48
- - 否 → 进入 Phase 2
49
- ```
50
-
51
- ### 1.1 收集用户链路线索
52
-
53
- 向用户询问:
54
-
55
- | 信息 | 问题 | 示例 |
56
- |------|------|------|
57
- | 场景名称 | 你想验证哪个资源→代码链路? | weapon-powerup-gungraph |
58
- | 资源引用字段 | 哪些序列化字段名触发资源加载? | `gungraph\|graph` |
59
- | 目标入口方法 | 加载的资源上哪些方法会被触发? | OnEnable, Awake |
60
- | 持有字段的类 | 哪些类持有触发加载的字段? | WeaponPowerUp |
61
- | 加载方法 | 哪些方法触发资源加载? | Equip |
62
- | 动态跳转 | 链路中是否有事件派发或回调(C# Action/SyncList/delegate)? | `NetEventHub.OnPickUpItem → OnClientPickItUp` |
63
- | 额外 lifecycle | 项目有自定义入口方法吗? | Init |
64
- | lifecycle 范围 | 自定义入口方法的作用范围? | Assets/Code/Graph |
65
-
66
- ### 1.2 图谱探索补全
67
-
68
- 用户不确定某些字段时,按优先级探索:**Cypher 直查 > gitnexus context > 文件 grep**
69
-
70
- ```
71
- # 查找资源引用字段名
72
- mcp__gitnexus__cypher:
73
- query: |
74
- MATCH ()-[r:CodeRelation {type:'UNITY_ASSET_GUID_REF'}]->()
75
- RETURN DISTINCT r.reason
76
- LIMIT 20
77
- repo: <repo-name>
78
-
79
- # 查找挂载在资源上的组件类
80
- mcp__gitnexus__cypher:
81
- query: |
82
- MATCH (c:Class)-[r:CodeRelation {type:'UNITY_COMPONENT_INSTANCE'}]->(f:File)
83
- WHERE f.filePath CONTAINS '.asset'
84
- RETURN c.name, f.filePath
85
- LIMIT 20
86
- repo: <repo-name>
87
-
88
- # 查找特定类的方法列表
89
- mcp__gitnexus__context:
90
- name: <ClassName>
91
- repo: <repo-name>
92
- ```
93
-
94
- 如果图谱查询无结果,回退到文件直读:
95
-
96
- ```
97
- # 查找 [SerializeField] 字段
98
- Grep: pattern="\[SerializeField\]" path=<Assets目录>
99
-
100
- # 查找特定方法定义
101
- Grep: pattern="void Init\b|void Setup\b" path=<Assets目录>
102
- ```
103
-
104
- ### 1.3 多路径确认
105
-
106
- - 同一位置 ≥2 候选路径 → **向用户确认**选择哪条
107
- - 探索 3 步无结果 → **向用户补充提问**
108
-
109
- ### 1.4 binding 类型判定
110
-
111
- | 链路特征 | binding kind | 说明 |
112
- |---------|-------------|------|
113
- | asset GUID 引用 → 目标资源组件激活 | `asset_ref_loads_components` | 序列化字段引用 asset,加载时触发组件 lifecycle |
114
- | 方法调用 → 字段引用的资源加载 | `method_triggers_field_load` | 特定方法触发序列化字段引用的资源加载 |
115
- | 方法调用 → SceneManager.LoadScene → 场景组件激活 | `method_triggers_scene_load` | 特定方法触发场景加载,场景中组件 lifecycle 被触发 |
116
- | 动态跳转(事件派发/回调/delegate,静态分析不可见) | `method_triggers_method` | 声明"方法 A 动态触发方法 B",注入合成 CALLS 边桥接 gap |
117
- | 项目自定义入口方法 | `lifecycle_overrides` | 非标准 Unity lifecycle 的自定义入口 |
118
-
119
- ### 1.5 生成规则 YAML
120
-
121
- 使用以下模板,根据收集的线索填充:
12
+ 1. Gather user-confirmed exact source/target pair(s).
13
+ 2. Curate/promote to `rules/approved/*.yaml`.
14
+ 3. Compile approved rules.
15
+ 4. Re-run analyze and verify via CLI graph checks (not MCP session query/context).
122
16
 
123
- ```yaml
124
- id: unity.<scenario-name>.v2
125
- version: 2.0.0
126
- family: analyze_rules
127
- description: >-
128
- (可选)描述该规则覆盖的业务场景和调用链背景,
129
- 包括动态跳转的机制说明(事件派发/回调绑定等)。
130
- trigger_family: <scenario-name>
131
- resource_types:
132
- - asset
133
- host_base_type:
134
- - MonoBehaviour
135
- - ScriptableObject
17
+ `gap-lab` is migration history only and is not part of active operator guidance.
136
18
 
137
- match:
138
- trigger_tokens:
139
- - <token1>
140
- - <token2>
141
- host_base_type:
142
- - MonoBehaviour
143
- - ScriptableObject
144
- resource_types:
145
- - asset
19
+ Read first:
146
20
 
147
- topology:
21
+ - `gitnexus/skills/_shared/unity-rule-authoring-contract.md`
22
+ - `docs/unity-runtime-process-source-of-truth.md`
23
+ - `docs/gap-lab-rule-lab-architecture.md`
148
24
 
149
- resource_bindings:
150
- - kind: asset_ref_loads_components
151
- ref_field_pattern: "<field_pattern>"
152
- target_entry_points:
153
- - OnEnable
154
- - Awake
25
+ ## Hard Boundaries
155
26
 
156
- - kind: method_triggers_field_load
157
- host_class_pattern: "<class_pattern>"
158
- field_name: "<field_name>"
159
- loader_methods:
160
- - <method_name>
27
+ 1. Query-time runtime closure remains graph-only.
28
+ 2. Event/delegate large-scale gaps are analyzer work, not rule-authoring work.
29
+ 3. This skill is for sparse irregular gaps only.
161
30
 
162
- # 类型 C(可选):方法触发场景加载,场景中组件 lifecycle 被触发
163
- - kind: method_triggers_scene_load
164
- host_class_pattern: "<class_pattern>"
165
- loader_methods:
166
- - <method_name>
167
- scene_name: "<scene_name>" # 匹配 .unity 文件名(不含扩展名)
168
- target_entry_points:
169
- - Awake
170
- - Start
171
- - OnEnable
31
+ ## Input Contract (required)
172
32
 
173
- # 类型 D(可选):声明静态分析无法捕获的动态跳转(事件派发/回调/delegate)
174
- # 适用场景:C# Action/UnityEvent 事件派发、Mirror SyncList 回调、delegate 绑定等
175
- # 注入一条 source_method → target_method 的合成 CALLS 边(精确匹配,一条边)
176
- - kind: method_triggers_method
177
- description: >-
178
- 说明动态跳转的机制:例如"A 通过 EventHub.OnXxx?.Invoke() 触发,
179
- B 在初始化时订阅该事件",或"A 调用 SyncList.Add(),
180
- 触发 SyncList.Callback 回调到 B"
181
- source_class_pattern: "<source_class_regex>" # 例如 "^PlayerActor$"
182
- source_method: "<source_method_name>" # 例如 "ProcessInteractables"
183
- target_class_pattern: "<target_class_regex>" # 例如 "^NetPlayer$"
184
- target_method: "<target_method_name>" # 例如 "OnClientPickItUp"
33
+ Provide exact pair intent for each candidate:
185
34
 
186
- lifecycle_overrides:
187
- additional_entry_points:
188
- - <custom_entry>
189
- scope: "<path_prefix>"
35
+ - source class + source method
36
+ - target class + target method
37
+ - expected missing runtime hop
190
38
 
191
- closure:
192
- required_hops:
193
- - resource
194
- - guid_map
195
- - code_loader
196
- - code_runtime
39
+ If anchors are ambiguous (multiple candidate methods/classes), stop and ask user to choose explicit options. Do not auto-guess.
197
40
 
198
- claims:
199
- guarantees:
200
- - resource_to_runtime_chain_closed
201
- non_guarantees:
202
- - no_runtime_execution
203
- - no_dynamic_data_flow_proof
204
- ```
205
-
206
- ### 1.6 暂存并询问
207
-
208
- 将生成的 YAML 暂存(不写入文件),向用户确认:
41
+ ## Direct Public Flow
209
42
 
210
- > 规则 `<ruleId>` 已生成。是否继续录入下一条规则?
43
+ ### Phase A: Prepare exact pairs
211
44
 
212
- - 回到 1.1
213
- - 进入 Phase 2
214
-
215
- ---
216
-
217
- ## Phase 2: 写入 + compile + analyze
218
-
219
- ### 2.1 写入规则文件
220
-
221
- ```bash
222
- mkdir -p "$TARGET_REPO/.gitnexus/rules/approved"
223
- # 将每条暂存的 YAML 写入对应文件
224
- # 文件名: approved/<ruleId>.yaml
225
- ```
45
+ 1. Confirm repo and index freshness.
46
+ 2. Normalize candidate pairs into explicit source/target tuples.
47
+ 3. Run duplicate precheck against `.gitnexus/rules/approved/*.yaml`.
226
48
 
227
- ### 2.2 更新 catalog.json
49
+ ### Phase B: Review and curate
228
50
 
229
51
  ```bash
230
- # 如果 catalog.json 不存在,创建初始结构
231
- if [ ! -f "$TARGET_REPO/.gitnexus/rules/catalog.json" ]; then
232
- echo '{"version":1,"rules":[]}' > "$TARGET_REPO/.gitnexus/rules/catalog.json"
233
- fi
52
+ gitnexus rule-lab analyze --repo-path "$REPO_PATH"
53
+ RUN_ID="$(ls -1t "$REPO_PATH/.gitnexus/rules/lab/runs" | head -n 1)"
54
+ SLICE_ID="$(find "$REPO_PATH/.gitnexus/rules/lab/runs/$RUN_ID/slices" -name 'slice.json' -maxdepth 2 | head -n 1 | xargs -I{} basename "$(dirname "{}")")"
55
+ gitnexus rule-lab review-pack --repo-path "$REPO_PATH" --run-id "$RUN_ID" --slice-id "$SLICE_ID"
56
+ gitnexus rule-lab curate --repo-path "$REPO_PATH" --run-id "$RUN_ID" --slice-id "$SLICE_ID" --input-path "$CURATION_JSON_PATH"
234
57
  ```
235
58
 
236
- `rules` 数组追加每条规则的条目:
237
-
238
- ```json
239
- {
240
- "id": "<ruleId>",
241
- "version": "2.0.0",
242
- "enabled": true,
243
- "file": "approved/<ruleId>.yaml",
244
- "family": "analyze_rules"
245
- }
246
- ```
59
+ Use `analyze` as proposal generation for exact pairs, then curate/promote only proposals that pass guards.
60
+ Do not ask users to provide `run-id`/`slice-id`; resolve them from generated artifacts.
247
61
 
248
- ### 2.3 编译规则
62
+ ### Phase C: Promote approved rule
249
63
 
250
64
  ```bash
251
- gitnexus rule-lab compile --repo-path "$TARGET_REPO"
65
+ gitnexus rule-lab promote --repo-path "$REPO_PATH" --run-id "$RUN_ID" --slice-id "$SLICE_ID"
252
66
  ```
253
67
 
254
- ### 2.4 重建索引
68
+ ### Phase D: Compile and re-index
255
69
 
256
70
  ```bash
257
- gitnexus analyze "$TARGET_REPO" --force --extensions ".cs,.meta"
258
- # 如果所有代码都在 Assets/ 下,可加 --scope-prefix Assets/
259
- ```
260
-
261
- ---
262
-
263
- ## Phase 3: 逐一验证
264
-
265
- 对每条规则执行 4 项验证,每项给出 PASS/FAIL 判定。
266
-
267
- ### 验证 1: 合成边存在性
268
-
269
- ```
270
- mcp__gitnexus__cypher:
271
- query: |
272
- MATCH (a)-[r:CodeRelation {type: 'CALLS'}]->(b)
273
- WHERE r.reason STARTS WITH 'unity-rule-'
274
- RETURN r.reason AS reason, count(*) AS cnt
275
- ORDER BY cnt DESC
276
- repo: <repo-name>
71
+ gitnexus rule-lab compile --repo-path "$REPO_PATH" --family analyze_rules
72
+ gitnexus analyze -f "$REPO_PATH"
277
73
  ```
278
74
 
279
- **PASS**: 返回 ≥1 行,且 `reason` 包含规则 ID。
280
- **FAIL 诊断**: 规则未被 pipeline 加载 → 检查 catalog.json 的 `family` 字段。
281
-
282
- ### 验证 2: 运行时链路验证
75
+ ## Three Mandatory Guards
283
76
 
284
- ```
285
- mcp__gitnexus__query:
286
- query: "<trigger_token>"
287
- runtime_chain_verify: "on-demand"
288
- repo: <repo-name>
289
- ```
77
+ 1. Duplicate-prevention:
78
+ - Block if pair already covered by `rules/approved/*.yaml`.
79
+ 2. Fail-closed binding resolution:
80
+ - Block if unresolved binding remains.
81
+ - `UnknownClass` / `UnknownMethod` placeholders are forbidden.
82
+ 3. Non-empty evidence before promote:
83
+ - `confirmed_chain.steps` (or equivalent) must be non-empty.
290
84
 
291
- **PASS**: `runtime_chain.status === 'verified_full'` 且 `evidence_level === 'verified_chain'`。
292
- **FAIL 诊断**:
293
- - `rule_not_matched` → 规则的 `trigger_tokens` 未匹配查询文本
294
- - `verification_failed` → 图谱中无匹配的 `unity-rule-*` 合成边
295
-
296
- ### 验证 3: Process 完整性
297
-
298
- ```
299
- mcp__gitnexus__context:
300
- name: "<target_class>"
301
- repo: <repo-name>
302
- ```
85
+ ## Verification
303
86
 
304
- **PASS**: `processes` 中至少有一个包含跨越资源层和代码层的步骤。
305
- **FAIL 诊断**: 合成边 confidence 过低 检查 `RULE_EDGE_CONFIDENCE`(应为 0.75)。
87
+ 1. Verify synthetic edges with **CLI in a fresh process** (for example `gitnexus cypher` / `gitnexus query`).
88
+ 2. Do not use current MCP session `query/context` as synthetic-edge acceptance evidence immediately after analyze/rebuild.
89
+ 3. Inspect analyze summary `rule_binding.*` diagnostics:
90
+ - `rule_binding.agent_report: should_report=false` → no anomaly to report.
91
+ - `rule_binding.agent_report: should_report=true` → summarize `rule_binding.anomaly:*` in your run report.
92
+ 4. Keep closure claims aligned to graph-only semantics.
93
+ 5. Under `hydration_policy=strict` with `fallbackToCompact=true`, run parity before final closure conclusion.
306
94
 
307
- ### 验证 4: 合成边分布
95
+ Suggested acceptance check (example):
308
96
 
97
+ ```bash
98
+ gitnexus cypher --repo "$REPO_ALIAS" \
99
+ "MATCH (a)-[r:CodeRelation {type:'CALLS'}]->(b)
100
+ WHERE r.reason STARTS WITH 'unity-rule-'
101
+ RETURN a.name, b.name, r.reason
102
+ LIMIT 50"
309
103
  ```
310
- mcp__gitnexus__cypher:
311
- query: |
312
- MATCH (a)-[r:CodeRelation {type: 'CALLS'}]->(b)
313
- WHERE r.reason STARTS WITH 'unity-rule-'
314
- RETURN
315
- CASE
316
- WHEN r.reason CONTAINS 'resource-load' THEN 'resource-load'
317
- WHEN r.reason CONTAINS 'lifecycle-override' THEN 'lifecycle-override'
318
- WHEN r.reason CONTAINS 'loader-bridge' THEN 'loader-bridge'
319
- WHEN r.reason CONTAINS 'scene-load' THEN 'scene-load'
320
- WHEN r.reason CONTAINS 'method-bridge' THEN 'method-bridge'
321
- ELSE 'other'
322
- END AS edgeKind,
323
- count(*) AS cnt
324
- repo: <repo-name>
325
- ```
326
-
327
- **PASS**: 规则涉及的边类型均有产出(`method_triggers_method` 对应 `method-bridge`)。
328
-
329
- ---
330
-
331
- ## 失败诊断路径
332
-
333
- | 症状 | 可能原因 | 修复方向 |
334
- |------|---------|---------|
335
- | 验证 1 失败(0 合成边) | 规则未被 compile 或 family 不对 | 检查 catalog.json + compiled bundle |
336
- | 验证 1 部分(只有 resource-load) | method_triggers_field_load 参数错误 | 检查 host_class_pattern / loader_methods |
337
- | 验证 1 部分(无 scene-load) | method_triggers_scene_load 参数错误 | 检查 scene_name 是否匹配 .unity 文件名 |
338
- | 验证 1 部分(无 method-bridge) | method_triggers_method 类名/方法名不匹配 | 检查 source/target_class_pattern 和 source/target_method 是否与图谱中节点名一致 |
339
- | 验证 2 失败(rule_not_matched) | trigger_tokens 未匹配查询文本 | 调整 match.trigger_tokens |
340
- | 验证 2 失败(verification_failed) | 合成边 reason 中的 ruleId 不匹配 | 检查规则 ID 一致性 |
341
- | 验证 3 失败(无 Process) | 合成边 confidence 过低 | 检查 RULE_EDGE_CONFIDENCE(应为 0.75) |
342
- | 验证 4 链路断裂(中间有动态跳转) | 事件派发/回调/delegate 无静态 CALLS 边 | 添加 `method_triggers_method` binding 桥接动态跳转 |
343
- | lifecycle_overrides 无效 | scope 值不是文件路径前缀 | scope 应匹配 filePath 而非类名 |
344
-
345
- ---
346
104
 
347
- ## 参考文档
105
+ ## Legacy Note
348
106
 
349
- - 设计文档:`docs/plans/2026-04-04-unity-rule-gen-skill-design.md`
350
- - YAML 格式定义:设计文档 section 3.3
351
- - 注入逻辑:`gitnexus/src/core/ingestion/unity-runtime-binding-rules.ts`
352
- - 规则类型定义:`gitnexus/src/rule-lab/types.ts:90-114`
353
- - 编译命令:`gitnexus rule-lab compile --repo-path <path>`
107
+ If historical `.gitnexus/gap-lab/runs/**` artifacts exist, treat them as migration evidence only. Do not require gap-lab parity/coverage gates for direct `approved -> compile -> analyze -> CLI validation` loops.