Skip to content
Open
21 changes: 21 additions & 0 deletions .changeset/transfer-cascade-lint.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
---
'@objectstack/lint': minor
'@objectstack/spec': minor
---

feat(lint): refuse a `transferBehavior: 'cascade'` the Change Owner action can never offer

Clause-②: no (narrowing)
Metadata-protocol: narrowed

<!-- adr-0087: registered transfer-cascade-never-offered-refused -->

**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.

`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:

- `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.
- `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.
- `transfer-cascade-child-update-unexposed`: the child's `enable` block does not serve `update` (`apiEnabled: false`, or `apiMethods` without update).

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.
6 changes: 6 additions & 0 deletions content/docs/api/data-api.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -572,6 +572,12 @@ object's cascade candidates (see the route below) is refused `400
VALIDATION_ERROR` before anything is written. `'cascade'` on a multi-value
reference (`multiple: true`) is refused when the metadata is saved: a record
there points at several parents, so no single Change Owner decides its owner.
`os validate`, `os build` and `os lint` also refuse a `'cascade'` that Change
Owner could never offer: one pointing at a parent in the stack that does not
offer Change Owner, one an object extension adds to an object that cannot take
a cascade, and one on a child whose `enable` block does not serve `update`
(`os explain transfer-cascade-parent-without-change-owner` and its two
siblings say why).

The answer gains one outcome per named relationship:

Expand Down
2 changes: 1 addition & 1 deletion content/docs/deployment/cli.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -937,7 +937,7 @@ os compile --json # JSON output for CI pipelines
→ Normalizing stack definition...
→ Lowering inline handlers...
→ Validating protocol compliance...
→ Running author-time rules (79)...
→ Running author-time rules (80)...
→ Checking that every required capability has a provider installable in this edition...
→ Collecting package docs (ADR-0046)... 0 collected
→ Writing artifact...
Expand Down
2 changes: 1 addition & 1 deletion content/docs/deployment/validating-metadata.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -867,7 +867,7 @@ A clean run walks the registry and reports timing:
Config: /path/to/support-desk/objectstack.config.ts
Load time: 21ms
→ Validating against ObjectStack Protocol...
→ Running author-time rules (79)...
→ Running author-time rules (80)...
→ Checking that every required capability has a provider installable in this edition...
→ Checking package docs (ADR-0046)...

Expand Down
2 changes: 1 addition & 1 deletion content/docs/getting-started/build-with-claude-code.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ visible: 'status != "resolved"'
◆ Validate
────────────────────────────────────────
→ Validating against ObjectStack Protocol...
→ Running author-time rules (79)...
→ Running author-time rules (80)...

✗ Author-time rules failed (1 issue)
• stack · action 'resolve_ticket' visible: bare reference `status` — a
Expand Down
2 changes: 1 addition & 1 deletion content/docs/ui/react-pages.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,7 @@ objectstack validate
────────────────────────────────────────
→ Loading configuration...
→ Validating against ObjectStack Protocol...
→ Running author-time rules (79)...
→ Running author-time rules (80)...
→ Checking that every required capability has a provider installable in this edition...
→ Checking package docs (ADR-0046)...

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,11 @@ const CALLERS: Record<string, Classification> = {
kind: 'not-a-served-read',
reason: 'authoring-time static analysis of metadata; reads no record',
},
// [#36714] A `transferBehavior: 'cascade'` judged against the parent's declared Change Owner switch.
'packages/lint/src/validate-transfer-cascades.ts': {
kind: 'not-a-served-read',
reason: 'authoring-time static analysis of metadata; reads no record',
},
// [#35146] The post-publish build probes' two landed-data checks.
'packages/metadata-protocol/src/build-probes.ts': {
kind: 'not-a-served-read',
Expand Down
31 changes: 31 additions & 0 deletions packages/lint/src/authoring-rules.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ import { runStackExpressionPasses } from './validate-expressions.js';
import { validateListViewMode } from './validate-list-view-mode.js';
import { validateFunctionalCompleteness } from './validate-functional-completeness.js';
import { validateManagedApiMethods } from './validate-managed-api-methods.js';
import { validateTransferCascades } from './validate-transfer-cascades.js';
import { validateViewContainers } from './validate-view-containers.js';
import { validateWidgetBindings } from './validate-widget-bindings.js';
import { validateDatasetMeasureAggregates } from './validate-dataset-measure-aggregates.js';
Expand Down Expand Up @@ -996,6 +997,36 @@ export const AUTHORING_RULES: readonly AuthoringRule[] = [
runtimeTypes: ['object'],
run: (stack) => validateManagedApiMethods(stack),
},
// [ruling 7000907189 point 4 · ADR-0049] A `transferBehavior: 'cascade'`
// the Change Owner action can never offer: the parent does not offer Change
// Owner, an extension's field cascades onto an object that cannot take a
// cascade (the `ObjectSchema` refinement judges only the object's own
// fields), or the child's declared exposure does not serve `update`. The
// runtime re-judges each relationship and offers none of these, silently;
// this puts the same verdicts, from the same spec predicates, where the
// author is. Gating for the `validateManagedApiMethods` reason above: the
// verdict is decidable from the stack, and the declaration is a key nothing
// honours.
{
name: 'validateTransferCascades',
tier: 'gating',
input: 'parsed',
commands: ALL,
source: 'packages/lint/src/validate-transfer-cascades.ts',
surfaces: CLI_ONLY,
// The crossing is follow-up #37397. The number lives in this comment, not in the string below: a
// string literal under packages/ carries no tracker number (`pnpm check:doc-authoring`).
surfaceReason:
'Not yet crossed, pending a measurement: at the runtime publish gate the snapshot\'s objects are the '
+ 'registry\'s served definitions, which carry the injected system columns (owner_id among them) as '
+ 'declared fields, and the Change Owner eligibility predicate this rule reads judges a declared '
+ 'owner_id (its readonly flag, and on an external object whether it is declared at all). Judging '
+ 'served definitions with it is unmeasured, and a false 422 on the only door a Studio or MCP author '
+ 'has is worse than the gap. Crossing owes that measurement, or reading the served objects back to '
+ 'their authored shape as lintDuplicateFieldLabels does at the object_extension door, and its own '
+ 'rollout decision; never a bare `runtimeTypes` edit.',
run: (stack) => validateTransferCascades(stack),
},
// A view container in `views: []` that registers zero views: nothing appears
// in the Console, and the schema step cannot tell it from an intentionally
// empty one. The FLAT-list-view arm no longer needs this tier — `ViewSchema`
Expand Down
12 changes: 12 additions & 0 deletions packages/lint/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -545,6 +545,18 @@ export type {
MembershipKeyOwners,
} from './validate-membership-key-declarations.js';

// [ruling 7000907189 point 4 · ADR-0049] A `transferBehavior: 'cascade'` the
// Change Owner action can never offer: a parent without Change Owner, an
// extension's field on an object that cannot take a cascade, a child whose
// declared exposure does not serve `update`.
export {
validateTransferCascades,
TRANSFER_CASCADE_PARENT_WITHOUT_CHANGE_OWNER,
TRANSFER_CASCADE_EXTENSION_CHILD_INELIGIBLE,
TRANSFER_CASCADE_CHILD_UPDATE_UNEXPOSED,
} from './validate-transfer-cascades.js';
export type { TransferCascadeFinding } from './validate-transfer-cascades.js';

export {
validateDashboardActionRefs,
DASHBOARD_ACTION_TARGET_UNDEFINED,
Expand Down
76 changes: 76 additions & 0 deletions packages/lint/src/rule-explanations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6611,6 +6611,79 @@ const FIELD_LABEL_DUPLICATE_EXPLANATION: RuleExplanation = {
],
};

// ── Change Owner cascades that can never run (`validate-transfer-cascades.ts`) ──

/** What every transfer-cascade id shares: where the verdict comes from and why it refuses. */
const TRANSFER_CASCADE_SHARED =
'A `transferBehavior: \'cascade\'` on a lookup or master_detail field asks a Change Owner of the ' +
'referenced (parent) record to move the records here that point at it, and that the parent\'s previous ' +
'owner holds, to the new owner too. The Change Owner endpoint re-judges every relationship on every call ' +
'and offers only the ones that can act, so nothing wrong happens at run time; but a declaration it never ' +
'offers is a key nothing honours (ADR-0049), and the author would never be told. The verdicts come from ' +
'the same spec predicates the endpoint reads (`resolveUserActionTransfer`, ' +
'`transferCascadeIneligibilityReason`, `apiExposureDenialReason` in `@objectstack/spec/data`), on the ' +
'objects as the registry serves them, every object extension\'s fields folded in. An object this stack ' +
'does not declare cannot be judged, on either side of the relationship, and is skipped.';

