Skip to content

fix(lint): os validate and the publish gate refuse an affinity field that does not point at its caller fact's object - #39026

Merged
objectstack-fleet[bot] merged 4 commits into
mainfrom
claude/project-thread-kg60zd
Dec 2, 2026
Merged

objectstack-fleet[bot] merged 4 commits into
mainfrom
claude/project-thread-kg60zd

Conversation

@objectstack-fleet

@objectstack-fleet objectstack-fleet Bot commented Dec 2, 2026 •

Copy link
Copy Markdown
Contributor

Requested by Yibo Wang · project thread

Fixes #38503

Clause-②: no
Metadata-protocol: none

维护者速读

  • 用户能看到什么变化:写应用的人在命令行校验或发布时,知识源的「按提问人排序」条目如果填了一个不指向用户或业务单元的字段,现在当场报错并告诉怎么改;以前只有在界面或接口里保存时才拦。
  • 为什么做:按提问人排序那张卡的第二部分(第一部分已合并),让随应用包发布的知识源和保存时走同一条规则。
  • 出错会怎样:只多报一种错误;规则写错的话,合法的排序条目会被拦下无法发布,撤回这个合并即可恢复。
  • 要你做什么:无。

What changes

PR 2 of 2 for #38503. PR 1 (#38606, merged) added source.affinity and the save door's refusal of an entry whose field does not point at the object its caller names (affinityTargetRefusalText in @objectstack/service-knowledge). That door judges only a source written through the metadata API. This PR adds the same verdict where a source a package ships or code registers is judged:

  • packages/lint/src/validate-knowledge-source.ts: new rule knowledge-source-affinity-field-not-caller-target (error), in validateKnowledgeSource, so it runs in os validate, os build, os lint and at the runtime publish gate. The target is read through the spec's one answer for a field's target (referenceTargetOf, so a user field points at sys_user), compared with sys_user for caller: 'user' and sys_business_unit for caller: 'business_unit'. Same scope as the save door: only a field that metadataFields lists (otherwise the parse refuses it) and the object declares (a missing field is knowledge-source-field-unknown, once; a system column the platform adds is not judged). The message and hint are the save door's sentence, split at its fix; lint cannot import a runtime service, so the predicate is composed here from the same spec function, as knowledge-source-document-by-not-parent-link is.
  • packages/lint/src/rule-explanations/knowledge-source.ts, rule-explanations.ts, index.ts: the os explain entry and the barrel export.
  • content/docs/protocol/knowledge.mdx, content/docs/ai/knowledge-rag.mdx: the sentence "Saving a source also refuses a field that does not point at the object its caller names" was only true of the save; it now names the save, os validate and the publish gate, and the rule id (ADR-0161 K2: docs move with the code).
  • .changeset/38503-validate-affinity-target.md: @objectstack/lint patch.

Clause-②: no / Metadata-protocol: none, as the claim (7333581918) and the documentBy precedent changeset declare: the save door already refuses this entry, and the key itself is new in this release line, so no released accept set narrows. No packages/spec/src change, so no contract-review face.

