Repository navigation
feat(knowledge): a knowledge source declares its document unit (source.documentBy); record search groups by it by default - #38564
Conversation
…umentBy Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FEkQ5oQLfL8thb6wtUHnTb
…unit by default; the save refuses a document unit that is no single-valued parent link Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FEkQ5oQLfL8thb6wtUHnTb
…usals and the unchanged hashes Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FEkQ5oQLfL8thb6wtUHnTb
Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FEkQ5oQLfL8thb6wtUHnTb
…urce.documentBy Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FEkQ5oQLfL8thb6wtUHnTb
… sites' schemas Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FEkQ5oQLfL8thb6wtUHnTb
…dles for the knowledge source's document unit row Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FEkQ5oQLfL8thb6wtUHnTb
…-ES, and count its label in the catalog's positive control Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FEkQ5oQLfL8thb6wtUHnTb
📓 Docs Drift CheckThis PR changes 3 package(s): 4 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 — 181 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 b420270a95aed080cc8cdf672edbd938dde4950a && git checkout b420270a95aed080cc8cdf672edbd938dde4950a
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin a133c8ad1b9066ec2141fa1f112f2063f45bd26a 43de68d58f094661a1f28d332f5becd486fe02bc && git checkout -B drift-repro a133c8ad1b9066ec2141fa1f112f2063f45bd26a && git merge --no-ff 43de68d58f094661a1f28d332f5becd486fe02bc
node scripts/docs-audit/affected-docs.mjs --json a133c8ad1b9066ec2141fa1f112f2063f45bd26a
|
… on the packages it moves Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FEkQ5oQLfL8thb6wtUHnTb
…owledge-document-by
|
repo:objectstack#5 · os-project-manager · session_01FEkQ5oQLfL8thb6wtUHnTb Contract-review-claim: session_01FEkQ5oQLfL8thb6wtUHnTb · head 5bbac4b · 2026-11-29T10:24Z Face: schema ( |
|
repo:objectstack#5 · os-project-manager · session_01FEkQ5oQLfL8thb6wtUHnTb Contract reviewServed-tier: PR #38564, PR 1 of 2 of card #38537 ( The rest of the diff is the lane seat's ACCEPT at Check-runs on this head, latest run per name, read at 10:37Z: 33 green, 10 skipped, 27 still running, none red. Green: Build Core, Check Changeset, Spec property liveness, Governed Surface Queue Guard, PR-body guards, Lint · PM dispatch-gates, every other Lint row, Type Check · workspace, source gates, consumer gates and debt ledger, Live E2E UI, and three of the twelve Test Core shards. Still running: Test Core (9 shards), Test UI (16 shards), Type Check UI, Build & E2E UI. One earlier Check Changeset run on this head (141311778549) was red: it read the PR body before the ① Derived judgments
② Semver levelChangeset Kind: Level, package by package (AGENTS.md, Post-Task step 3: a kind takes at least
No ③ Boundary flags
④ Design judgmentNo must-fix. S1 (should-fix) — the schema's jsdoc says In Fix: state the save refusal alone at this head, and if wanted that a packaged or code-registered source is not judged yet. PR 2 adds Nits:
File by file: On
The On On
The save arm agrees with its jsdoc: after the "does not exist" arm and before On On On Round: S1 earns a delta review of its fix, by this reviewer. N1 to N3 are accepted as they stand unless they ride that commit. Implemented-by: VERDICT: PASS |
…ad does The documentBy docblock names the save refusal alone (a packaged or code-registered source is not judged yet) and where each surface carries the parent: metadata[documentBy] on IKnowledgeService.search, groupValue on the search_knowledge hit. The form help and changeset say that listing the parent in Filter fields for the first time does rebuild. hitOf serves the parent only for a source that lists documentBy in metadataFields, as its groupBy arm does, with a pin over a stub service. The granularity and groupBy contract TSDoc and the search_knowledge description name the document unit. Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FEkQ5oQLfL8thb6wtUHnTb
…it's help Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FEkQ5oQLfL8thb6wtUHnTb
… unit The topK TSDoc in the knowledge-service contract, and in search_knowledge the topK, granularity and groupBy input descriptions, the matching input and output TSDoc and the granularity refusal, say that for a source that declares documentBy (its document unit) a record-level result counts one hit per parent record instead. Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FEkQ5oQLfL8thb6wtUHnTb
|
repo:objectstack#5 · os-project-manager · session_01FEkQ5oQLfL8thb6wtUHnTb Contract-review-claim: session_01FEkQ5oQLfL8thb6wtUHnTb · head 43de68d · 2026-11-29T11:18Z Delta round 1 of record 7254573293 (S1 should-fix open; N1–N3), plus the contract TSDoc widened by claim amendments on #38537. Face: schema, so |
|
repo:objectstack#5 · os-project-manager · session_01FEkQ5oQLfL8thb6wtUHnTb Contract reviewServed-tier: Delta round 1 on PR #38564 (PR 1 of 2 of card #38537), from head The delta is three commits and no merge: The file list gained The rest of the diff is the lane seat's ACCEPT at Check-runs on this head, latest run per name, read at 11:25Z: 23 green, 10 skipped, 36 still running, none red. Green: Check Changeset (both runs), Spec property liveness, Governed Surface Queue Guard, PR-body guards (one earlier run cancelled, its re-run green), Lint · PM dispatch-gates and every other Lint row under Lint & Repo Gates, Type Check · source gates, Build Docs, Build UI Deps. Still running: Build Core, Type Check · workspace, consumer gates and debt ledger, the twelve Test Core shards, the UI lint, type-check, test and E2E jobs. The running shards hold the acceptance pins, the new stub-service pin and the type-check of the ① Derived judgments
② Semver levelChangeset Kind: Level, package by package:
No ③ Boundary flags
④ Design judgmentNo must-fix, no should-fix.
New, both nits:
File by file. On On On
Tried to break it with a search over two sources, one declaring and one not: On On Generated output and the PR body, for the lane seat, not graded: the seven extractor-filled bundles (ar, de, fr, ko, pt-BR, ru, zh-Hant) still hold the previous English help with its recorded source hash. That is the extractor's merge rule, and Round: S1 is closed on this head and nothing new earns a delta review. N4 and N5 are accepted as they stand. Implemented-by: VERDICT: PASS |
|
repo:objectstack#5 · os-project-manager · session_01FEkQ5nNJM8FQkBco82NDFb 席位核对 — L1 ACCEPT · head 43de68d · 2026-11-29T11:33ZI read the diff at 43de68d (36 files, +784/−41) against the L1 checklist, card #38537 and its claim 7253127987 with three amendments. The contract face is the contract review's: round 1 7254573293 PASS, delta 7255137073 PASS. At reading, the checks on this head were 31 success, 11 skipped, 30 pending and 0 failed. One cancelled "PR-body guards" run at 11:17:38Z was superseded by a green run at 11:17:55Z. This verdict is on the diff, so landing waits for green. Part of #38537 is right. The card's Scope wires the rule into Every acceptance line of the card is pinned:
What I checked in the code:
Measured by me: spec The two notes the reviewer passed on:
Out of scope here: the "one hit per record" sentences in ACCEPT once the pending checks finish green. Not governed, so the area lands it. |
|
repo:objectstack#5 · os-project-manager · session_01FEkQ5oQLfL8thb6wtUHnTb Landing: head 43de68d · L1-a ACCEPT 7255197091 · CONTRACT_REVIEW_TIER review 7254573293 (PASS, S1 should-fix) and delta 7255137073 (PASS; S1, N1–N3 closed; N4, N5 nits stand) · |
Requested by Leehom · project thread
Part of #38537
Clause-②: yes (widening)
Metadata-protocol: added
维护者速读
What changes
PR 1 of 2 for the card. This PR lands the key, its parse rule, its save-time refusal and its first reader; the
os validaterule (in the lint package, held by another seat until it is released) is PR 2, which closes the card.ObjectKnowledgeSourceSchemagainsdocumentBy?: string. A refinement refuses a value thatmetadataFieldsdoes not list, with a message that names the field, the list, and the fix (add it tometadataFields, name a listed field, or remove the key). The refinement is a cross-key rule JSON Schema cannot state, so it is ledgered indropped-refinements.baseline.json(two schemas plus the four installed-package response schemas that embed a source; header totals updated).knowledge-search-scope.tsnow exportsparentLinkRule(schema)(the rulescopeTermsForalready used, factored out of the privateparentLinksOf, which now calls it; scope behaviour unchanged) anddocumentUnitOf(field, schema)(the rule plus "notmultiple: true"). Both are pure functions of the object definition, so PR 2 can call them with no knowledge service.admitAuthoredSourcerefuses adocumentBythatmetadataFieldslists and that is not a single-valued parent link:400 VALIDATION_ERROR,fieldset, after the "does not exist" arm and before every permission arm. The sentence is built bydocumentUnitRefusalTextinknowledge-source-admission.ts, one wording per reason (undeclared, withheld, not a link, no readable target, multiple). AdocumentBythatmetadataFieldsdoes not list is left to the parse, which already names that fix.searchByKey, with record granularity and nogroupBy,groupKeyOfnow asksdocumentKeyOf(hit, documentBy):parent:SOURCE#VALUEwhen the hit's source declaresdocumentByand the hit carries a parent, else the existing per-record key. The explicitgroupBypath,sourcesGroupableByand chunk granularity are untouched.hitOfsetsgroupValueto the parent under the default grouping too (absent for a record with no parent).documentUnitValueOfis the one predicate both the service key and the tool read. Like itsgroupByarm, the tool serves the parent only for a source that listsdocumentByinmetadataFields.documentByis in neither the index fingerprint nor the recipe hash (both enumerate their inputs explicitly);__tests__/index-fingerprint.test.tsis unchanged and green.metadata-form-zod-reconciliation.test.ts) refused the key without a form row, so the single picker is added besidemetadataFields(widget: 'field-ref',dependsOn: 'object') with its form test. This folds in the form half of Studio form, docs and skill text for knowledge sourcedocumentBy#38538; the docs andskills/**half stays there. The row brings its regenerated translation bundles (ja-JP, es-ES and zh-CN authored, the rest the extractor's fill) and the catalog's positive-control count (866 to 867).minorfor@objectstack/spec(the new authorable key),@objectstack/service-knowledge(the reader and the save refusal) and@objectstack/platform-objects(the form row's translated label and help), withMetadata-protocol: added: a new key a metadata author can write.Zone 2 choices
metadata[documentBy], the value assembly stored beside the passage. The parse holdsdocumentByinmetadataFields, so every hit of such a source carries it; grouping runs over the hits the adapters already answered and reads no record (SQL first: no per-hit read was added). The freshness check and the permission re-check are unchanged.parent:+ index key of the hit's source +#+String(value). The source key keeps two sources apart on equal parent ids; theparent:prefix keeps it apart fromrecord:anddocument:keys;String()compares values as a scope term does. A value that is absent, null, empty, or not a string or finite number falls back to the per-record key, so those records are never dropped.knowledge_source.source: accepted by the Zod but unauthorable in the form — documentBy), so it is in this PR.Acceptance
documentByabsent frommetadataFieldsknowledge-source.test.ts› "refuses adocumentBythatmetadataFieldsdoes not list…", "…whenmetadataFieldsis omitted…"userfield, aninternallookup and amultiplelookup, each naming the fixdocument-by-38537.test.ts› "refuses a text field / a user field / an internal lookup / a multiple lookup, 400 VALIDATION_ERROR, naming the field and the fix" (+ positive controls: lookup and master_detail admitted)document-by-38537.test.ts› "6 records under 2 parents plus 1 with no parent…: 3 hits"groupBy: 'clause_hash'unchanged; a source withoutdocumentByunchangeddocument-by-38537.test.ts› "an explicit groupBy is answered as before…", "a source without documentBy is answered as before…", "chunk granularity is answered as before"index-fingerprint.test.tsunchanged and green;document-by-38537.test.ts› "the fingerprint and the recipe hash are the same with and without documentBy"hitOfsetsgroupValueAblation
Both legs run with
scripts/ablation-replace.mjs(mutation verified on disk, restore verified as blob equal to HEAD and an emptygit diff HEAD). No build was needed: both suites import the subject fromsrc/.Reader reverted (default key back to the per-record key): 4 red
Anchor
if (groupBy === undefined) return documentKeyOf(...)replaced withreturn recordKeyOf(hit)inknowledge-service.ts.document-by-38537.test.ts: 4 failed / 12 passed — the 3-hit test, the empty-parent test, the two-sources test and thegroupValuetest. Restored: blob c98a03680da8 equals HEAD.Parse rule removed (the refinement dropped): 2 red
Anchor
.superRefine(refuseDocumentByOutsideMetadataFields)removed fromknowledge-source.zod.ts.knowledge-source.test.ts: 2 failed / 35 passed — both refusal tests. Restored: blob 211cb6dc13af equals HEAD. (A first attempt was refused by the tool before running anything, because its replacement text already occurred in the file; it was re-run with a distinct replacement.)Delta round 1: the tool's metadataFields guard removed: 1 red
The condition
&& objSource.metadataFields?.includes(objSource.documentBy)removed fromhitOfinknowledge-tools.ts(on-disk count 0).document-by-38537.test.ts: 1 failed / 16 passed, the stub-service test ("expected … to not have property groupValue"). Restored from a copy (on-disk count 1) before commit12cd7dc8a6, whose blobe49165a005carries the condition. This leg used a copy-and-restore, notablation-replace.mjs.Tests
Delta round 1 (contract review 7254573293, PASS with S1 open), head
e0ebb9ad8e. S1: thedocumentBydocblock names the save refusal alone, and says a source registered in code or installed with a package meets no save and is not judged yet. N1: the docblock and the changeset say where each surface carries the parent:metadata[documentBy]onIKnowledgeService.search, and alsogroupValueon asearch_knowledgehit. N2: the form help reads "Setting it rebuilds nothing; adding the field to Filter fields does." The changeset says the same, and the zh-CN, ja-JP and es-ES help is retranslated. The eleven bundles are regenerated:check:i18nreports all in sync, andcheck:i18n-stale-fillfinds no new stale fill. N3: thehitOfguard, pinned by one stub-service test with a positive control. Claim widening: the contract TSDoc and the tool description above. Readings one0ebb9ad8e:@objectstack/service-knowledge: test 23/23 files, 803/803 tests; the new test file 17/17 after its type fix; typecheck exit 0.@objectstack/spectest: 913/913 files, 28896 passed, 1 todo.@objectstack/platform-objectstest: 130/130 files, 2218/2218 tests.check:generated: all 14 artifacts up to date, against a dist built after the spec edits.check-changeset-no-majorwith this body as its event payload (level axisyes (widening)/added),check-empty-changeset,check-adr-0087-registration,check-changeset-fixed,check-nul-bytes,check-spec-docblock-symbol-anchors.selection; a list view'sbulkActionsis retired #38550 and feat(objectql): a record in a closed state, and its lines, are closed to change (closedStates, ADR-0162) — trunk #38497, on the hand-maintained counters as before.Delta round 1, second commit, head
43de68d58f. The claim was amended to add thetopKTSDoc and the tool'sgranularityinput description. Both now say what the fixed docblocks say: "for a source that declaresdocumentBy(its document unit), one hit per parent record instead". So do the other record-unit sentences in the two files (see Acceptance notes). Readings on43de68d58f:@objectstack/service-knowledge: test 23/23 files, 803/803 tests; typecheck exit 0. This covers thegranularityrefusal sentence: no test pins its text.check:generated: all 14 artifacts up to date, against a dist built after the edit.check-spec-docblock-symbol-anchorsandcheck-nul-bytes: each exit 0.selection; a list view'sbulkActionsis retired #38550 and feat(objectql): a record in a closed state, and its lines, are closed to change (closedStates, ADR-0162) — trunk #38497 on the counters).The
@objectstack/mcpknowledge-tool tests compare the listed description with the definition itself and pin no text, so they were not re-run here.Earlier, the head was
5bbac4b457, a clean merge of main that brings in #38509 (the record sync change inknowledge-service.ts). Re-checked on that head:@objectstack/service-knowledgetest 23/23 files, 802/802 tests; its typecheck exits 0;@objectstack/speccheck:generatedreports all 14 artifacts up to date; overlap-check finds origin/main merges cleanly. Below it,231e7c6339changes only the changeset (levelminor,Metadata-protocol: added); the changeset families were re-run there (check-changeset-no-majorwith this body as its event payload,check-empty-changeset,check-adr-0087-registration, all exit 0). The gate union was re-run after the last code commit, ata92874657e(the translation commit landed while it ran, and the families that read it,check:i18n,check:i18n-stale-fillandcheck:nul-bytes, were run again ona92874657e).Package suites and typecheck
pnpm --filter @objectstack/service-knowledge test— Test Files 23 passed (23), Tests 788 passed (788).typecheck(tsc + test layer) — exit 0.pnpm --filter @objectstack/spec test— Test Files 912 passed / 1 failed (913), Tests 28895 passed / 1 failed: the dropped-refinements ledger's header totals; corrected,scripts/dropped-refinements.test.tsre-run 30/30.typecheck— exit 0.pnpm --filter @objectstack/platform-objects test— Test Files 130 passed (130), Tests 2218 passed (2218).typecheck— exit 0.pnpm --filter @objectstack/spec check:generated— two stale artifacts found (reference page, liveness counts), regenerated with--fix, re-checked green.Derived gate families (dispatch-gates --commands, 120)
node scripts/pm/dispatch-gates.mjs --ran— "120 derived, 120 run, 0 NOT-MEASURED, 0 UNRUN"; every family exit 0 on the re-run. On the first run three families refused with exit 3 (prerequisite not met: no built CLI, client-react or package dists); each was built and re-run green, andcheck:i18nthen reported the form row's bundles drifted, regenerated in this PR.Not run locally:
check:i18n-coverage(not derived for this diff; prerequisite needs the example apps built) and every CI-only family; CI reports them on this PR. Dogfood: n/a (no!in the title, no(narrowing)arm).Acceptance notes
admitAuthoredSourceinknowledge-service.ts(the save-time admission lives there, not inknowledge-source-admission.ts, which holds the sentence);dropped-refinements.baseline.json(the parse rule is a refinement, which the spec build refuses unledgered); the platform-objects translation bundles and the catalog positive control (forced by the form row the gate required).KnowledgeSearchOptions.granularityandgroupBy(packages/spec/src/contracts/knowledge-service.ts) and thesearch_knowledgedescription: a source'sdocumentBysets the unit for record-level results. After the claim's second amendment, every other sentence in those two files that stated the record-level unit as "record" now names the document unit too: thetopKTSDoc and thegroupBy"instead of by record" line in the contract; in the tool, thetopK,granularityandgroupByinput descriptions, the matchingSearchKnowledgeInputandSearchKnowledgeOutput.hitsTSDoc, and thegranularityrefusal sentence. Left for Studio form, docs and skill text for knowledge sourcedocumentBy#38538, outside those two files:content/docs/ai/knowledge-rag.mdx(thegranularityrow) andcontent/docs/protocol/knowledge.mdx(the record-level paragraph).metadataFields) but no save door, so the parent-link rule does not judge it; PR 2'sos validaterule covers packaged sources.os validaterule), left undecided here:@objectstack/lintdoes not depend on@objectstack/service-knowledge, andparentLinkRule/documentUnitOfare pure over the object definition (they read@objectstack/core's withheld-field collectors and the spec'sreferenceTargetOf). Two ways for PR 2 to call them: (A) add the@objectstack/lintto@objectstack/service-knowledgedependency and import the functions, which first need a line in that package'sindex.ts: today they are module exports only, not on itsexportssurface; (B) move the pure rule to a package lint already reads (for example@objectstack/core) and haveknowledge-search-scope.tsimport it from there. PR 2 chooses.groupBy(grouping runs in the service over adapter answers), so no live cluster was started.overlap-checkis clean againstmainand feat(service-knowledge): record sync consumes the database queue in batches of 100, and a large backlog is reconciled #38509 (sharesknowledge-service.ts). It reports textual conflicts with two open drafts on hand-maintained counters: feat(spec)!: actions that act on many records are placed atselection; a list view'sbulkActionsis retired #38550 (the dropped-refinements ledger and the catalog positive control) and feat(objectql): a record in a closed state, and its lines, are closed to change (closedStates, ADR-0162) — trunk #38497 (the positive control). Whichever lands second re-applies its lines.Read first
packages/services/service-knowledge/src/knowledge-service.ts—groupKeyOf/documentKeyOf(the reader) and the new arm inadmitAuthoredSource.packages/services/service-knowledge/src/knowledge-search-scope.ts—parentLinkRulereplaces the body ofparentLinksOf; check the scope still behaves the same.packages/spec/src/ai/knowledge-source.zod.ts— the key and its refinement.Two-minute check:
pnpm --filter @objectstack/service-knowledge exec vitest run src/__tests__/document-by-38537.test.ts— 16 passed, including "…: 3 hits, each parent's best and the orphan".Session: https://claude.ai/code/session_01FEkQ5oQLfL8thb6wtUHnTb
🤖 Generated with Claude Code