feat(kbdb): 藏書地圖 M1+M2 — library_map template+/map 端點(聚合 SQL 住基本盤)(#39)

M1:library_map template(migration 0003 seed+runtime ensure,D6 零建表零 ALTER);
核實 triplet 按庫定位=不足(prod triplet template 無 library slot、entries
metadata.library 未標記)→ 走 SDD 預案:recompute 冪等補 optional library slot
(改 template 不動表),slot 值由 ingest 端(M3)補寫,核實結果記入 design §1。

M2:kbdb base 三端點(design §2 歸屬裁定:聚合 SQL 只准住基本盤):
- POST /map/recompute?library=X:degree top-N/predicate 分布/跨庫 bridges/
  triplet_count 一段 SQL 聚合;narrative 本輪收 body 傳入(wiki 抽取屬 M3);
  寫入順序安全(先建新 active map block 再標舊 superseded,讀端取最新 active 自癒);
  過渡 source_prefix fallback 讓無 library 值的舊 triplet 靠 source_uri 前綴歸庫。
- GET /map:全館地圖每庫一行(library+narrative+top 3 entities+triplet_count),
  MCP instructions/GUI 共用(數百 token 內)。
- GET /map/:library:該庫詳圖(完整 slots+可嵌人話 content,design §5 M6 直用)。

測試:node:sqlite(零新依賴)當真 SQLite 實跑 migrations+聚合 SQL,
Hono route 行為同款覆蓋;45/45 過、tsc --noEmit 乾淨。

關聯 #39

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JUmjwkHLVBHM3ydhT1WSW3
This commit is contained in:
Claude
2026-07-19 08:40:22 +00:00
parent bad68ef149
commit 15fe012006
9 changed files with 731 additions and 2 deletions
+2 -2
View File
@@ -4,8 +4,8 @@
| # | 任務 | 類 | 依賴 | 狀態 | 備註 |
|---|---|---|---|---|---|
| M1 | `library_map` Templateslots 定義(含 triplet 按庫過濾現況核實;不足則 Triplet template 加 optional library slot | B | — | | D6 零建表 |
| M2 | kbdb base `POST /map/recompute?library=``GET /map``GET /map/:library`(聚合 SQL 住基本盤;交易式 supersede | B | M1 | | PR+測試;merge 後 gated 部署(leo 閘) |
| M1 | `library_map` Templateslots 定義(含 triplet 按庫過濾現況核實;不足則 Triplet template 加 optional library slot | B | — | 🔨 PR 已開 | D6 零建表。核實:triplet 無 library slot → 已走預案(design §1 核實結果) |
| M2 | kbdb base `POST /map/recompute?library=``GET /map``GET /map/:library`(聚合 SQL 住基本盤;交易式 supersede | B | M1 | 🔨 PR 已開 | PR+測試(真 SQLite 驗聚合)merge 後 gated 部署(leo 閘)+逐庫 backfill recompute |
| M3 | ingest 尾端接鏈:diff 涉及庫 → 逐庫呼 recomputerag-ingest-cards v2+個人庫 ingest 同款改版) | A | M2 | ⬜ | workflow 改版走 bundle 分發 |
| M4 | MCPinstructions 注入全館地圖+`get_map` 工具 | B | M2 | ⬜ | 與 #68 同族薄殼 |
| M5 | GUI 首頁:全館地圖 renderconsoleportal | B | M2 | ⬜ | 取代空白搜尋框 |