Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions .changeset/34664-rollup-source-unreadable-reason.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
'@objectstack/spec': minor
'@objectstack/lint': minor
---

feat(spec, lint): a permission set can acknowledge a meant roll-up read with `rollupSourceUnreadableReason`

Clause-②: yes (widening) — one new optional authorable key, `rollupSourceUnreadableReason` on `FieldPermissionSchema` (a permission set's `fields` entry); nothing that parsed before is refused
Metadata-protocol: added
Skills-docs: follow-up #34742

`security-rollup-source-unreadable` warns when a permission set reads a roll-up `summary` column over child data it cannot read. The pair is legal and often meant, but `os lint --strict` fails on any warning and there was no way to say so. Now the set's entry for the summary column can carry the reason: `fields: { 'crm_account.invoiced_amount': { readable: true, rollupSourceUnreadableReason: 'Service staff read account totals but not invoice rows' } }`. That one finding (this set, this column) is reported as an `info` note quoting the reason, so `--strict` passes; other sets, other columns and `security-rollup-source-row-scoped` are unchanged. The key is read only at authoring time; the runtime does not read it. A blank reason, and a reason beside `readable: false`, are refused at parse time.
19 changes: 19 additions & 0 deletions content/docs/data-modeling/fields.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -415,6 +415,25 @@ If the value should not be visible, set `readable: false` on the summary field i
that set: it hides the field from every holder of the set, and another set they
hold with no entry for the field does not restore it, so declare `readable: true`
on the field in the sets whose holders should keep it.
If the set is meant to read the total without its children (an account total
shown to staff who may not see invoice rows), acknowledge that on the same entry
with the reason, and the warning for that set and column becomes a note quoting
it, so `os lint --strict` passes:

```ts
fields: {
'crm_account.invoiced_amount': {
readable: true,
rollupSourceUnreadableReason: 'Service staff read account totals but not invoice rows',
},
},
```

Only these authoring checks read the key. The entry that carries it is still an
ordinary field permission, though, and votes `readable: true`: on a set that had
no entry for the summary, adding one restores the column for holders whose other
sets mask it. Every other set and column is still reported, and a blank reason,
or one beside `readable: false`, is refused.

A child validation rule can read a parent summary one hop through its
reference, for example "each supplier has at most one primary contact" as a
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 @@ -528,7 +528,7 @@ orthogonal to both, and no cell here can carry it; it is written out in
| Row-level-security predicates (#4983) — a permission set's policies, an object's `defaultRowScope`, a membership key's `filter` and a field permission entry's `when` (#25866); at the save door also a membership key nothing owns (#25234) | ✓ | ✓ | ✓ | ✓ᵖᵉᵒ |
| Membership key declarations — `userField` / `valueField` columns, one key on one object, a key the registered resolver also owns (save door only) (#25234) | ✓ | ✓ | ✓ | ✓ᵒ |
| Advisory: retired permission residue — the `allowRestore` / `allowPurge` default the parse strips in silence (`permission-retired-lifecycle-residue`, #17425) | ✓ | ✓ | ✓ | ✓ᵖᵉ |
| Advisory: a roll-up a permission set reads over child data it cannot read — the child object, the aggregated child field or a field the roll-up's `filter` tests unreadable to the set, through its grants, its field entries or a `requiredPermissions` capability it lacks (`security-rollup-source-unreadable`, a warning), or child rows a row-level policy narrows (`security-rollup-source-row-scoped`, a note); a roll-up aggregates the whole child collection and follows only the parent field's own permissions | ✓ | ✓ | ✓ | — |
| Advisory: a roll-up a permission set reads over child data it cannot read — the child object, the aggregated child field or a field the roll-up's `filter` tests unreadable to the set, through its grants, its field entries or a `requiredPermissions` capability it lacks (`security-rollup-source-unreadable`, a warning), or child rows a row-level policy narrows (`security-rollup-source-row-scoped`, a note); a roll-up aggregates the whole child collection and follows only the parent field's own permissions. A set whose entry for the summary column carries `rollupSourceUnreadableReason` gets that warning as a note quoting the reason | ✓ | ✓ | ✓ | — |
| Platform-schedule `create_record` organization (#6285) | — | — | — | ✓ᶠ |
| Public-form anonymous intake on this deployment's tenancy posture — advisory only (#21476) | — | — | — | ✓ᵛ |
| Public-form file fields — a form open to anonymous intake whose sections declare a `file`, `image`, `avatar`, `video` or `audio` field (#25650) | ✓ | ✓ | ✓ | ✓ᵛ |
Expand Down
5 changes: 4 additions & 1 deletion content/docs/protocol/objectql/security.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ rowLevelSecurity:

## 3. Field-Level Security

Field permissions are a map on the permission set keyed by `<object>.<field>`, each with two boolean flags and an optional row condition (`FieldPermissionSchema`):
Field permissions are a map on the permission set keyed by `<object>.<field>`, each with two boolean flags, an optional row condition and, on a roll-up summary column, an optional authoring-time acknowledgement (`FieldPermissionSchema`):

```yaml
# sales_rep.permission.yml (continued)
Expand Down Expand Up @@ -259,12 +259,15 @@ fields:
readable: true | false # default true — can see the field
editable: true | false # default false — can modify the field
when: "status == 'approved'" # optional — a row condition on the EDIT vote, in RLS `using`'s CEL
rollupSourceUnreadableReason: "…" # optional — meaningful on a summary column: why this set reads the roll-up without its child data (read by `os lint`, never at runtime)
```

> There is no separate `create` flag for fields. `editable` governs both create-time and update-time writes; read stripping is governed by `readable`.

> `when` narrows **where** the entry votes: on a matching row it votes as declared, on every other row it is absent (as if the set had not declared the field). The write gate judges the stored row before an update and each incoming row of an insert, in process; a row it cannot judge (a predicate update, a stored row the caller cannot read, a condition that does not resolve for the request) applies the entry as its lock. `readable: false` beside a `when` is refused at parse time, and `objectstack validate` judges the condition like an RLS predicate. Readers that hold no row (`/auth/me/permissions`, `os explain`) report the entry as its lock; the record-scoped projection (`GET /data/{object}/{id}/field-access`, the answer a record's edit form reads) judges the stored row exactly as the write gate does. See [Field-level security](/docs/permissions/field-level-security#row-conditioned-edit-locks-when).

> The runtime does not read `rollupSourceUnreadableReason`, but the entry carrying it votes like any declaring entry (`readable: true` by default), so on a set that had no entry for the column, adding one restores the column for holders whose other sets mask it. A set that reads a roll-up `summary` column but not the child data it aggregates draws the `security-rollup-source-unreadable` warning from `os lint`, `os validate` and `os build`; a non-blank reason on the set's entry for that column turns that one warning into a note quoting the reason. A blank reason, or one beside `readable: false`, is refused at parse time. See [Calculation types](/docs/data-modeling/fields#calculation-types).

### Static `readonly` fields on the write path

`readonly: true` on a field definition is a *schema-level* lock, independent of permission
Expand Down
3 changes: 2 additions & 1 deletion content/docs/references/api/protocol.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -1711,7 +1711,7 @@ One changed key path of the pending draft, and the last write that changed it.
| :--- | :--- | :--- | :--- |
| **object** | `string` | ✅ | Object name |
| **permissions** | `{ allowCreate?: boolean; allowRead?: boolean; allowEdit?: boolean; allowDelete?: boolean; … }` | ✅ | Object-level permissions |
| **fieldPermissions** | `Record<string, { readable?: boolean; editable?: boolean; when?: string }>` | optional | Field-level permissions keyed by field name |
| **fieldPermissions** | `Record<string, { readable?: boolean; editable?: boolean; when?: string; rollupSourceUnreadableReason?: string }>` | optional | Field-level permissions keyed by field name |

### Nested Shape: `GetObjectPermissionsResponse.permissions`

Expand Down Expand Up @@ -1739,6 +1739,7 @@ One changed key path of the pending draft, and the last write that changed it.
| **readable** | `boolean` | optional (default: `true`) | Field read access |
| **editable** | `boolean` | optional (default: `false`) | Field edit access |
| **when** | `string` | optional | Row condition narrowing where this entry votes, authored in canonical CEL like `rowLevelSecurity[].using` (a field of this object compared with a literal or a `current_user.*` value using `==`, `!=`, `<`, `<=`, `>`, `>=` or `in`, combined with `&&` / `\|\|`; e.g. status in ["approved", "signing", "active"]). Absent, the entry votes on every row. Present, the entry votes as declared on the rows the condition matches and is ABSENT on every other row, so the most-permissive merge across the caller's sets is unchanged: a set that locks a field only from a stage onward does not lock the rows before it, and a co-held set that says nothing about the field still lifts nothing, unless it holds the super-user bypass on the object (its own entry for the object, otherwise its `'*'` wildcard). Such a set votes on every field of the object, on every row, whatever `when` says: `viewAllRecords` votes `readable: true`, and `modifyAllRecords` votes `readable: true` and `editable: true`, so a row-conditioned lock never binds a Modify All holder. View All never grants an edit. Otherwise union without deny is unchanged. The write gate judges the condition on the stored row BEFORE an update (so a lock on `status in [...]` holds on an approved row even when the write changes `status`) and on the incoming row of an insert, as the caller sent it. It reaches the EDIT vote only — reads are judged row-blind — so `readable: false` beside a `when` is refused at parse time: keep `readable: true` (the default) on a row-conditioned entry. Where no row can be judged (a predicate update with no row address, a stored row the caller cannot read, a condition that does not resolve for the request) the entry is judged as its lock: it contributes no edit grant on that write. Validated like an RLS predicate at authoring and publish time: the fields it names must exist on the entry's object and it may not reach across a relation; a condition that cannot be lowered is refused there, never dropped at runtime. Readers that hold no row (`/auth/me/permissions`, the object-wide field projections, the write preview on an update) report a row-conditioned entry as its lock, so a client never advertises an edit the gate refuses. The record-scoped field projection (`GET /data/{object}/{id}/field-access`, the answer a record's edit form reads) holds the row: it judges the condition on the stored row exactly as the write gate does on an update of that row, so a lock that applies only from a stage onward disables the field only on the rows it names. |
| **rollupSourceUnreadableReason** | `string` | optional | Authoring-time acknowledgement, read only by `os lint` (the runtime does not read it): why holders of this set are meant to read this roll-up `summary` column although the set cannot read the child object, the aggregated child field or a child field the roll-up's `filter` tests (e.g. 'Service staff read account totals but not invoice rows'). Declared on the set's entry for the summary column, it turns that set's `security-rollup-source-unreadable` warning for the column into an `info` note quoting the reason, so `os lint --strict` passes; every other finding is unchanged. The runtime does not read the key, but the entry that carries it is an ordinary declaring entry: it votes `readable: true` in the field merge (only declaring sets vote, and the most permissive vote wins), so on a set that had no entry for the column, adding one to carry the reason restores the column for holders whose other sets mask it. A blank reason is refused, and so is a reason beside `readable: false`, an entry that declares no read to acknowledge. |


---
Expand Down
Loading
Loading