simple-skills 1.8.8 → 1.9.0
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/README.md +1 -0
- package/package.json +1 -1
- package/skills/engineering/knowledge-base/SKILL.md +122 -0
- package/skills/engineering/knowledge-base/references/consumption.md +171 -0
- package/skills/engineering/knowledge-base/references/format.md +565 -0
- package/skills/engineering/knowledge-base/scripts/knowledge.py +2175 -0
|
@@ -0,0 +1,565 @@
|
|
|
1
|
+
# 知识库格式参考(v0.2)
|
|
2
|
+
|
|
3
|
+
本文件是知识库格式 v0.2 的紧凑参考,覆盖创建、校验、消费所需的规范细节。
|
|
4
|
+
|
|
5
|
+
## 目录
|
|
6
|
+
|
|
7
|
+
1. [Bundle 结构](#1-bundle-结构)
|
|
8
|
+
2. [Concept 文档](#2-concept-文档)
|
|
9
|
+
3. [Frontmatter 字段](#3-frontmatter-字段)
|
|
10
|
+
4. [来源与可信度信号](#4-来源与可信度信号)
|
|
11
|
+
5. [生成、验证与信任层级](#5-生成验证与信任层级)
|
|
12
|
+
6. [生命周期](#6-生命周期)
|
|
13
|
+
7. [链接与路径](#7-链接与路径)
|
|
14
|
+
8. [index.md](#8-indexmd)
|
|
15
|
+
9. [log.md](#9-logmd)
|
|
16
|
+
10. [Attested Computation](#10-attested-computation)
|
|
17
|
+
11. [符合性与宽容消费](#11-符合性与宽容消费)
|
|
18
|
+
12. [v0.1 兼容](#12-v01-兼容)
|
|
19
|
+
13. [完整示例](#13-完整示例)
|
|
20
|
+
14. [写作检查清单](#14-写作检查清单)
|
|
21
|
+
|
|
22
|
+
---
|
|
23
|
+
|
|
24
|
+
## 1. Bundle 结构
|
|
25
|
+
|
|
26
|
+
Bundle 是一个目录树,叶子是 markdown 文件。目录层级**不绑定领域**,producer 按知识本身组织。
|
|
27
|
+
|
|
28
|
+
```
|
|
29
|
+
path/to/bundle/
|
|
30
|
+
index.md # 可选:目录索引,渐进披露
|
|
31
|
+
log.md # 可选:变更日志
|
|
32
|
+
<concept>.md # 根层 concept
|
|
33
|
+
<subdirectory>/
|
|
34
|
+
index.md
|
|
35
|
+
<concept>.md
|
|
36
|
+
<subdirectory>/
|
|
37
|
+
...
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
分发方式可以是 git 仓库(推荐)、tar/zip,或更大仓库的子目录。
|
|
41
|
+
|
|
42
|
+
### 保留文件名
|
|
43
|
+
|
|
44
|
+
以下文件名在任意层级都有特殊含义,**不能**作为 concept:
|
|
45
|
+
|
|
46
|
+
| 文件名 | 用途 |
|
|
47
|
+
| --- | --- |
|
|
48
|
+
| `index.md` | 目录列表,见 §8 |
|
|
49
|
+
| `log.md` | 更新历史,见 §9 |
|
|
50
|
+
|
|
51
|
+
其余 `.md` 都是 concept。标签通过 `tags` frontmatter 表达,不单独建文件。
|
|
52
|
+
|
|
53
|
+
---
|
|
54
|
+
|
|
55
|
+
## 2. Concept 文档
|
|
56
|
+
|
|
57
|
+
每个 concept 是 UTF-8 markdown,由两部分组成:
|
|
58
|
+
|
|
59
|
+
1. 文件开头的 YAML frontmatter,用两行 `---` 包围。
|
|
60
|
+
2. 之后的 markdown 正文。
|
|
61
|
+
|
|
62
|
+
最小合法 concept 只需要一个非空 `type`:
|
|
63
|
+
|
|
64
|
+
```markdown
|
|
65
|
+
---
|
|
66
|
+
type: Reference
|
|
67
|
+
---
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
正文没有必需小节。以下标题有约定含义,适用时优先使用:
|
|
71
|
+
|
|
72
|
+
| 标题 | 用途 |
|
|
73
|
+
| --- | --- |
|
|
74
|
+
| `# Schema` | 资产字段/列的结构化说明 |
|
|
75
|
+
| `# Examples` | 具体用法示例,常用围栏代码块 |
|
|
76
|
+
| `# Computation` | 受证计算的计算内容,见 §10 |
|
|
77
|
+
|
|
78
|
+
正文优先用结构化 markdown(标题、列表、表格、围栏代码块),而不是自由散文;这对人和 Agent 检索都更友好。逐条归因用脚注,键是 `sources[].id`,不要用正文 `# Citations` 列表。
|
|
79
|
+
|
|
80
|
+
---
|
|
81
|
+
|
|
82
|
+
## 3. Frontmatter 字段
|
|
83
|
+
|
|
84
|
+
```yaml
|
|
85
|
+
---
|
|
86
|
+
type: <Type name> # 必填
|
|
87
|
+
title: <Optional display name>
|
|
88
|
+
description: <Optional one-line summary>
|
|
89
|
+
resource: <Optional canonical URI>
|
|
90
|
+
tags: [<tag>, <tag>, ...] # 可选
|
|
91
|
+
# 以下家族可选:provenance / trust / lifecycle / computation
|
|
92
|
+
# 也可以带任意 producer 自定义 key
|
|
93
|
+
---
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
### 字段表
|
|
97
|
+
|
|
98
|
+
| 字段 | 必填 | 形状 | 说明 |
|
|
99
|
+
| --- | --- | --- | --- |
|
|
100
|
+
| `type` | **是** | 非空字符串 | concept 类型,用于路由/过滤/展示 |
|
|
101
|
+
| `title` | 否(推荐) | 字符串 | 展示名;缺省时 consumer 可从文件名推导 |
|
|
102
|
+
| `description` | 否(推荐) | 一句话字符串 | 被 `index.md`、搜索摘要、预览复用 |
|
|
103
|
+
| `resource` | 否(推荐) | URI/路径 | 概念所描述底层资产的规范 URI;抽象概念可省略 |
|
|
104
|
+
| `tags` | 否(推荐) | 字符串列表 | 跨领域分类 |
|
|
105
|
+
| `sources` | 否 | 映射列表 | 来源与 provenance,见 §4 |
|
|
106
|
+
| `usage_window` | 否 | `{from, to}` | 框定所有 `usage_count` 的时间窗 |
|
|
107
|
+
| `generated` | 否 | `{by, at}` | 当前内容如何产生,见 §5 |
|
|
108
|
+
| `verified` | 否 | `{by, at}` 或列表 | 谁/什么确认过内容,见 §5 |
|
|
109
|
+
| `status` | 否 | `draft\|stable\|deprecated` | 生命周期,缺省 `stable`,见 §6 |
|
|
110
|
+
| `stale_after` | 否 | ISO 8601 时刻 | 内容在该时刻及之后过期,见 §6 |
|
|
111
|
+
| `runtime` | 仅受证计算 | 字符串 | 计算运行时,见 §10 |
|
|
112
|
+
| `parameters` | 否 | `{name, type, required}` 列表 | 受证计算的可绑定参数,见 §10 |
|
|
113
|
+
| `computation` | 否 | 路径 | 计算文件路径;与正文围栏二选一 |
|
|
114
|
+
| `executor` | 否 | `{resource, receipt}` | 如何执行计算,见 §10 |
|
|
115
|
+
| `attester` | 否 | `{resource}` | 确定性检查代码,见 §10 |
|
|
116
|
+
|
|
117
|
+
`type` 的取值**不集中注册**。Producer 应选描述性强的名字,例如 `BigQuery Table`、`BigQuery Dataset`、`API Endpoint`、`Metric`、`Playbook`、`Reference`、`Attested Computation`。Consumer 必须宽容未知 type,通常当成普通 concept。
|
|
118
|
+
|
|
119
|
+
### 扩展
|
|
120
|
+
|
|
121
|
+
Producer 可以加任意额外 key。Consumer 在 round-trip 时应保留未知 key,且**不得**因为不认识的字段拒绝文档。
|
|
122
|
+
|
|
123
|
+
---
|
|
124
|
+
|
|
125
|
+
## 4. 来源与可信度信号
|
|
126
|
+
|
|
127
|
+
`sources` 记录 concept 从哪些材料派生,材料可以在 bundle 外,也可以在 bundle 内。
|
|
128
|
+
|
|
129
|
+
```yaml
|
|
130
|
+
sources:
|
|
131
|
+
- id: ga4-schema
|
|
132
|
+
resource: https://developers.google.com/analytics/bigquery/export-schema
|
|
133
|
+
title: GA4 BigQuery Export schema
|
|
134
|
+
author: team:ga4-docs
|
|
135
|
+
usage_count: 5000
|
|
136
|
+
last_modified: 2026-05-30T00:00:00Z
|
|
137
|
+
usage_window: { from: 2026-06-01T00:00:00Z, to: 2026-06-30T00:00:00Z }
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
每个条目:
|
|
141
|
+
|
|
142
|
+
| 字段 | 必填 | 说明 |
|
|
143
|
+
| --- | --- | --- |
|
|
144
|
+
| `resource` | **是** | 可跟随的具体 artifact(绝对 URL、bundle 相对路径、`references/` 内路径),或无法跟随的范围描述(如 `all queries in BigQuery project X`) |
|
|
145
|
+
| `id` | 否 | 稳定 key;正文要引用该来源时 SHOULD 提供 |
|
|
146
|
+
| `title` | 否 | 人类可读标签 |
|
|
147
|
+
| `author` | 否 | 来源的生产者,actor 约定见 §5 |
|
|
148
|
+
| `usage_count` | 否 | `usage_window` 内该来源被使用的次数;采用度/活跃度信号 |
|
|
149
|
+
| `last_modified` | 否 | 来源自身最后修改时间,区别于 `generated.at` |
|
|
150
|
+
| `usage_window` | 否 | 条目级覆盖共享时间窗 |
|
|
151
|
+
|
|
152
|
+
关于 `usage_count`:
|
|
153
|
+
|
|
154
|
+
- 它是粗粒度信号,只适合比较「活/死」和数量级,或同一来源自身的历史趋势。
|
|
155
|
+
- 不适合跨类型精确排名:定时查询执行次数与人工看板浏览次数不等价。
|
|
156
|
+
- Consumer 应把它读作活跃度和趋势,而不是分数。
|
|
157
|
+
|
|
158
|
+
**可信度是推断出来的,不是存下来的。** 本格式只记录客观的 per-source 信号;credibility score 是主观的、不可跨 consumer 移植的、会过期的,所以不存储。Consumer 像推导 trust tier 一样从信号推断。
|
|
159
|
+
|
|
160
|
+
**血缘用链接表达,不用专门字段。** 当 `resource` 指向另一个 concept 时,bundle 图里已经有这条派生边;consumer 可以递归进入该来源自己的 `sources`,让可信度传播。外部叶子来源只有自身信号。更深的血缘(显式外部 `derived_from`、数据 lineage)v0.2 不覆盖。
|
|
161
|
+
|
|
162
|
+
### 逐条归因(脚注)
|
|
163
|
+
|
|
164
|
+
正文里的具体 claim 用脚注归因,label 必须等于某个 `sources[].id`:
|
|
165
|
+
|
|
166
|
+
```markdown
|
|
167
|
+
`events_` 表按天分片为 `events_YYYYMMDD`。[^ga4-schema]
|
|
168
|
+
|
|
169
|
+
[^ga4-schema]: GA4 BigQuery Export schema
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
Consumer 通过 label 查 `sources` 条目,不解析脚注正文。用稳定 `id` 而不是位置索引(`sources[0]`):Agent 会不断重写文档,列表一重排位置索引就会静默错配。
|
|
173
|
+
|
|
174
|
+
---
|
|
175
|
+
|
|
176
|
+
## 5. 生成、验证与信任层级
|
|
177
|
+
|
|
178
|
+
### generated
|
|
179
|
+
|
|
180
|
+
```yaml
|
|
181
|
+
generated: { by: reference_agent/gemini-2.5-pro, at: 2026-06-20T22:53:05Z }
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
- `generated.by`:必填(在 `generated` 内),actor 字符串。
|
|
185
|
+
- `generated.at`:内容最后一次有意义变更的时间。
|
|
186
|
+
- 二者回答「当前内容怎么来的、什么时候写的」。
|
|
187
|
+
|
|
188
|
+
### verified
|
|
189
|
+
|
|
190
|
+
```yaml
|
|
191
|
+
verified:
|
|
192
|
+
- { by: human:ahormati, at: 2026-06-25T09:00:00Z }
|
|
193
|
+
- { by: process:finance-nightly, at: 2026-06-26T02:00:00Z }
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
- `verified` 是验证事件列表,每项 `{by, at}`;多次独立检查就多条。
|
|
197
|
+
- 「最近一次验证」是列表里最大的 `at`。
|
|
198
|
+
- 单个验证者可以写成不带列表横线的映射;consumer **必须**把裸映射当成单元素列表:
|
|
199
|
+
|
|
200
|
+
```yaml
|
|
201
|
+
verified: { by: human:ahormati, at: 2026-06-25T09:00:00Z }
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
`verified` 与 `generated.at` 相互独立:内容变了可以没重新确认;事实被重新确认了也可以没重新生成。
|
|
205
|
+
|
|
206
|
+
### Actor 约定
|
|
207
|
+
|
|
208
|
+
记录身份(`generated.by`、`verified[].by`)统一使用:
|
|
209
|
+
|
|
210
|
+
- `<producer>/<version>`:Agent/工具,例如 `reference_agent/gemini-2.5-pro`。
|
|
211
|
+
- `human:<id>`:人,例如 `human:ahormati`。
|
|
212
|
+
- `process:<id>`:自动化流程,例如 `process:finance-nightly`。
|
|
213
|
+
|
|
214
|
+
Trust 分类依赖 `human:` 前缀,所以手写或人工确认的内容**必须**用它。
|
|
215
|
+
|
|
216
|
+
### Trust tier
|
|
217
|
+
|
|
218
|
+
从 `verified` 推导,由低到高:
|
|
219
|
+
|
|
220
|
+
| 条件 | Tier |
|
|
221
|
+
| --- | --- |
|
|
222
|
+
| 没有 `verified` key | `unverified` |
|
|
223
|
+
| 只有非 `human:` actor | `machine-confirmed` |
|
|
224
|
+
| 存在 `human:<id>` actor | `human-reviewed` |
|
|
225
|
+
|
|
226
|
+
Trust tier 是建议信号,不是访问控制。没有 trust frontmatter 的 concept 仍然可消费;consumer 不得因此拒绝。
|
|
227
|
+
|
|
228
|
+
---
|
|
229
|
+
|
|
230
|
+
## 6. 生命周期
|
|
231
|
+
|
|
232
|
+
### status
|
|
233
|
+
|
|
234
|
+
```yaml
|
|
235
|
+
status: stable # draft | stable | deprecated
|
|
236
|
+
```
|
|
237
|
+
|
|
238
|
+
- `draft`:未审核,可能不完整。
|
|
239
|
+
- `stable`:默认值,可消费。
|
|
240
|
+
- `deprecated`:保留用于链接和历史,不再当前。
|
|
241
|
+
|
|
242
|
+
缺省 `status` 等价于 `stable`。
|
|
243
|
+
|
|
244
|
+
### stale_after
|
|
245
|
+
|
|
246
|
+
```yaml
|
|
247
|
+
stale_after: 2026-09-23T00:00:00Z # 此刻及之后视为过期
|
|
248
|
+
```
|
|
249
|
+
|
|
250
|
+
- 可选,绝对时刻,不是相对 TTL。
|
|
251
|
+
- `now >= stale_after` 时 concept 过期。
|
|
252
|
+
- 用绝对时刻的好处:过期判断只是普通比较,不依赖「什么时候读的」。
|
|
253
|
+
- 日期不带时区(`2026-12-31`)在不同时区是不同瞬间,视为无效而不是猜测。
|
|
254
|
+
|
|
255
|
+
---
|
|
256
|
+
|
|
257
|
+
## 7. 链接与路径
|
|
258
|
+
|
|
259
|
+
### Concept 之间的链接
|
|
260
|
+
|
|
261
|
+
用标准 markdown 链接,两种形式:
|
|
262
|
+
|
|
263
|
+
**绝对(bundle 根相对)**,以 `/` 开头,推荐,因为文档在子目录内移动时仍稳定:
|
|
264
|
+
|
|
265
|
+
```markdown
|
|
266
|
+
见 [customers 表](/tables/customers.md)。
|
|
267
|
+
```
|
|
268
|
+
|
|
269
|
+
**相对**,标准 markdown 相对路径:
|
|
270
|
+
|
|
271
|
+
```markdown
|
|
272
|
+
见 [相邻 concept](./other.md)。
|
|
273
|
+
```
|
|
274
|
+
|
|
275
|
+
A → B 的链接断言一种关系;具体是父子、引用、join、依赖,由上下文散文表达。图消费通常把所有链接当作无类型有向边。
|
|
276
|
+
|
|
277
|
+
**坏链接必须被容忍**:目标不存在不代表文档 malformed,可能只是知识还没写。
|
|
278
|
+
|
|
279
|
+
### 路径字段
|
|
280
|
+
|
|
281
|
+
以下字段值是路径或 URI:`resource`、`sources[].resource`、`computation`、`executor.resource`、`attester.resource`。
|
|
282
|
+
|
|
283
|
+
每个字段接受:
|
|
284
|
+
|
|
285
|
+
- 绝对 URL(`https://...`);
|
|
286
|
+
- bundle 根相对路径(`/...`);
|
|
287
|
+
- 相对路径(`../computations/revenue.md`)。
|
|
288
|
+
|
|
289
|
+
`sources[].resource` 还可以是范围描述,此时不是路径。
|
|
290
|
+
|
|
291
|
+
### references/ 约定
|
|
292
|
+
|
|
293
|
+
`references/` 子目录习惯上镜像外部材料、运行说明或代码,作为 bundle 内的一等 concept。`sources`、`executor`、`attester` 常指向其中,例如 `references/attesters/revenue.py`。这是命名约定,不是强制要求。
|
|
294
|
+
|
|
295
|
+
---
|
|
296
|
+
|
|
297
|
+
## 8. index.md
|
|
298
|
+
|
|
299
|
+
`index.md` 可以出现在任意目录(包括根),用于**渐进披露**:让人或 Agent 先看有什么,再决定打开哪篇。
|
|
300
|
+
|
|
301
|
+
- 通常没有 frontmatter。
|
|
302
|
+
- 唯一例外:bundle 根 `index.md` 可以带 `format_version` key(例如 `format_version: "0.2"`)。
|
|
303
|
+
- 正文用一个或多个 `#` 分组标题,每组下列出链接:
|
|
304
|
+
|
|
305
|
+
```markdown
|
|
306
|
+
# Metrics
|
|
307
|
+
|
|
308
|
+
* [Revenue](revenue.md) - Recognized revenue for a fiscal year.
|
|
309
|
+
* [Gross margin](gross-margin.md) - Gross margin for a period.
|
|
310
|
+
|
|
311
|
+
# Subdirectories
|
|
312
|
+
|
|
313
|
+
* [Computations](computations/index.md) - Attested computations.
|
|
314
|
+
```
|
|
315
|
+
|
|
316
|
+
- 条目 SHOULD 复用被链接 concept 的 `description`。
|
|
317
|
+
- Producer 可以自动生成;没有 `index.md` 时 consumer 可以即时合成。
|
|
318
|
+
- 链接目录时 `subdir/` 和 `subdir/index.md` 都是常见写法。
|
|
319
|
+
|
|
320
|
+
---
|
|
321
|
+
|
|
322
|
+
## 9. log.md
|
|
323
|
+
|
|
324
|
+
`log.md` 可以出现在任意层级,记录该范围的变更历史。格式是日期分组的扁平列表,**最新在前**:
|
|
325
|
+
|
|
326
|
+
```markdown
|
|
327
|
+
# Directory Update Log
|
|
328
|
+
|
|
329
|
+
## 2026-05-22
|
|
330
|
+
|
|
331
|
+
* **Update**: Added a BigQuery table reference for [Customer Metrics](/tables/customer-metrics.md).
|
|
332
|
+
* **Creation**: Established the [Dataplex Playbook](/playbooks/dataplex.md).
|
|
333
|
+
|
|
334
|
+
## 2026-05-15
|
|
335
|
+
|
|
336
|
+
* **Initialization**: Created foundational directory structure.
|
|
337
|
+
```
|
|
338
|
+
|
|
339
|
+
- 日期标题必须是 ISO 8601 `YYYY-MM-DD`。
|
|
340
|
+
- 条目是散文;开头的粗体词(`**Update**`、`**Creation**`、`**Deprecation**`)是约定,不是必需。
|
|
341
|
+
- 与 concept 不同,`log.md` 不是 concept,不参与 `type` 必填检查。
|
|
342
|
+
|
|
343
|
+
---
|
|
344
|
+
|
|
345
|
+
## 10. Attested Computation
|
|
346
|
+
|
|
347
|
+
受证计算不只说明一个值「是什么」,还给出「必须怎么算」,让 consumer 确认 Agent 跑的是 sanctioned computation,而不是自己临时改写的查询。
|
|
348
|
+
|
|
349
|
+
- **Provenance** 回答:这个 claim 从哪来。
|
|
350
|
+
- **Attestation** 回答:这个数字是不是按我们说的方法产生的。
|
|
351
|
+
|
|
352
|
+
本格式只记录计算和检查方式,**不执行**任何东西。
|
|
353
|
+
|
|
354
|
+
### 10.1 计算是独立 concept
|
|
355
|
+
|
|
356
|
+
一个 sanctioned computation 是 `type: Attested Computation` 的独立 concept。需要该值的 concept(`Metric`、`BigQuery Table` 等)用普通 markdown 链接指向它。
|
|
357
|
+
|
|
358
|
+
独立成 concept 的三个理由:
|
|
359
|
+
|
|
360
|
+
- `runtime` 决定 `parameters` 的绑定语义;放在同一个 frontmatter 里,语义自明。
|
|
361
|
+
- 一个计算可以被 metric、dashboard、report 多处复用,写一次即可。
|
|
362
|
+
- trust 状态按计算独立:revenue、profit、margin 各自 verify、各自 attest、各自过期,所以是三个 concept,而不是一个 frontmatter 里的三个条目。
|
|
363
|
+
|
|
364
|
+
### 10.2 契约字段
|
|
365
|
+
|
|
366
|
+
除 §3–§6 的通用字段外:
|
|
367
|
+
|
|
368
|
+
| 字段 | 必填 | 说明 |
|
|
369
|
+
| --- | --- | --- |
|
|
370
|
+
| `runtime` | **该类型必填** | 唯一决定「怎么跑」以及 `parameters` 含义的字段。例:`bigquery`、`postgres`、`dbt`、`python`、`Looker` |
|
|
371
|
+
| `parameters` | 否 | Agent 可以填的具名类型化空洞,每项 `{name, type, required}`;绑定语义随 `runtime` |
|
|
372
|
+
| `computation` | 否 | 计算文件路径;缺省时正文 `# Computation` 围栏就是计算 |
|
|
373
|
+
| `executor` | 否 | `resource` 指向运行说明或代码;`receipt` 声明一次运行必须返回哪些字段(attester 检查的证据) |
|
|
374
|
+
| `attester` | 否 | `resource` 指向确定性(无 LLM)代码,接收 receipt 返回 verdict;在 consumer 侧运行 |
|
|
375
|
+
|
|
376
|
+
`resource` 背后是 Skill、脚本还是容器,是打包选择;本格式固定接口,不固定打包。
|
|
377
|
+
|
|
378
|
+
````markdown
|
|
379
|
+
---
|
|
380
|
+
type: Attested Computation
|
|
381
|
+
title: Revenue for fiscal year
|
|
382
|
+
description: Recognized revenue for a fiscal year, per Finance's definition.
|
|
383
|
+
status: stable
|
|
384
|
+
runtime: bigquery
|
|
385
|
+
parameters:
|
|
386
|
+
- { name: year, type: integer, required: true }
|
|
387
|
+
executor:
|
|
388
|
+
resource: references/skills/run-on-bq.md
|
|
389
|
+
receipt: [job_id, executed_sql, result]
|
|
390
|
+
attester:
|
|
391
|
+
resource: references/attesters/revenue.py
|
|
392
|
+
generated: { by: reference_agent/gemini-2.5-pro, at: 2026-06-20T22:53:05Z }
|
|
393
|
+
verified: { by: human:ahormati, at: 2026-06-25T09:00:00Z }
|
|
394
|
+
stale_after: 2026-09-23T00:00:00Z
|
|
395
|
+
sources:
|
|
396
|
+
- id: rev-policy
|
|
397
|
+
resource: https://wiki.acme/finance/revenue-recognition
|
|
398
|
+
title: Revenue recognition policy
|
|
399
|
+
---
|
|
400
|
+
|
|
401
|
+
# Computation
|
|
402
|
+
|
|
403
|
+
```sql
|
|
404
|
+
SELECT SUM(amount) AS revenue
|
|
405
|
+
FROM finance.recognized_revenue
|
|
406
|
+
WHERE fiscal_year = @year
|
|
407
|
+
```
|
|
408
|
+
|
|
409
|
+
该计算只绑定声明过的 `parameters`,依据 recognition policy。[^rev-policy]
|
|
410
|
+
|
|
411
|
+
[^rev-policy]: Revenue recognition policy
|
|
412
|
+
````
|
|
413
|
+
|
|
414
|
+
### 10.3 计算内容
|
|
415
|
+
|
|
416
|
+
两种提供方式,二选一:
|
|
417
|
+
|
|
418
|
+
- **内联**:正文 `# Computation` 下的单个围栏代码块。适合短小、需要和契约一起 review 的计算。
|
|
419
|
+
- **文件**:设置 `computation` 为路径,并省略正文围栏。适合长计算、生成的计算,或已经被外部工具共享的真实文件。
|
|
420
|
+
|
|
421
|
+
```yaml
|
|
422
|
+
runtime: bigquery
|
|
423
|
+
computation: references/computations/lib/revenue.sql
|
|
424
|
+
parameters:
|
|
425
|
+
- { name: year, type: integer, required: true }
|
|
426
|
+
```
|
|
427
|
+
|
|
428
|
+
Agent **只能**为声明的 `parameters` 提供值,**不能**创作或修改 computation。把 `computation` 与参数值绑定成可执行 artifact 是 consumer 的职责;attester 独立地重新推导同一绑定,再和实际运行的东西比较。比较的是 receipt 里的展开/编译后 artifact(`executed_sql`、`compiled_sql`),所以改写查询、替换计算文件、篡改依赖都会失败。类型化、只允许参数值的接口,让「是否跑了 sanctioned 的东西」成为机械比较,而不是判断题。
|
|
429
|
+
|
|
430
|
+
### 10.4 使用计算的 concept
|
|
431
|
+
|
|
432
|
+
一个文档很少只有一个计算。收入概览可能讨论 revenue、profit、margin,但仍是一篇可读的 concept,每个数字链接到一个 Attested Computation:
|
|
433
|
+
|
|
434
|
+
```markdown
|
|
435
|
+
---
|
|
436
|
+
type: Metric
|
|
437
|
+
title: Revenue
|
|
438
|
+
description: Recognized revenue for a fiscal year.
|
|
439
|
+
tags: [finance, revenue]
|
|
440
|
+
status: stable
|
|
441
|
+
generated: { by: reference_agent/gemini-2.5-pro, at: 2026-06-20T22:53:05Z }
|
|
442
|
+
---
|
|
443
|
+
|
|
444
|
+
# Definition
|
|
445
|
+
|
|
446
|
+
Recognized revenue sums `amount` over rows booked to the fiscal year,
|
|
447
|
+
由 [revenue computation](../computations/revenue.md) 计算。
|
|
448
|
+
```
|
|
449
|
+
|
|
450
|
+
因为每个计算独立,revenue 可以新鲜而 profit 已过期,各自 attest。放在同一个 `computations/` 目录只是目录选择,不是 frontmatter 约束。
|
|
451
|
+
|
|
452
|
+
### 10.5 Consumer 如何使用(信息性)
|
|
453
|
+
|
|
454
|
+
运行时 artifact **不存进 bundle**。推荐流程:
|
|
455
|
+
|
|
456
|
+
1. **Discover**:通过 `type: Attested Computation`、链接或 `index.md` 找到计算。
|
|
457
|
+
2. **Load**:从 frontmatter 读契约,从正文围栏或 `computation` 文件读计算。
|
|
458
|
+
3. **Parameterize**:Agent 只为声明的参数提供值。
|
|
459
|
+
4. **Execute**:executor 运行绑定后的计算,返回 `executor.receipt` 声明的字段。
|
|
460
|
+
5. **Attest**:consumer 运行 attester 检查 receipt。它确认:
|
|
461
|
+
- **Provenance**:实际运行的 computation 等于 `computation` 绑定声明参数后的结果,不是 Agent 自己写的 SQL;
|
|
462
|
+
- **Fidelity**:展示的值等于 receipt 权威来源里的值(按 job id 重读,而不是相信 Agent 的文本)。
|
|
463
|
+
6. **Gate**:attestation 失败就拒绝展示;`now >= stale_after` 时警告或拒绝;成功时展示 verdict(例如 job log 链接),让信任可见。
|
|
464
|
+
|
|
465
|
+
### 10.6 Verification 与 attestation 的区别
|
|
466
|
+
|
|
467
|
+
两者都需要,且不同:
|
|
468
|
+
|
|
469
|
+
- `verified` 确认**定义**仍符合 policy。它是文档级、慢速、记录在 bundle 里的。
|
|
470
|
+
- Attestation 确认**单次运行**是否按 sanctioned 方式产生了值。它是每次调用、运行时、不记录在 bundle 里的。
|
|
471
|
+
|
|
472
|
+
定义过期了仍可能干净地 attest;定义刚 verified 仍需要每次运行都 attest。
|
|
473
|
+
|
|
474
|
+
---
|
|
475
|
+
|
|
476
|
+
## 11. 符合性与宽容消费
|
|
477
|
+
|
|
478
|
+
Bundle 符合知识库格式 v0.2,当且仅当:
|
|
479
|
+
|
|
480
|
+
1. 树中每个非保留 `.md` 文件都包含可解析的 YAML frontmatter;
|
|
481
|
+
2. 每个 frontmatter 都包含非空 `type`;
|
|
482
|
+
3. 每个保留文件名(`index.md`、`log.md`)存在时符合 §8/§9 的结构。
|
|
483
|
+
|
|
484
|
+
当 trust、lifecycle、provenance、computation 家族存在时,producer SHOULD 遵循 §4–§10;consumer:
|
|
485
|
+
|
|
486
|
+
- MUST 把裸 `verified` 映射当成单元素列表;
|
|
487
|
+
- MUST NOT 因为缺少可选家族而拒绝 concept;
|
|
488
|
+
- SHOULD 只从规范字段推导 trust tier 和 staleness;
|
|
489
|
+
- SHOULD 展示而不是静默丢弃失败的 attestation。
|
|
490
|
+
|
|
491
|
+
其他约束都是 soft guidance。Consumer **不得**因为以下原因拒绝 bundle:
|
|
492
|
+
|
|
493
|
+
- 缺可选 frontmatter 字段;
|
|
494
|
+
- 未知 `type`;
|
|
495
|
+
- 未知额外 frontmatter key;
|
|
496
|
+
- 坏 cross-link;
|
|
497
|
+
- 缺 `index.md`。
|
|
498
|
+
|
|
499
|
+
---
|
|
500
|
+
|
|
501
|
+
## 12. v0.1 兼容
|
|
502
|
+
|
|
503
|
+
v0.2 相对 v0.1 有两个破坏性变更:
|
|
504
|
+
|
|
505
|
+
- `timestamp` 被 `generated.at` 取代。Consumer 可以在 `generated` 缺失时回退读 `timestamp`。
|
|
506
|
+
- 正文 `# Citations` 被 `sources` 取代。Consumer 应读 `sources`,也可以继续解析 v0.1 的 `# Citations` 列表。
|
|
507
|
+
|
|
508
|
+
其余都是增量:`sources` 及可信度信号、`usage_window`、`generated`/`verified`、`status`/`stale_after`、`Attested Computation` 及计算字段、`# Computation` 标题、actor 约定。缺失这些时,文档就是普通 v0.1 concept。
|
|
509
|
+
|
|
510
|
+
---
|
|
511
|
+
|
|
512
|
+
## 13. 完整示例
|
|
513
|
+
|
|
514
|
+
一篇同时使用 provenance、trust、lifecycle 的指标:
|
|
515
|
+
|
|
516
|
+
```markdown
|
|
517
|
+
---
|
|
518
|
+
type: Metric
|
|
519
|
+
title: Revenue
|
|
520
|
+
description: Recognized revenue for a fiscal year, per Finance's definition.
|
|
521
|
+
tags: [finance, revenue]
|
|
522
|
+
status: stable
|
|
523
|
+
generated: { by: reference_agent/gemini-2.5-pro, at: 2026-06-20T22:53:05Z }
|
|
524
|
+
verified:
|
|
525
|
+
- { by: human:ahormati, at: 2026-06-25T09:00:00Z }
|
|
526
|
+
- { by: process:finance-nightly, at: 2026-06-26T02:00:00Z }
|
|
527
|
+
stale_after: 2026-12-31T00:00:00Z
|
|
528
|
+
sources:
|
|
529
|
+
- id: fpa-handbook
|
|
530
|
+
resource: https://wiki.acme/finance/fpa-handbook
|
|
531
|
+
title: FP&A reporting handbook
|
|
532
|
+
author: team:finance-fpa
|
|
533
|
+
usage_count: 1200
|
|
534
|
+
last_modified: 2026-04-02T00:00:00Z
|
|
535
|
+
usage_window: { from: 2026-06-01T00:00:00Z, to: 2026-06-30T00:00:00Z }
|
|
536
|
+
---
|
|
537
|
+
|
|
538
|
+
# Definition
|
|
539
|
+
|
|
540
|
+
收入按 [revenue computation](../computations/revenue.md) 计算,
|
|
541
|
+
口径见 FP&A handbook。[^fpa-handbook]
|
|
542
|
+
|
|
543
|
+
# Usage
|
|
544
|
+
|
|
545
|
+
本指标用于季度经营回顾,不用于法定报表。
|
|
546
|
+
|
|
547
|
+
[^fpa-handbook]: FP&A reporting handbook
|
|
548
|
+
```
|
|
549
|
+
|
|
550
|
+
---
|
|
551
|
+
|
|
552
|
+
## 14. 写作检查清单
|
|
553
|
+
|
|
554
|
+
创建或修改 concept 后逐项检查:
|
|
555
|
+
|
|
556
|
+
- [ ] 文件以 `---` frontmatter 开头,`type` 非空。
|
|
557
|
+
- [ ] `title`、`description` 存在且各自一行;`description` 能独立说明概念。
|
|
558
|
+
- [ ] 所有时间都是带时区的 ISO 8601 完整时刻。
|
|
559
|
+
- [ ] `generated.by` / `verified[].by` 符合 actor 约定;人工确认用了 `human:`。
|
|
560
|
+
- [ ] 来源在 `sources` 里,`resource` 真实且可跟随;没有编造 URL。
|
|
561
|
+
- [ ] 正文脚注 label 都能在 `sources[].id` 中找到。
|
|
562
|
+
- [ ] 内部链接目标存在;暂时不存在的链接已确认是有意留白。
|
|
563
|
+
- [ ] `status` / `stale_after` 与内容真实状态一致。
|
|
564
|
+
- [ ] 受证计算有 `runtime`、参数、executor、attester;计算只来自 sanctioned 来源。
|
|
565
|
+
- [ ] 跑过 `validate`,`index --write`,需要时补 `log`。
|