The card's measured three-arm comparison was taken on PR 1 (record in #38606's body: arm 2 82.6%, arm 3 86.7%, run-to-run 79.5–84.1 vs 86.4–87.5) and the maintainer ruled it needs no comparison (seat answer 7257868078 on #38503). This PR changes no ordering.

Tests

  • New packages/lint/src/validate-knowledge-source.affinity.test.ts (18 tests): six refusals at os validate (user caller on a lookup to another object, on a text field, on a lookup to the units; a unit boost on a user field; nearest on a lookup to sys_user; nearest on a lookup with no target), each pinning rule, severity, path, where, the field, what it points at and the fix; controls for every admitted pairing and for a source without affinity; per-index reporting; unlisted field left to the parse; unknown field reported once; system columns not judged; an unadmitted caller left to the parse; a fields array; the publish door refusing with the words os validate prints, and its control; the barrel export and os explain.
  • Ablation at b01aa19: the rule made to admit everything (target === expected || true) reds 9 of the 18; restored from the commit.
  • pnpm --filter @objectstack/lint test: 260 files, 10,299 passed, 5 skipped, 1 failed (covers over 60 characters), fixed in 9161bc0; that file re-run: 9/9. pnpm --filter @objectstack/lint typecheck: 0.

Acceptance notes

  • none

Verification

Read first: validate-knowledge-source.ts (affinityTargetRefusal and the loop at the end of validateKnowledgeSource), then the test's REFUSED table.

Two minutes: pnpm --filter @objectstack/lint exec vitest run --maxWorkers=2 src/validate-knowledge-source.affinity.test.ts answers 18 passed.

Local derived gates (dispatch-gates --commands)

At 9161bc0: 96 derived commands; 92 exit 0 (the two lint doc gates after building @objectstack/lint, which they read compiled). NOT MEASURED, left to CI: check:dual-build-cjs-loads, check:lean-entry-closure and @objectstack/spec check:skill-examples (PREREQUISITE NOT MET: they read built output of packages outside the lint closure); check-plugin-teardown-shape.mjs --self-test (checker-health only; its fixture commit is unreachable from this shallow clone); check:query-options-erasure and check:type-check-debt (stopped at a 240 s local cap).


Generated by Claude Code

🤖 Generated with Claude Code

https://claude.ai/code/session_01WGufzfW9cn6HikHhefGc4Q

… that does not point at its caller fact's object

Claude-Session: https://claude.ai/code/session_01WGufzfW9cn6HikHhefGc4Q
Co-authored-by: Claude <noreply@anthropic.com>
@github-actions github-actions Bot added size/m documentation Improvements or additions to documentation tests tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface labels Dec 2, 2026
@github-actions

github-actions Bot commented Dec 2, 2026 •

Copy link
Copy Markdown
Contributor

📓 Docs Drift Check

This PR changes 1 package(s): @objectstack/lint, touching 9 documentable anchor(s). ⚠️ 1 changed file(s) yielded no anchor (packages/lint/src/index.ts), so the pages documenting them are NOT COVERED by this run — this is not a clean bill of health for those files.

14 hand-written doc(s) NAME something this change touched and may need an implementation-accuracy re-verification:

  • content/docs/ai/knowledge-rag.mdx (via business_unit (symbol, a field of const object AFFINITY_CALLER_TARGETS), business_unit (literal, a string literal in AFFINITY_CALLER_TARGETS; a string literal in affinityTargetRefusal), sys_business_unit (literal, a string literal in affinityTargetRefusal; a string literal in business_unit))
  • content/docs/automation/approvals.mdx (via sys_business_unit (literal, a string literal in affinityTargetRefusal; a string literal in business_unit))
  • content/docs/automation/queues-and-assignment-rules.mdx (via business_unit (symbol, a field of const object AFFINITY_CALLER_TARGETS), business_unit (literal, a string literal in AFFINITY_CALLER_TARGETS; a string literal in affinityTargetRefusal))
  • content/docs/data-modeling/objects.mdx (via business_unit (symbol, a field of const object AFFINITY_CALLER_TARGETS), business_unit (literal, a string literal in AFFINITY_CALLER_TARGETS; a string literal in affinityTargetRefusal))
  • content/docs/deployment/validating-metadata.mdx (via business_unit (symbol, a field of const object AFFINITY_CALLER_TARGETS), business_unit (literal, a string literal in AFFINITY_CALLER_TARGETS; a string literal in affinityTargetRefusal))
  • content/docs/permissions/administrator-guide.mdx (via sys_business_unit (literal, a string literal in affinityTargetRefusal; a string literal in business_unit))
  • content/docs/permissions/authorization.mdx (via sys_business_unit (literal, a string literal in affinityTargetRefusal; a string literal in business_unit))
  • content/docs/permissions/delegated-administration.mdx (via sys_business_unit (literal, a string literal in affinityTargetRefusal; a string literal in business_unit))
  • content/docs/permissions/index.mdx (via business_unit (symbol, a field of const object AFFINITY_CALLER_TARGETS), business_unit (literal, a string literal in AFFINITY_CALLER_TARGETS; a string literal in affinityTargetRefusal))
  • content/docs/permissions/permissions-matrix.mdx (via business_unit (symbol, a field of const object AFFINITY_CALLER_TARGETS), business_unit (literal, a string literal in AFFINITY_CALLER_TARGETS; a string literal in affinityTargetRefusal), sys_business_unit (literal, a string literal in affinityTargetRefusal; a string literal in business_unit))
  • content/docs/permissions/positions.mdx (via sys_business_unit (literal, a string literal in affinityTargetRefusal; a string literal in business_unit))
  • content/docs/permissions/sharing-rules.mdx (via business_unit (symbol, a field of const object AFFINITY_CALLER_TARGETS), business_unit (literal, a string literal in AFFINITY_CALLER_TARGETS; a string literal in affinityTargetRefusal), sys_business_unit (literal, a string literal in affinityTargetRefusal; a string literal in business_unit))
  • content/docs/protocol/knowledge.mdx (via business_unit (symbol, a field of const object AFFINITY_CALLER_TARGETS), business_unit (literal, a string literal in AFFINITY_CALLER_TARGETS; a string literal in affinityTargetRefusal), sys_business_unit (literal, a string literal in affinityTargetRefusal; a string literal in business_unit))
  • content/docs/protocol/objectql/security.mdx (via business_unit (symbol, a field of const object AFFINITY_CALLER_TARGETS), business_unit (literal, a string literal in AFFINITY_CALLER_TARGETS; a string literal in affinityTargetRefusal), sys_business_unit (literal, a string literal in affinityTargetRefusal; a string literal in business_unit))

⛔ 6 release-owned page(s) also name something this change touched. These are read-only:

  • content/docs/releases/implementation-status.mdx (via business_unit (symbol, a field of const object AFFINITY_CALLER_TARGETS), business_unit (literal, a string literal in AFFINITY_CALLER_TARGETS; a string literal in affinityTargetRefusal))
  • content/docs/releases/v13.mdx (via sys_business_unit (literal, a string literal in affinityTargetRefusal; a string literal in business_unit))
  • content/docs/releases/v16.mdx (via sys_business_unit (literal, a string literal in affinityTargetRefusal; a string literal in business_unit))
  • content/docs/releases/v17/17-0.mdx (via business_unit (symbol, a field of const object AFFINITY_CALLER_TARGETS), business_unit (literal, a string literal in AFFINITY_CALLER_TARGETS; a string literal in affinityTargetRefusal))
  • content/docs/releases/v17/17-4.mdx (via sys_business_unit (literal, a string literal in affinityTargetRefusal; a string literal in business_unit))
  • content/docs/releases/v18/18-3.mdx (via sys_business_unit (literal, a string literal in affinityTargetRefusal; a string literal in business_unit))

content/docs/releases/ is RELEASE-OWNED (AGENTS.md "Documentation Guardrails"): release
notes are written centrally at release time, and a code PR that edits them is the exact PR
that guardrail exists to stop. They are still audited — read-only. If one of them is actually
wrong, file an issue or open a dedicated docs-only PR; do not edit it here.

What this run could not see
  • 1 changed file(s) yielded no anchor (packages/lint/src/index.ts) — pages documenting those are invisible to this run
  • 1 anchor(s) matched too much of the corpus to be a work list: sys_user (literal, 60 pages)
  • 4 name(s) were too generic to anchor anything (single lowercase words)
  • the SDK route bridge reached 71 of 254 client-bound route-ledger rows — the other 183 have no registrar path: tail to select them, so pages documenting THEIR client methods cannot appear above, on this or any run. Of those 183: 0 are remediable by widening that discovery convention (an in-repo file declares the path; the convention did not scan it); 59 are structural — on a ledger where NOT ONE row is declared in-repo, so no discovery change reaches them at any price; 124 are undecided (no in-repo declaration, on a ledger that has other in-repo registrars — absence and an unreadable spelling are not distinguishable here). The rows themselves: node scripts/docs-audit/affected-docs.mjs --bridge-coverage
  • a page that states a rule by its inputs shares no identifier with the emitter that implements the rule, so an emitter-only diff cannot list it — not on this run and not on any run. Measured on fix(driver-sql): emit varchar(maxLength) for a text field a declared index keys on #11430: content/docs/protocol/objectql/types.mdx documents the text-family column mapping by the ObjectQL type names it maps FROM (text / textarea / html) while the diff changed createColumn; it went unlisted, and it was the page that diff falsified, in four places. No shared token exists to detect this on, so a rule your change carries has to be re-read by hand in the pages that restate it.
  • a key NAME is not a key, so the hand re-read the line above prescribes can land on the wrong schema. The same spelling is authorable on one governed type and a [REMOVED] tombstone on another for each of active, aria, joins, objects, template, tools and version (censused on [finding] tools is a key on BOTH AgentSchema (tombstoned, dead) and SkillSchema (live, cloud-attested), so a name-based search attributes skill examples to the agent key — it produced a false stop-the-line alarm on PR #19059 #19093 over the liveness ledger's governed types, top-level keys); nothing in a search result distinguishes the two, so a grep hit on a LIVE example reads as evidence about the DEAD key. Measured on fix(spec): the agent.tools liveness row says dead — it claimed live on a key the schema tombstoned #19059: content/docs/ai/agents.mdx was reported as contradicting the agent.tools tombstone over its tools: example at :161, which is inside the defineSkill({ block opened at :155 — the page was already correct. Settle ownership by PARSING the value against both schemas, never by the name: that literal PASSES SkillSchema, and as an AgentSchema it FAILS at tools with the tombstone prescription. ⛔ These names are not the whole class — a key retired through a .strict() guidance map leaves no tombstone in the walked shape and none of them here (tool.category, live as AIToolDefinition.category).

Coarse fallback — 4 page(s) merely mention a changed package (the pre-#9192 predicate, kept for the deliberately-wide backstop): node scripts/docs-audit/affected-docs.mjs --json c748e7dfd647ca9b4e679d59425f358c9ff84b04 → packageMentionDocs.

Which tree this was computed on

This run read content/docs from 20e2d7c870505d2966cadc306786bebaded70c03 — the merge of head 4a2868656e2ec5ff6e51812b82e0d3f20c761b5d into base c748e7dfd647ca9b4e679d59425f358c9ff84b04, which is what actions/checkout gives a pull_request run. Not the PR head.

A worktree cut from an older main holds a different content/docs, so re-deriving there can legitimately return a different list — that is a different tree, not a wrong row. To answer on the same tree:

# while this PR is open — GitHub drops the merge commit once it closes
git fetch origin 20e2d7c870505d2966cadc306786bebaded70c03 && git checkout 20e2d7c870505d2966cadc306786bebaded70c03
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin c748e7dfd647ca9b4e679d59425f358c9ff84b04 4a2868656e2ec5ff6e51812b82e0d3f20c761b5d && git checkout -B drift-repro c748e7dfd647ca9b4e679d59425f358c9ff84b04 && git merge --no-ff 4a2868656e2ec5ff6e51812b82e0d3f20c761b5d

node scripts/docs-audit/affected-docs.mjs --json c748e7dfd647ca9b4e679d59425f358c9ff84b04

⚠️ That checkout carried uncommitted changes, so the commit above does not fully identify what was read.

Advisory only, and a precision-first one (#9192): a page is listed because it names a
symbol, wire route or SDK method this diff touched — not because it mentions a changed
package. Each row says which anchor put it there, so a wrong row is reportable rather than
merely annoying. To re-verify, run the docs-accuracy-audit workflow scoped to these files:
node scripts/docs-audit/affected-docs.mjs c748e7dfd647ca9b4e679d59425f358c9ff84b04 → pass the list as
args.docs, on the commit named under Which tree this was computed on.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

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

2026-12-02T03:54Z · Lint · repo & tooling gates is red at head 9161bc0 on one gate only: check:closed-ceremony-text dies with spawnSync git ENOBUFS in trackedFiles (scripts/check-closed-ceremony-text.mjs:82), inside its own --self-test, before it judges any file (job 143201108773). That is #39025: the script's git ls-files read outgrows the 1 MiB default buffer on any PR that adds a path under packages/, content/docs/ or .changeset/, and this PR adds a test file and a changeset. Not this diff's defect; no change here. This PR merges main once #39025's fix lands, and the gate re-runs then. Every other gate step in the job passed.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

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

L1 review · PR #39026 (#38503) · head 9161bc0 · 2026-12-02T04:23Z

ACCEPT on code at 9161bc08a549769324653ae0e716e95a0150fd79. It lands only on a merge-of-main head after #39025, with my delta on that head.

  • Checks: 62 success, 14 expected skips, 0 pending, and 2 failed. The two failures are Lint · repo & tooling gates (job 143201108773) and its roll-up Lint & Repo Gates. Both die at check:closed-ceremony-text with spawnSync git ENOBUFS, the fleet-wide red that repo gates: check-closed-ceremony-text dies with ENOBUFS (git ls-files output past the 1 MiB default buffer) — every PR that adds a path under packages/, content/docs/ or .changeset/ now fails Lint & Repo Gates #39025 fixes, not anything in this diff. That lane stops at its first failure, so the gates after it did not run on this head. They must read green on the merge-of-main head before landing.
  • Face: Fixes #38503 is right, because PR 1 (feat(knowledge): a knowledge source orders its hits for the person asking (source.affinity) #38606) merged and this is PR 2 as the claim (7333581918) narrows it. The PR is not governed, at +369/−4. Clause-②: no holds: the lint package gains one exported rule-id constant next to its siblings, the same shape as every earlier rule. Metadata-protocol: none follows the documentBy precedent (service-knowledge: a knowledge source declares its document unit (source.documentBy); record search groups by it by default #38537) that the claim names. The save door already refused this entry, and this rule extends the same refusal to os validate and the publish gate.
  • validate-knowledge-source.ts: affinityTargetRefusal reproduces the save door's affinityTargetRefusalText (service-knowledge knowledge-source-admission.ts) word for word, split into message and hint. It resolves targets through the same referenceTargetOf, so a user field counts as sys_user. It judges only a field that metadataFields lists and the object declares. Unlisted fields go to the parse, unknown members go to knowledge-source-field-unknown, and system columns are skipped, as at the door.
  • Tests: refusal per case with the fix, controls for sound fields and for no affinity, per-index reporting, the unlisted, unknown, system-column and bad-caller cases, a fields array, the publish gate with the same words, the barrel, and os explain.
  • Changeset and both docs pages read sentence by sentence: true to the tree.
  • Nit, no action: the refusal sentence exists in two packages with no pin holding them equal. A future edit to one can drift. A follow-up could share it or pin the parity.

Next: once #39025 merges, the card thread merges main and sends the green head; I post the delta and the zone lands.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

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

L1 delta · PR #39026 (#38503) · head 4a28686 · 2026-12-02T05:26Z

ACCEPT, on head 4a2868656e2ec5ff6e51812b82e0d3f20c761b5d.

  • Pure merge. The parents are 9161bc08, the code ACCEPTed in my L1 on that head, and c748e7df, main at the fix(scripts): tree-scaled git listings in two gate scripts read past the 1 MiB default buffer #39027 merge. git merge-tree --write-tree gives tree 6b999dee, the same as 4a286865^{tree}. Nothing was resolved by hand, so the earlier L1 covers this head unchanged.
  • The gates the L1 could not read now pass. Lint & Repo Gates succeeds, check:closed-ceremony-text passes, and the gates after it in the tooling lane ran. Overall: 62 success, 12 expected skips, 0 failed, 0 pending, and mergeable_state is clean. l1-face is CLEAN.

Next: zone landing. The merge closes #38503.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

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

席位核对

ACCEPT — PR #39026 @ 4a2868656e (Fixes #38503, PR 2 of the card; card thread of seat os-support-ai, claim 7333581918).

  • Reviews adopted: L1 ACCEPT 7334867253 on the code, and the L1 delta 7335952838 on this head: a pure merge of main after fix(scripts): tree-scaled git listings in two gate scripts read past the 1 MiB default buffer #39027, with the tooling lane (which the earlier head never got past) now green. Clause-② no and no packages/spec/src path, so no contract-tier record is owed.
  • What lands: the lint rule knowledge-source-affinity-field-not-caller-target (error) refuses, at os validate, build, lint and the publish gate, an affinity entry whose field does not point at the object its caller names (sys_user or sys_business_unit), with the save door's sentence; plus its os explain entry and the two docs sentences. Metadata-protocol none, as the documentBy precedent.
  • Fixes #38503: PR 1 (feat(knowledge): a knowledge source orders its hits for the person asking (source.affinity) #38606) shipped the key and ordering; this is the last piece the card named.
  • Nit kept, not carded: the refusal sentence lives in both lint and service-knowledge with no parity pin (L1).

落地

reading value
check-governed-merges.mjs --pr 39026 NOT governed; 373 changed lines ≤ 3000
pr-state.mjs on 4a286865 62 success · 12 expected skip · 0 failed · 0 pending; mergeable_state clean
landing-k.mjs --pr 39026 K = 1 < 15
l1-face.mjs --pr 39026 CLEAN, 13 items read

State change: ready for review + auto-merge, by the owning seat; on merge it closes #38503.

@objectstack-fleet
objectstack-fleet Bot marked this pull request as ready for review December 2, 2026 05:28
@objectstack-fleet
objectstack-fleet Bot added this pull request to the merge queue Dec 2, 2026
Merged via the queue into main with commit 2595004 Dec 2, 2026
75 checks passed
@objectstack-fleet
objectstack-fleet Bot deleted the claude/project-thread-kg60zd branch December 2, 2026 05:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation size/m tests tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

2 participants