Skip to content

service-knowledge: a knowledge source declares its document unit (source.documentBy); record search groups by it by default #38537

Description

@os-bob

maintainer · os-bob · session_012dn2Abw1d1dVAyngaACxQF

Filing gate: ③ maintainer-directed (topic child). Source: topic #38536. Key words (maintainer, 2026-11-29, this session): 「立新的专题卡,用 fable 分拆任务,然后立刻交给5号座位优先派发」.
Grading: area:ai · Feature · p1 (topic's grade, the maintainer's 「优先派发」) · reach: apps that index child records of a parent (BrightRule: ~60k clauses under ~2k policies) · evidence: read from the code on main 63acc6c.

维护者速读

  • 做什么:知识源加 source.documentBy(指向父记录的字段,须在 metadataFields 里),并在同一 PR 落它的第一个读者:granularity: 'record' 且没给 groupBy 时,默认按它聚合。
  • 不改索引内容:不进指纹、不进 recipe 哈希,不触发重建。

Scope

  • Spec: documentBy?: string on ObjectKnowledgeSourceSchema (packages/spec/src/ai/knowledge-source.zod.ts:136-212, strictObject). Parse refuses a value that is not a member of metadataFields, with a message naming the fix.
  • Save / os validate: refuse a field that is not a single-valued parent link. Reuse the parent-link rule of knowledge-search-scope.ts (parentLinksOf, :138-166, private today; export it): lookup / master_detail only (:47), never a credential-class or internal field (:143-148), never multiple: true (:223). Wire it into packages/lint/src/validate-knowledge-source.ts and the save-time admission.
  • Reader (same PR, ADR-0049): in search(), when byRecord and groupBy === undefined (knowledge-service.ts:2510, :2533-2535), key each hit by its own source's documentBy value.
    • A null or empty parent value falls back to the per-record key (recordKeyOf, :4871). groupKeyOf today answers undefined for null (:2611-2612); do not let those records vanish.
    • The default key includes the source id, so two sources never merge on equal parent ids (the explicit groupBy key is value:<json> with no source, :2613; leave that path as it is, including sourcesGroupableBy, :2593).
    • hitOf (knowledge-tools.ts:539) sets groupValue for the default grouping too.
  • Fingerprint: documentBy stays out of the fingerprint (knowledge-index-fingerprint.ts:17-19) and the recipe hash (:116-121).
  • Regenerate the JSON schema and the liveness ledger; changeset notes that granularity: 'record' returns one hit per parent for a source that declares documentBy.

Acceptance

  • Parse refuses documentBy absent from metadataFields.
  • Save refuses a text field, a user field, an internal lookup and a multiple lookup, each with a message naming the fix.
  • 6 records under 2 parents plus 1 null-parent record, granularity: 'record', topK: 10 → 3 hits.
  • Explicit groupBy: 'clause_hash' output is unchanged; a source without documentBy is unchanged.
  • The pinned hashes in __tests__/index-fingerprint.test.ts are unchanged.

Reader

repo:objectstack#5. File roots: packages/spec/src/ai/, packages/services/service-knowledge/src/, packages/lint/src/validate-knowledge-source.ts. Size M. Blocked-by: none.
Dedupe: documentBy 0 · knowledge document unit count 105 (none on this).


Generated by Claude Code

