portal-auth P1(#24 #25):KBDB library filter 地基(不 merge,待總管審) #50
Reference in New Issue
Block a user
Delete Branch "portal-auth-p1-library-filter"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
portal-auth SDD P1(
system-dev/docs/3-specs/portal-auth/,design §3.2/§3.3)。只動kbdb/+SDD tasks.md,不碰 cypher-executor/portal。不 merge,待總管審。Vectorize
$in核實結論(P1 開工第一件事)支援,走主路徑
$in,不需 fan-out fallback。$eq/$ne/$in/$nin/$lt/$lte/$gt/$gte;「For $in and $nin, filter object values can be arrays of string, number, boolean, or null values」。@cloudflare/workers-types@4.20260702.1原生 typingVectorizeVectorMetadataFilterCollectionOp = "$in" | "$nin"(index.d.ts:15782);wrangler 4.98.0。改動
kbdb/src/actions/entry-crud.tslistEntries/searchEntries加library?: string[];謂詞COALESCE(json_extract(metadata_json,'$.library'),'general') IN (…)(≡ design §3.3 OR 形狀,語意相同、單組佔位符)kbdb/src/routes/entries.tsGET /entries、GET /entries/search接library逗號多值參數;空值→不過濾kbdb/src/embed.tslibrary(寫入端正規化:未標記→'general',因 Vectorize filter 做不了 COALESCE);semanticSearch支援libraryfilter$in;backfill/reindex 向量同步帶 library;SemanticHit加 library 欄kbdb/wrangler.tomlkbdb/tests/library-filter.test.tstasks.md驗收證據(本機真跑)
tsc --noEmitexit 0;vitest 17/17 綠(新 11+既有 6)。wrangler d1 migrations apply --local,灌 5 筆(finance/hr/無 metadata/有 metadata 無 library/顯式 general):/entries?q=P1TEST(不帶 library)?library=finance?library=finance,hr?library=general?library=nonexistent/entries/search?q=…(不帶)search?library=hr/library=general,financesearch?mode=semantic&library=finance(無 Vectorize)requested_mode:semantic,library 仍 enforce(1 筆)search?owner_id=t1&entry_type=block舊參數組合誠實邊界
$in實跑待雲端排練。部署清單(待雲端排練驗)
wrangler vectorize create-metadata-index arcrun-kbdb-embed --property-name library --type stringPOST /embed/backfill {"reindex":true}分批到remaining=0(metadata index 只收建立後 upsert 的向量,不 reindex 則帶 library filter 一律 0 命中)library=命中正確;不帶行為不變cli/src/lib/deploy.tsensureVectorizeMetadataIndexes()待補library(cli/ 屬本次派工範圍外)範圍矛盾註記(給總管)
tasks.md P1 原含「cypher
kbdb-proxy透傳 library」,與派工紅線「只動 kbdb」矛盾——照窄範圍執行,該項留[ ]順延(一行 query 透傳,建議隨 P3 動 cypher 時一併)。