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>
This commit is contained in:
@@ -6,17 +6,17 @@
|
||||
## A. 契約 + template slot
|
||||
|
||||
- [x] **3.1** 搬 `contracts/ingest-candidate.json` 進本 repo + `contracts/README.md` 標明候選≠已存(2026-06-26)
|
||||
- [ ] **3.2** `ensureTemplate` 改 slot-diff 補丁(命中既有 → base `PATCH /templates/:id` 補缺 slot,不再 early-return);`TRIPLET_SLOTS` 加 `status` + `superseded_by` + `source_uri` + `content_hash`
|
||||
- [ ] **3.2b** `ENTITY_SLOTS` 加 `gloss`(已核實現無)
|
||||
- [x] **3.2** `ensureTemplate` 改 slot-diff 補丁(命中既有 → base `PATCH /templates/:id` 補缺 slot,不再 early-return);`TRIPLET_SLOTS` 加 `status`+`superseded_by`+`source_uri`+`content_hash`(2026-06-26,`kbdb-client.ts`+`templates.ts`)
|
||||
- [x] **3.2b** `ENTITY_SLOTS` 加 `gloss`(已核實現無)(2026-06-26)
|
||||
- [ ] **3.2c** normalize 分層 fallback 接口:exact-only 先做;semantic 留接口(待 base embed,Arcrun #7)
|
||||
|
||||
## B. 寫入端 + 取代(核心)
|
||||
|
||||
- [ ] **3.3a** `KbdbClient.updateRecord(id, values)` → base `PATCH /records/:id`(已核實現無)
|
||||
- [ ] **3.3b** `src/actions/triplet-ingest.ts`:驗證 envelope(422 擋禁送欄位)→ idempotency(uri+hash)→ deprecate-then-append(先 append 後翻舊批 status)。<100 行純函式
|
||||
- [ ] **3.3c** `POST /triplets/ingest` route(只驗證 + 呼叫 action)
|
||||
- [ ] **3.4** 測試(mock,不打真網路):正常 envelope / 同 hash no-op / 新 hash deprecate / 污染 envelope(帶 bridge_score) 422 / rollback(翻回 status)
|
||||
- [ ] **3.5** 查詢 active-only:traverse/search/neighbors 組圖前 filter `status==='active'`(缺省視為 active,相容舊資料)
|
||||
- [x] **3.3a** `KbdbClient.updateRecord(id, values)` → base `PATCH /records/:id`(2026-06-26,mock 同步)
|
||||
- [x] **3.3b** `src/actions/triplet-ingest.ts`:Zod strict 驗證 → idempotency(uri+hash)→ **先 append 後 deprecate**。88 行純函式(2026-06-26)
|
||||
- [x] **3.3c** `POST /triplets/ingest` route(驗證失敗 → 422 hook,只驗證+呼叫 action)(2026-06-26)
|
||||
- [x] **3.4** 測試 6 案全綠:正常 / 同 hash no-op / 新 hash deprecate / 污染(bridge_score+頂層 id) 422 / rollback(`vitest run` 16 passed)(2026-06-26)
|
||||
- [x] **3.5** 查詢 active-only:`queryTriplets` 缺省 filter `status==='active'`(traverse/search/neighbors 皆經此;`includeDeprecated` opt-out 供 rollback/考古)(2026-06-26)
|
||||
|
||||
## C. MCP(⚠️ 跨 repo,需 arcrun 配合 → issue 標清)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user