feat: KBDB-graph 插件獨立 — 全面改寫成走基本盤 API(API-as-Wall)

按 leo 鐵律(2026-06-14)把插件從「直接 SQL 操作基本盤表」改寫成
「只透過基本盤 arcrun/kbdb HTTP API 讀寫」。零建表、零 migration、零 SQL。

- 新增 src/lib/kbdb-client.ts:唯一對外通道,封裝 entries/templates/records API
- 新增 src/lib/templates.ts:triplet/entity template 定義(替代建表)
- 改寫 21 個違規 action(triplet/graph/entity/search)→ 走 client,圖在插件層記憶體組裝
- 移除所有 migrations、D1/Vectorize/AI 綁定;embedding/語意搜尋歸基本盤 optional 模組
- index.ts 只掛 triplets/graph/entities/search 路由;基本盤路由歸 arcrun/kbdb
- 測試改走 mock client(純 node);裁剪 CLAUDE.md 只留 graph 插件 + 鐵律
- 修正 SDD design.md「讀現狀推翻鐵律」的錯誤判斷(共用 D1 → API-as-Wall)

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-06-14 20:59:41 +08:00
commit efe8e165cf
62 changed files with 7671 additions and 0 deletions
+34
View File
@@ -0,0 +1,34 @@
# 架構決策摘要
> 遇到設計判斷時查這裡。
> 完整脈絡在 docs/2-architecture/decisions/。
---
## KBDB-graph 定位 — 2026-06-13
**結論**:本目錄 = KBDB 的 graph 插件(triplet 採集 + graph 查詢),獨立成 repo,類比 Apache AGE 之於 Postgres。
**原因**:graph 能力較龐大、非基本儲存功能、leo 產權、較複雜 → 不留 arcrun。基本盤(block CRUDD1 三表)= `arcrun/kbdb`,不在本目錄。
**詳細**`docs/HANDOFF-kbdb-plugin.md`;來源 InkStoneCo 頂層 `matrix-rearrange` Phase 2 (R2)。
## 獨立 repo 名 + 邊界乾淨度 — 2026-06-14
**結論**:獨立 repo = 新 repo `uncle6me-web/kbdb-graph-plugin`(leo 拍板,沿用目錄名)。grep 證實插件與基本盤 action 層零耦合,耦合只在 DB 層(讀 blocks/entry_values + triplets VIEW)。
**原因**:乾淨的 AGE-on-Postgres,插件抽出無程式碼牽連;唯一要設計的是 DB 掛載介面。
**詳細**`docs/3-specs/kbdb-graph-extraction/design.md`(灰色地帶結論 + 掛載介面)。
## 萬物皆 BlockKBDB v3)— 2026-02-28
**結論**:一張 Block 表 + type 欄位,禁 CREATE/ALTER TABLE,新資料類型用 templateAPI-as-Wall。
**原因**:零 migration 擴充;所有讀寫經 API 不繞過直打 D1。
**詳細**`CLAUDE.md` 下半(v3 全規範,含基本盤,待裁剪只留 graph 插件相關)。
## 避免再被 GitHub flag(上游鐵律)— 沿用
**結論**:禁跨 repo 自動同步 Actions;部署繞開 GitHubwrangler / scp);新 repo 預設不開 Actions。
**原因**:當初 monorepo→多 worker 的 Actions 自動同步 + 高頻 API 害帳號被 flag。
**詳細**InkStoneCo 頂層 CLAUDE.md。
---
格式:
## [主題] — [YYYY-MM-DD]
**結論**[一句話]
**原因**[簡短說明]
**詳細**docs/2-architecture/decisions/[對應檔案]