fix(kbdb): 開通 PATCH /kbdb/records/:id proxy + 補三元組 library 補標測試
leo 2026-08-11:貼 wiki 卡「這裏就有 3 個三元組,如果三元組是 0 一定是有錯」—— 三元組沒有不見(新式 1,633 筆/舊式 636 筆都還在),問題是地圖看不到:新式三元組 只有 171 筆填了 library slot,其餘因寫入時 template 還沒有該 slot 而被靜默丟棄 (record-crud.ts createRecord 只替「已宣告」的 slot 建值,不是替 caller 傳的 values 建值——順序錯了值就消失,不報錯)。 本次改動: - cypher-executor/src/routes/kbdb-proxy.ts:補 PATCH /kbdb/records/:recordId。 基本盤(kbdb/src/routes/records.ts)早有這個端點(mira-dissolve T2.1 的 updateRecord),但這條 proxy 之前只轉發 GET/POST /kbdb/records,外部(工作流/ CLI/補標腳本)打不到——能力在,通道沒開,補標三元組只能繞去改表(違 D38)。 純轉發、無業務邏輯,比照既有 PATCH /kbdb/entries/:id 慣例。 - kbdb/tests/triplet-library-backfill.test.ts:真 node:sqlite 驗三件事—— ①源頭順序(ensure-slot 必須在 write 之前,事後補救不了已寫的那筆,重現+ 驗證正解)②存量補標(地圖輸出前後對照)③不會重複做(同批跑兩次,第二次 touch 0 筆)。順手記錄一個相關但不在本次範圍的小落差:liveTripletCountsByLibrary 的 'general' fallback 桶與 recomputeLibraryMap 的精確比對語意沒對齊。 - cypher-executor/tests/kbdb-records-patch-proxy.test.ts:新端點的租戶閘/ 參數驗證/轉發/404 透傳。 全數綠燈:kbdb 181/181、cypher-executor 新增 8 案全過(既有 14 案失敗為 pre-existing,已用 git stash 比對確認與本次改動無關)。 kbdb-graph-plugin(實際的三元組寫入端 createTriplet/ingestEnvelope)需要同款 修正(library 補進 TRIPLET_SLOTS + 從 source_uri 推導),但該 repo 現行 0 份 active SDD,其 sdd-guard 明確要求人決定要不要開啟——本次不越界代為決定, 留在報告中交回。 Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
@@ -119,6 +119,27 @@ kbdbProxyRouter.get('/kbdb/records/:recordId', async (c) => {
|
||||
return new Response(res.body, { status: res.status, headers: { 'Content-Type': 'application/json' } });
|
||||
});
|
||||
|
||||
// PATCH /kbdb/records/:recordId — 翻某筆 record 的 slot 值({ values:{slot:content} })。
|
||||
// 補上基本盤既有能力(kbdb/src/routes/records.ts 的 PATCH /records/:recordId,mira-dissolve T2.1)
|
||||
// 缺的對外通道——2026-08-11 leo 三元組 library 補標核實:base 早有這個端點,但這條 proxy
|
||||
// 之前只轉發 GET/POST,插件/工作流打不到,補標三元組只能繞去改表(違 D38)。單純轉發,無業務邏輯。
|
||||
// by-id 沿用既有慣例(require-key,不額外做 owner 比對——與本檔 GET .../:recordId、
|
||||
// PATCH /kbdb/entries/:id 同款)。
|
||||
kbdbProxyRouter.patch('/kbdb/records/:recordId', async (c) => {
|
||||
if (!tenant(c)) return c.json(NEED_KEY, 401);
|
||||
const body = await c.req.json().catch(() => null);
|
||||
if (!body || typeof body.values !== 'object' || body.values === null) {
|
||||
return c.json({ error: 'values 必填({slot名: 內容})' }, 400);
|
||||
}
|
||||
const { base, headers } = kbdbBase(c.env);
|
||||
const res = await fetch(`${base}/records/${encodeURIComponent(c.req.param('recordId'))}`, {
|
||||
method: 'PATCH',
|
||||
headers,
|
||||
body: JSON.stringify({ values: body.values }),
|
||||
});
|
||||
return new Response(res.body, { status: res.status, headers: { 'Content-Type': 'application/json' } });
|
||||
});
|
||||
|
||||
// ── search(限本租戶範圍內)────────────────────────────────────────────────────
|
||||
|
||||
// GET /kbdb/search?q=&entry_type=&source=&library=&mode= — entries 搜尋,限本租戶 owner_id。
|
||||
|
||||
Reference in New Issue
Block a user