Files
kbdb-graph-plugin/docs/3-specs/ingest-contract/tasks.md
T
Leo 27f7448914 feat(ingest): POST /triplets/ingest 寫入端 + deprecate-then-append (T3.2-3.5)
對應 issue #1 T3 B 段。

- templates: TRIPLET_SLOTS 加 status/superseded_by/source_uri/content_hash;
  ENTITY_SLOTS 加 gloss;recordToTriplet 映射新欄位(缺省 status=active 相容舊資料)
- kbdb-client: ensureTemplate 改 slot-diff 補丁(既有 template 走 PATCH /templates/:id
  補缺 slot,取代 early-return → 免遷移腳本);新增 updateRecord(PATCH /records/:id)
- triplet-ingest action(88 行純函式):Zod strict 鏡射 ingest-candidate 契約 →
  idempotency(uri+hash 同→no-op)→ 先 append 後 deprecate(無「全無 active」空窗)
- POST /triplets/ingest route:strict 驗證失敗 → 422(禁送 graph 領域欄位)
- queryTriplets 預設 active-only(traverse/search/neighbors 皆經此),
  includeDeprecated opt-out 供 rollback/考古
- 6 測試案全綠(vitest 16 passed);mock-client 同步 slot-diff + updateRecord

gates: zero SQL / zero migration / 無 D1·Vectorize·AI 綁定 / dry-run bundle 乾淨

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-26 18:13:49 +08:00

2.6 KiB
Raw Blame History

ingest-contract — tasks

唯一進度來源,不靠對話記憶。對應 issue #1(頂層 mira-dissolve T3)。 完成一項即時打勾 + 註記證據。端到端需 leo21c 部署的,標「待部署驗」,不假綠。

A. 契約 + template slot

  • 3.1contracts/ingest-candidate.json 進本 repo + contracts/README.md 標明候選≠已存(2026-06-26
  • 3.2 ensureTemplate 改 slot-diff 補丁(命中既有 → base PATCH /templates/:id 補缺 slot,不再 early-return);TRIPLET_SLOTSstatus+superseded_by+source_uri+content_hash2026-06-26kbdb-client.ts+templates.ts
  • 3.2b ENTITY_SLOTSgloss(已核實現無)(2026-06-26
  • 3.2c normalize 分層 fallback 接口:exact-only 先做;semantic 留接口(待 base embedArcrun #7

B. 寫入端 + 取代(核心)

  • 3.3a KbdbClient.updateRecord(id, values) → base PATCH /records/:id2026-06-26mock 同步)
  • 3.3b src/actions/triplet-ingest.tsZod strict 驗證 → idempotencyuri+hash)→ 先 append 後 deprecate。88 行純函式(2026-06-26
  • 3.3c POST /triplets/ingest route(驗證失敗 → 422 hook,只驗證+呼叫 action)(2026-06-26
  • 3.4 測試 6 案全綠:正常 / 同 hash no-op / 新 hash deprecate / 污染(bridge_score+頂層 id) 422 / rollbackvitest run 16 passed)(2026-06-26
  • 3.5 查詢 active-onlyqueryTriplets 缺省 filter status==='active'traverse/search/neighbors 皆經此;includeDeprecated opt-out 供 rollback/考古)(2026-06-26

C. MCP⚠️ 跨 repo,需 arcrun 配合 → issue 標清)

  • 3.6 圖查詢 + refresh HTTP API/邏輯備好(graph 端);MCP 註冊薄殼併入 arcrun KBDB MCP(協調後接,不另起 graph MCP
  • 3.6b refresh 紅線:只人發起 MCP 觸發,禁排程/webhook 自動
  • 3.6d 移除 search-query.ts 代理 base 關鍵字那條(重複,歸 KBDB MCP)
  • 3.7 get_source 端點(指回 source.uri + anchor
  • 3.7b graph CLI 延後不做(人少用、AI 用不到 → 不誤導)

完成準則

  • 全程 zero SQL / zero migration / 無 D1·Vectorize·AI 綁定(wrangler deploy --dry-run bundle 乾淨)
  • 所有 action ≤100 行;vitest run 全綠(mock client
  • 端到端 ingest→graph 走通需 base 上線 + ingest repoT4)就緒 → 標「待部署驗」
  • issue #1 留 open,待實證綠燈才結案