Skip to content

fix(lint)!: judge a tree field's dependsOn filter key like a lookup's - #38605

Merged
os-zhuang merged 2 commits into
mainfrom
claude/project-thread-ab6y6m
Nov 30, 2026
Merged

os-zhuang merged 2 commits into
mainfrom
claude/project-thread-ab6y6m

Conversation

@objectstack-fleet

@objectstack-fleet objectstack-fleet Bot commented Nov 29, 2026 •

Copy link
Copy Markdown
Contributor

Requested by Warren · project thread
Fixes #37936
Clause-②: no (narrowing)
Metadata-protocol: narrowed
Skills-docs: none — no published skill page teaches a dependsOn entry on a tree field, or a filter key computed on read

维护者速读

  • 用户能看到什么变化:搭建应用的人给树形(上下级)字段写依赖字段时,如果写错了名字,或者指向一个公式字段,校验和发布现在会直接拒绝并说明原因,不会等到导入数据时才发现每行都查找失败;普通查找字段原本就是这样检查的。
  • 为什么做:收口「导入按依赖字段限定查找范围」这一块的检查遗漏:导入对树形字段也按依赖字段限定,检查却只看了查找类字段,上一张修复这类问题的卡审核时留下了这个尾巴。
  • 出错会怎样:只影响写元数据时的检查,出错时最多是一条本该通过的配置被拒;三个仓库里实测没有任何树形字段写依赖字段,可以直接撤回。
  • 要你做什么:无

What changes