/**
* Where these ids run, and what the field parse already refuses. The runtime publish gate crossing is
* follow-up #37397; the number stays in this comment, since an author is shown the text and it carries no
* tracker number (`rule-explanations.test.ts`, `pnpm check:doc-authoring`).
*/
const TRANSFER_CASCADE_SCOPE =
'Judged by `os validate`, `os build` and `os lint`, not yet at the runtime publish gate (its objects are ' +
'served definitions carrying the injected owner_id, which the eligibility predicate reads; crossing ' +
'waits on a measurement). The field parse refuses the other shapes with their own prescription: ' +
'`transferBehavior` off a lookup or master_detail field, `\'cascade\'` on a multi-value reference or ' +
'on a reference to a `sys_` object; and `ObjectSchema` refuses a cascade on a field the object declares ' +
'itself when the object cannot take one. Those are not reported again here.';

const TRANSFER_CASCADE_PARENT_WITHOUT_CHANGE_OWNER_EXPLANATION: RuleExplanation = {
rule: 'transfer-cascade-parent-without-change-owner',
covers: 'why a cascade needs a parent that offers Change Owner',
paragraphs: [
TRANSFER_CASCADE_SHARED,
'The cascade runs inside a Change Owner of the parent and nowhere else, and the endpoint refuses the ' +
'whole call on an object that does not offer the action. A parent does not offer it when it is not ' +
'structurally eligible (ownership `business_unit`, `org` or `none`, any `managedBy`, ' +
'`systemFields: false`, an `owner_id` declared readonly, an external object with no provable owner) or ' +
'when its `userActions.transfer` is off, by the author or by the `controlled_by_parent` default. The ' +
'message names which; where the parent can be changed to offer the action, the reason ends with that ' +
'change. Otherwise the fix is on the field: set it to `none` or remove it.',
TRANSFER_CASCADE_SCOPE,
],
};

