portal-auth P1(#24 #25):KBDB library filter 地基

- /entries 與 /entries/search 加 library 多值參數(逗號分隔);不帶=行為一字不變(向後相容)
- D1:COALESCE(json_extract(metadata_json,'$.library'),'general') IN (…)(≡ design §3.3 OR 形狀;
  未標記舊資料歸 general)
- semantic:Vectorize upsert metadata 加 library(寫入端正規化 general);查詢 filter $in 主路徑
  (官方文件+workers-types 4.20260702.1 核實支援,fan-out fallback 不需)
- 測試:library-filter.test.ts 11 項+既有 6 項全綠;tsc exit 0;本機 miniflare local D1 十案例實跑全過
- semantic 線上路徑(metadata index+reindex backfill)=部署清單,待雲端排練驗(本機無 Vectorize)
- cypher kbdb-proxy 透傳順延(P1 派工紅線只動 kbdb,tasks.md 已註)

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
uncle6me-web
2026-07-14 11:45:08 +08:00
parent 18c0846af0
commit e788c52dd2
6 changed files with 274 additions and 14 deletions
+6 -2
View File
@@ -24,8 +24,12 @@ ENVIRONMENT = "production"
# wrangler vectorize create-metadata-index arcrun-kbdb-embed --property-name owner_id --type string
# wrangler vectorize create-metadata-index arcrun-kbdb-embed --property-name entry_type --type string
# wrangler vectorize create-metadata-index arcrun-kbdb-embed --property-name source --type string
# metadata index 只收「建立後 upsert」的向量 → 既有向量須 `POST /embed/backfill {"reindex":true}` 重推。
# deploy.ts 的 ensureVectorizeMetadataIndexes() 已把上述三個 index 隨部署冪等建好。
# wrangler vectorize create-metadata-index arcrun-kbdb-embed --property-name library --type string
# libraryportal-auth P1「庫」filterupsert 端把未標記正規化成 'general',查詢走 $in
# metadata index 只收「建立後 upsert」的向量 → 既有向量須 `POST /embed/backfill {"reindex":true}` 重推
# (建 library index 後同樣要 reindex,否則舊向量帶 library filter 一律 0 命中)。
# deploy.ts 的 ensureVectorizeMetadataIndexes() 已把前三個 index 隨部署冪等建好;library 待補進該清單
# cli/ 屬 portal-auth P1 範圍外,見 portal-auth tasks.md 部署清單附註)。
# 沒有這兩個 binding 時,kbdb/src/embed.ts 的 embedEnabled() 回 false → 維持 LIKE keyword、API 不變。
#
# [[vectorize]]