An import scopes a reference cell by the field's dependsOn entries on lookup, master_detail, user and tree fields (referenceScopeSources, packages/core/src/utils/import-coerce.ts:1055; the target comes from referenceTargetOf via buildFieldMetaMap, so these are the spec's REFERENCE_VALUE_TYPES). Rule object-field-ref-unknown judged the filter half of an entry (param, or the bare name) only on PICKER_FIELD_TYPES (lookup, master_detail, user), so on a tree field a filter key naming no field, or naming a formula, published clean and every import of the column failed its lookup. Route A as recorded on the card (comment 7232839355), with the seat's correction in the order: PICKER_FIELD_TYPES is untouched.

  1. Rule (packages/lint/src/validate-object-field-refs.ts). FieldNameSlot gains referenceTypes (the types on which a REFERENCE slot's target is judged; unset = PICKER_FIELD_TYPES) and treeSelfTarget. The dependsOn REFERENCE slot sets referenceTypes: DEPENDS_ON_SCOPED_TYPES = REFERENCE_VALUE_TYPES, imported from @objectstack/spec/data, never restated, and treeSelfTarget: true: a tree that names no reference is judged against its own object, the self-reference the registry stamps on it (materializeTreeSelfReferences), because the runtime save door passes the raw body. That is set on this one slot; graphObjectOf and every other graph rule are unchanged. lookupColumns and lookupFilters keep the picker set. The DEPENDS_ON_SCOPED_TYPES docblock records that the importer's IMPORT_REFERENCE_TYPES also admits the legacy reference spelling, which is inert (no target, so nothing is scoped). The module note and the os explain paragraph (rule-explanations.ts) say so.
  2. Spec describe (field.zod.ts, dependsOn): names every reference type it scopes and the import lookup, and says the key must be a stored field of the referenced object. Prose following the implementation (governing text: pm-dispatch SKILL.md 「未声明键随实现,文档随之」). Generated reference pages regenerated by check:generated --fix (4 files, one line each).
  3. Docs (content/docs/data-modeling/import-mappings.mdx): the check judges every field the import scopes, a tree with or without reference, so the case list is down to two: metadata stored before the check, and an os validate of a stack that does not hold both objects.
  4. ADR-0087 ledger: new semantic entry 19.lookup-depends-on-param-computed-field-refused-on-tree (the published lookup-depends-on-param-computed-field-refused entry is not edited).
  5. Changeset 37936-depends-on-filter-key-tree.md: @objectstack/lint minor, @objectstack/spec patch, fix(lint)!, adr-0087: registered, following the precedent changeset 34562-record-structural-lint.md.

Read first, by risk:

  1. validate-object-field-refs.ts targetOn(slot) in the field-level loop: the only behaviour change (type gate, then meta.reference, then the tree self-target on the opted-in slot).
  2. The dependsOn REFERENCE slot entry in FIELD_NAME_SLOTS (referenceTypes, treeSelfTarget).
  3. field.zod.ts dependsOn describe.

Tests

validate-object-field-refs.test.ts, in the dependsOn block, seven new cases: a tree field's formula filter key refused (object arm at .param, and the bare name); a misspelt key refused and a stored one passing; lookupColumns/lookupFilters on a tree field still unjudged; the runtime publish gate refuses the tree case; a tree that names no reference judged against its own object on the os validate path (formula, misspelt, stored) and refused at the runtime publish gate on the raw body; a legacy reference field stays unjudged, and FieldSchema refuses that type.

Ablations at the final head, each line removed on disk, then restored (155/155): referenceTypes: DEPENDS_ON_SCOPED_TYPES → 5 failed (every tree refusal case); treeSelfTarget: true → 2 failed (the two reference-less tree cases).

Acceptance notes

  • Producers measured (route A's breakage): tree fields with dependsOn = 0 in objectstack (origin/main 75108ea: field-zoo f_tree, plus the skill sample), hotcrm (62c5e24: 0 tree fields; src/psa/views/project_task.view.ts:71 is a tree list view, and .claude/skills/objectstack-data/rules/relationships.md:147 a vendored skill sample) and cloud (c9f775d: 0). Legacy type: 'reference' fields: 0 in all three.
  • lookupColumns and lookupFilters on a tree field stay unjudged: their slots keep PICKER_FIELD_TYPES, while the console renders a tree with the lookup widget that reads them. Out of this card's route; the seat files the follow-up (with the PICKER_FIELD_TYPES / "types that render the picker" wording in rule-explanations.ts).
  • Legacy reference: in the importer's IMPORT_REFERENCE_TYPES, but buildFieldMetaMap takes the target from referenceTargetOf, which answers none for it, so no such cell is scoped; the rule does not judge it either, and FieldSchema refuses the spelling (suggesting lookup).
  • The describe also names user, which the importer and the lint already scope and judge; the earlier text named lookup/master_detail only.
  • Rework round 1 (L1 REWORK + contract-review L2 FAIL on ff55ba60): items 1 to 5 of the seat's order are in 5004e80785.

Verification

Two-minute check: pnpm --filter @objectstack/lint exec vitest run --maxWorkers=2 src/validate-object-field-refs.test.ts -t "tree field" (after building @objectstack/spec): 6 cases pass; delete the referenceTypes: DEPENDS_ON_SCOPED_TYPES, line and 5 fail.

Local gates and tests (head 5004e80)

All at head 5004e80785, each exit captured before any pipe.

  • Tests: pnpm --filter @objectstack/lint exec vitest run --maxWorkers=2 → Test Files 246 passed (246), Tests 9965 passed (9965); the rule file alone 155/155. @objectstack/spec build and pnpm --filter @objectstack/lint typecheck → VERDICT command-exit 0.
  • Ablations (each line removed on disk, then restored to 155/155): referenceTypes: DEPENDS_ON_SCOPED_TYPES → Tests 5 failed | 150 passed (155); treeSelfTarget: true → Tests 2 failed | 153 passed (155).
  • Generated: pnpm --filter @objectstack/spec check:generated → exit 0 (14 of 14 fresh).
  • Derived gates: node scripts/pm/dispatch-gates.mjs --commands --repo objectstack-ai/objectstack → 122 families, all run, all exit 0 (scenarios and studio dist built first; full clone). --ran with exit codes: 122 derived, 122 run, 0 NOT-MEASURED (a derived zero).
  • check:nul-bytes exit 0. overlap-check.mjs → VERDICT clean exit 0.
  • Full dogfood (the (narrowing) arm), at this head: dependency closure build, then pnpm --filter @objectstack/dogfood test under the lock → VERDICT command-exit 0 · Test Files 495 passed, 3 skipped (498) · Tests 4187 passed, 68 skipped (4255).
  • CI at 5004e80785 (pr-state.mjs): 62 success · 10 expected skip · 0 unexpected skip · 0 failed · 0 pending; mergeable_state clean.

🤖 Generated with Claude Code

https://claude.ai/code/session_01JQwxbWsgwGTTtiWhh4xY9e

The importer scopes a reference cell by dependsOn on every type in
IMPORT_REFERENCE_TYPES, while object-field-ref-unknown judged the filter
half only on lookup, master_detail and user. The dependsOn REFERENCE slot
now takes its own type set, imported from @objectstack/spec/data, so a tree
field's filter key that names no field or a formula is refused at
authoring. lookupColumns and lookupFilters keep PICKER_FIELD_TYPES.

The dependsOn describe names every reference type it scopes, the
import-mappings page drops the tree case it no longer has, and the ADR-0087
ledger gains lookup-depends-on-param-computed-field-refused-on-tree.

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

github-actions Bot commented Nov 29, 2026 •

Copy link
Copy Markdown
Contributor

📓 Docs Drift Check

This PR changes 2 package(s): @objectstack/lint, @objectstack/spec, touching 8 documentable anchor(s). ⚠️ 2 changed file(s) yielded no anchor (packages/spec/docs/references/system/migration.md, packages/spec/docs/references/system/migration.part-2.md), so the pages documenting them are NOT COVERED by this run — this is not a clean bill of health for those files.

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

  • content/docs/concepts/metadata-driven.mdx (via FieldSchema (symbol, a top-level const))
  • content/docs/data-modeling/external-datasources.mdx (via FieldSchema (symbol, a top-level const))
  • content/docs/data-modeling/field-types.mdx (via FieldSchema (symbol, a top-level const))
  • content/docs/data-modeling/validation-rules.mdx (via FieldSchema (symbol, a top-level const))
  • content/docs/deployment/troubleshooting.mdx (via FieldSchema (symbol, a top-level const))
  • content/docs/deployment/validating-metadata.mdx (via FieldSchema (symbol, a top-level const))
  • content/docs/getting-started/quick-reference.mdx (via FieldSchema (symbol, a top-level const))
  • content/docs/kernel/contracts/data-engine.mdx (via FieldSchema (symbol, a top-level const))
  • content/docs/protocol/backward-compatibility.mdx (via FieldSchema (symbol, a top-level const))
  • content/docs/protocol/objectql/types.mdx (via FieldSchema (symbol, a top-level const))
  • content/docs/protocol/objectui/concept.mdx (via FieldSchema (symbol, a top-level const))

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

  • content/docs/releases/v17/17-0.mdx (via FieldSchema (symbol, a top-level const))
  • content/docs/releases/v17/17-1.mdx (via FieldSchema (symbol, a top-level const))
  • content/docs/releases/v18/18-3.mdx (via FieldSchema (symbol, a top-level const))
  • content/docs/releases/v18/18-4.mdx (via FieldSchema (symbol, a top-level const))

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
  • 2 changed file(s) yielded no anchor (packages/spec/docs/references/system/migration.md, packages/spec/docs/references/system/migration.part-2.md) — pages documenting those are invisible to this run
  • 4 name(s) were too generic to anchor anything (single lowercase words)
  • the SDK route bridge reached 69 of 252 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 — 182 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 0ba5e06ae735cff3fe387347df66b22b49a7dd41 → packageMentionDocs.

Which tree this was computed on

This run read content/docs from 61855c27d4d89128a661b0979046fdc7fb371067 — the merge of head 5004e80785a40f7db6b12c5584424f6d11418918 into base 0ba5e06ae735cff3fe387347df66b22b49a7dd41, 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 61855c27d4d89128a661b0979046fdc7fb371067 && git checkout 61855c27d4d89128a661b0979046fdc7fb371067
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin 0ba5e06ae735cff3fe387347df66b22b49a7dd41 5004e80785a40f7db6b12c5584424f6d11418918 && git checkout -B drift-repro 0ba5e06ae735cff3fe387347df66b22b49a7dd41 && git merge --no-ff 5004e80785a40f7db6b12c5584424f6d11418918

node scripts/docs-audit/affected-docs.mjs --json 0ba5e06ae735cff3fe387347df66b22b49a7dd41

⚠️ 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 0ba5e06ae735cff3fe387347df66b22b49a7dd41 → pass the list as
args.docs, on the commit named under Which tree this was computed on.

…gainst its own object

A tree that names no `reference` is a self-reference the registry stamps
(materializeTreeSelfReferences), but the runtime save door passes the raw
body, so the graph had no target and such a tree published clean. The
dependsOn REFERENCE slot now supplies the same self-target, for that slot
only.

The slot's set is REFERENCE_VALUE_TYPES, what the importer really resolves:
its IMPORT_REFERENCE_TYPES also admits the legacy `reference` spelling, but
buildFieldMetaMap takes the target from referenceTargetOf, which answers
none for it. The ledger entry, changeset and import-mappings page no longer
say the import scopes a legacy `reference` field.

Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JQwxbWsgwGTTtiWhh4xY9e
@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#2 · os-warren · session_01JQwxba2oTCUuCosPm6pkRu
2026-11-29T22:35Z · L2 record for PR #38605, round 2 (narrowing face).

Contract review

Served-tier: CONTRACT_REVIEW_TIER
Head-sha: 5004e80785a40f7db6b12c5584424f6d11418918
Local-runs: probe — vitest packages/lint/src/validate-object-field-refs.test.ts at the head with two ablations, to confirm the new rejection bites
Scope: packages/spec/src/data/field.zod.ts, packages/spec/src/migrations/entries/semantic/19.lookup-depends-on-param-computed-field-refused-on-tree.ts + packages/lint/src/validate-object-field-refs.ts, packages/lint/src/validate-object-field-refs.test.ts, packages/lint/src/rule-explanations.ts, content/docs/data-modeling/import-mappings.mdx, .changeset/37936-depends-on-filter-key-tree.md

① Derived judgments

  • The lint's judged set equals the types the importer has a target for: DEPENDS_ON_SCOPED_TYPES = REFERENCE_VALUE_TYPES (validate-object-field-refs.ts:477); the importer takes its target from referenceTargetOf (import-field-meta.ts:102), which answers only inside REFERENCE_VALUE_TYPES (field-value.zod.ts:219), and referenceScopeSources returns [] without meta.reference (import-coerce.ts:1057). Legacy reference is inert and is no longer claimed.
  • The filter key is read the same way on both sides (param ?? field, or the bare name): lint :666, importer import-field-meta.ts:118-131.
  • A reference-less tree's self-target is judged in the dependsOn slot only (treeSelfTarget at :670, targetOn :1074-1080); lookupColumns/lookupFilters slots (:613/:622/:635) and PICKER_FIELD_TYPES (:461) are untouched.
  • Tests bite: 155/155 at the head; dropping treeSelfTarget turns 2 red, dropping referenceTypes turns 5 red. Both doors are covered (validate-object-field-refs.test.ts:1304-1328; the save door reaches runRuntimeAuthoringRules via protocol-save.ts:1935-1945).

② Semver level

  • Narrowing correctly declared: title fix(lint)!; changeset @objectstack/lint minor + @objectstack/spec patch (precedent 34562-record-structural-lint.md); Clause-②: no (narrowing) and Metadata-protocol: narrowed in PR body and changeset; new semantic ledger entry with its adr-0087 marker; the published …-refused entry is not edited.

③ Boundary flags

  • No false rejection found: a stored key passes (tests :1283, :1317); first-party trees with dependsOn: 0. user behaviour unchanged. No new id materialisation or in-app join.
  • Not measured end to end: whether the import's getMetaItem().item (packages/rest/src/import-prepare.ts:693-699) carries the registry-stamped self-reference for a bare tree. If not, that path is over-strict (picker still reads the key), never a wrong target. Goes to the follow-up card.

④ Design judgment

  • The slot-local self-target fallback (:1076-1079) is a caller-side self-target that the referenceTargetOf docblock forbids (field-value.zod.ts:201-203); it was scoped to one slot by round 1's order. Nit, accepted; the follow-up card moves it into the object graph via materializeTreeSelfReferences.
  • Nits accepted: PICKER_FIELD_TYPES docblock wording (:453-459); one over-long ledger comment line; second commit subject lacks ! (the squash takes the PR title). No must-fix, no should-fix.

Implemented-by: claude/project-thread-ab6y6m
Reviewed-by: session_01JQwxba2oTCUuCosPm6pkRu

VERDICT: PASS

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#2 · os-warren · session_01JQwxba2oTCUuCosPm6pkRu
2026-11-29T22:36Z · L1 ACCEPT · Head-sha: 5004e80 · L2 PASS: comment 7263807289

速读

  • 树形字段的“依赖筛选”如果写错了筛选键,以前要到导入数据时才出问题,现在保存或检查元数据时就会直接指出来。
  • 这是一次收紧:原来能保存的错误写法现在会被拒绝,已登记为升级说明,正确写法不受影响。
  • 平台自带的应用里没有受影响的配置。
  • 要你做什么:发布冻结解除后批准合并本 PR(契约复核 PASS 见上方评论 7263807289,同一 head)。冻结期间保持 draft、不入队。

席位意见: ACCEPT。非受管面(0/11 路径),228 行;申报收窄 ⇒ 终局四件套含向维护者请审。

席位核对

  • 形态: open draft → main,标题 fix(lint)!,首行 Fixes #37936(N1 已由 docs(data-modeling): name what the lookup dependsOn formula check does not see on import #38125 落地,本 PR 交付余下的 N2)。Clause-②: no (narrowing) · Metadata-protocol: narrowed,正文与 changeset 一致。11 文件 +211/−17。l1-face 第 2 轮仅旗 dogfood 欠读数,已由 dev 报告 7263780310 补上(全量 dogfood 在本 head VERDICT 0)。
  • 前提实测: 导入只在 referenceTargetOf 有答案的类型上按 dependsOn 限定(import-coerce.ts:1057、import-field-meta.ts:102、field-value.zod.ts:219);legacy reference 无目标属惰性成员,不再声称覆盖。裸 tree 的自指由注册表写入(registry-object-registration.ts:450),保存门把原始正文交给门禁(protocol-save.ts:1935-1945)。
  • 门禁 check-runs @5004e807: 62 success · 10 预期 skip · 0 失败 · mergeable clean。Lint & Repo Gates、TypeScript Type Check、Test Core、Check Changeset、Spec property liveness、Build Docs 均 success。dev 本地:lint 全包 9965/9965,派生 122 族 exit 0。
  • 抽查读数: validate-object-field-refs.ts:477(DEPENDS_ON_SCOPED_TYPES = REFERENCE_VALUE_TYPES)、:669-670(仅 dependsOn 槽带 referenceTypes 与 treeSelfTarget)、:1074-1080(targetOn)、:461(PICKER_FIELD_TYPES 未动);测试 :1304-1328 裸 tree 两道门。席位本地复跑 155/155;去 treeSelfTarget 红 2,去 referenceTypes 红 5。changeset、import-mappings.mdx:379-386、台账条目逐句核过。
  • 接受的偏差: 槽内自指回退(:1076-1079)与 field-value.zod.ts:201-203 的 ⛔ 字面相悖,限一槽,转后续卡;PICKER_FIELD_TYPES 注释措辞过时(:453-459);台账注释一行过长;第二个 commit 标题无 !(squash 取 PR 标题)。dev 报告偏差 (5) 已自行更正:消融窗口内 check-comment-mask-corpus 在跑,该族在终态文件上 exit 0,不影响结论。
  • 范围外去向: 后续卡一张(裸 tree 在对象图中无目标、tree 上 lookupColumns/lookupFilters 不判、PICKER_FIELD_TYPES 措辞、导入读法实测),席位立卡后在此补指针。Skills-docs: none,属实。
  • 落地条款: 发布冻结:保持 draft,不翻 ready、不入队、不挂 auto-merge。收窄 ⇒ 挂 pm:awaiting-merge 并请维护者审;解冻且获批后过落地前检 → ready → 入队。head 再移(非纯散文或重生成)须重读 delta。

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#2 · os-warren · session_01JQwxba2oTCUuCosPm6pkRu
2026-11-29T22:38Z · 席位记录判词行补正(读数器只认标题行判词)。

席位核对 — ACCEPT · Head-sha: 5004e80

全文见本 PR 评论 7263823449(同一 head,内容不变)。

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#2 · os-warren · session_01JQwxba2oTCUuCosPm6pkRu
2026-11-29T22:40Z · 请审:本 PR 申报收窄,按规则由维护者批准后合并。

维护者速读

  • 树形字段的“依赖筛选”写错筛选键时,以前要到导入数据才出问题,现在保存或检查元数据时就直接指出。
  • 这是一次收紧:原来能保存的错误写法会被拒绝,已登记升级说明;正确写法不受影响,平台自带应用无受影响配置。
  • 席位审核通过(评论 7263823449),契约复核 PASS(评论 7263807289),两者都在 head 5004e80785 上,CI 全绿。
  • 要你做什么:批准本 PR。发布冻结期间保持 draft、不入队;解冻后席位翻 ready 并入队。

@objectstack-fleet objectstack-fleet Bot added the pm:awaiting-merge PR only: landing waits on the maintainer's own review and merge (SKILL.md 复核 ②); never on an issue label Nov 29, 2026
@os-zhuang
os-zhuang marked this pull request as ready for review November 30, 2026 00:40
@os-zhuang
os-zhuang added this pull request to the merge queue Nov 30, 2026
Merged via the queue into main with commit 08a1a89 Nov 30, 2026
82 checks passed
@os-zhuang
os-zhuang deleted the claude/project-thread-ab6y6m branch November 30, 2026 01:09
@objectstack-fleet objectstack-fleet Bot removed the pm:awaiting-merge PR only: landing waits on the maintainer's own review and merge (SKILL.md 复核 ②); never on an issue label Nov 30, 2026
Nenzyz pushed a commit to Nenzyz/objectstack that referenced this pull request Dec 1, 2026
…the engine accepts it (objectstack-ai#38635)

<!-- claude-projects-attribution: {"github_login":"os-steve"} -->
_Requested by **Steve** · [project
thread](https://claude.ai/code/project/chan_01FdL1XeUyvVNxLreh3F4Qi9?thread=cmsg_01FdL1XeUyvVNxLreh3F4Qi9JeHmqv6CKCkW8ewrPBLekk)_
Refs objectstack-ai#38433 (items 1, 2)
Clause-②: no
Metadata-protocol: none

## 维护者速读

- 作者与智能体在校验或保存看板视图时看到的修复建议变了:分组字段是多值、JSON
存储或公式字段时,不再建议改用表格分组,而是建议改用表格列;普通文本、数字、日期字段的建议不变。
- 属于看板分组字段校验规则的复核跟进:原建议会把作者引到一个打开即报错的表格分组。
- 只是提示文字和规则说明变了,不改任何校验结论或严重级别;出错时作者只会读到不准确的建议,可直接撤回。
- 无。

## What changes

`list-view-kanban-group-field-uncategorical` now offers the
grid-grouping remedy only on the branch where it holds.

- **Hint** (`checkKanbanGroupField`,
`packages/lint/src/validate-list-view-field-refs.ts`): the tail is keyed
on the engine's own refusal set, read from the same spec predicates the
two `engine.aggregate` doors use:
- multi-valued (`isMultiValueField`, the multi branch) and
structured-JSON (`STRUCTURED_JSON_TYPES`) are refused by
`assertGroupByNamesNoJsonStoredField`;
- virtual `formula` (`isVirtualSearchField`) is refused by
`assertGroupByTargetsAreStored`;
- both answer `400 INVALID_FIELD`. A list view `grouping` compiles to
that group-header query (`compileListViewGroupQuery`), which the grid
sends.
- For those three classes the hint now ends `or show "FIELD" as a grid
column (a list cannot be grouped by REASON)`; every other warned field
(text, number, date and the rest of the stored single-valued scalars)
keeps `or show "FIELD" as a grid grouping`.
- **Explanation** (`rule-explanations.ts`, this rule's entry only): the
fix paragraph now says the same, branch by branch: stored single-valued
field gives grid grouping; multi-valued, JSON-stored or `formula` gives
grid column only, with the reason.
- Measured from the rule's code: before this PR a JSON-stored or
`formula` group field already warned, on the **single-valued** branch
(it is not in `KANBAN_CATEGORICAL_TYPES`), and got the grid-grouping
tail. No finding, severity or accept set changes.
- **N2 (item 4), decided: keep the short list deliberately.** `select`,
boolean and lookup are the heads of the three families the rule accepts
(`select`/`radio`, `BOOLEAN_VALUE_TYPES`, `REFERENCE_VALUE_TYPES`).
Naming each member would hand-copy `KANBAN_CATEGORICAL_TYPES` into prose
that drifts from it, and would lengthen a hint held to 200 characters.

Read first, by risk:
1. `packages/lint/src/validate-list-view-field-refs.ts`, the
`ungroupable` / `gridRemedy` hunk in `checkKanbanGroupField`: this is
where the set is keyed.
2. `packages/lint/src/validate-list-view-kanban-lanes.test.ts`, the new
per-field `it.each`.

Two-minute check: `pnpm --filter @objectstack/lint exec vitest run
--maxWorkers=2 src/validate-list-view-kanban-lanes.test.ts`. Expect 34
passed. The `tags`, `watchers`, `meta`, `address` and `score` rows
assert a grid column; `amount`, `due_date` and `subject` assert a grid
grouping.

## Tests

At head `e0e643722a`:

<details><summary>@objectstack/lint: full suite and typecheck</summary>

- `pnpm --filter @objectstack/lint exec vitest run --maxWorkers=2`: Test
Files 246 passed (246), Tests 9962 passed, 5 skipped (9967).
- `pnpm --filter @objectstack/lint typecheck`: exit 0;
check:test-typecheck OK.
- `src/validate-list-view-kanban-lanes.test.ts`: 34 passed.

</details>

<details><summary>Ablation</summary>

Forced `gridRemedy` to always take the grid-grouping arm, on disk, then
ran the target file: 5 failed / 29 passed. The failures were exactly the
five ungroupable rows (`tags`, `watchers`, `meta`, `address`, `score`).
Restored with `git checkout HEAD --`, tree clean.

</details>

## Acceptance notes

- Item 3 of the card (a finding of its own for a
`grouping.fields[].field` naming a multi-value, JSON-stored or
non-stored field) is not in this PR. It is a narrowing and stays on the
card.
- `engine.aggregate` also refuses a `groupBy` on a credential or
`internal`-flagged column (`rejectCredentialEvaluation`,
`rejectInternalFieldEvaluation`). The hint is not keyed on those,
because the refusal comes from a flag and not from the storage class. A
kanban board grouped by a password field is not a realistic producer.
Noted only.

## Verification

<details><summary>Derived local gates (dispatch-gates --commands, 70
families)</summary>

- `dispatch-gates --ran`: 70 derived, 67 run with exit 0, 3 NOT MEASURED
(exit 3, prerequisite), 0 unrun.
- NOT MEASURED: `check-plugin-teardown-shape --self-test` (shallow clone
cannot reach its pinned fixture commit), `check:dual-build-cjs-loads`
and `check:lean-entry-closure` (need dist of packages outside this
diff's closure). Left to CI.
- `check:docs-transcript-drift` was re-run after building
`@objectstack/lint`: exit 0. `check:type-check-debt` and
`check:query-options-erasure`: exit 0.
- `overlap-check --branch=HEAD`: clean against origin/main and objectstack-ai#38628,
objectstack-ai#38605, objectstack-ai#38594, objectstack-ai#38550.

</details>

---
_Generated by [Claude
Code](https://claude.ai/code/session_01ADHkmSwS4mQyXWrddL4r6B)_

<!-- signed: repo:objectstack#3 · os-steve ·
session_01ADHkmSwS4mQyXWrddL4r6B -->

---------

Co-authored-by: Claude <noreply@anthropic.com>
Nenzyz pushed a commit to Nenzyz/objectstack that referenced this pull request Dec 1, 2026
… whose documentBy is not a single-valued parent link (objectstack-ai#38662)

<!-- claude-projects-attribution: {"github_login":"os-warren"} -->
_Requested by **Warren** · [project
thread](https://claude.ai/code/project/chan_01U5RdnAAmkSQmZbqh6FtqZ8?thread=cmsg_01U5RdnAAmkSQmZbqh6FtqZ8Xj6YfMRKw8XnmTA1ohBr6K)_

Fixes objectstack-ai#38537

Clause-②: no
Metadata-protocol: none

**Lands after objectstack-ai#38594** (merged 2026-11-30T01:10Z; main merged into this
branch at `d1e1ba3f03`). Both PRs are seat 2's. The overlap is two files
(`packages/lint/src/index.ts`,
`packages/lint/src/rule-explanations.ts`), in hunks far apart;
`overlap-check` reads both clean against each other and main.

## 维护者速读

- 用户能看到什么变化:知识源的“文档单位”(`documentBy`)如果填的不是指向父记录的单值查找字段,`os validate` /
`os build` / `os lint` 和发布时都会报错并说明怎么改。之前只有在 Studio / 元数据 API 保存时才会拒绝。
- 为什么做:随包发布或代码注册的知识源不经过保存这道门,填错了没人拦,检索按父记录聚合会悄悄失效。这是 objectstack-ai#38537 的第二个也是最后一个
PR。
- 出错会怎样:只影响声明了 `documentBy` 的知识源;规则误判会让正确的知识源发布失败,删掉 `documentBy` 即可绕开。
- 要你做什么:无。

## What changes

- **New rule** `knowledge-source-document-by-not-parent-link` (`error`)
in `validate-knowledge-source.ts`. It refuses a `source.documentBy` that
`metadataFields` lists and that is not a single-valued parent link of
the indexed object. The checks run in the save door's order: declared by
the object, neither credential-class nor `internal`, a `lookup` /
`master_detail` type, a target `referenceTargetOf` can read, and not
`multiple: true`. Each reason gets its own message, worded like the save
door's `documentUnitRefusalText`, naming the field and the fix. Path:
`knowledgeSources[i].source.documentBy`.
- **Where it runs.** The rule rides the existing
`validateKnowledgeSource` registry entry, so it reaches `os validate` /
`build` / `lint` and the runtime publish gate (`knowledge_source`
writes) with no new wiring. This is what judges a source a package ships
or code registers; until now only the metadata API's save door did
(objectstack-ai#38564).
- **Not judged twice.** A `documentBy` that `metadataFields` does not
list is left to the parse, which already names that fix. A member the
object does not have is reported once, as
`knowledge-source-field-unknown`. An object with no readable field map
is not judged.
- **Published and explained.** The rule id is re-exported from the root
barrel (`index.ts`, one line in the knowledge block).
`rule-explanations.ts` gets its `os explain` entry and table row beside
the five sibling rules.
- **Census pin**
(`packages/core/src/security/second-object-read-exposure.pin.test.ts`):
the new `referenceTargetOf` import makes `validate-knowledge-source.ts`
a caller of the reference-target arbiter, so it is classified
`not-a-served-read` beside the other lint callers. It only asks whether
a target is declared, and reads and serves nothing of the target.
Admitted by the seat for this fix after CI's Test Core (8/12) flagged
the unclassified caller. Locally: 1 failed / 3 passed before the entry,
4/4 after.
- **Changeset** `patch` for `@objectstack/lint`.

## Route chosen for the parent-link rule (objectstack-ai#38564's PR 2 question)

objectstack-ai#38564 left PR 2 two ways to reach `parentLinkRule` / `documentUnitOf`
(`service-knowledge`'s `knowledge-search-scope.ts`). The seat accepted a
third:

- **A: lint imports `@objectstack/service-knowledge`.** Not taken.
`@objectstack/lint`'s package description says it "Depends on
@objectstack/spec; never on a runtime", and service-knowledge is a
runtime service. It would also need a new line on service-knowledge's
`exports` surface.
- **B: move the rule to "a package lint already reads, for example
`@objectstack/core`".** Not taken. Lint does not depend on
`@objectstack/core`; its workspace dependencies are `formula`,
`metadata-core`, `sdui-parser` and `spec`. Moving it to `spec` would put
runtime-shaped logic into the protocol package and widen this PR well
past its card.
- **C (taken): compose the verdict in lint from the spec predicates
`parentLinkRule` itself asks.** Withheld =
`isMaskedOnReadFieldType(type, managedBy)` or `internal === true`. That
is the reading this file already takes for
`knowledge-source-field-never-indexed`, and the one
`collectCredentialWriteResponseFields` /
`collectInternalWriteResponseFields` compute in core. Target =
`referenceTargetOf` (`@objectstack/spec/data`). The type pair `lookup` /
`master_detail` is spelled locally, as eight other lint rule files
already spell it. Cost: the four-part rule now lives in two places. No
test pins their agreement, because no package that depends on both can
import `documentUnitOf` without one more barrel line in
service-knowledge. The module header names the save door's function so a
change to one points at the other.

## Why

ADR-0161 K4: "a packaged item meets the gates that need no principal in
`os validate` and at publish". `documentBy` is such a gate: it reads
only the object definition. objectstack-ai#38564 left it judged at save only, and its
body says "PR 2's `os validate` rule covers packaged sources."

## Clause-② and Metadata-protocol, measured from the diff

`Clause-②: no` / `Metadata-protocol: none`, a judgement call stated here
for review. The rule refuses values of `source.documentBy`, a key objectstack-ai#38564
added in this same prerelease line. Its changeset
`.changeset/38537-knowledge-document-by.md` is still pending (not moved
to `.changeset/pre/`), so no published version carries the key and
nothing an author could write against a release is refused. The metadata
API's save door already refuses the same values. Read against `main`
instead, a packaged source with a non-parent-link `documentBy` passed
`os validate` before this PR and fails it after. If review prefers that
reading, the lines become `Clause-②: no (narrowing)` /
`Metadata-protocol: narrowed` (level `minor` and an ADR-0087
disposition).

## Verification

### Acceptance (the card's `os validate` half)

| Card line | Test (`validate-knowledge-source.document-by.test.ts`) |
|:--|:--|
| Refuse a text field, a `user` field, an `internal` lookup and a
`multiple` lookup, each naming the fix | "refuses a text field / a user
field / an internal lookup / a multiple lookup as the document unit,
naming the field and the fix" |
| (the save door's other reasons) | "… a credential-class field", "… a
lookup with no readable target", "… a system column the platform adds" |
| Positive controls | "CONTROL: a lookup and a master_detail to the
parent are admitted", "CONTROL: a source without documentBy is judged as
before" |
| Same verdict at publish | "refuses the publish with the words os
validate prints", "CONTROL: a single-valued parent link publishes with
nothing to report" |
| Published id + `os explain` | "the root barrel re-exports it", "os
explain answers it" |

### Ablation (`scripts/ablation-replace.mjs`, each mutation verified on
disk, each restore verified blob == HEAD `d9f63681062f` with an empty
`git diff HEAD`)

<details><summary>Call site disabled (<code>const refusal =
documentUnitRefusal(…)</code> → <code>undefined</code>): 9 red</summary>

`validate-knowledge-source.document-by.test.ts`: 9 failed / 8 passed.
All seven refusal tests, "a fields array is read like a field map", and
"refuses the publish with the words os validate prints". The controls
stay green.
</details>

<details><summary><code>multiple</code> arm deleted: 1 red</summary>

1 failed / 16 passed: "refuses a multiple lookup as the document unit…".
</details>

<details><summary><code>internal</code> half of the withheld arm
removed: 1 red</summary>

1 failed / 16 passed: "refuses an internal lookup as the document
unit…". (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.)
</details>

### Package suite and typecheck

- `pnpm --filter @objectstack/lint test`: Test Files 248 passed (248),
Tests 9989 passed / 5 skipped. Exit 0.
- `pnpm --filter @objectstack/lint typecheck` (tsc + test layer): exit
0.
- `eslint` on the four changed source files: exit 0.
- `overlap-check`: VERDICT clean exit 0. origin/main merges cleanly, and
so do the 7 open PRs sharing a file (objectstack-ai#38651, objectstack-ai#38650, objectstack-ai#38643, objectstack-ai#38605,
objectstack-ai#38594, objectstack-ai#38550, objectstack-ai#38497).

### Derived gate families (`dispatch-gates.mjs --commands`, 70)

- First pass, captured per the tool's idiom: `--ran` reports "70 derived
famil(ies) accounted for — 66 run, 4 NOT-MEASURED (4 DERIVED from a
recorded exit 3)". All 66 that ran exited 0, including
`check-changeset-no-major --base origin/main`,
`check-adr-0087-registration --base origin/main`, `check:doc-authoring`,
`check:issue-citations` and `check:cross-package-test-inputs`.
- The four exit-3 families each had a prerequisite missing. Three were
re-run after fixing it, each exit 0: `check-plugin-teardown-shape
--self-test` (needed `git fetch --unshallow`),
`check:docs-transcript-drift` (needed the built lint) and
`check:lean-entry-closure` (needed the built objectql). These re-runs
were by hand, outside the `--ran` record.
- `check:dual-build-cjs-loads` was not measured locally: it reads every
package's `dist/`, which needs a full build. CI's `Build Core` job runs
it on this PR.

## Human Minimum

- [x] 1. Schemas start as Zod; `packages/spec` holds no runtime logic.
(spec untouched)
- [x] 2. Every name I added uses the casing for its kind.
- [x] 3. No formatter ran; `pnpm lint` passes (eslint on the changed
files).
- [x] 4. One issue, one branch off an up-to-date `main`, one pull
request.
- [x] 5. A change that publishes carries a changeset, and both
declaration lines are filled in here and in the changeset.
- [x] 6. `packages/spec` touched: n/a.
- [x] 7. No hand edits to `content/docs/references/`,
`packages/*/CHANGELOG.md` or `content/docs/releases/`.
- [x] 8. Title, body and comments are in English (the 维护者速读 block is the
maintainer's Chinese brief).
- [x] The *Before Submitting* list in CONTRIBUTING.md is done.

## Read first

1. `packages/lint/src/validate-knowledge-source.ts`:
`documentUnitRefusal` and the call site after
`judgeMembers('metadataFields')`.
2. `packages/services/service-knowledge/src/knowledge-search-scope.ts`:
`parentLinkRule` / `documentUnitOf`, the save door's rule this one
restates.

**Two-minute check:** `pnpm --filter @objectstack/lint exec vitest run
src/validate-knowledge-source.document-by.test.ts`. Expect 17 passed.

Dogfood: n/a (no `!` in the title, no `(narrowing)` arm).

🤖 Generated with [Claude Code](https://claude.com/claude-code)

https://claude.ai/code/session_01JQwxbWsSJprjGydwaCH1gD

<!-- signed: repo:objectstack#2 · os-warren ·
session_01JQwxbWsSJprjGydwaCH1gD -->

---------

Co-authored-by: Claude <noreply@anthropic.com>
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 protocol:data 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.

lookup dependsOn: the import-mappings docs overstate the new lint's reach, and a tree field's formula filter key is still found only at import

3 participants