const TRANSFER_CASCADE_EXTENSION_CHILD_INELIGIBLE_EXPLANATION: RuleExplanation = {
rule: 'transfer-cascade-extension-child-ineligible',
covers: 'why an extension field cannot cascade onto this object',
paragraphs: [
TRANSFER_CASCADE_SHARED,
'A cascade moves the records of the object that declares the field, by the same Change Owner action, ' +
'so that object must offer the action itself: structurally eligible, not a `controlled_by_parent` ' +
'detail (its access already follows its master), and its `userActions.transfer` not off. `ObjectSchema` ' +
'refuses a cascade on a field the object declares itself, but a field an object extension ' +
'(`objectExtensions[].fields`) adds never passes through that parse, so this rule judges it on the ' +
'extended object. An extension\'s `fieldPatches` cannot carry `transferBehavior` at all: a patch sets ' +
'display properties only, and its schema refuses the key.',
TRANSFER_CASCADE_SCOPE,
],
};

const TRANSFER_CASCADE_CHILD_UPDATE_UNEXPOSED_EXPLANATION: RuleExplanation = {
rule: 'transfer-cascade-child-update-unexposed',
covers: 'why a cascading object must serve update',
paragraphs: [
TRANSFER_CASCADE_SHARED,
'The cascade reads and writes the child\'s rows as a second object of the call, each move the caller\'s ' +
'own update, so the child is asked its own declared API exposure for `update`, the operation the data ' +
'route judges. An object with `enable.apiEnabled: false`, or an `enable.apiMethods` list that does not ' +
'grant update, is left out of the cascades Change Owner offers. Either open update on the child or set ' +
'the field to `none`.',
TRANSFER_CASCADE_SCOPE,
],
};

// ── Publish-time refusals of metadata that parses and does nothing ──────────
// (`validate-flow-node-executors.ts`, `lint-flow-patterns.ts`,
// `validate-inert-object-declarations.ts`, `validate-action-object-binding.ts`)
Expand Down Expand Up @@ -7074,6 +7147,9 @@ export const RULE_EXPLANATIONS: Readonly<Record<string, RuleExplanation>> = Obje
[STORED_EXPRESSION_CROSS_RECORD_INPUT_EXPLANATION.rule]: STORED_EXPRESSION_CROSS_RECORD_INPUT_EXPLANATION,
[STORED_EXPRESSION_VOLATILE_INPUT_EXPLANATION.rule]: STORED_EXPRESSION_VOLATILE_INPUT_EXPLANATION,
[FIELD_LABEL_DUPLICATE_EXPLANATION.rule]: FIELD_LABEL_DUPLICATE_EXPLANATION,
[TRANSFER_CASCADE_PARENT_WITHOUT_CHANGE_OWNER_EXPLANATION.rule]: TRANSFER_CASCADE_PARENT_WITHOUT_CHANGE_OWNER_EXPLANATION,
[TRANSFER_CASCADE_EXTENSION_CHILD_INELIGIBLE_EXPLANATION.rule]: TRANSFER_CASCADE_EXTENSION_CHILD_INELIGIBLE_EXPLANATION,
[TRANSFER_CASCADE_CHILD_UPDATE_UNEXPOSED_EXPLANATION.rule]: TRANSFER_CASCADE_CHILD_UPDATE_UNEXPOSED_EXPLANATION,
[FLOW_NODE_TYPE_NO_EXECUTOR_EXPLANATION.rule]: FLOW_NODE_TYPE_NO_EXECUTOR_EXPLANATION,
[FLOW_APPROVAL_DECISION_UNROUTED_EXPLANATION.rule]: FLOW_APPROVAL_DECISION_UNROUTED_EXPLANATION,
[FLOW_HTTP_TIMEOUT_MISSING_EXPLANATION.rule]: FLOW_HTTP_TIMEOUT_MISSING_EXPLANATION,
Expand Down
Loading
Loading