Activity

  1. added
    priority:p1
    area:ai
    on Nov 29, 2026
  2. added theissue type on Nov 29, 2026
  3. objectstack-fleet commented on Nov 29, 2026

    @objectstack-fleet
    Contributor

    repo:objectstack#5 · os-project-manager · session_01FEkQ5oQLfL8thb6wtUHnTb
    Claim: PM loop round 1 · 2026-11-29T08:27Z
    Session: session_01FEkQ5oQLfL8thb6wtUHnTb
    Account: os-project-manager
    Branch: claude/issue-38537-knowledge-document-by
    Worktree: objectstack-issue-38537
    Domain: domain:server
    Seat: repo:objectstack#5
    Area: o5-ai37000
    File surface: packages/spec/src/ai/knowledge-source.zod.ts and packages/spec/src/ai/knowledge-source.test.ts; packages/spec/src/ai/knowledge-source.metadata-form.ts and its test only if the form-coverage gate refuses the key without them (then #38538's form half folds in, said in the PR); packages/spec/liveness/knowledge_source.json and the generated outputs the spec build writes for this key; packages/services/service-knowledge/src/knowledge-service.ts (record-search grouping in search() and the key helpers only), packages/services/service-knowledge/src/knowledge-tools.ts (hitOf groupValue only), packages/services/service-knowledge/src/knowledge-search-scope.ts (export the parent-link rule only), packages/services/service-knowledge/src/knowledge-source-admission.ts (the save-time refusal only), their tests under packages/services/service-knowledge/src/__tests__/ (new document-by-38537.test.ts plus knowledge-search-scope.test.ts and knowledge-source-admission.test.ts; index-fingerprint.test.ts read, never edited); one changeset .changeset/38537-knowledge-document-by.md (stop on breach; explain in the report). Not in it: packages/lint/** (held by #35143, seat 6, until the seat releases it; the os validate rule is this card's PR 2, claimed by amendment then), docs, skills/**, the search_knowledge description (#38538). PR 1 is Part of #38537; PR 2 (lint) carries Fixes #38537.
    Container & model: M, mode:subagent, model: default (dispatch-gates --tier at 430a311, "Model tier — no path-derived mandate"), effort: high (M)
    Clause-②: yes (widening)
    Metadata-protocol: none
    Responsibility: new feature, topic #38536 (maintainer-directed, seat post 7252899468); no producer.
    Thread-read: none
    Premise: holds at 430a311 — ObjectKnowledgeSourceSchema has no documentBy; record search with no groupBy keys each hit per record (knowledge-service.ts byRecord path); parentLinksOf in knowledge-search-scope.ts is private. Read from main, line numbers per the card body (63acc6c).
    Serial constraints cleared: check-handover --inflight at 430a3119d3 (08:27Z): one meet left, #38413 (claim 7253083650) on knowledge-service.ts, shared by the seat's ruling (seat thread 08:22Z: parallel, its sync path vs this card's search grouping, overlap-check before every push, the later merges main); #38528 re-claimed narrow (7253110162); no packages/lint path, so #36496 and #35143 do not meet; #38369 parked pm:blocked Blocked-by #38537 (7253072512)
    Pre-claim lane: packages/services/service-knowledge/** ⇒ domain:server (file ownership only); topic #38536 routed to this area by the seat, ahead of the rest of #37000/#38346.
    Pre-claim deps: none.
    Prior rulings read: maintainer's topic order (seat post 7252899468, 「立新的专题卡,用 fable 分拆任务,然后立刻交给5号座位优先派发」); ADR-0161 dated notes (K1, K4: a key lands with its first reader; K8).

  4. added
    domain:server
    pm:dispatched
    on Nov 29, 2026
  5. objectstack-fleet commented on Nov 29, 2026

    @objectstack-fleet
    Contributor

    repo:objectstack#5 · os-project-manager · session_01FEkQ5oQLfL8thb6wtUHnTb
    os-dev-report

    {
      "issue": 38537,
      "status": "done",
      "branch": "claude/issue-38537-knowledge-document-by",
      "pr": "https://github.com/objectstack-ai/objectstack/pull/38564",
      "session": "session_01FEkQ5oQLfL8thb6wtUHnTb",
      "premise_still_valid": true,
      "summary": "PR 1 of 2 (Part of #38537; the os validate rule in packages/lint is PR 2). Adds source.documentBy to ObjectKnowledgeSourceSchema with a parse refinement refusing a value not in metadataFields; exports the parent-link rule from knowledge-search-scope.ts (parentLinkRule, plus documentUnitOf = rule + not multiple; parentLinksOf now calls it, scope unchanged) and wires a 400 VALIDATION_ERROR save refusal into admitAuthoredSource; record search with no groupBy keys each hit parent:SOURCE#VALUE from the hit's own stored metadata[documentBy] (no record read), falling back to the per-record key for an absent/null/empty parent, and hitOf sets groupValue for that default grouping. Form-coverage gate refused the key without a form row, so the single field-ref picker is added and #38538's form half is folded in. File surface beyond the claim's list, each forced by a Zone 1 line and declared in the PR: knowledge-service.ts admitAuthoredSource (the save-time admission lives there; knowledge-source-admission.ts only builds the sentence), packages/spec/dropped-refinements.baseline.json (the spec build refuses an unledgered refinement), and the platform-objects metadata-form translation bundles plus the catalog positive-control count in object-lifecycle-panel-echo-decisions.test.ts (forced by the form row; ja-JP/es-ES/zh-CN authored). PR assignee os-project-manager set by pr_create; card assignee untouched.",
      "tests": "At a92874657e unless noted. service-knowledge: pnpm --filter @objectstack/service-knowledge test -> Test Files 23 passed (23), Tests 788 passed (788); typecheck exit 0. spec: pnpm --filter @objectstack/spec test (at 494c378d5e) -> 912 passed / 1 failed (dropped-refinements header totals), fixed, scripts/dropped-refinements.test.ts 30/30; spec typecheck exit 0. platform-objects: test -> 130/130 files, 2218/2218 tests; typecheck exit 0. New/changed pins: document-by-38537.test.ts 16 tests (3-hit acceptance, empty/absent parent, two sources, explicit groupBy:'clause_hash' identical with/without documentBy, no-documentBy source unchanged, chunk unchanged, groupValue, fingerprint+recipe hash equal, save refusals text/user/internal/multiple each 400 VALIDATION_ERROR naming field and fix, lookup/master_detail admitted); knowledge-source.test.ts 4 documentBy parse pins; knowledge-search-scope.test.ts 5 parentLinkRule/documentUnitOf pins; form test row pin. index-fingerprint.test.ts not edited, green. Ablation via scripts/ablation-replace.mjs (no build needed: subjects imported from src): reader reverted to recordKeyOf -> document-by-38537.test.ts 4 failed / 12 passed (incl. the 3-hit test), restored blob c98a03680da8 == HEAD; parse refinement removed -> knowledge-source.test.ts 2 failed / 35 passed, restored blob 211cb6dc13af == HEAD (first attempt was refused by the tool before running: replacement text already occurred; re-run with a distinct replacement). Live pgvector: not run, no pgvector/turso live suite touches granularity or groupBy (grouping is in the service).",
      "gates": "dispatch-gates --commands at a92874657e: 120 families, re-run after the last code commit, all exit 0; node scripts/pm/dispatch-gates.mjs --ran -> '120 derived, 120 run, 0 NOT-MEASURED, 0 UNRUN' (exit 0). First run: check:skill-examples, check:dual-build-cjs-loads, check:i18n exited 3 (prerequisite builds); built and re-run exit 0; check:i18n then found the form row's bundles drifted -> regenerated in the PR. check:i18n, check:i18n-stale-fill, check:nul-bytes re-run on a92874657e exit 0. spec check:generated: 2 stale (reference page, liveness counts) -> --fix, re-check green. overlap-check: clean vs main and #38509; VERDICT overlap exit 1 for textual conflicts with open drafts #38550 (dropped-refinements ledger + catalog positive control) and #38497 (positive control) on hand-maintained counters; second lander re-applies. Not run locally: check:i18n-coverage (not derived; needs example builds). CI check-runs on #38564: NOT MEASURED, reason: report delivered at the end of local verification, CI not awaited per dispatch contract.",
      "dogfood_battery": "n/a — no `!` in the PR title and no (narrowing) arm",
      "mcp_calls": "0",
      "api_writes": "3 REST writes via the fleet-write relay: POST /repos/objectstack-ai/objectstack/pulls (draft #38564) and POST /repos/objectstack-ai/objectstack/issues/38564/assignees (one pr_create action, one dispatch), plus POST /repos/objectstack-ai/objectstack/issues/38537/comments (this report, post-stamped.mjs). git pushes to the branch not counted.",
      "open_questions": [
        {
          "question": "The claim and dispatch fix `Metadata-protocol: none`, but AGENTS.md Post-Task Checklist step 3 and the Check Changeset table in pr-automation.yml define a new authorable key as `added` (-> minor). I copied `none` (patch) into the PR body and changeset as the os-dev rule requires. Which stands?",
          "options": [
            "A: correct to `Metadata-protocol: added` and both changeset entries to minor (PR body line + changeset, one edit each)",
            "B: keep `none` / patch as claimed"
          ],
          "recommendation": "A, because `documentBy` is a new key a metadata author can write, which is the table's own example of `added`; `none` covers description text, internal types and services."
        },
        {
          "question": "PR 2 (os validate in packages/lint) needs parentLinkRule/documentUnitOf, but @objectstack/lint does not depend on @objectstack/service-knowledge. Where should PR 2 read the rule from?",
          "options": [
            "A: PR 2 adds the lint -> service-knowledge dependency and imports the exported functions",
            "B: PR 2 moves the pure rule to a package lint already reads (e.g. core) and service-knowledge re-imports it"
          ],
          "recommendation": "B if the dependency direction lint -> service is unwanted; the functions are pure over the object definition plus @objectstack/core collectors and spec's referenceTargetOf, so the move is mechanical. PR 2's call."
        }
      ],
      "security_findings": "none",
      "out_of_scope_findings": [
        "carrier: #38538 · the TSDoc of KnowledgeSearchOptions.granularity/topK in packages/spec/src/contracts/knowledge-service.ts and the search_knowledge description still say 'record' is one hit per record; for a documentBy source it is one per parent. Noted in Acceptance notes, not edited (outside the file surface; docs half of that card).",
        "carrier: none · a source registered in code passes the parse (documentBy in metadataFields) but no save door, so the parent-link rule does not judge it; noted in Acceptance notes."
      ]
    }
  6. objectstack-fleet commented on Nov 29, 2026

    @objectstack-fleet
    Contributor

    repo:objectstack#5 · os-project-manager · session_01FEkQ5oQLfL8thb6wtUHnTb
    Claim amendment · 2026-11-29T10:05Z · amends claim 7253127987 on this card
    Metadata-protocol: added (corrects the claim's none: documentBy is a new authorable key, which AGENTS.md and the Check Changeset table in pr-automation.yml name added, taking minor).
    File surface: adds packages/services/service-knowledge/src/knowledge-service.ts admitAuthoredSource (the save-time admission lives there; knowledge-source-admission.ts builds only the sentence), packages/spec/dropped-refinements.baseline.json (the spec build refuses an unledgered refinement), packages/spec/authorable-surface/ai.json, packages/spec/liveness/state-counts/knowledge_source.md, content/docs/references/ai/knowledge-source.mdx (generated reference page), packages/platform-objects/src/apps/translations/*.metadata-forms.generated.ts and *.source-hashes.generated.ts (forced by the form row), and the catalog positive-control count in packages/platform-objects/src/apps/translations/object-lifecycle-panel-echo-decisions.test.ts. The form row folds in #38538's form half (the form-coverage gate refused the key without it).
    Reason: dev report 7254182965 on PR #38564; each file is forced by a Zone 1 line or a gate and declared in the PR.

  7. objectstack-fleet commented on Nov 29, 2026

    @objectstack-fleet
    Contributor

    repo:objectstack#5 · os-project-manager · session_01FEkQ5oQLfL8thb6wtUHnTb
    Claim amendment · 2026-11-29T10:39Z · amends claim 7253127987 on this card
    File surface: adds packages/spec/src/contracts/knowledge-service.ts (the granularity and groupBy TSDoc only, which still say "one hit per record" where a source's documentBy now sets the unit).
    Reason: contract review 7254573293 on PR #38564, ③ escalation: that TSDoc and the search_knowledge description (knowledge-tools.ts, already in this surface) would ship stale in the next release if left to #38538, which names neither the contract file nor a release gate and is now with seat 1. Both go into PR 1 with the S1 fix, so the release that publishes documentBy describes it. check-handover --inflight on the added path: clear. #38538 keeps its docs pages, skill text and the form-help wording.

  8. objectstack-fleet commented on Nov 29, 2026

    @objectstack-fleet
    Contributor

    repo:objectstack#5 · os-project-manager · session_01FEkQ5oQLfL8thb6wtUHnTb
    Claim amendment · 2026-11-29T11:09Z · amends claim 7253127987 on this card
    File surface: adds the topK TSDoc in packages/spec/src/contracts/knowledge-service.ts (beside the granularity and groupBy TSDoc added before) and the tool's granularity input description in packages/services/service-knowledge/src/knowledge-tools.ts.
    Reason: dev report on PR #38564 head e0ebb9a: both still state the old unit ("counts records", "per record") for a documentBy source, the same staleness the previous amendment fixes. Folded in before the delta review so the release carries no stale unit text.

  9. objectstack-fleet commented on Nov 29, 2026

    @objectstack-fleet
    Contributor

    repo:objectstack#1 · zhuangjianguo · session_01QsR2jTsdScTh3o2fSjbxSz

    2026-11-29T12:03Z · Takeover · seat repo:objectstack#5's account os-project-manager is out of tokens; seat 1 continues its claim.

    Release: claim 7253127987 (session session_01FEkQ5oQLfL8thb6wtUHnTb, account os-project-manager, seat repo:objectstack#5) — taken over, not abandoned. Provenance: who = the maintainer (Jianguo); words, verbatim: 「hotlong 和 5号座位os-project-manager没token了,他的任务你都继续处理完」; where = seat 1's project chat, 2026-11-29T11:57:54Z.
    Handover: branch claude/issue-38537-knowledge-document-by last pushed 43de68d58f; PR #38564. Picked-up work is UNVERIFIED until seat 1 re-reads it at that head.
    Assignee: os-project-manager → zhuangjianguo in this stroke.

    Claim: PM loop round 3 (takeover of 7253127987)
    Session: session_01QsR2jTsdScTh3o2fSjbxSz
    Account: zhuangjianguo
    Branch: claude/issue-38537-knowledge-document-by
    Worktree: objectstack-issue-38537
    Domain: domain:server
    Seat: repo:objectstack#1
    Area: o1-know
    File surface: packages/spec/src/ai/knowledge-source.zod.ts and packages/spec/src/ai/knowledge-source.test.ts; packages/spec/src/ai/knowledge-source.metadata-form.ts and its test only if the form-coverage gate refuses the key without them (then #38538's form half folds in, said in the PR); packages/spec/liveness/knowledge_source.json and the generated outputs the spec build writes for this key; packages/services/service-knowledge/src/knowledge-service.ts (record-search grouping in search() and the key helpers only), packages/services/service-knowledge/src/knowledge-tools.ts (hitOf groupValue only), packages/services/service-knowledge/src/knowledge-search-scope.ts (export the parent-link rule only), packages/services/service-knowledge/src/knowledge-source-admission.ts (the save-time refusal only), their tests under packages/services/service-knowledge/src/__tests__/ (new document-by-38537.test.ts plus knowledge-search-scope.test.ts and knowledge-source-admission.test.ts; index-fingerprint.test.ts read, never edited); one changeset .changeset/38537-knowledge-document-by.md (stop on breach; explain in the report). Not in it: packages/lint/** (held by #35143, seat 6, until the seat releases it; the os validate rule is this card's PR 2, claimed by amendment then), docs, skills/**, the search_knowledge description (#38538). PR 1 is Part of #38537; PR 2 (lint) carries Fixes #38537.
    Container & model: M, mode:subagent, model: default (dispatch-gates --tier at 430a311, "Model tier — no path-derived mandate"), effort: high (M)
    Clause-②: yes (widening)
    Metadata-protocol: none
    Responsibility: new feature, topic #38536 (maintainer-directed, seat post 7252899468); no producer.
    Thread-read: 7254921447
    Premise: holds at 430a311 — ObjectKnowledgeSourceSchema has no documentBy; record search with no groupBy keys each hit per record (knowledge-service.ts byRecord path); parentLinksOf in knowledge-search-scope.ts is private. Read from main, line numbers per the card body (63acc6c).
    Serial constraints cleared: check-handover --inflight at 430a3119d3 (08:27Z): one meet left, #38413 (claim 7253083650) on knowledge-service.ts, shared by the seat's ruling (seat thread 08:22Z: parallel, its sync path vs this card's search grouping, overlap-check before every push, the later merges main); #38528 re-claimed narrow (7253110162); no packages/lint path, so #36496 and #35143 do not meet; #38369 parked pm:blocked Blocked-by #38537 (7253072512)
    Pre-claim lane: packages/services/service-knowledge/** ⇒ domain:server (file ownership only); topic #38536 routed to this area by the seat, ahead of the rest of #37000/#38346.
    Pre-claim deps: none.
    Prior rulings read: maintainer's topic order (seat post 7252899468, 「立新的专题卡,用 fable 分拆任务,然后立刻交给5号座位优先派发」); ADR-0161 dated notes (K1, K4: a key lands with its first reader; K8).

  10. objectstack-fleet commented on Nov 29, 2026

    @objectstack-fleet
    Contributor

    repo:objectstack#1 · zhuangjianguo · session_01QsR2jTsdScTh3o2fSjbxSz

    2026-11-29T12:32Z · Claim amendment to 7255544301: PR 1 (#38564) merged; the claim narrows to PR 2, which frees packages/services/service-knowledge/** and packages/spec/src/ai/knowledge-source* for the topic's next cards.

    Claim: PM loop round 3 (amendment of 7255544301)
    Session: session_01QsR2jTsdScTh3o2fSjbxSz
    Account: zhuangjianguo
    Branch: none yet — PR 2 is not started; a card thread is named in a later amendment
    Worktree: objectstack-issue-38537
    Domain: domain:server
    Seat: repo:objectstack#1
    Area: o1-know
    File surface (PR 2): packages/lint/src/validate-knowledge-source.ts and its tests, the os validate wiring of that rule, one changeset .changeset/38537-*.md (PR 2 question A/B as in #38564's body) (stop on breach; explain in the report)
    Container & model: M, mode:subagent, model: default (dispatch-gates --tier at 430a311, "Model tier — no path-derived mandate"), effort: high (M)
    Clause-②: yes (widening)
    Metadata-protocol: none
    Responsibility: new feature, topic #38536 (maintainer-directed, seat post 7252899468); no producer.
    Thread-read: 7254921447
    Premise: holds at 430a311 — ObjectKnowledgeSourceSchema has no documentBy; record search with no groupBy keys each hit per record (knowledge-service.ts byRecord path); parentLinksOf in knowledge-search-scope.ts is private. Read from main, line numbers per the card body (63acc6c).
    Serial constraints cleared: PR 2 waits behind #35143 on packages/lint/** (claim 7255708748, seat 1's own takeover); none other
    Pre-claim lane: packages/services/service-knowledge/** ⇒ domain:server (file ownership only); topic #38536 routed to this area by the seat, ahead of the rest of #37000/#38346.
    Pre-claim deps: none.
    Prior rulings read: maintainer's topic order (seat post 7252899468, 「立新的专题卡,用 fable 分拆任务,然后立刻交给5号座位优先派发」); ADR-0161 dated notes (K1, K4: a key lands with its first reader; K8).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

area:aidomain:serverpm:dispatchedpriority:p1

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions