You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit f9dd033
Browse filesBrowse the repository at this point in the historyBrowse files
feat(lint): refuse a transferBehavior cascade the Change Owner action can never offer (#37382)
<!-- claude-projects-attribution: {"github_login":"os-bill"} -->
_Requested by **Bill** · [project
thread](https://claude.ai/code/project/chan_016iMXWSZDzqWRWvWzdNo8wg?thread=cmsg_016iMXWSZDzqWRWvWzdNo8wg8ZBQe4UHadd2fGHGeWRW9V)_
repo:objectstack#5 · os-bill · session_01Utp6CbdHk3orAeensH6EzS
Fixes#36714
Clause-②: no (narrowing)
Metadata-protocol: narrowed
Skills-docs: follow-up #35769 (row 7178935378:
skills/objectstack-data/rules/relationships.md, the three lint refusals)
## 维护者速读
-
用户能看到什么变化:应用作者在命令行校验、构建或检查应用时,若关联字段声明了「变更负责人时连带转移」而这种转移永远不会发生(父对象不提供变更负责人、经对象扩展加到不支持它的对象上、或子对象的接口不允许更新),现在会直接报错并写明怎么改;最终用户无感,运行时行为不变。
- 为什么做:数据模型专区「声明了就要生效」的收尾,替变更负责人连带转移功能补上作者期的提醒。
- 出错会怎样:若判断有误,作者的应用会在命令行校验时被误拦,改字段或对象即可通过;不影响已部署的应用和工作室保存,可直接撤回。
- 要你做什么:无。
## What changes
A `transferBehavior: 'cascade'` that the Change Owner endpoint can never
offer used to parse silently (ADR-0049, declared but not enforced). One
new `@objectstack/lint` rule, `validateTransferCascades`, refuses each
of the card's three cases at `error`, with the fix in the hint:
| Rule id | Case | Verdict from (spec, `@objectstack/spec/data`) |
|:---|:---|:---|
| `transfer-cascade-parent-without-change-owner` | 1: the reference
points at a parent in the stack that does not offer Change Owner |
`resolveUserActionTransfer` + `transferIneligibilityReason` (what the
endpoint's `changeOwnerOffReason` asks) |
| `transfer-cascade-extension-child-ineligible` | 2: an
`objectExtensions[].fields` field cascades onto an object that cannot
take a cascade | `transferCascadeIneligibilityReason` (what
`refuseIneligibleTransferCascades` and `transferCascadeRelations` ask) |
| `transfer-cascade-child-update-unexposed` | 3: the child's `enable`
block does not serve `update` | `apiExposureDenialReason`
(`canServeApiOperation` is its boolean face, the exposure filter in
`transferCascadeRelations`) |
- `packages/lint/src/validate-transfer-cascades.ts`: the walk only.
Objects are judged as served (`objectsAsServed`, every extension field
folded in), since `transferCascadeRelations` reads the registered,
merged definitions. An object the stack does not declare is skipped on
either side. Only single-value `lookup` / `master_detail` fields are
judged; off-type, multi-value and `sys_`-parent cascades stay the field
parse's refusals and are not reported twice.
- Registered in `authoring-rules.ts`: `gating`, all three commands,
`surfaces: CLI_ONLY` with a `surfaceReason` (see Acceptance notes).
Exported from the barrel (rule ids included), and the three ids have `os
explain` entries in `rule-explanations.ts` (inserted, not reordered).
-
`packages/spec/src/migrations/entries/semantic/18.transfer-cascade-never-offered-refused.ts`:
the ADR-0087 ledger entry `check:adr-0087-registration` requires for a
`Metadata-protocol: narrowed` changeset. It is a data file, not a schema
change.
- Docs: one sentence in `content/docs/api/data-api.mdx` beside the
existing multi-value refusal, and the CLI transcripts' author-time rule
count 79 → 80 (`check:docs-transcript-drift`).
- Changeset: `@objectstack/lint` minor, `@objectstack/spec` minor (the
kind is `narrowed`).
Mechanism assumptions measured at `origin/main` 98bda0a before code: A1
holds (the predicates are exported from `@objectstack/spec/data`; lint
imports them the way `validate-managed-api-methods.ts` does, no third
copy). A2: `error`, following `validateManagedApiMethods` (a declaration
decidable from the stack that the runtime silently drops) and the
parse's own refusal of the declaring object's half. A3 holds
(`child.enable` through the exposure predicate). A4: the two
`validate-predicate-path-refs.test.ts` pins count form predicates, not
registry entries; nothing moved.
Files to read first, by risk:
1. `packages/lint/src/validate-transfer-cascades.ts` —
`validateTransferCascades`, the served-object lookup and the `sys_` /
not-declared skips.
2. `packages/lint/src/authoring-rules.ts` — the new entry's tier and
`surfaceReason`.
3.
`packages/spec/src/migrations/entries/semantic/18.transfer-cascade-never-offered-refused.ts`.
## Tests
`packages/lint/src/validate-transfer-cascades-36714.test.ts`: every
fixture is a full `ObjectSchema` / `ObjectExtensionSchema` parse, so
each refusal is one the parse lets through. Each case is refused with
its rule, severity, `where`, `path` and the reason fragment its message
names; each eligible shape passes (an eligible parent, a parent outside
the stack, a `sys_` parent, an eligible extension target, a target
outside the stack, `update` served); the `packages[]` artifact shape is
read; and the `fieldPatches` arm is pinned as refused by the schema.
<details><summary>Local runs at 3e1fa4a (lint, spec,
ablation)</summary>
- `pnpm --filter @objectstack/lint test`: Test Files 236 passed (236),
Tests 9648 passed, 5 skipped (VERDICT command-exit 0).
- `pnpm --filter @objectstack/lint typecheck`: VERDICT command-exit 0.
- `pnpm --filter @objectstack/spec test`: Test Files 894 passed, 1
skipped (895), Tests 28417 passed (VERDICT command-exit 0).
- `pnpm --filter @objectstack/cli exec vitest run
test/migrate-meta-engine-guidance.test.ts`: 3 passed.
- Ablation (rule committed first): `scripts/ablation-replace.mjs`
replaced the walk's `for (const site of cascadeSites(stack))` with an
empty loop, x0 -> x1 on disk; the card's test file went 15 failed, 9
passed (24). Every refusal case red, every pass case green. Restored:
blob == HEAD, `git diff HEAD` empty.
</details>
## Acceptance notes
- The `Clause-②:` line carries the `(narrowing)` arm (body and
changeset, commit 8737482): Check Changeset reads `Metadata-protocol:
narrowed` beside a clause line without the arm as a contradiction. The
claim's `Clause-②: no` was copied first, at 3e1fa4a.
- Premise, partly narrower than written: case 2's `fieldPatches` arm
cannot occur. A field patch carries display properties only (`label`,
`description`, `inlineHelpText`, `placeholder`), and
`ObjectExtensionSchema` refuses `transferBehavior` there as an
unrecognized key, so the rule walks extension `fields` only; a test pins
the refusal.
- Not on the runtime publish gate yet (`surfaces: CLI_ONLY`): the door's
objects are served definitions carrying the injected `owner_id` as a
declared field, which the eligibility predicate reads (its `readonly`,
and on an external object whether it is declared). Crossing owes that
measurement or a read-back to the authored shape, as
`lintDuplicateFieldLabels` does. Until then a Studio or MCP save of
these shapes still passes. The runtime stays safe.
- Boundary: a cascade on a field an object declares itself, where only
an extension makes the served object ineligible, is not reported as case
2 (the card scopes case 2 to extension fields; the object's own half is
the parse's).
- File surface: the ADR-0087 ledger entry under
`packages/spec/src/migrations/entries/semantic/` is outside the claim's
listed surface. `check:adr-0087-registration` requires it for
`narrowed`; it changes no schema and no runtime.
- First-party exposure: zero. No example app, platform object, skill or
docs sample declares a cascade.
- Other open PRs that add an author-time rule (#37354, #37371) move the
same transcript count; whichever lands second gets a one-number docs
conflict or a `check:docs-transcript-drift` red.
## Verification
Two-minute check: `pnpm --filter @objectstack/lint exec vitest run
src/validate-transfer-cascades-36714.test.ts` prints 24 passed.
<details><summary>Gates: local derivation and reconciliation</summary>
`node scripts/pm/dispatch-gates.mjs --ran` at 3e1fa4a: 117 derived, 113
run, 4 NOT-MEASURED, 0 UNRUN. All 113 run exited 0. NOT-MEASURED, left
to CI:
- `check:type-check-debt`: the 300 s local timeout fired (repo-wide tsc
census).
- `check-plugin-teardown-shape.mjs --self-test`: shallow checkout.
- `spec check:skill-examples`: its client SDK surface reads
`packages/client-react` dist, not built locally.
- `check:dual-build-cjs-loads`: reads every workspace dist.
Outside the derivation, local-only: `check:dev-prereqs` exit 1, because
104 of 110 workspace packages are unbuilt in this container (machine
state, not this diff).
</details>
🤖 Generated with [Claude Code](https://claude.com/claude-code)
<!-- signed: repo:objectstack#5 · os-bill ·
session_01Utp6CbdHk3orAeensH6EzS -->
---------
Co-authored-by: Claude <noreply@anthropic.com>
**BREAKING** for a stack that declares one of these cascades: `os validate`, `os build` and `os lint` now refuse it where they accepted it before. Fix it as below; the runtime never ran such a cascade, so no data changes.
14
+
15
+
`os validate`, `os build` and `os lint` now refuse three `transferBehavior: 'cascade'` declarations that parsed and then did nothing, because the Change Owner endpoint re-judges every relationship and never offers them. Each is an `error`, with the fix named:
16
+
17
+
-`transfer-cascade-parent-without-change-owner`: the reference points at a parent in the stack that does not offer Change Owner (`ownership: 'business_unit' | 'org' | 'none'`, any `managedBy`, a pinned or unprovable owner, or `userActions.transfer` off, by the author or by the `controlled_by_parent` default). A `sys_` parent stays the field parse's refusal.
18
+
-`transfer-cascade-extension-child-ineligible`: an object extension's field (`objectExtensions[].fields`) declares the cascade on an object that cannot take one. `ObjectSchema` already refused this on a field the object declares itself; an extension's field skipped that parse. A `fieldPatches` entry cannot carry the key at all.
19
+
-`transfer-cascade-child-update-unexposed`: the child's `enable` block does not serve `update` (`apiEnabled: false`, or `apiMethods` without update).
20
+
21
+
Fix: set the field's `transferBehavior` to `'none'` or remove it, or change the object the message names (offer Change Owner on the parent, or open update on the child). The verdicts come from the spec predicates the runtime reads (`resolveUserActionTransfer`, `transferCascadeIneligibilityReason`, `apiExposureDenialReason`); the runtime is unchanged. New exports: `validateTransferCascades` and the three rule id constants. Not yet run at the runtime publish gate (follow-up #37397). Migration entry `transfer-cascade-never-offered-refused` (`@objectstack/spec`) carries the same fix for `os migrate meta` and the upgrade guide.
0 commit comments