Skip to content

Commit 0e36120

Browse files
docs(data-modeling): name what the lookup dependsOn formula check does not see on import (#38125)
Part of #37936 Clause-②: no Metadata-protocol: none ## 维护者速读 - 用户能看到什么变化:导入数据的人在文档的导入映射页上读到,作者时的检查在哪几种情况下看不到问题,导入时仍会遇到“无法在范围内查找”的提示;产品行为不变。 - 为什么做:这是上一轮查找字段依赖筛选收严之后,复审留下的文档尾巴,原句把检查说得比实际更全。 - 出错会怎样:只改一段文档,读者最多读到不准确的说明,可以直接撤回。 - 要你做的:无(另一半,树形字段是否也该受检查,等席位转决策)。 ## What changes `content/docs/data-modeling/import-mappings.mdx`, one paragraph. The sentence "so an import meets this sentence only on metadata stored before that check" overstated the authoring check that refuses a `dependsOn` filter key naming a formula of the target. It now says the check judges a `lookup`, `master_detail` or `user` field against the objects it can see, and names the cases where an import still meets the could-not-be-looked-up sentence. Each case was measured against `origin/main` at 6e06729 before it was named: 1. **Metadata stored before the check** (unchanged from the old sentence). 2. **A `tree` field, or a legacy `reference` field.** The lint resolves the referenced half only on `PICKER_FIELD_TYPES = lookup, master_detail, user` (`packages/lint/src/validate-object-field-refs.ts:442`, applied at `:1002`); the importer scopes by `dependsOn` on every type in `IMPORT_REFERENCE_TYPES` (`packages/spec/src/data/field-value.zod.ts:154-155` adds `tree`, `packages/spec/src/data/import-coercion.ts:44-47` adds `reference`; read at `packages/core/src/utils/import-coerce.ts:1056-1061`). Probe: the same task/project pair with the target field a formula gives one `computed on read` finding for `lookup` and `master_detail`, zero for `tree` and `reference`. 3. **`os validate` of a stack that does not hold both objects.** The rule's graph is the validated stack alone (`indexServedObjectGraph(stack)`, `validate-object-field-refs.ts:683`), the formula check reads `graph.get(against)?.fields` (`:1054`), and only the stack's own objects are walked (`:998`). Probe: a lookup whose target is not in the stack gives zero findings; the control with the formula target in the stack gives one. The same holds for the owning side: a target field turned into a formula in a package validated without the owning object is never judged there. The card's third wording, "a target field changed from stored to formula after the owning object was published", was **measured false for the runtime publish gate** and is not named as a gap there. The gate's context is every object the environment serves, registry plus stored rows (`packages/metadata-protocol/src/protocol-authoring-gate.ts:527-552`); its differential drops the written item from the baseline (`packages/lint/src/runtime-gate.ts:968`) and charges findings the candidate adds (`addedFindings`, `:1344`). Probe: writing the target object with the field now a formula, while the owning object sits in the context, is refused with `objects.pr_task.fields.project.dependsOn[0].param "acct_label" is a formula field of "pr_project", computed on read`. The page says so in its last sentence. The case survives only on the CLI, as part of item 3. ## Tests Docs-only. No test changed. The measurements above came from a throwaway vitest file in `packages/lint/src` (deleted before commit, never pushed), run as `pnpm --filter @objectstack/lint exec vitest run --maxWorkers=2 PROBE_FILE` after building the lint dependency closure; it printed: <details><summary>probe output (4 tests passed)</summary> ```text C ["objects[0].fields.project.dependsOn[0].param"] CASE1 [] CASE3-tree [] CASE3-reference [] CASE3-master_detail ["objects[0].fields.project.dependsOn[0].param"] CASE2-gate-target-write: includes objects.pr_task.fields.project.dependsOn[0].param ... computed on read CASE2-control-owner-write ["objects.pr_task.fields.project.dependsOn[0].param"] CASE1-gate-owner-write-target-absent [] ``` </details> ## Acceptance notes **N2 is measured here, not changed** (the card stays open). Readings, each against `origin/main` at 6e06729: - (a) **The spec.** `dependsOn`'s describe (`packages/spec/src/data/field.zod.ts:2657`) declares candidate-query scoping "For `lookup`/`master_detail`" and option gating for `select`/`multiselect`/`radio`; it names neither `tree` nor `user` nor `reference`. The Studio field form offers `dependsOn` only on `lookup`, `master_detail`, `select`, `multiselect`, `radio`, `checkboxes` (`packages/spec/src/data/field.metadata-form.ts:327`). Control: the schema itself does not gate `dependsOn` by type (`field.zod.ts:2650`), so a `tree` field carrying it parses. - (b) **The importer.** Scopes by `dependsOn` on `lookup`, `master_detail`, `user`, `tree` (`REFERENCE_VALUE_TYPES`, `field-value.zod.ts:154-155`) and `reference` (`import-coercion.ts:44-47`), read at `import-coerce.ts:1056-1061`. A `tree` with no `reference` is not scoped (`:1056`, `!meta?.reference`). - (c) **The lint.** Judges the referenced half of `dependsOn` only on `lookup`, `master_detail`, `user` (`validate-object-field-refs.ts:442`, `:1002`). Its docblock says on any other type "those keys have no reader" (`:436-441`). Counter-reading: the console renders `tree` with the lookup widget (`ui/packages/fields/src/field-type-alias.ts:142`, `tree: 'field:lookup'`), the widget that reads `dependsOn`. And a `tree` field's `reference` may only name its own object (`packages/spec/src/data/object.zod.ts:2018`), so its target is always in the stack the lint sees. - (d) **Producers.** `git grep` over `examples/`, `packages/platform-objects/`, `skills/`: `tree` fields at 3 source sites (`examples/app-showcase/src/data/objects/field-zoo.object.ts:122`, `examples/app-showcase/src/ui/views/business-unit.view.ts:27`, `packages/platform-objects/src/identity/sys-business-unit.object.ts:55`) plus one skill sample (`skills/objectstack-data/rules/relationships.md:147`); `type: 'reference'` at 0 sites. None of them carries `dependsOn`: zero files hold both outside a `CHANGELOG.md` and the skill page, whose `dependsOn` mention is the lookup paragraph at `:106`, not the tree sample. Control: the same grep finds `dependsOn` in 3 example object files (`cascading-select`, `contact`, `invoice`), all on lookup or option fields. Sibling repos (hotcrm, cloud) were not measured. The two options the card names, for the seat: - **A. The lint covers the importer's set** (add `tree` and `reference` to the types whose `dependsOn` reference half is judged). Cost: a narrowing of `@objectstack/lint` (Clause-② narrowing, minor), zero known producers broken by (d). It matches the console, which already reads `dependsOn` on `tree`. `reference` is not a `FieldType` the parse accepts, so it only matters for legacy stored rows the lint sees. Size XS. - **B. The importer stops scoping types the spec does not declare it for** (scope only on `lookup`/`master_detail`, maybe `user`). Cost: an import behaviour change in `@objectstack/core`. A `tree` cell that is scoped today would resolve across the whole object, and the import would disagree with the console picker, which still filters a `tree` by `dependsOn`. Also needs a spec describe decision on `user`. Size S. Recommendation: A. It closes the lint gap without opening a new one between the import and the picker. The spec describe would then name `tree` beside `lookup`/`master_detail` (prose that follows the ruling). ## Verification Two-minute check: open `content/docs/data-modeling/import-mappings.mdx` at the paragraph beginning "A `dependsOn` entry whose `param` names a target field". It should list three cases (stored metadata, `tree`/legacy `reference`, an `os validate` of a stack without both objects) and end saying the runtime publish gate refuses turning such a target field into a formula. Read first: the one changed paragraph, lines 372-386. Co-authored-by: Claude <noreply@anthropic.com>
1 parent cad3030 commit 0e36120

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

‎content/docs/data-modeling/import-mappings.mdx‎

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -376,8 +376,14 @@ the scope and names the cause (`Task: "Design review" could not be looked up wit
376376
"Gemini": the target field this lookup's dependsOn filters by cannot be filtered on, …`),
377377
never `reference_out_of_scope`. Point `param` at a stored field of the target. `os validate`
378378
and the runtime publish gate refuse such an entry at authoring (`object-field-ref-unknown`,
379-
naming the target field), so an import meets this sentence only on metadata stored before that
380-
check.
379+
naming the target field). That check judges a `lookup`, `master_detail` or `user` field, against
380+
the objects it can see, so an import still meets this sentence in three cases: on metadata stored
381+
before the check; on a `tree` field or a legacy `reference` field, which the import scopes by
382+
`dependsOn` too but the check does not judge; and after an `os validate` of a stack that does not
383+
hold both objects, such as a target object from another package, or a target field turned into a
384+
formula in a package validated without the object whose lookup filters by it. The runtime publish
385+
gate judges against every object the environment serves, so a publish that turns such a target
386+
field into a formula is refused there.
381387

382388
A scoped lookup whose reads are all refused for any other reason, such as no read access to
383389
the target or a master cell the scoping field's type cannot take, keeps `reference_not_found`

0 commit comments

Comments
 (0)