kld-sdd 2.6.8 → 2.6.9
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/package.json +1 -1
- package/skywalk-sdd/context-client.cjs +59 -5
- package/templates/skills/kld-sdd/openspec-sync-specs/SKILL.md +148 -0
- package/templates/skills/kld-sdd/openspec-update-change/SKILL.md +86 -0
- package/templates/skills/kld-sdd/opsx-archive/SKILL.md +1 -1
- package/templates/skills/kld-sdd/opsx-check/SKILL.md +34 -1
- package/templates/skills/kld-sdd/opsx-design/SKILL.md +9 -0
- package/templates/skills/kld-sdd/opsx-kb-ingest/SKILL.md +9 -14
- package/templates/skills/kld-sdd/opsx-ontology-query/SKILL.md +83 -109
- package/templates/skills/kld-sdd/opsx-ontology-query/phase-1-prechange.md +276 -0
- package/templates/skills/kld-sdd/opsx-ontology-query/phase-2-during.md +354 -0
- package/templates/skills/kld-sdd/opsx-ontology-query/phase-3-postchange.md +223 -0
- package/templates/skills/kld-sdd/opsx-ontology-query/phase-4-explore.md +240 -0
- package/templates/skills/kld-sdd/opsx-ontology-query/phase-5-governance.md +232 -0
- package/templates/skills/kld-sdd/opsx-ontology-query/reference.md +92 -4
- package/templates/skills/kld-sdd/opsx-propose/SKILL.md +45 -3
- package/templates/skills/kld-sdd/opsx-propose/checklist.md +1 -0
- package/templates/skills/kld-sdd/opsx-spec/SKILL.md +33 -3
- package/templates/skills/kld-sdd/opsx-task/SKILL.md +9 -0
|
@@ -0,0 +1,240 @@
|
|
|
1
|
+
# Phase 4 · 跨迭代探索(Cross-iteration Exploration)
|
|
2
|
+
|
|
3
|
+
> **触发时机**:开发者手动查询 / Agent 按需加载
|
|
4
|
+
> **加载方式**:任意阶段可 `Read` 本文件
|
|
5
|
+
> **前置条件**:`.local/state.json` 已完成 Session 启动
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## §1 版本谱系追踪(Lineage)
|
|
10
|
+
|
|
11
|
+
### 场景
|
|
12
|
+
|
|
13
|
+
查看某实体的完整变更历史,理解它经历了哪些变更、每次变更改了什么。
|
|
14
|
+
|
|
15
|
+
### API
|
|
16
|
+
|
|
17
|
+
```
|
|
18
|
+
GET {base}/entities/{entityId}/lineage
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
### 示例
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
curl -sS -H "Authorization: Bearer $API_KEY" \
|
|
25
|
+
"$API/v1/spaces/$SPACE_ID/knowledge-bases/$KB_ID/entities/e89287e8-0000-0000-0000-000000000000/lineage"
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
### 响应解读
|
|
29
|
+
|
|
30
|
+
返回按时间排序的版本数组,每版包含:
|
|
31
|
+
|
|
32
|
+
| 字段 | 含义 |
|
|
33
|
+
|------|------|
|
|
34
|
+
| `entityVersionId` | 该版本的 UUID |
|
|
35
|
+
| `predecessorVersionId` | 前序版本 UUID(v1 为 null) |
|
|
36
|
+
| `deltaState` | added / modified / removed |
|
|
37
|
+
| `changeId` | 来源变更 ID |
|
|
38
|
+
| `attributes` | 该版本的属性快照 |
|
|
39
|
+
| `source` | 来源文件(file / line / change_id / archive_id) |
|
|
40
|
+
| `createdAt` | 入库时间 |
|
|
41
|
+
|
|
42
|
+
### 使用场景
|
|
43
|
+
|
|
44
|
+
- **变更审计**:追溯某需求从创建到当前的完整路径
|
|
45
|
+
- **回溯根因**:理解某属性何时被修改、由哪次变更引入
|
|
46
|
+
- **差异对比**:对比 v1 和 v2 的 attributes 变化
|
|
47
|
+
|
|
48
|
+
---
|
|
49
|
+
|
|
50
|
+
## §2 语义检索(Semantic Search)
|
|
51
|
+
|
|
52
|
+
### 场景
|
|
53
|
+
|
|
54
|
+
用自然语言查找相关工程事实,不依赖精确锚点。
|
|
55
|
+
|
|
56
|
+
### API
|
|
57
|
+
|
|
58
|
+
```
|
|
59
|
+
POST {base}/context/search
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
### 请求
|
|
63
|
+
|
|
64
|
+
```json
|
|
65
|
+
{
|
|
66
|
+
"query": "用户登录认证流程",
|
|
67
|
+
"entityTypes": [],
|
|
68
|
+
"limit": 15
|
|
69
|
+
}
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
### 检索通道
|
|
73
|
+
|
|
74
|
+
| 通道 | 说明 | matchType |
|
|
75
|
+
|------|------|-----------|
|
|
76
|
+
| 精确 | 锚点 / canonicalKey 完全匹配 | `exact` |
|
|
77
|
+
| 结构 | entityType + 属性结构匹配 | `structural` |
|
|
78
|
+
| 全文 | PostgreSQL FTS 关键词匹配 | `fulltext` |
|
|
79
|
+
| 向量 | pgvector 语义相似 | `vector` |
|
|
80
|
+
| 图谱 | AGE 关系扩展邻居 | `graph` |
|
|
81
|
+
|
|
82
|
+
### 响应解读
|
|
83
|
+
|
|
84
|
+
```json
|
|
85
|
+
{
|
|
86
|
+
"degraded": false,
|
|
87
|
+
"degradationReasons": [],
|
|
88
|
+
"results": [
|
|
89
|
+
{
|
|
90
|
+
"matchType": "exact",
|
|
91
|
+
"entityId": "e89287e8-0000-0000-0000-000000000000",
|
|
92
|
+
"entityType": "Capability",
|
|
93
|
+
"displayName": "user-login",
|
|
94
|
+
"anchorId": "CAP-USER-LOGIN",
|
|
95
|
+
"scoreExplanation": {
|
|
96
|
+
"method": "rrf",
|
|
97
|
+
"ranks_by_channel": { "exact": 1, "fulltext": 1, "vector": 19 }
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
]
|
|
101
|
+
}
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
### 降级处理
|
|
105
|
+
|
|
106
|
+
| `degraded` | `degradationReasons` | 影响 |
|
|
107
|
+
|------------|----------------------|------|
|
|
108
|
+
| `false` | `[]` | 全通道可用 |
|
|
109
|
+
| `true` | `["vector_unavailable"]` | 向量通道缺失,精确/全文仍可用 |
|
|
110
|
+
| `true` | `["age_unavailable"]` | 图谱扩展缺失 |
|
|
111
|
+
|
|
112
|
+
> 降级不阻塞查询,精确/结构/全文通道始终可用。
|
|
113
|
+
|
|
114
|
+
---
|
|
115
|
+
|
|
116
|
+
## §3 原文溯源(Disclosure)
|
|
117
|
+
|
|
118
|
+
### 场景
|
|
119
|
+
|
|
120
|
+
从实体回到源文档,查看该实体在 spec.md / design.md / tasks.md 中的原文上下文。
|
|
121
|
+
|
|
122
|
+
### API
|
|
123
|
+
|
|
124
|
+
```
|
|
125
|
+
POST {base}/context/disclosures
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
### 请求
|
|
129
|
+
|
|
130
|
+
```json
|
|
131
|
+
{
|
|
132
|
+
"anchorId": "STMT-USER-LOGIN-001",
|
|
133
|
+
"sourceLevel": "preview"
|
|
134
|
+
}
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
### sourceLevel 选项
|
|
138
|
+
|
|
139
|
+
| sourceLevel | 返回内容 | 适用场景 |
|
|
140
|
+
|-------|----------|----------|
|
|
141
|
+
| `preview` | 锚点附近几行 | 快速确认实体内容 |
|
|
142
|
+
| `section` | 包含子节的完整章节 | 理解实体及其下属 AC/CON |
|
|
143
|
+
| `document` | 整个源文档 | 全面上下文 |
|
|
144
|
+
|
|
145
|
+
### 使用场景
|
|
146
|
+
|
|
147
|
+
- **代码审查**:查看 STMT 的原始规格定义
|
|
148
|
+
- **需求对齐**:对比 AC 场景与实际实现行为
|
|
149
|
+
- **文档生成**:提取原文片段生成技术文档
|
|
150
|
+
|
|
151
|
+
---
|
|
152
|
+
|
|
153
|
+
## §4 知识图谱导航(Ontology View)
|
|
154
|
+
|
|
155
|
+
### 场景
|
|
156
|
+
|
|
157
|
+
浏览某实体的一跳关系结构,理解其在本体中的位置。
|
|
158
|
+
|
|
159
|
+
### API
|
|
160
|
+
|
|
161
|
+
```
|
|
162
|
+
GET {base}/entities/{entityId}/ontology-view
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
### 响应结构
|
|
166
|
+
|
|
167
|
+
```json
|
|
168
|
+
{
|
|
169
|
+
"focus": { "entityId": "...", "canonicalKey": "CAP-USER-LOGIN", ... },
|
|
170
|
+
"attributes": [ { "key": "description", "value": "..." } ],
|
|
171
|
+
"businessStructure": {
|
|
172
|
+
"changes": [...],
|
|
173
|
+
"capabilities": [...],
|
|
174
|
+
"statements": [...],
|
|
175
|
+
"tasks": [...],
|
|
176
|
+
"designElements": [...],
|
|
177
|
+
"acceptanceCriteria": [...]
|
|
178
|
+
},
|
|
179
|
+
"relations": [
|
|
180
|
+
{ "relationType": "contains", "direction": "outbound", "neighbor": {...} },
|
|
181
|
+
{ "relationType": "verifiedBy", "direction": "outbound", "neighbor": {...} }
|
|
182
|
+
],
|
|
183
|
+
"evidence": {
|
|
184
|
+
"artifacts": [...],
|
|
185
|
+
"documentSections": [...],
|
|
186
|
+
"source": { "file": "proposal.md", "line": 66 }
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
### 使用场景
|
|
192
|
+
|
|
193
|
+
- **影响评估**:从 Capability 出发看下游 STMT → AC → DES → TASK
|
|
194
|
+
- **覆盖分析**:从 STMT 出发看 verifiedBy → AC 列表
|
|
195
|
+
- **溯源链**:从任意实体出发看 sourcedFrom → DocumentSection → Artifact
|
|
196
|
+
|
|
197
|
+
---
|
|
198
|
+
|
|
199
|
+
## §5 多跳影响分析(Impact)
|
|
200
|
+
|
|
201
|
+
### 场景
|
|
202
|
+
|
|
203
|
+
评估变更的级联影响,超出直接关联。
|
|
204
|
+
|
|
205
|
+
### API
|
|
206
|
+
|
|
207
|
+
```
|
|
208
|
+
GET {base}/entities/{entityId}/impact
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
### 示例
|
|
212
|
+
|
|
213
|
+
```bash
|
|
214
|
+
curl -sS -H "Authorization: Bearer $API_KEY" \
|
|
215
|
+
"$API/v1/spaces/$SPACE_ID/knowledge-bases/$KB_ID/entities/e89287e8-0000-0000-0000-000000000000/impact"
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
### 响应解读
|
|
219
|
+
|
|
220
|
+
```json
|
|
221
|
+
{
|
|
222
|
+
"anchorEntityId": "e89287e8-0000-0000-0000-000000000000",
|
|
223
|
+
"maxDepth": 4,
|
|
224
|
+
"nodes": [
|
|
225
|
+
{ "entityId": "...", "entityVersionId": "...", "entityType": "Capability", "displayName": "user-login", "depth": 0 },
|
|
226
|
+
{ "entityId": "...", "entityVersionId": "...", "entityType": "SpecificationStatement", "displayName": "用户登录认证", "depth": 1 },
|
|
227
|
+
{ "entityId": "...", "entityVersionId": "...", "entityType": "AcceptanceCriterion", "displayName": "正确凭证登录成功", "depth": 2 }
|
|
228
|
+
],
|
|
229
|
+
"edges": [
|
|
230
|
+
{ "relationType": "contains", "fromEntityId": "cap-id", "toEntityId": "stmt-id", "assertionType": "asserted" },
|
|
231
|
+
{ "relationType": "verifiedBy", "fromEntityId": "stmt-id", "toEntityId": "ac-id", "assertionType": "inferred" }
|
|
232
|
+
]
|
|
233
|
+
}
|
|
234
|
+
```
|
|
235
|
+
|
|
236
|
+
### 使用场景
|
|
237
|
+
|
|
238
|
+
- **变更前评估**:修改某 Capability 会波及哪些下游
|
|
239
|
+
- **回归测试范围**:确定受影响的 AC 需要回归验证
|
|
240
|
+
- **架构决策**:理解实体间的依赖深度
|
|
@@ -0,0 +1,232 @@
|
|
|
1
|
+
# Phase 5 · 治理与监控(Governance & Monitoring)
|
|
2
|
+
|
|
3
|
+
> **触发时机**:治理流程 / 定期巡检 / opsx-check 深度验证
|
|
4
|
+
> **加载方式**:治理角色按需 `Read` 本文件
|
|
5
|
+
> **前置条件**:`.local/state.json` 已完成 Session 启动
|
|
6
|
+
>
|
|
7
|
+
> ✅ conformance / drift API **已实现**,但需要先通过 `POST /evidence-ingestions` 入库代码证据后才有数据。
|
|
8
|
+
> 无 evidence 时返回 `{"integrationStatus":"not_integrated","reports":[]}`,Agent 遇到此状态应提示用户"需先入库 evidence",不当作错误。
|
|
9
|
+
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
## §1 覆盖率仪表盘(Coverage Dashboard)
|
|
13
|
+
|
|
14
|
+
### 场景
|
|
15
|
+
|
|
16
|
+
全局监控规格覆盖完整性,按 gapType 分类统计缺失项。
|
|
17
|
+
|
|
18
|
+
### API
|
|
19
|
+
|
|
20
|
+
```
|
|
21
|
+
GET {base}/coverage
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
> KB 级别 API,路径含 kbId。
|
|
25
|
+
|
|
26
|
+
### 示例
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
curl -sS -H "Authorization: Bearer $API_KEY" \
|
|
30
|
+
"$API/v1/spaces/$SPACE_ID/knowledge-bases/$KB_ID/coverage"
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
### 响应解读
|
|
34
|
+
|
|
35
|
+
```json
|
|
36
|
+
{
|
|
37
|
+
"gaps": [
|
|
38
|
+
{
|
|
39
|
+
"entityId": "xxx-0000-0000-0000-000000000000",
|
|
40
|
+
"entityType": "SpecificationStatement",
|
|
41
|
+
"displayName": "某规格声明",
|
|
42
|
+
"gapType": "missing_acceptance_criterion"
|
|
43
|
+
}
|
|
44
|
+
]
|
|
45
|
+
}
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
### 统计维度
|
|
49
|
+
|
|
50
|
+
| gapType | 实体类型 | 含义 | 建议 |
|
|
51
|
+
|---------|----------|------|------|
|
|
52
|
+
| `missing_acceptance_criterion` | STMT | 无验收场景 | 补充 AC |
|
|
53
|
+
| `missing_specification_statement` | DES | 无规格依据 | 补充 realizes 或创建 STMT |
|
|
54
|
+
| `missing_upstream_trace` | TASK | 无上游追溯 | 补充 covers/implements |
|
|
55
|
+
|
|
56
|
+
### 使用场景
|
|
57
|
+
|
|
58
|
+
- **定期巡检**:每周/每迭代检查全局覆盖率
|
|
59
|
+
- **质量门禁**:归档前覆盖率必须达标
|
|
60
|
+
- **技术债识别**:长期 missing 的实体标记为技术债
|
|
61
|
+
|
|
62
|
+
> **Agent 行为指导**:遇到 `integrationStatus: "not_integrated"` 时,提示用户"需先通过 `POST /evidence-ingestions` 入库代码证据",不当作"无数据"或错误处理。
|
|
63
|
+
|
|
64
|
+
---
|
|
65
|
+
|
|
66
|
+
## §2 一致性检查(Conformance)
|
|
67
|
+
|
|
68
|
+
### 场景
|
|
69
|
+
|
|
70
|
+
验证代码实现与规格定义的一致性,对比 KB 规格事实与实现证据。
|
|
71
|
+
|
|
72
|
+
### API
|
|
73
|
+
|
|
74
|
+
```
|
|
75
|
+
GET {base}/conformance
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
### 示例
|
|
79
|
+
|
|
80
|
+
```bash
|
|
81
|
+
curl -sS -H "Authorization: Bearer $API_KEY" \
|
|
82
|
+
"$API/v1/spaces/$SPACE_ID/knowledge-bases/$KB_ID/conformance"
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
### 检查维度
|
|
86
|
+
|
|
87
|
+
| 维度 | 含义 | 数据源 |
|
|
88
|
+
|------|------|--------|
|
|
89
|
+
| 规格断言 vs 代码实现 | STMT/AC 是否在代码中实现 | semantic facts vs implementation_evidence |
|
|
90
|
+
| 规格覆盖 vs 实际行为 | AC 场景是否被测试覆盖 | AC vs test evidence |
|
|
91
|
+
|
|
92
|
+
### 使用场景
|
|
93
|
+
|
|
94
|
+
- **发布前验证**:确认实现与规格一致
|
|
95
|
+
- **回归检测**:代码变更后检查是否仍符合规格
|
|
96
|
+
- **审计报告**:生成一致性报告供评审
|
|
97
|
+
|
|
98
|
+
---
|
|
99
|
+
|
|
100
|
+
## §3 漂移检测(Drift)
|
|
101
|
+
|
|
102
|
+
### 场景
|
|
103
|
+
|
|
104
|
+
检测实现偏离规格的程度,识别"规格说 A 但代码做 B"的情况。
|
|
105
|
+
|
|
106
|
+
### API
|
|
107
|
+
|
|
108
|
+
```
|
|
109
|
+
GET {base}/drift
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
### 示例
|
|
113
|
+
|
|
114
|
+
```bash
|
|
115
|
+
curl -sS -H "Authorization: Bearer $API_KEY" \
|
|
116
|
+
"$API/v1/spaces/$SPACE_ID/knowledge-bases/$KB_ID/drift"
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
### 漂移类型
|
|
120
|
+
|
|
121
|
+
| 类型 | 含义 | 严重度 |
|
|
122
|
+
|------|------|--------|
|
|
123
|
+
| 规格未实现 | STMT/AC 无对应代码 | 高 |
|
|
124
|
+
| 实现无规格 | 代码无对应 STMT/AC | 中 |
|
|
125
|
+
| 行为不一致 | 代码行为与 AC 描述不符 | 高 |
|
|
126
|
+
| 规格过期 | 代码已变更但规格未更新 | 中 |
|
|
127
|
+
|
|
128
|
+
### 使用场景
|
|
129
|
+
|
|
130
|
+
- **迭代回顾**:识别本迭代引入的漂移
|
|
131
|
+
- **技术债管理**:长期漂移项纳入技术债看板
|
|
132
|
+
- **重构决策**:高漂移区域优先重构
|
|
133
|
+
|
|
134
|
+
> **Agent 行为指导**:同 §2,遇到 `integrationStatus: "not_integrated"` 时提示用户需先入库 evidence。
|
|
135
|
+
|
|
136
|
+
---
|
|
137
|
+
|
|
138
|
+
## §4 关系候选审批(Relation Candidate Review)
|
|
139
|
+
|
|
140
|
+
### 场景
|
|
141
|
+
|
|
142
|
+
`suggested` 关系(AI 推荐但未确认)需要人工审批后才能进入正式本体。
|
|
143
|
+
|
|
144
|
+
### API
|
|
145
|
+
|
|
146
|
+
```
|
|
147
|
+
GET {base}/relation-candidates
|
|
148
|
+
POST {base}/relation-candidates/{candidateId}/review
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
> 审批通过/拒绝都走同一个 `/review` 端点,用 body 中的 `decision` 区分。
|
|
152
|
+
|
|
153
|
+
### 示例
|
|
154
|
+
|
|
155
|
+
```bash
|
|
156
|
+
# 列出待审批候选(可按 status 过滤)
|
|
157
|
+
curl -sS -H "Authorization: Bearer $API_KEY" \
|
|
158
|
+
"$API/v1/spaces/$SPACE_ID/knowledge-bases/$KB_ID/relation-candidates?status=pending"
|
|
159
|
+
|
|
160
|
+
# 审批通过
|
|
161
|
+
curl -sS -X POST -H "Authorization: Bearer $API_KEY" -H "Content-Type: application/json" \
|
|
162
|
+
"$API/v1/spaces/$SPACE_ID/knowledge-bases/$KB_ID/relation-candidates/{candidateId}/review" \
|
|
163
|
+
-d '{"decision":"accept","reason":"关系正确,确认批准"}'
|
|
164
|
+
|
|
165
|
+
# 拒绝
|
|
166
|
+
curl -sS -X POST -H "Authorization: Bearer $API_KEY" -H "Content-Type: application/json" \
|
|
167
|
+
"$API/v1/spaces/$SPACE_ID/knowledge-bases/$KB_ID/relation-candidates/{candidateId}/review" \
|
|
168
|
+
-d '{"decision":"reject","reason":"证据不足"}'
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
### 候选字段
|
|
172
|
+
|
|
173
|
+
| 字段 | 含义 |
|
|
174
|
+
|------|------|
|
|
175
|
+
| `candidateId` | 候选 UUID |
|
|
176
|
+
| `relationType` | 推荐的关系类型 |
|
|
177
|
+
| `fromEntityId` / `fromName` | 源实体 |
|
|
178
|
+
| `toEntityId` / `toName` | 目标实体 |
|
|
179
|
+
| `confidence` | 置信度(0-1) |
|
|
180
|
+
| `supportEvidence` / `oppositionEvidence` | 支持/反对证据 |
|
|
181
|
+
| `status` | pending / accepted / rejected |
|
|
182
|
+
|
|
183
|
+
### 审批请求
|
|
184
|
+
|
|
185
|
+
```json
|
|
186
|
+
{ "decision": "accept | reject", "reason": "string" }
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
### 审批决策
|
|
190
|
+
|
|
191
|
+
| confidence | support vs opposition | 建议 |
|
|
192
|
+
|------------|----------------------|------|
|
|
193
|
+
| > 0.8 | support >> opposition | accept |
|
|
194
|
+
| 0.5-0.8 | 有争议 | 人工审查后决定 |
|
|
195
|
+
| < 0.5 | opposition >> support | reject |
|
|
196
|
+
|
|
197
|
+
### 使用场景
|
|
198
|
+
|
|
199
|
+
- **日常治理**:定期审批待确认关系
|
|
200
|
+
- **本体质量提升**:高置信度候选批量批准
|
|
201
|
+
- **误报过滤**:低置信度候选拒绝并反馈
|
|
202
|
+
|
|
203
|
+
---
|
|
204
|
+
|
|
205
|
+
## §5 变更统计与趋势(Change Analytics)
|
|
206
|
+
|
|
207
|
+
### 场景
|
|
208
|
+
|
|
209
|
+
查看 KB 中所有变更的统计信息,分析迭代趋势。
|
|
210
|
+
|
|
211
|
+
### API
|
|
212
|
+
|
|
213
|
+
```
|
|
214
|
+
GET {base}/changes
|
|
215
|
+
GET {base}/changes/{changeId}
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
### 分析维度
|
|
219
|
+
|
|
220
|
+
| 维度 | 指标 | 用途 |
|
|
221
|
+
|------|------|------|
|
|
222
|
+
| 变更频率 | 每迭代变更数 | 评估迭代节奏 |
|
|
223
|
+
| 变更类型分布 | added / modified / removed 比例 | 评估系统成熟度 |
|
|
224
|
+
| 实体增长率 | 每迭代新增实体数 | 评估规格膨胀 |
|
|
225
|
+
| 覆盖率趋势 | 各 gapType 随时间变化 | 评估质量改进 |
|
|
226
|
+
| 冲突频率 | VERSION_CONFLICT / EXTERNAL_REF_CONFLICT / EXTERNAL_REFERENCE_FORMAT_INVALID / SCOPE_MISMATCH / FEATURE_UNBOUND 次数 | 评估 Continuity 与编号体系流程成熟度 |
|
|
227
|
+
|
|
228
|
+
### 使用场景
|
|
229
|
+
|
|
230
|
+
- **迭代报告**:每迭代生成本体变更统计
|
|
231
|
+
- **成熟度评估**:评估团队的 SDD 流程成熟度
|
|
232
|
+
- **容量规划**:预测 KB 增长趋势
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# 本体查询 · 参考
|
|
2
2
|
|
|
3
|
-
需要鉴权细节、state
|
|
3
|
+
需要鉴权细节、state 字段、API curl 示例或响应字段时再读。
|
|
4
4
|
|
|
5
5
|
## `.local/state.json`
|
|
6
6
|
|
|
@@ -68,6 +68,12 @@ API Key 一般为租户范围;`apiKeySpaceId` 为空时可列出租户下多
|
|
|
68
68
|
|
|
69
69
|
`POST {base}/context/search`
|
|
70
70
|
|
|
71
|
+
```bash
|
|
72
|
+
curl -sS -X POST "$API/v1/spaces/$SPACE_ID/knowledge-bases/$KB_ID/context/search" \
|
|
73
|
+
-H "Authorization: Bearer $API_KEY" -H "Content-Type: application/json" \
|
|
74
|
+
-d '{"query":"用户登录与会话","entityTypes":[],"limit":15}'
|
|
75
|
+
```
|
|
76
|
+
|
|
71
77
|
```json
|
|
72
78
|
{ "query": "string", "entityTypes": [], "limit": 15 }
|
|
73
79
|
```
|
|
@@ -75,14 +81,30 @@ API Key 一般为租户范围;`apiKeySpaceId` 为空时可列出租户下多
|
|
|
75
81
|
| 字段 | 含义 |
|
|
76
82
|
|------|------|
|
|
77
83
|
| `degraded` / `degradationReasons` | 向量/AGE/rerank 等降级 |
|
|
84
|
+
| `advisory` | true=结果为建议性,非权威;Agent 应在输出中标注 |
|
|
78
85
|
| `results[].matchType` | exact / structural / fulltext / vector / graph … |
|
|
79
86
|
| `results[].entityId` / `entityVersionId` | 溯源 |
|
|
87
|
+
| `results[].snippet` | 命中片段预览 |
|
|
88
|
+
| `results[].source` | 溯源信息(file/line/anchor_id/change_id/archive_id) |
|
|
89
|
+
| `results[].reviewStatus` | 审核状态 |
|
|
90
|
+
| `results[].score` | 归一化分数 |
|
|
80
91
|
| `results[].scoreExplanation` | RRF channel ranks 等 |
|
|
81
92
|
|
|
82
93
|
## entities/resolve(Continuity / 外部需求号)
|
|
83
94
|
|
|
84
95
|
`POST {base}/entities/resolve`
|
|
85
96
|
|
|
97
|
+
```bash
|
|
98
|
+
curl -sS -X POST "$API/v1/spaces/$SPACE_ID/knowledge-bases/$KB_ID/entities/resolve" \
|
|
99
|
+
-H "Authorization: Bearer $API_KEY" -H "Content-Type: application/json" \
|
|
100
|
+
-d '{
|
|
101
|
+
"externalSystem":"requirement-mgmt",
|
|
102
|
+
"externalObjectType":"requirement",
|
|
103
|
+
"externalId":"REQ-FI-2024-001",
|
|
104
|
+
"entityType":"Capability"
|
|
105
|
+
}'
|
|
106
|
+
```
|
|
107
|
+
|
|
86
108
|
```json
|
|
87
109
|
{
|
|
88
110
|
"externalSystem": "requirement-mgmt",
|
|
@@ -97,16 +119,60 @@ API Key 一般为租户范围;`apiKeySpaceId` 为空时可列出租户下多
|
|
|
97
119
|
| 结果 | 含义 |
|
|
98
120
|
|------|------|
|
|
99
121
|
| `resolution=LINK_EXISTING` + `inheritanceAllowed=true` | ≥1 可继承绑定;`candidates` 仅存活实体;`removedBindingCount` 为失效绑定数 |
|
|
122
|
+
| `resolution=SAME_ITERATION` | entityId/previousVersionId 精确命中,已对齐同一实体 |
|
|
123
|
+
| `resolution=CREATE_NEW` | 无匹配,全新需求 |
|
|
124
|
+
| `resolution=RELATED_ONLY` | canonicalKey/名称匹配但无确定性身份,仅候选 |
|
|
100
125
|
| `matchType=HISTORICAL_ONLY` | 有绑定但全部无 current / removed;`inheritanceAllowed=false`,不得当迭代继承 |
|
|
101
126
|
| `NEEDS_CONFIRM` / `SIMILAR_REQUIREMENT` | 名称/结构相似,仅候选 |
|
|
102
127
|
| `NEW_REQUIREMENT` | 无命中 |
|
|
103
128
|
|
|
104
|
-
|
|
129
|
+
> **补充响应字段**:
|
|
130
|
+
> - `reviewRequired`:true=需人工确认
|
|
131
|
+
> - `supportEvidence` / `oppositionEvidence`:支持/反对决议的证据列表,Agent 可向用户展示
|
|
132
|
+
> - `clarificationQuestions`:AI 生成的澄清问题,Agent 可用 `ask_user` 呈现给用户
|
|
133
|
+
|
|
134
|
+
**KB 可用时禁止**用本地 `archive/` 目录当跨迭代继承源,entity-id 必须来自 KB resolve by canonicalKey。KB degraded 时 archive 可作为降级手段(标注 `source: archive(degraded)`)。
|
|
135
|
+
|
|
136
|
+
## 按功能号圈能力(FEAT query)
|
|
137
|
+
|
|
138
|
+
在 propose 前,用 feature 编号查询该功能下已有能力清单,辅助勾选本次 CAP 范围。
|
|
139
|
+
|
|
140
|
+
`POST {base}/entities/resolve`(与 Continuity 同一接口,`externalObjectType:"feature"`)
|
|
141
|
+
|
|
142
|
+
```bash
|
|
143
|
+
curl -sS -X POST "$API/v1/spaces/$SPACE_ID/knowledge-bases/$KB_ID/entities/resolve" \
|
|
144
|
+
-H "Authorization: Bearer $API_KEY" -H "Content-Type: application/json" \
|
|
145
|
+
-d '{
|
|
146
|
+
"externalSystem":"requirement-mgmt",
|
|
147
|
+
"externalObjectType":"feature",
|
|
148
|
+
"externalId":"FEAT-FI-012",
|
|
149
|
+
"entityType":"Capability"
|
|
150
|
+
}'
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
响应中 `candidates` 列出该 FEAT 下存活 / 失效能力清单;`removedBindingCount` 为已失效绑定数。
|
|
154
|
+
|
|
155
|
+
> 此查询只作范围参考,不改变 Continuity 判定优先级。
|
|
105
156
|
|
|
106
157
|
## context/match-requirement
|
|
107
158
|
|
|
108
159
|
`POST {base}/context/match-requirement`
|
|
109
160
|
|
|
161
|
+
```bash
|
|
162
|
+
curl -sS -X POST "$API/v1/spaces/$SPACE_ID/knowledge-bases/$KB_ID/context/match-requirement" \
|
|
163
|
+
-H "Authorization: Bearer $API_KEY" -H "Content-Type: application/json" \
|
|
164
|
+
-d '{
|
|
165
|
+
"query":"用户登录与会话",
|
|
166
|
+
"targetStage":"spec",
|
|
167
|
+
"entityId":"<capability-entity-uuid>",
|
|
168
|
+
"externalSystem":"requirement-mgmt",
|
|
169
|
+
"externalObjectType":"requirement",
|
|
170
|
+
"externalId":"REQ-FI-2024-001"
|
|
171
|
+
}'
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
检索通道:精确/结构 + 全文 + 向量(就绪时)→ RRF →(可选)图谱扩展。看 `degraded` / `degradationReasons`。
|
|
175
|
+
|
|
110
176
|
```json
|
|
111
177
|
{
|
|
112
178
|
"query": "string",
|
|
@@ -129,6 +195,13 @@ API Key 一般为租户范围;`apiKeySpaceId` 为空时可列出租户下多
|
|
|
129
195
|
| `NEEDS_CONFIRM` | 需人确认 |
|
|
130
196
|
| `NEW_REQUIREMENT` | 无可信复用 |
|
|
131
197
|
|
|
198
|
+
> **补充响应字段**:
|
|
199
|
+
> - `advisory`:true=结果为建议性
|
|
200
|
+
> - `reviewRequired`:true=需人工确认
|
|
201
|
+
> - `specGenerationContext`:复用统计(`reusableStatements`/`reusableAcceptanceCriteria`/`reusableConstraints`/`reusableDesignElements`/`unresolvedQuestions`),Agent 可据此判断复用率
|
|
202
|
+
> - `warnings`:注意事项(如"相似度只能产生候选,不能自动 sameAs")
|
|
203
|
+
> - `clarificationQuestions`:AI 生成的澄清问题,Agent 可用 `ask_user` 呈现给用户
|
|
204
|
+
|
|
132
205
|
## 对象读
|
|
133
206
|
|
|
134
207
|
| 方法 | 路径 |
|
|
@@ -141,6 +214,8 @@ API Key 一般为租户范围;`apiKeySpaceId` 为空时可列出租户下多
|
|
|
141
214
|
|
|
142
215
|
`impact` / `ontology-view` 走 PG 关系;与 `context/search` 不同链路。
|
|
143
216
|
|
|
217
|
+
`impact` 响应字段:`anchorEntityId`(锚点实体 ID)、`maxDepth`(最大影响深度≤4)、`nodes`(含 entityId/entityVersionId/entityType/displayName/depth)、`edges`(含 relationType/fromEntityId/toEntityId/assertionType)。
|
|
218
|
+
|
|
144
219
|
## disclosures
|
|
145
220
|
|
|
146
221
|
`POST {base}/context/disclosures`
|
|
@@ -150,8 +225,21 @@ API Key 一般为租户范围;`apiKeySpaceId` 为空时可列出租户下多
|
|
|
150
225
|
"anchorId": "STMT-…",
|
|
151
226
|
"entityId": null,
|
|
152
227
|
"entityVersionId": null,
|
|
153
|
-
"
|
|
228
|
+
"sourceLevel": "preview"
|
|
154
229
|
}
|
|
155
230
|
```
|
|
156
231
|
|
|
157
|
-
`
|
|
232
|
+
`sourceLevel`:`preview` | `section` | `document`。
|
|
233
|
+
|
|
234
|
+
> 注:请求字段名为 `sourceLevel`(不是 `level`)。响应中对应字段为 `disclosureLevel`。
|
|
235
|
+
> 请求还支持可选的 `relationDepth`、`direction`、`relationTypes`、`entityTypes`、`relatedLimit`。
|
|
236
|
+
|
|
237
|
+
## 实现备注
|
|
238
|
+
|
|
239
|
+
> 控制台 Agent 架构 / Skills 激活机制 / 记忆策略。对查询操作无直接影响,仅供维护者参考。
|
|
240
|
+
|
|
241
|
+
- 控制台知识库页另有浮动 Ontology Agent(会话登录 + SSE);本 Skill 走 API Key,二者分开。
|
|
242
|
+
- **Agent 角色(V1)**:控制台 Agent 是**单一 ReActAgent + 角色人格切换**(架构师 / 业务分析师 / 数据分析师),不是三个独立 JVM agent。共享工具集,仅 sysPrompt 与工具偏好不同——Studio 仍单 run、延迟更低,后续需要再拆。
|
|
243
|
+
- 交互硬规则:自然语言优先,不向用户索要 UUID;多实体时用 `ask_user` Generative UI 卡片(`type=choice`,options.label=名称)。
|
|
244
|
+
- **Skills 激活**:控制台 Agent 通过 AgentScope `FileSystemSkillRepository`(`skillsRoot`,见 `classpath:agent/agent.yml`)挂载本目录;运行时用内置工具 `load_skill_through_path`(skillId=`opsx-ontology-query`,path=`SKILL.md` / `reference.md`)按需加载,不把全文塞进 system prompt。
|
|
245
|
+
- **记忆**:会话短期用 AgentScope `InMemoryAgentStateStore`;本体事实仍走 KB(pgvector/SQL)。不需要 mem0,除非以后要跨会话个人偏好记忆。
|