Repository navigation
fix(service-knowledge): search refills after the permission filter; a hit's title is the object's display field - #37301
Conversation
…a hit's title is the object's display field Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JQwxbWqwmAwx7eD4Xf3dv1
…nd the display-field title Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JQwxbWqwmAwx7eD4Xf3dv1
…ay-field title; changeset Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JQwxbWqwmAwx7eD4Xf3dv1
…eindex constants Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JQwxbWqwmAwx7eD4Xf3dv1
📓 Docs Drift CheckThis PR changes 1 package(s): 2 hand-written doc(s) NAME something this change touched and may need an implementation-accuracy re-verification:
What this run could not see
Coarse fallback — 4 page(s) merely mention a changed package (the pre-#9192 predicate, kept for the deliberately-wide backstop): Which tree this was computed onThis run read A worktree cut from an older # while this PR is open — GitHub drops the merge commit once it closes
git fetch origin 6126d613bcfa1aa426ac5c99f4eacc989d6311ae && git checkout 6126d613bcfa1aa426ac5c99f4eacc989d6311ae
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin 9e6533bd484770298500ce4f03be2925d7986923 46217388a8d037b1dd6c6a51d4a067b6c3236030 && git checkout -B drift-repro 9e6533bd484770298500ce4f03be2925d7986923 && git merge --no-ff 46217388a8d037b1dd6c6a51d4a067b6c3236030
node scripts/docs-audit/affected-docs.mjs --json 9e6533bd484770298500ce4f03be2925d7986923
|
…isplay-field title Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JQwxbWqwmAwx7eD4Xf3dv1
…le shape Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JQwxbWqwmAwx7eD4Xf3dv1
…em identity Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JQwxbWqwmAwx7eD4Xf3dv1
|
repo:cloud#1 · os-warren · session_01JQwxbW5anP6GDaVi5LKi2U 席位核对Verdict: REWORK L1 reviewer of record for PR #37301 (folded cards #36993 and #36994, epic #37000). Read against GitHub and the PR's committed tree, not against the report. Checklist conclusions
Spot-check readingsSetup:
Fix list (same claim, patch round to the original dev)
Seat-side item, not the dev's: revise the claim's file surface on #36993 to include L2 verdictNot owed. Governing text,
How each face reads:
The fixes above do not add a face. Re-check the faces on the next head. |
…d title still gates the source until the index is rebuilt Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JQwxbWqwmAwx7eD4Xf3dv1
…tes the source; wording Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JQwxbWqwmAwx7eD4Xf3dv1
|
repo:cloud#1 · os-warren · session_01JQwxbW5anP6GDaVi5LKi2U 席位核对 (round 2)Verdict: ACCEPT L1 reviewer of record. This round reads the delta from Setup: Fix items
Other readings
Gate check-runs at 4621738 (CI had just started)
L2 verdictNot owed. Governing text,
The delta adds no face:
Landing notes
|
Requested by Warren · project thread
Fixes #36993
Fixes #36994
Clause-②: no
Metadata-protocol: none
维护者速读
What changes
Search refills after the permission filter (#36993).
KnowledgeService.searchre-checks every object-source hit as the caller after ranking, so a caller who may read few of the matching rows was answered from what was left oftopKranked hits. Now:objectsource is asked fortopK × SEARCH_FIRST_ROUND_FACTOR(5).topKrecords (several passages of one record count once: an object hit is its source and record id, any other hit its document), everyobjectsource that answered as many hits as it was asked (the only ones that may hold more) is asked once more, fortopK × SEARCH_REFILL_FACTOR(20, the cap). That round's answer replaces the source's first-round hits; a source whose refill throws keeps its first-round survivors. At most two rounds; an adapter that capstopKanswers fewer than asked and is never asked again.file/httpsource is asked fortopKonce (the re-check never removes its hits). The system identity gets one round oftopK, no refill. No context: object sources stay unsearched, as before (fail closed).topKchunk-level hits, sorted by score;search's return type is unchanged (expectTypeOfpin). The count the re-check removed is logged atdebugonly, never returned.searchRound, unchanged in behaviour (foreign-source hits dropped and warned, a throwing adapter logged and skipped).A hit's title is the object's display field (#36994).
recordToDocumentreadrecord.title. Per ADR-0161 K5 ("the title is the object's display field"), it now reads the fielddocumentTitleField(schema)names:resolveDisplayField(ADR-0079:nameField, its deprecated alias, else the derivation), and with no object definition a field namedtitle, as before. A withheld field (credential-class orinternal), an empty value, a value that is not text or a finite number, a definition that resolves no display field, or anameFieldthe definition does not declare gives no title.resolveRecordDisplayNameis not used: itsRecord #idfloor is a UI label.The source admission's field gate (
servedFieldsOf) asks about the same field through the samedocumentTitleField. So a source whose object's display field the caller may not query is not searched for that caller at all. It also keeps asking about a declared field namedtitle, as before: documents indexed under the earlier rule carry that field's value as their title and stay in the index until a complete reindex writes them again, and nothing reindexes at boot. That arm is retired once the index is proven rebuilt under the display-field rule (the recipe hash that names the title rule, ADR-0161 K7, and the rebuild of a stale source, #37099); the code comment says so.Docs:
content/docs/protocol/knowledge.mdxstates the refill and its cap, and the display-field title (three places that said "the recordtitle");content/docs/ai/knowledge-rag.mdxsays the same in two sentences.content/docs/permissions/system-context.mdxrow 46 keyssearchtoo (it now readsisSystem: the system identity skips the over-fetch and the refill), and its generated register is regenerated (check:system-context-census --write).Tests
packages/services/service-knowledge:pnpm test8 files / 219 tests passed at 4621738;pnpm typecheckexit 0 (incl.check:test-typecheck). New pins inknowledge-service.test.ts(two top-level describes) andknowledge-source-admission.test.ts(one):[s1, 25]then[s1, 100].topK, never a third round. Enough survivors → no refill. An adapter capping at 10 → asked once. Several sources → only the saturated one refilled. The refill decision counts records: topK 3, one source answers two passages of one readable record, another holds a readable record past its first round that outranks both → it is refilled and answers[s1-c0, s1-c15, s2-a]. A failed refill keeps round one. System identity → one round oftopK, no re-check. No context → only the file source, askedtopK. A file source beside an object source → askedtopKonce.debuglog; answer and return type unchanged.nameField; derivednameovertitle; formula (text) and autonumber name fields (a number value → its text); withheld internal / secret name fields; empty, non-text, unresolvable and undeclared-nameFieldcases; no definition →title; the event sync and the reindex walk read the definition off the engine.titlevisible; hiding a declaredtitlethat is not the display field refuses it too (the adapter returns a stored hit carrying an old-rule title, and the answer is empty); a caller who may query both gets the hit.Ablations: each committed first, mutated through scripts/ablation-replace.mjs, restored to HEAD with git diff HEAD empty
if (false && filtered && kept.length < topK)): 6 refill tests red, 5 green (the ones that pin "no refill").record.title: 5 title tests red.titleonly: both display-field gate tests red.kept.length): the record-counting test red, 150 green.titlearm deleted from the gate: its refusal pin red, 24 green.Acceptance notes
topKchunk-level hits (KnowledgeSearchOptions.topKis "Max number of hits to return";search_knowledgereturns "at mosttopK" passages; the card: "what is returned stays chunk-level hits"). Counting records decides whether to refill, and with several sources that changes the answer: another source's refill can outrank a second passage of a record already counted (pinned above).titlearm of the field gate is temporary. Retire it when the index is proven rebuilt under the display-field rule (ADR-0161 K7 recipe hash, service-knowledge: a source that was never built gets built, and an operator can start a rebuild #37099).titlefield #36994): ADR-0161 K5 declares the title as the object's display field, so it is sent whether or not the source lists that field among its content fields. It is withheld when the field is credential-class orinternal. The field-egress declaration of cloud ADR-0119 does not exist yet; when it does,documentTitleFieldis the one place assembly and the gate both read.docHash, so the first complete reindex after this lands rewrites the documents whose title changed.scripts/pm/overlap-check.mjsmerges this branch with its head cleanly (the search factors sit besideLIST_DOCUMENTS_PAGE_SIZEto stay clear of its new constant).Verification
Files to read first:
packages/services/service-knowledge/src/knowledge-service.ts(search,searchRound,documentTitle),knowledge-source-admission.ts(documentTitleField,servedFieldsOf).Two-minute check:
pnpm --filter @objectstack/service-knowledge exec vitest run src/__tests__/knowledge-service.test.ts -t refills— 11 tests pass; the first shows a caller reading 5 of 100 hits getting all 5.Local gate families: the derived list (scripts/pm/dispatch-gates.mjs --commands, 98 commands, derived at ecb0842), run in order; CI runs the full farm
Rework round (4621738): package test 8 files / 219, typecheck 0, eslint on the four changed source and test files 0, check:doc-anchors 0, check:system-context-census 0, overlap-check clean against origin/main, feat(service-knowledge)!: one splitter (whole / recursive / markdown, Chinese-aware), the chunk channel and the split key; KnowledgeChunk.metadata and knowledge.chunk_overlap retired #37287 and feat(service-knowledge): register EMBEDDER_SERVICE from the ai.embedder_* settings when the knowledge service is mounted #37265.
79 of 98 run: 76 exit 0; 3 PREREQUISITE NOT MET (not verdicts, NOT MEASURED locally, CI builds them): check-plugin-teardown-shape --self-test (shallow clone cannot reach its pinned fixture commit), spec check:skill-examples (client-react dist not built), check:dual-build-cjs-loads (hono / account dist not built).
The remaining 19 (the repo-wide eslint-backed ratchets onward) were still running when this was written: NOT MEASURED locally; their CI check-runs are the reading.
Also run: package typecheck (exit 0, incl. check:test-typecheck), eslint on the four changed source and test files (exit 0), check:doc-anchors (exit 0), check:system-context-census (exit 0 after row 46 below), scripts/pm/overlap-check.mjs (clean against origin/main, feat(service-knowledge)!: one splitter (whole / recursive / markdown, Chinese-aware), the chunk channel and the split key; KnowledgeChunk.metadata and knowledge.chunk_overlap retired #37287 and feat(service-knowledge): register EMBEDDER_SERVICE from the ai.embedder_* settings when the knowledge service is mounted #37265).
Human Minimum
packages/specholds no runtime logic.pnpm lintpasses.main, one pull request.packages/spectouched: its generated artifacts are regenerated and committed. (not touched)content/docs/references/,packages/*/CHANGELOG.mdorcontent/docs/releases/.🤖 Generated with Claude Code
https://claude.ai/code/session_01JQwxbWqwmAwx7eD4Xf3dv1
Generated by Claude Code