@veewo/gitnexus 1.5.0 → 1.5.1
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/dist/benchmark/agent-context/runner.js +3 -0
- package/dist/benchmark/agent-context/runner.test.js +22 -0
- package/dist/benchmark/agent-context/tool-runner.d.ts +7 -6
- package/dist/benchmark/agent-safe-query-context/io.d.ts +2 -0
- package/dist/benchmark/agent-safe-query-context/io.js +86 -0
- package/dist/benchmark/agent-safe-query-context/io.test.d.ts +1 -0
- package/dist/benchmark/agent-safe-query-context/io.test.js +13 -0
- package/dist/benchmark/agent-safe-query-context/report.d.ts +57 -0
- package/dist/benchmark/agent-safe-query-context/report.js +159 -0
- package/dist/benchmark/agent-safe-query-context/report.test.d.ts +1 -0
- package/dist/benchmark/agent-safe-query-context/report.test.js +362 -0
- package/dist/benchmark/agent-safe-query-context/runner.d.ts +44 -0
- package/dist/benchmark/agent-safe-query-context/runner.js +406 -0
- package/dist/benchmark/agent-safe-query-context/runner.test.d.ts +1 -0
- package/dist/benchmark/agent-safe-query-context/runner.test.js +290 -0
- package/dist/benchmark/agent-safe-query-context/semantic-tuple.d.ts +20 -0
- package/dist/benchmark/agent-safe-query-context/semantic-tuple.js +225 -0
- package/dist/benchmark/agent-safe-query-context/semantic-tuple.test.d.ts +1 -0
- package/dist/benchmark/agent-safe-query-context/semantic-tuple.test.js +122 -0
- package/dist/benchmark/agent-safe-query-context/subagent-live.d.ts +47 -0
- package/dist/benchmark/agent-safe-query-context/subagent-live.js +128 -0
- package/dist/benchmark/agent-safe-query-context/subagent-live.test.d.ts +1 -0
- package/dist/benchmark/agent-safe-query-context/subagent-live.test.js +155 -0
- package/dist/benchmark/agent-safe-query-context/telemetry-tool.d.ts +9 -0
- package/dist/benchmark/agent-safe-query-context/telemetry-tool.js +77 -0
- package/dist/benchmark/agent-safe-query-context/types.d.ts +61 -0
- package/dist/benchmark/agent-safe-query-context/types.js +8 -0
- package/dist/benchmark/runtime-poc/provenance-artifact.d.ts +47 -0
- package/dist/benchmark/runtime-poc/provenance-artifact.js +89 -0
- package/dist/benchmark/runtime-poc/runner.d.ts +31 -0
- package/dist/benchmark/runtime-poc/runner.js +163 -0
- package/dist/benchmark/u2-e2e/hydration-policy-repeatability-runner.d.ts +8 -0
- package/dist/benchmark/u2-e2e/hydration-policy-repeatability-runner.js +21 -0
- package/dist/benchmark/u2-e2e/phase2-runtime-claim-acceptance-runner.d.ts +0 -1
- package/dist/benchmark/u2-e2e/phase2-runtime-claim-acceptance-runner.js +53 -51
- package/dist/benchmark/u2-e2e/phase2-runtime-claim-acceptance-runner.test.js +0 -1
- package/dist/benchmark/u2-e2e/phase5-rule-lab-acceptance-runner.d.ts +1 -1
- package/dist/benchmark/u2-e2e/phase5-rule-lab-acceptance-runner.js +82 -18
- package/dist/benchmark/u2-e2e/phase5-rule-lab-acceptance-runner.test.js +1 -2
- package/dist/benchmark/u2-e2e/retrieval-runner.js +15 -7
- package/dist/benchmark/u2-e2e/retrieval-runner.test.js +46 -0
- package/dist/cli/ai-context.js +2 -12
- package/dist/cli/ai-context.test.js +8 -0
- package/dist/cli/analyze-runtime-summary.js +1 -0
- package/dist/cli/analyze-runtime-summary.test.js +2 -0
- package/dist/cli/analyze-summary.d.ts +2 -0
- package/dist/cli/analyze-summary.js +24 -0
- package/dist/cli/analyze-summary.test.js +65 -1
- package/dist/cli/analyze.js +5 -1
- package/dist/cli/benchmark-agent-safe-query-context.d.ts +20 -0
- package/dist/cli/benchmark-agent-safe-query-context.js +39 -0
- package/dist/cli/benchmark-agent-safe-query-context.test.d.ts +1 -0
- package/dist/cli/benchmark-agent-safe-query-context.test.js +271 -0
- package/dist/cli/benchmark.d.ts +29 -0
- package/dist/cli/benchmark.js +55 -0
- package/dist/cli/index.js +23 -0
- package/dist/cli/rule-lab.d.ts +3 -7
- package/dist/cli/rule-lab.js +13 -22
- package/dist/cli/rule-lab.test.js +23 -3
- package/dist/cli/tool.d.ts +2 -0
- package/dist/cli/tool.js +2 -0
- package/dist/core/config/unity-config.d.ts +0 -1
- package/dist/core/config/unity-config.js +0 -1
- package/dist/core/ingestion/pipeline.js +35 -6
- package/dist/core/ingestion/unity-lifecycle-synthetic-calls.test.js +18 -20
- package/dist/core/ingestion/unity-parity-seed.d.ts +2 -1
- package/dist/core/ingestion/unity-parity-seed.js +8 -0
- package/dist/core/ingestion/unity-resource-processor.d.ts +11 -0
- package/dist/core/ingestion/unity-resource-processor.js +102 -0
- package/dist/core/ingestion/unity-resource-processor.test.js +449 -0
- package/dist/core/ingestion/unity-runtime-binding-rules.d.ts +15 -0
- package/dist/core/ingestion/unity-runtime-binding-rules.js +178 -30
- package/dist/core/lbug/csv-generator.test.js +2 -2
- package/dist/core/unity/doc-contract.test.d.ts +1 -0
- package/dist/core/unity/doc-contract.test.js +30 -0
- package/dist/core/unity/prefab-source-scan.d.ts +25 -0
- package/dist/core/unity/prefab-source-scan.js +152 -0
- package/dist/core/unity/prefab-source-scan.test.d.ts +1 -0
- package/dist/core/unity/prefab-source-scan.test.js +70 -0
- package/dist/core/unity/scan-context.d.ts +12 -0
- package/dist/core/unity/scan-context.js +50 -2
- package/dist/core/unity/scan-context.test.js +74 -0
- package/dist/mcp/local/agent-safe-response.d.ts +10 -0
- package/dist/mcp/local/agent-safe-response.js +639 -0
- package/dist/mcp/local/derived-process-reader.js +1 -1
- package/dist/mcp/local/local-backend.d.ts +18 -1
- package/dist/mcp/local/local-backend.js +319 -125
- package/dist/mcp/local/process-confidence.d.ts +1 -2
- package/dist/mcp/local/process-confidence.js +0 -3
- package/dist/mcp/local/process-confidence.test.js +4 -2
- package/dist/mcp/local/process-evidence.d.ts +1 -8
- package/dist/mcp/local/process-evidence.js +1 -23
- package/dist/mcp/local/process-evidence.test.js +2 -16
- package/dist/mcp/local/process-ref.d.ts +1 -1
- package/dist/mcp/local/runtime-chain-closure-evaluator.d.ts +33 -0
- package/dist/mcp/local/runtime-chain-closure-evaluator.js +273 -0
- package/dist/mcp/local/runtime-chain-graph-candidates.d.ts +23 -0
- package/dist/mcp/local/runtime-chain-graph-candidates.js +131 -0
- package/dist/mcp/local/runtime-chain-verify.d.ts +1 -1
- package/dist/mcp/local/runtime-chain-verify.js +149 -138
- package/dist/mcp/local/runtime-chain-verify.test.js +126 -68
- package/dist/mcp/local/runtime-claim-rule-registry.d.ts +4 -0
- package/dist/mcp/local/runtime-claim-rule-registry.js +4 -0
- package/dist/mcp/local/runtime-claim-rule-registry.test.js +37 -4
- package/dist/mcp/local/runtime-claim.d.ts +11 -0
- package/dist/mcp/local/runtime-claim.js +28 -0
- package/dist/mcp/local/unity-evidence-view.d.ts +1 -1
- package/dist/mcp/local/unity-evidence-view.js +1 -1
- package/dist/mcp/local/unity-evidence-view.test.js +22 -0
- package/dist/mcp/tools.js +51 -21
- package/dist/rule-lab/analyze.d.ts +2 -1
- package/dist/rule-lab/analyze.js +94 -59
- package/dist/rule-lab/analyze.test.js +238 -20
- package/dist/rule-lab/curate.d.ts +2 -1
- package/dist/rule-lab/curate.js +24 -3
- package/dist/rule-lab/curate.test.js +65 -0
- package/dist/rule-lab/curation-input-builder.d.ts +45 -0
- package/dist/rule-lab/curation-input-builder.js +133 -0
- package/dist/rule-lab/promote.js +80 -7
- package/dist/rule-lab/promote.test.js +150 -0
- package/dist/rule-lab/review-pack.d.ts +3 -0
- package/dist/rule-lab/review-pack.js +41 -1
- package/dist/rule-lab/review-pack.test.js +67 -0
- package/dist/rule-lab/types.d.ts +29 -0
- package/dist/types/pipeline.d.ts +3 -0
- package/package.json +3 -2
- package/scripts/run-node-tests.mjs +61 -0
- package/skills/_shared/unity-rule-authoring-contract.md +64 -0
- package/skills/_shared/unity-runtime-process-contract.md +16 -0
- package/skills/gitnexus-cli.md +8 -0
- package/skills/gitnexus-debugging.md +9 -0
- package/skills/gitnexus-exploring.md +66 -18
- package/skills/gitnexus-guide.md +42 -3
- package/skills/gitnexus-impact-analysis.md +8 -0
- package/skills/gitnexus-pr-review.md +8 -0
- package/skills/gitnexus-refactoring.md +8 -0
- package/skills/gitnexus-unity-rule-gen.md +66 -312
|
@@ -1,353 +1,107 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: gitnexus-unity-rule-gen
|
|
3
|
-
description: "
|
|
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
|
|
6
|
+
# Unity Reduced Rule-Lab Authoring
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
This skill is the post-rollback workflow.
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
Primary path:
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
157
|
-
|
|
158
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
scope: "<path_prefix>"
|
|
35
|
+
- source class + source method
|
|
36
|
+
- target class + target method
|
|
37
|
+
- expected missing runtime hop
|
|
190
38
|
|
|
191
|
-
|
|
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
|
-
|
|
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
|
-
|
|
43
|
+
### Phase A: Prepare exact pairs
|
|
211
44
|
|
|
212
|
-
|
|
213
|
-
|
|
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
|
-
###
|
|
49
|
+
### Phase B: Review and curate
|
|
228
50
|
|
|
229
51
|
```bash
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
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
|
-
|
|
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
|
-
###
|
|
62
|
+
### Phase C: Promote approved rule
|
|
249
63
|
|
|
250
64
|
```bash
|
|
251
|
-
gitnexus rule-lab
|
|
65
|
+
gitnexus rule-lab promote --repo-path "$REPO_PATH" --run-id "$RUN_ID" --slice-id "$SLICE_ID"
|
|
252
66
|
```
|
|
253
67
|
|
|
254
|
-
###
|
|
68
|
+
### Phase D: Compile and re-index
|
|
255
69
|
|
|
256
70
|
```bash
|
|
257
|
-
gitnexus
|
|
258
|
-
|
|
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
|
-
|
|
280
|
-
**FAIL 诊断**: 规则未被 pipeline 加载 → 检查 catalog.json 的 `family` 字段。
|
|
281
|
-
|
|
282
|
-
### 验证 2: 运行时链路验证
|
|
75
|
+
## Three Mandatory Guards
|
|
283
76
|
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
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
|
-
|
|
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
|
-
**
|
|
305
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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.
|