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 7365c82
Browse filesBrowse the repository at this point in the historyBrowse files
fix(objectql)!: a `runAs: 'system'` flow's record writes keep the reference check while keeping their authorization elevation (#28881)
8
+
9
+
Clause-②: no (narrowing) — a `runAs: 'system'` flow's `create_record` / `update_record` (and any custom node writing through `resolveRunDataContext`) that names a lookup, user or master-detail id resolving to no row is refused, which it admitted before. Nothing is widened.
10
+
Metadata-protocol: none
11
+
12
+
<!-- adr-0087: not-required (no-migration-prescription) No key of any schema is added, removed, renamed or re-shaped. The write-time reference check the user path already applies now also applies to an elevated flow's record writes, with the same reference_not_found refusal; the mark that keeps it on is an internal symbol on the run's context, not an authorable key, so there is nothing for a migration to rewrite and no tombstone. -->
13
+
14
+
**BREAKING** accept-set narrowing at an elevated flow's record writes (`@objectstack/objectql`, `@objectstack/service-automation`).
15
+
16
+
-**Before.** The write-time reference check returned early for every system context. A flow that runs as system writes with `isSystem: true`, so its `create_record` / `update_record` stored a reference to a deleted row with no error, while the same write on the user path was refused `reference_not_found`.
17
+
-**Now.**`resolveRunDataContext` marks a system run's data context (`markFlowWriteReferenceCheck`, `@objectstack/core`: a symbol, in no schema, not authorable), and the check keeps checking a marked write. The refusal is the user path's own: `VALIDATION_FAILED` with the field's `reference_not_found` error, carried as the node's inner refusal.
18
+
-**Unchanged.** The run's authorization elevation: it still writes rows other people own, past RLS and FLS, inside the trigger's organization. Every system writer outside a flow run keeps the exemption: seed replay, package install, boot provisioning, import under a system principal, restore and migration, the cascade and set-null legs of a delete no flow made, and a hook's or action body's writes when no flow-run write set them off.
19
+
-**Writes a flow write sets off.** They carry the mark too and are checked as the flow's own, as on the user path: a hook's `ctx.api` (and its `runAs: 'system'` or `ctx.api.sudo()` elevation) under a flow's write, and the engine's cascade legs under a flow's delete. A cascade leg writes no new link, so only the value it writes is judged.
20
+
-**Who sees it.** A system flow that writes an id naming no row in its organization, including the owner it stamps from its trigger user when that user has no `sys_user` row. A flow that wants to tolerate a missing target clears the field first. One case surfaces data that is already wrong: a flow's `delete_record` whose `set_null` cascade removes the deleted id from a `multiple: true` reference field rewrites the members that remain, so if one of them already names a row that is gone, the cascade write is refused `reference_not_found` and the delete fails. The same delete on the user path fails the same way; a multi-value field keeping a deleted id is tracked in #29062.
21
+
22
+
**The remedy.** Write an id that resolves, or leave the field empty.
fix(cli): a `define*` helper that refuses its input while the config loads is reported as one located refusal (file, line, helper, path, the issue in words), not a raw JSON array
6
+
7
+
Clause-②: no — CLI output text only. No schema, export or accepted input changes; a refused config is refused with the same exit code as before.
8
+
Metadata-protocol: none
9
+
10
+
`defineView`, `defineAction` and the other strict helpers call `Schema.parse` and throw the `ZodError` as is. `os validate`, `os build`, `os lint`, `os dev` and `os serve` printed that error's message, which is its issues as a JSON array, with no file and no helper. The config module now loads through one seam that turns such an error into a refusal rendered by `formatZodError`:
✗ list.columns.0: Invalid input: expected string, received object
17
+
```
18
+
19
+
The file and line come from the evaluated bundle's source map. When the stack cannot tell which module threw, the refusal names the config entry and says so. The `--json` envelope's `error` carries the same text. Every other load failure (a syntax error, a missing import, a helper's own prose refusal, `defineStack`'s formatted refusal) is unchanged.
fix(create-objectstack): the scaffolded AGENTS.md lists only the `src/` directories the project's `objectstack.config.ts` loads
6
+
7
+
Clause-②: no
8
+
Metadata-protocol: none
9
+
10
+
The "Project Structure" block of the `AGENTS.md` a new project gets named `src/reports/`, `src/agents/`, `src/i18n/` and `src/handlers/`, which the scaffolded `objectstack.config.ts` never imports, so metadata a coding agent wrote there was never loaded and `npm run validate` still passed. It left out `src/skills/` and `src/picklists/`, which the config does load. The block now lists exactly the eight wired directories (objects, views, actions, flows, dashboards, apps, skills, picklists) and says that a new `src/` directory is never loaded or validated until its barrel is imported in `objectstack.config.ts`. What the config loads is unchanged.
11
+
12
+
An existing project keeps the `AGENTS.md` it was created with; to adopt the fix, edit its Project Structure block to match the directories its own `objectstack.config.ts` imports.
Copy file name to clipboardExpand all lines: content/docs/permissions/system-context.mdx
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -134,7 +134,7 @@ bugs — it is the protection or the side effect that silently does not happen.
134
134
| 21 |**`readonly` strip bypassed — INSERT**| objectql | Same, on create — one gate over BOTH create-side passes since the 2026-09-03 ruling moved the static-`readonly` strip in beside the runtime-owned one and deleted the DataProtocol ingress copy. `isSystem` is the **only** exemption on this path: `preserveAudit` is deliberately not read on create, so a non-system historical import is still stripped. A second read in the same symbol gates the pass that withholds those caller values from `beforeInsert` before the strip, the same exemption, so a system caller's hook still sees what it sent |`insert`|
135
135
| 21b |**`readonly` strip bypassed — the write PREVIEW (`ObjectQL.validate`)**| objectql | Same as 19–21, in the preview: it runs the write's caller-write strips under the write's own gate, so a system preview reports no `readonly` drop and judges the value a system write would store. The `computed` strip of a `formula` value is NOT gated here or on either write verb — no driver has a column for it, so it runs for every caller |`validate`|
136
136
| 22 | Strict-drop refusal never fires | objectql | Lose: a caller that opted into loud refusal gets **silence** — strict refuses exactly what the strip would have taken, and the strip took nothing. Two exceptions, both judged in every context: a `formula` value, which the `computed` strip takes from every caller, and a value for a stored field that declares `expression` when it differs from the value the engine computes in its place (`stored_expression`), so strict still refuses both |`insert`, `packages/objectql/src/readonly-strict-errors.ts#READONLY_CLASS_REASONS`|
137
-
| 23 |**Referential-integrity check skipped**| objectql | Get: writes proceed against unreachable/unresolvable targets. Lose: an `isSystem` caller can write a **dangling reference**|`assertReferencesResolve`|
137
+
| 23 |**Referential-integrity check skipped**— except a `runAs: 'system'` flow's record writes, which keep it | objectql | Get: writes proceed against unreachable/unresolvable targets — a seed replay, an import, a restore or a cascade may store a reference to a row that does not exist yet. Lose: an `isSystem` caller can write a **dangling reference**. A flow run's elevated context (`resolveRunDataContext`) carries an internal mark that keeps the check, so a flow's `create_record` / `update_record` naming a row that does not exist is refused `400 VALIDATION_FAILED` / `reference_not_found`, as on the user path; its authorization elevation is unchanged. A write the flow's write sets off (a hook's `ctx.api`, its `sudo()`, a cascade leg of a flow's delete) spreads the run's context and is checked as the flow's own, as on the user path. The mark is a symbol no flow definition or request can spell, and `ExecutionContextSchema.parse` drops it|`assertReferencesResolve`|
138
138
| 23b |**Position-catalog check skipped** — a `sys_user_position` write whose `position` names no position in the security catalog is not refused | plugin-security | Get: a system writer can store an assignment naming no position — the seed loader writes `stack.data` from `AppPlugin.start()` under a system context, as invitation acceptance and the platform's own bootstraps do. Lose: such a row grants nothing and nothing says so. A non-system insert, or a non-system update that changes `position`, is refused `400 VALIDATION_FAILED` / `reference_not_found` instead when the security catalog holds no position of that name: the environment registry (ADR-0131 D3), one per deployment, which takes no organization, so a name only a `sys_position` row carries — any organization's — is refused like one nobody carries. It is the same stand-down as the engine's referential-integrity check for a lookup column |`assertPositionNamesCatalogRow`|
139
139
| 23c |**Grant-name catalog check skipped** — a `sys_user_permission_set` write whose `permission_set` names no permission set in the security catalog is not refused | plugin-security | Get: a system writer can store a grant naming a set not yet registered — seed replay and boot provisioning may write the grant before the definition it names is registered. Lose: such a row grants nothing and nothing says so. A non-system insert, or a non-system update that changes `permission_set`, is refused `400 VALIDATION_FAILED` / `reference_not_found` instead when the security catalog holds no set by that name; a grant that names no set at all is refused `required` for every caller. The grant names its set by name alone, and nothing derives the name from `permission_set_id` (ADR-0131 D4, D10) |`packages/plugins/plugin-security/src/grant-permission-set-name.ts#onInsert`, `packages/plugins/plugin-security/src/grant-permission-set-name.ts#onUpdate`|
140
140
| 23d | **Grant-holder membership check skipped** — a `sys_user_position` or `sys_user_permission_set` write naming a user with no `sys_member` row in the row's organization is not refused | plugin-security | Get: a system writer can store such a grant — invitation acceptance writes the membership and its placement together, and seed replay, the organization-admin reconcile and the platform bootstraps write grants as the system. Lose: such a row takes effect once its user is admitted to the organization. A non-system insert, or a non-system update that moves `user_id` or `organization_id`, is refused `400 VALIDATION_FAILED` / `reference_not_found` at `user_id` instead, for every caller, a platform administrator included; the membership is read as `{ isSystem: true, tenantId }` with `tenantId` the row's own organization, never another one. A row stored with no organization is not judged. Under `single`, 18.0 stamps a new grant with the Default Organization, so such a row is one an earlier release wrote | `packages/plugins/plugin-security/src/grant-holder-membership-refusal.ts#onInsert`, `packages/plugins/plugin-security/src/grant-holder-membership-refusal.ts#onUpdate` |
@@ -147,7 +147,7 @@ bugs — it is the protection or the side effect that silently does not happen.
147
147
| 28 | Dependent-count disclosure on a blocked delete | objectql | Get: the count of blocking children. Nothing was elevated past the caller, so nothing is withheld |`dependentCountIsDisclosable`|
148
148
| 29 | Reference-cleanup log attributes the write to `'system'`| objectql | Get: an honest actor label instead of `anonymous` when the context carries neither `userId` nor `actor`|`recordReferenceCheckElevation`|
149
149
| 29b | A traversing validation rule's related read skips the **caller's bounds**| objectql | Get: no row bound from the caller's own read on a related object no organization wall scopes, no read door on a header the rule reads through a `master_detail` field, and a related read even with no organization under a walled posture (a `tenantId` on the context still scopes it). Every caller that is not system is held to all three: a header its read door does not return is unavailable to the rule exactly as a header that exists nowhere is, whatever it holds, and a header it can read is judged on its stored values. A plain `lookup` to an object an organization wall scopes asks no read door, system caller or not |`resolveOneHopRelated`|
150
-
| 29c | A detail write's master-detail header read asks **no read door**| objectql | Get: the write binds the header a parent-scoped `requiredWhen` / `readonlyWhen` reads as `parent` from the header's stored row whoever can read it, as before. Every caller that is not system meets its own read door first: a header that read does not return answers as a header that exists nowhere — an unbound `parent`, and `reference_not_found` on the reference check (which a system caller's write skips altogether) |`masterDetailHeadersCallerReads`|
150
+
| 29c | A detail write's master-detail header read asks **no read door**| objectql | Get: the write binds the header a parent-scoped `requiredWhen` / `readonlyWhen` reads as `parent` from the header's stored row whoever can read it, as before. Every caller that is not system meets its own read door first: a header that read does not return answers as a header that exists nowhere — an unbound `parent`, and `reference_not_found` on the reference check (which a system caller's write skips, a flow run's excepted) |`masterDetailHeadersCallerReads`|
151
151
| 30 |**Bulk data event `organizationId` OMITTED** — the batch is published "not asserted" | plugin-security | Get: nothing — the `data.records.*` event still publishes. Lose: the per-organization attribution: this exit is taken before the security middleware composes any tenant wall, so it records no Layer 0 verdict on the operation (`OperationContext.tenantLayer0Verdict`, #15813), and the engine's bulk producer — which reads that recorded verdict and nothing else — omits the key rather than filling it from the caller's `tenantId`; a tenant-scoped consumer then does not deliver the event inside an organization wall (#15225) |`registerAuthzMiddleware`|
152
152
| 30b |**The import doors admit a control opt-out** — `runAutomations: false` and `treatAsHistorical: true` on `POST /data/:object/import` and `/import/jobs`| rest | Get: an import whose rows are written with `skipAutomations` (no metadata-bound hook, no record-change trigger: an app's approvals and record freezes among them) or with `skipStateMachine` and `preserveAudit`. Every other caller, every signed-in user and administrator included, is refused `403 PERMISSION_DENIED` before the body is parsed, so nothing is written and no job is created. Inbound HTTP never carries the flag, so this is an in-process caller's door. Note: the flag still suppresses none of those controls by itself (see below); it only admits the opt-outs that do |`importControlOptOutRefusal`|
153
153
| 30c |**The import undo keeps the control skips** — `POST /data/import/jobs/:jobId/undo`| rest | Get: an undo whose deletes and restores are written with `skipAutomations` and `skipStateMachine`, so no metadata-bound hook, record-change trigger or `state_machine` rule refuses a reversal. Every other caller, every signed-in user and administrator included, undoes under those controls: a reversal one of them refuses is reported per row in the undo answer's `failures` and kept in the job's undo log, and the job is stamped reverted only once every row is. A historical job's `preserveAudit` belongs to the job, not the caller, and rides every undo. Inbound HTTP never carries the flag, so this is an in-process caller's door |`importUndoWriteContext`|
0 commit comments