Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion doc/architecture/SPEC/kb_service.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# kb_service/ —— 规范

<!-- verified-against: 2026-10-06 -->
<!-- verified-against: 2026-10-07 -->

`知识服务核心:仓库配置、账本、outbox、CLI · refactor-status: new`

Expand Down Expand Up @@ -526,6 +526,20 @@ x 必须为正。因阈值停下的调用(`stop_reason="max_budget"`)→ `Mo

## kb init:解释性知识(knowledge)

证据补齐批次可显式设置 `KB_KNOWLEDGE_CONTEXT_VERSION=5`:从已有功能页的固定版本
引用定位实际实现,优先保留相关测试断言,再读取引用行段及其邻近上下文。已有正文只作
定位与背景,新说明仍须使用实际展示的源码或项目文档并经过独立评审。默认版本4的提示词
及历史原生记录保持兼容;更换版本使用新状态目录,保留旧批次修正历史。

适配器与 portable 初始化均通过 `SharedModelDispatch` 共享生成和评审槽位,默认总并发13;
`KB_INIT_GLOBAL_CONCURRENCY` 可设置1至13,`KB_INIT_DISPATCH_DIR` 可指定同一主机的共享
锁目录。基础和深化并行运行时不能各自创建独立槽池。原生输入、流式输出和用量继续保存
于状态目录的 trace,未报告费用保持未知。

深化补齐优先注入目标功能已认可的基础区块,按缺失维度选择完整区块,再加入组件背景。
保留的深度页须先复核证明和正文哈希;阶段预览及最终组装为这些页面补齐缺少的 owner
导航,避免全部维度已认可的页面因没有新提取而漏掉目录链接。

`kb init REPO --stage knowledge --dry-run` 在 skeleton 和 modules 之后提炼解释性知识。
`init_knowledge._Knowledge` 从固定源码与相关文档分别生成架构、API、配置、设计取舍、
功能关系和验证六个维度。源码 owner 按最具体的路由边界确定,按改动频率排序;已有
Expand Down
10 changes: 9 additions & 1 deletion doc/architecture/SPEC/knowledge_service.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@
# knowledge_service/ — provider curation components

<!-- verified-against: 2026-10-06 -->
<!-- verified-against: 2026-10-07 -->

Pinned source identities and depth markers accept full SHA-1 or SHA-256 Git
commits. Evidence bodies, stored hashes and native approval semantics remain
unchanged; accepting a wider object identity never renews an old approval.

`PinnedObserver` reuses successful Git tree and blob reads by full commit SHA
and path within one observer. Concurrent readers share its lock and cache;
mutable references are resolved on each call before choosing a cache key, and
returned top-level sets cannot mutate cached values. A fresh observer reads
again, read failures are never cached, and live PR metadata is always fetched.
This avoids repeated Git subprocesses during checkpoint evidence replay while
preserving the same source text and evidence hashes.

The provider owns knowledge curation beneath the public SDK v1 facade.
`KnowledgeCurator` composes four domain components over one explicit work
checkout: `CatalogMixin` discovers contained owner rule pages and their
Expand Down
11 changes: 9 additions & 2 deletions doc/architecture/SPEC/knowledge_service/pinned_claims.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# knowledge_service/pinned_claims.py —— 规范

<!-- verified-against: 2026-10-06 -->
<!-- verified-against: 2026-10-07 -->

`LOC ~200 · 在钉住的上游 SHA 上核验规则声明与代码证据(kb init §9.1) · refactor-status: new`
`LOC ~280 · 在钉住的上游 SHA 上核验规则声明与代码证据(kb init §9.1) · refactor-status: new`

## 职责
- `PinnedObserver(repo_dir, repository, pin, pull=)`:在本地 git 仓库(bare 或非 bare)上实现
Expand All @@ -21,6 +21,11 @@
哈希口径:`str.splitlines()` 切行(`\n`、`\r\n`、缺末尾换行视为相同),取 `start..end` 行以
`\n` 连接再补一个 `\n`,UTF-8 编码后 SHA-256。`Evidence.to_dict()/from_dict()` 用于 init 记录。

同一 observer 复用成功的树项、文件正文和顶层目录读取,缓存键绑定完整提交 SHA 与路径。
`HEAD`、分支等可变引用每次先解析为完整提交,再选缓存键;新 observer 从空缓存开始。
成功的空树项查询可以缓存,读取失败不缓存;实时 PR 元数据仍逐次查询。
并发读取使用实例锁,顶层目录集合返回副本,不允许调用方改写缓存。缓存不改变证据正文或哈希口径。

## 不变量
- 与服务端 `facts.attest` 的声明抽取完全一致(同一 `claims_in`),只是观测点从上游 head 换成钉点。
- 不修改 `facts.Observer` 协议,不影响服务与发布器。
Expand All @@ -35,3 +40,5 @@
## 测试
`test_kb_pinned_claims.py`(临时 git 仓库:钉点前后文件、符号、PR 合并先后与未合并、证据区间与
哈希、换行风格无关、非法钉点)。
`test_kb_pinned_observer_cache.py`(真实 Git 对象的重复读取、不同提交、并发复用、错误恢复、
返回集合隔离、实时 PR 查询及移动 HEAD/分支的回归检查)。
8 changes: 5 additions & 3 deletions eval/knowledge-depth/assemble_depth_campaign.py
Original file line number Diff line number Diff line change
Expand Up @@ -318,10 +318,12 @@ def assemble(root: Path, state: Path, source: Path, *, retirement_reports=(),
"checkpoint_accepted_sha256": accepted_sha, "assembled_sha256": digest(proposed),
"baseline_sha256": digest(old) if old is not None else None, "new_facets": added})
# Add only missing depth-page routes; never copy regenerated worker indexes.
# Retained proof-checked baseline pages may intentionally precede their
# navigation publication in a new batch with immutable foundation indexes.
indexes, new_links = {}, []
for page in proposals:
if page in baseline_pages:
continue
routed_pages = {page for page, blocks in old_blocks.items() if blocks}
routed_pages.update(page for page in proposals if DEPTH_BLOCK.search(proposals[page]))
for page in sorted(routed_pages):
feature = by_page[page]
directory = PurePosixPath(page).parent
index = str(directory / "_index.md")
Expand Down
Loading
Loading