Skip to content

knowledge_source: order hits by the asker's relation to a declared field (affinity: boost and nearest, #38412 ruling) #38503

Description

@objectstack-fleet

repo:objectstack#5 · os-project-manager · session_01FEkQ5mzSTSPADAvwapnhxr

Filing gate: ① ruled. Ruling-ref: 7251603512 on #38412 (maintainer 「A 精简:排序加带出」, option A-lean; analysis 7251063339). Built to the ADR-0161 dated note of 2026-11-29 (PR #38511, merged; card #38502), K1 "What follows from the two lists". Body rewritten by the seat after the note landed and both blockers (#38502, #38363) merged.
Grading: area:ai · Feature · p3, dispatched in the topic's order · reach: every app with a knowledge source · contract-tier review (a new authorable key, built to the note).
Part of #38346.
Related: #38515 (ruled D 「D 全员可读,应用不用授权」, record 7252551540: every internal member reads its organization's business units by default, so a plain member's chain is whole once that build card lands).

维护者速读

What

Build source.affinity exactly as the note fixes it (the note's bullets "◆ The keys, on the object arm", "affinity", "◆ The caller facts are a closed list of two", "◆ By position, never by score", "Refused when it is written"):

  • The key, on the object arm, with its first reader (K4, K10 rule 1): a list of { field, caller, mode, places? }; mode is boost or nearest only; at most one nearest per source; several entries add.
  • Set the upper bound of places and state it on the key (the note fixes no number and leaves it to this card). Give the reason for the number in the PR body (for example, a bound tied to the refill bound or the tool's topK), and refuse a larger value at write time with a sentence that names the fix.
  • Caller facts: the closed list user and business_unit (primary unit, then each parent to the root), read from the mcp: tell the model who is signed in — the asker's user and business-unit chain reach the ask route (cloud#5099) but not an MCP client #38363 resolver's one answer, at most once per search and only when a searched source declares an entry that reads it; never a tool argument, a search option, or a client or model value. Settle with mcp: tell the model who is signed in — the asker's user and business-unit chain reach the ask route (cloud#5099) but not an MCP client #38363's resolver where it lives so the knowledge service can call it (the note's slice line).
  • Ordering by position only, per source, judged on the hit standing for each unit; nearest tiers; inside a tier key = number − sum of matched places, ties to the larger sum then the earlier number; each hit keeps its adapter's score; no count reported; inside the existing refill bound.
  • Every refusal in the note's "Refused when it is written" line that concerns affinity, each with a sentence naming the fix (filter answered that narrowing is the search scope and visibility is sharing).

Acceptance

Not in scope: expand.window (#38504); expand.follow (#38505); filter mode; date decay; other caller facts (active organization, positions, teams); any opt-out argument on the tool.

Dedupe: knowledge_source affinity nearest boost 0 open.

Activity

  1. added
    area:ai
    domain:server
    on Nov 29, 2026
  2. objectstack-fleet commented on Nov 29, 2026

    @objectstack-fleet
    ContributorAuthor

    triage#1 · sunhaolin · session_017xRBcSxvUE3fDrox79CL9t

    Triage: lands in packages/spec/src/ai/knowledge-source.zod.ts (the affinity key, in the shape #38502's note fixes) and packages/services/service-knowledge (re-order inside the refill bound), with the caller-fact resolver from #38363 and a three-arm measurement record · area:ai · domain:server (+ domain:spec for the key; Seam) · Feature · p3 · pm:blocked (Blocked-by: #38502 and #38363, in the body) · size L. Rationale: a slice named by the maintainer's #38412 ruling (record 7251603512, 「A 精简:排序加带出」), with its blockers and acceptance. So it is pre-authorised execution, and the key's shape is decided in the Tier H note #38502. Both blockers are unmerged. The card carried no pm state, a half state this touch resolves. If arm 3 does not beat arm 2, the result goes back to the maintainer before #38505.

    Recorded 2026-11-29T06:54Z.

  3. added
    pm:blocked
    on Nov 29, 2026
  4. added
    pm:queue
    and removed
    pm:blocked
    on Nov 29, 2026
  5. objectstack-fleet commented on Nov 29, 2026

    @objectstack-fleet
    ContributorAuthor

    repo:objectstack#1 · zhuangjianguo · session_01QsR2jTsdScTh3o2fSjbxSz

    2026-11-29T12:43Z · Claim of PR 1 (spec, core, service, docs). The os validate half of the target refusal is PR 2: packages/lint/src/validate-knowledge-source.ts is held by #38537 PR 2 (claim 7255895735), which queues after #35143 (packages/lint/**).

    Claim: PM loop round 3 · PR 1 of 2 (affinity: order hits by the asker's relation to a declared field, boost and nearest)
    Session: session_01QsR2jTsdScTh3o2fSjbxSz
    Thread session: session_01QsR2jSArETHHmJzkH5368W
    Account: zhuangjianguo
    Branch: claude/project-thread-ku5ipy
    Worktree: objectstack-issue-38503
    Domain: domain:server
    Seat: repo:objectstack#1
    Area: o1-know
    File surface (PR 1): packages/spec/src/ai/knowledge-source.zod.ts, packages/spec/src/ai/knowledge-source.test.ts, packages/spec/src/ai/knowledge-source.metadata-form.ts (+ .metadata-form.test.ts), packages/spec/src/contracts/knowledge-service.ts (jsdoc); the regenerated packages/spec/authorable-surface/ai.json, packages/spec/dropped-refinements.baseline.json, packages/spec/liveness/knowledge_source.json, packages/spec/liveness/state-counts/knowledge_source.md, content/docs/references/ai/knowledge-source.mdx, packages/platform-objects/src/apps/translations/*.metadata-forms.generated.ts, packages/platform-objects/src/apps/translations/*.source-hashes.generated.ts and the count pin in object-lifecycle-panel-echo-decisions.test.ts; packages/core/src/caller-identity.ts (new; the #38363 resolver moves here) + its test, packages/core/src/index.ts; packages/runtime/src/domains/mcp.ts (imports and re-exports the resolver; behaviour unchanged); packages/services/service-knowledge/src/knowledge-affinity.ts (new), packages/services/service-knowledge/src/__tests__/affinity-38503.test.ts (new), packages/services/service-knowledge/src/knowledge-service.ts, packages/services/service-knowledge/src/knowledge-source-admission.ts, packages/services/service-knowledge/src/testing.ts if needed; content/docs/ai/knowledge-rag.mdx, content/docs/protocol/knowledge.mdx; .changeset/38503-knowledge-affinity.md. Not packages/lint/** (PR 2), not skills/** (Skills-docs: follow-up owed for skills/objectstack-ai/SKILL.md) (stop on breach; explain in the report)
    Container & model: M, mode:thread, model: default (spec/contract cards build at default tier; a CONTRACT_REVIEW_TIER L2 follows), effort: high; the arm measurement uses the maintainer-supplied AI gateway key from the environment (never printed), else NOT MEASURED with the reason
    Clause-②: yes — a new published key on knowledge_source
    Metadata-protocol: added
    Responsibility: n/a — not a defect card
    Thread-read: 7252145063
    Premise: holds (rulings: #38412 decision and the ADR-0161 dated note of #38502 fix the key's shape; #38564 merged at 2026-11-29T12:14Z)
    Serial constraints cleared: check-handover --inflight at 2026-11-29T12:40Z names #38529 (read-only measurement, no file), #37087 and #36496 (they regenerate the same translation generated files: regenerated outputs, resolved by the os-regen merge order), and the lint holders #38537 / #35143 / #37766 (lint left to PR 2); #38369 PR 2 (claim of this round) shares knowledge-service.ts and the two docs pages and goes first (p2): this branch merges main after it lands, and runs overlap-check.mjs before each push. #38504 (expand siblings) waits for this PR.

  6. added
    pm:dispatched
    and removed
    pm:queue
    on Nov 29, 2026
  7. objectstack-fleet commented on Nov 29, 2026

    @objectstack-fleet
    ContributorAuthor

    repo:objectstack#1 · zhuangjianguo · session_01QsR2jTsdScTh3o2fSjbxSz

    2026-11-29T12:55Z · Claim amendment to 7256019231: the maintainer ruled at 2026-11-29T12:54:37Z that the AI gateway key is only for generating embeddings; any LLM-dependent arm is NOT MEASURED; nothing else changes.

    Claim: PM loop round 3 (amendment of 7256019231)
    Session: session_01QsR2jTsdScTh3o2fSjbxSz
    Thread session: session_01QsR2jSArETHHmJzkH5368W
    Account: zhuangjianguo
    Branch: claude/project-thread-ku5ipy
    Worktree: objectstack-issue-38503
    Domain: domain:server
    Seat: repo:objectstack#1
    Area: o1-know
    File surface (PR 1): packages/spec/src/ai/knowledge-source.zod.ts, packages/spec/src/ai/knowledge-source.test.ts, packages/spec/src/ai/knowledge-source.metadata-form.ts (+ .metadata-form.test.ts), packages/spec/src/contracts/knowledge-service.ts (jsdoc); the regenerated packages/spec/authorable-surface/ai.json, packages/spec/dropped-refinements.baseline.json, packages/spec/liveness/knowledge_source.json, packages/spec/liveness/state-counts/knowledge_source.md, content/docs/references/ai/knowledge-source.mdx, packages/platform-objects/src/apps/translations/*.metadata-forms.generated.ts, packages/platform-objects/src/apps/translations/*.source-hashes.generated.ts and the count pin in object-lifecycle-panel-echo-decisions.test.ts; packages/core/src/caller-identity.ts (new; the #38363 resolver moves here) + its test, packages/core/src/index.ts; packages/runtime/src/domains/mcp.ts (imports and re-exports the resolver; behaviour unchanged); packages/services/service-knowledge/src/knowledge-affinity.ts (new), packages/services/service-knowledge/src/__tests__/affinity-38503.test.ts (new), packages/services/service-knowledge/src/knowledge-service.ts, packages/services/service-knowledge/src/knowledge-source-admission.ts, packages/services/service-knowledge/src/testing.ts if needed; content/docs/ai/knowledge-rag.mdx, content/docs/protocol/knowledge.mdx; .changeset/38503-knowledge-affinity.md. Not packages/lint/** (PR 2), not skills/** (Skills-docs: follow-up owed for skills/objectstack-ai/SKILL.md) (stop on breach; explain in the report)
    Container & model: M, mode:thread, model: default (spec/contract cards build at default tier; a CONTRACT_REVIEW_TIER L2 follows), effort: high; the maintainer-supplied AI gateway key (from the environment, never printed) is used for embeddings only — no chat or LLM calls (maintainer ruling 「api key 只是给你生成向量用的」); any arm needing a live LLM is NOT MEASURED by ruling
    Clause-②: yes — a new published key on knowledge_source
    Metadata-protocol: added
    Responsibility: n/a — not a defect card
    Thread-read: 7252145063
    Premise: holds (rulings: #38412 decision and the ADR-0161 dated note of #38502 fix the key's shape; #38564 merged at 2026-11-29T12:14Z)
    Serial constraints cleared: check-handover --inflight at 2026-11-29T12:40Z names #38529 (read-only measurement, no file), #37087 and #36496 (they regenerate the same translation generated files: regenerated outputs, resolved by the os-regen merge order), and the lint holders #38537 / #35143 / #37766 (lint left to PR 2); #38369 PR 2 (claim of this round) shares knowledge-service.ts and the two docs pages and goes first (p2): this branch merges main after it lands, and runs overlap-check.mjs before each push. #38504 (expand siblings) waits for this PR.

  8. objectstack-fleet commented on Nov 29, 2026

    @objectstack-fleet
    ContributorAuthor

    repo:objectstack#1 · zhuangjianguo · session_01QsR2jTsdScTh3o2fSjbxSz

    2026-11-29T14:38Z · Claim amendment to 7256166933: admits one docs page that the census gate reds once the caller-identity resolver moves to core; nothing else changes.

    Claim: PM loop round 3 (amendment of 7256166933)
    Session: session_01QsR2jTsdScTh3o2fSjbxSz
    Thread session: session_01QsR2jSArETHHmJzkH5368W
    Account: zhuangjianguo
    Branch: claude/project-thread-ku5ipy
    Worktree: objectstack-issue-38503
    Domain: domain:server
    Seat: repo:objectstack#1
    Area: o1-know
    File surface (PR 1): packages/spec/src/ai/knowledge-source.zod.ts, packages/spec/src/ai/knowledge-source.test.ts, packages/spec/src/ai/knowledge-source.metadata-form.ts (+ .metadata-form.test.ts), packages/spec/src/contracts/knowledge-service.ts (jsdoc); the regenerated packages/spec/authorable-surface/ai.json, packages/spec/dropped-refinements.baseline.json, packages/spec/liveness/knowledge_source.json, packages/spec/liveness/state-counts/knowledge_source.md, content/docs/references/ai/knowledge-source.mdx, packages/platform-objects/src/apps/translations/*.metadata-forms.generated.ts, packages/platform-objects/src/apps/translations/*.source-hashes.generated.ts and the count pin in object-lifecycle-panel-echo-decisions.test.ts; packages/core/src/caller-identity.ts (new; the #38363 resolver moves here) + its test, packages/core/src/index.ts; packages/runtime/src/domains/mcp.ts (imports and re-exports the resolver; behaviour unchanged); packages/services/service-knowledge/src/knowledge-affinity.ts (new), packages/services/service-knowledge/src/__tests__/affinity-38503.test.ts (new), packages/services/service-knowledge/src/knowledge-service.ts, packages/services/service-knowledge/src/knowledge-source-admission.ts, packages/services/service-knowledge/src/testing.ts if needed; content/docs/ai/knowledge-rag.mdx, content/docs/protocol/knowledge.mdx; .changeset/38503-knowledge-affinity.md. Not packages/lint/** (PR 2), not skills/** (Skills-docs: follow-up owed for skills/objectstack-ai/SKILL.md) (stop on breach; explain in the report)
    Container & model: M, mode:thread, model: default (spec/contract cards build at default tier; a CONTRACT_REVIEW_TIER L2 follows), effort: high; the maintainer-supplied AI gateway key (from the environment, never printed) is used for embeddings only — no chat or LLM calls (maintainer ruling 「api key 只是给你生成向量用的」); any arm needing a live LLM is NOT MEASURED by ruling
    Clause-②: yes — a new published key on knowledge_source
    Metadata-protocol: added
    Responsibility: n/a — not a defect card
    Thread-read: 7252145063
    Premise: holds (rulings: #38412 decision and the ADR-0161 dated note of #38502 fix the key's shape; #38564 merged at 2026-11-29T12:14Z)
    Serial constraints cleared: check-handover --inflight at 2026-11-29T12:40Z names #38529 (read-only measurement, no file), #37087 and #36496 (they regenerate the same translation generated files: regenerated outputs, resolved by the os-regen merge order), and the lint holders #38537 / #35143 / #37766 (lint left to PR 2); #38369 PR 2 (claim of this round) shares knowledge-service.ts and the two docs pages and goes first (p2): this branch merges main after it lands, and runs overlap-check.mjs before each push. #38504 (expand siblings) waits for this PR.

    File surface: File surface (PR 1): packages/spec/src/ai/knowledge-source.zod.ts, packages/spec/src/ai/knowledge-source.test.ts, packages/spec/src/ai/knowledge-source.metadata-form.ts (+ .metadata-form.test.ts), packages/spec/src/contracts/knowledge-service.ts (jsdoc); the regenerated packages/spec/authorable-surface/ai.json, packages/spec/dropped-refinements.baseline.json, packages/spec/liveness/knowledge_source.json, packages/spec/liveness/state-counts/knowledge_source.md, content/docs/references/ai/knowledge-source.mdx, packages/platform-objects/src/apps/translations/*.metadata-forms.generated.ts, packages/platform-objects/src/apps/translations/*.source-hashes.generated.ts and the count pin in object-lifecycle-panel-echo-decisions.test.ts; packages/core/src/caller-identity.ts (new; the #38363 resolver moves here) + its test, packages/core/src/index.ts; packages/runtime/src/domains/mcp.ts (imports and re-exports the resolver; behaviour unchanged); packages/services/service-knowledge/src/knowledge-affinity.ts (new), packages/services/service-knowledge/src/__tests__/affinity-38503.test.ts (new), packages/services/service-knowledge/src/knowledge-service.ts, packages/services/service-knowledge/src/knowledge-source-admission.ts, packages/services/service-knowledge/src/testing.ts if needed; content/docs/ai/knowledge-rag.mdx, content/docs/protocol/knowledge.mdx; .changeset/38503-knowledge-affinity.md. Not packages/lint/** (PR 2), not skills/** (Skills-docs: follow-up owed for skills/objectstack-ai/SKILL.md) Plus content/docs/permissions/system-context.mdx (census row 46a, which the moved caller-identity resolver reds) (stop on breach; explain in the report)

  9. 12 remaining items

  10. added
    pm:queue
    and removed
    pm:dispatched
    on Nov 30, 2026
  11. objectstack-fleet commented on Dec 1, 2026

    @objectstack-fleet
    ContributorAuthor

    triage@os-warren · os-warren · session_01JQwxbZzZ2f5mzcvJbRrRNZ

    Grade raised: priority:p3 → priority:p2 · 2026-12-01T12:53Z

  12. added
    priority:p2
    and removed on Dec 1, 2026
  13. objectstack-fleet commented on Dec 2, 2026

    @objectstack-fleet
    ContributorAuthor

    repo:objectstack@os-support-ai · os-support-ai · session_01WGufzhPdWmTd47Fi2bKYZS

    Claim: card thread of seat repo:objectstack@os-support-ai (PR 2 of #38503; the card was returned to the queue by seat repo:objectstack#3, 7282353486, and graded p2 by triage, 7311816488)
    Session: session_01WGufzhPdWmTd47Fi2bKYZS
    Thread session: session_01WGufzfW9cn6HikHhefGc4Q
    Account: os-support-ai
    Branch: claude/project-thread-kg60zd
    Domain: domain:server
    Seat: repo:objectstack@os-support-ai
    File surface: packages/lint/src/validate-knowledge-source.ts, packages/lint/src/validate-knowledge-source.affinity.test.ts (new), packages/lint/src/rule-explanations/knowledge-source.ts, packages/lint/src/rule-explanations.ts, packages/lint/src/index.ts, content/docs/protocol/knowledge.mdx, content/docs/ai/knowledge-rag.mdx (the sentence on refusing a field that does not point at the caller's object widens to os validate and the publish gate), .changeset/38503-validate-affinity-target.md. Stop on breach; explain in the report.
    Container & model: M, mode:card-thread, model: TIER_DEFAULT (dispatch-gates --tier on the surface prints no MANDATORY line), effort: high
    Clause-②: no
    Metadata-protocol: none — as the #38537 documentBy precedent's changeset.
    Responsibility: n/a — feature card, PR 2
    Premise: holds on main 363c967, narrowed from the card body. PR 1 (#38606: the key, ordering, resolver move, docs) merged 2026-11-30 after contract review PASS 7259099085 and ACCEPT 7265045628; the three-arm comparison was run there and the maintainer ruled it needs no further comparison (seat answer 7257868078). What remains is PR 2 as 7265064924 and 7280501078 name it: an os validate / publish-gate rule that refuses an affinity entry whose field does not point at the object its caller names (sys_user or sys_business_unit), mirroring the save door's refusal text and the #38537 documentBy precedent. No such lint rule exists today.
    Prior rulings read: 7251603512 on #38412 (A-lean); the ADR-0161 dated note of 2026-11-29 (PR #38511); seat answers 7257868078.
    Serial constraints cleared: check-handover.mjs --inflight --card=38503 meets only the .changeset/*.md globs of #38939, #38940 and #38941, whose PRs have merged; a uniquely named changeset cannot collide. Out of scope: who may read business units (#38515).

  14. added
    pm:dispatched
    and removed
    pm:queue
    on Dec 2, 2026
  15. objectstack-fleet commented on Dec 2, 2026

    @objectstack-fleet
    ContributorAuthor

    repo:objectstack@os-support-ai · os-support-ai · session_01WGufzfW9cn6HikHhefGc4Q
    os-dev-report

    PR 2 of 2 for this card is open: #39026, reported 2026-12-02T03:47Z.

    {
      "issue": 38503,
      "piece": "PR 2 of 2 (the os validate / publish-gate half; PR 1 #38606 merged)",
      "status": "done",
      "branch": "claude/project-thread-kg60zd",
      "pr": "https://github.com/objectstack-ai/objectstack/pull/39026",
      "head": "9161bc08a549769324653ae0e716e95a0150fd79",
      "claim": "7333581918",
      "session": "session_01WGufzfW9cn6HikHhefGc4Q",
      "premise_still_valid": true,
      "declarations": { "Clause-②": "no", "Metadata-protocol": "none" },
      "container": { "model": "default tier (served model matches the claim)", "effort": "high" },
      "summary": "New lint rule knowledge-source-affinity-field-not-caller-target (error) in validateKnowledgeSource: an affinity entry whose field does not point at sys_user (caller user, a user field included) or sys_business_unit (caller business_unit) is refused in os validate / build / lint and at the runtime publish gate, with the save door's sentence split at its fix. Same scope as the save door: only a field metadataFields lists and the object declares. os explain entry, barrel export, the two docs sentences (save only -> save, os validate, publish gate) and a lint patch changeset.",
      "tests": "new validate-knowledge-source.affinity.test.ts 18/18; ablation (rule admits everything) reds 9/18, restored from commit b01aa19a; pnpm --filter @objectstack/lint test at b01aa19a: 10299 passed, 5 skipped, 1 failed (covers > 60 chars) fixed in 9161bc08, that file 9/9; lint typecheck 0",
      "gates": "dispatch-gates --commands at 9161bc08: 96 commands, 92 exit 0; NOT MEASURED -> CI: check:dual-build-cjs-loads, check:lean-entry-closure, spec check:skill-examples (prerequisite: built output outside the lint closure), check-plugin-teardown-shape --self-test (fixture commit unreachable in shallow clone), check:query-options-erasure and check:type-check-debt (240 s local cap). PR check-runs not yet concluded.",
      "mcp_calls": "0",
      "api_writes": "2 - fleet-write relay pr_create (+ assign os-support-ai) and this report comment",
      "classifier_refusals": [],
      "open_questions": [],
      "security_findings": "none",
      "out_of_scope_findings": [],
      "owed": ["landing waits for #39025 (closed-ceremony-text ENOBUFS ejects new files), then a merge of main", "L1 by osa-L1-a; no contract-review face"]
    }
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:p2

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions