Files
kbdb-graph-plugin/src
Claude 454ea8d240 fix(kbdb-client): ensureTemplate 誤判「不存在」導致重複建 template → base 500
補跑實測(POST /triplets/ingest 端到端跑不過)發現的真契約漂移,非單純部署坑:
- ensureTemplate() 假設 GET /templates/:name 回傳 {id, slots} 平鋪陣列,
  但 base(arcrun-kbdb)實際回 {success, template:{id, slots_json:"[...]"}}
  (多包一層 + slots 是 JSON 字串)。existing.id 永遠 undefined → 一律走「不存在」
  分支重複 POST 同名 template → base 對重名衝突沒有優雅的 409,直接 500,
  ingest 端到端全斷。
- 改為解 existing.template + JSON.parse(slots_json),修好後 POST /triplets/ingest
  → GET /triplets 端到端打通(見部署驗證 curl 記錄)。

同時讓 KbdbClient 支援可選 fetcher(service binding 的 Fetcher),
搭配上一個 commit 的 KBDB_BASE_SVC binding 繞開 workers.dev 互連封鎖;
沒有 binding 時(本地 dev/mock)仍 fallback 回全域 fetch,不影響既有單元測試。

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-07-03 08:57:53 +00:00
..