diff --git a/.changeset/36053-skills-three-permission-axes.md b/.changeset/36053-skills-three-permission-axes.md new file mode 100644 index 00000000000..d4e757e16ae --- /dev/null +++ b/.changeset/36053-skills-three-permission-axes.md @@ -0,0 +1,17 @@ +--- +'@objectstack/skills': patch +'@objectstack/spec': patch +--- + +docs(skills): the data skill teaches the three permission axes, `viewAllFields` and the sensitivity tiers + +Clause-②: no +Metadata-protocol: none + +objectstack-data's `rules/security.md` now teaches the permission model in three axes. Object permission (`allowRead`, `allowCreate`, `allowEdit`, `allowDelete`) decides whether the caller can use the object at all. Record scope (`viewAllRecords`, `modifyAllRecords`) widens which records the caller reaches, and from v19 those two bits open no field. Fields are visible by default, so an author writes only the exceptions: nothing for an ordinary field, `fields` rows in the sets that differ for a position-dependent one, and `requiredPermissions` on the field itself for a high-sensitivity one (salary, ID numbers), with `maskingRule` where a partial value is needed. That gate is strictest-wins over every field row, `viewAllFields`, View All and Modify All. + +A new section teaches `viewAllFields: true` as the way to say "this set reads every field", for admin-like sets: a read vote on every field, fields added later included, and never an edit vote; the set's own `readable: false` row beats it; it grants no object access and widens no record; on the `'*'` entry it also votes on the fields of private-posture objects, which a plain `'*'` does not grant; it is authored in metadata, as Studio's permission matrix keeps the key and has no control for it. + +`evals/hooks-security-seeds-datasources.json` gains two cases: a read-everything auditor set written with `viewAllFields`, and salary and ID-number fields gated with `requiredPermissions` and `maskingRule`. Two restatements in `rules/security.md` were removed to pay for part of the new text (the "Locks, never grants" bullet and the recipe link of the `when` section). + +`@objectstack/spec`: two docblock sentences in `src/security/permission.zod.ts`, comments only. The `viewAllFields` docblock now says the key changes nothing on an object entry that carries View All or Modify All (it said "on a set"), and the `FieldPermissionSchema` docblock names `viewAllFields` beside the super-user bits as a voter in the field merge. No schema, description or generated artifact changes. diff --git a/content/docs/permissions/authorization.mdx b/content/docs/permissions/authorization.mdx index 70ef1ea2fc7..63f6de390e2 100644 --- a/content/docs/permissions/authorization.mdx +++ b/content/docs/permissions/authorization.mdx @@ -166,7 +166,11 @@ another set they hold casts a read vote on the field (its own `readable: true` entry, or View All or Modify All on the object); a co-held set that says nothing about the field does not restore it. A Modify All set still votes on every field, its own entries included. Otherwise union without deny is -unchanged. +unchanged. A set that carries `viewAllFields` on the object casts the same +read vote as View All, under the same own-entry exception, and never an edit +vote. From v19 View All and Modify All stop voting on fields: where a set +should read every field, grant +[`viewAllFields`](/docs/permissions/field-level-security#viewallfields-a-set-that-reads-every-field). Until the muting layer lands, protect sensitive fields by granting them only in the sets that need them, grant the object without Modify All to a set that must withhold a field from its own holders, and treat "sensitive field on a diff --git a/content/docs/permissions/field-level-security.mdx b/content/docs/permissions/field-level-security.mdx index 1801a80edbc..be86458f622 100644 --- a/content/docs/permissions/field-level-security.mdx +++ b/content/docs/permissions/field-level-security.mdx @@ -6,6 +6,92 @@ description: "Control visibility and editability of specific fields — readable Control visibility and editability of specific fields. +## The three axes + +A permission set answers three separate questions, and each key answers one +of them: + +| Axis | Keys | What it decides | +|:---|:---|:---| +| **Object permission** | `allowRead`, `allowCreate`, `allowEdit`, `allowDelete` | Whether the caller can use the object at all. | +| **Record scope** | `viewAllRecords`, `modifyAllRecords` | Which records the caller reaches. | +| **Fields** | `fields` rows, `viewAllFields`, and a field's own `requiredPermissions` | Which fields of those records the caller reads and edits. | + + +**From v19, View All and Modify All stop opening fields.** Until then a set +that holds `viewAllRecords` on an object also reads every field of it, and a +set that holds `modifyAllRecords` reads and edits every field (the exact votes +are under [Server-side enforcement](#server-side-enforcement-of-declared-rules)). +Do not build on that: where a set should read every field, grant +[`viewAllFields`](#viewallfields-a-set-that-reads-every-field). + + +## Choosing by sensitivity + +Fields are visible by default: a field that no permission set names follows +the object grant. Write a rule only for an exception, and pick the mechanism +by how sensitive the field is: + +| The field is | Write | Why | +|:---|:---|:---| +| **Ordinary** | Nothing. | It follows the object grant. | +| **Position-dependent**: one position reads or edits it, another does not | `fields` rows in the permission sets that differ. | Rows union across a user's sets, and the most permissive answer wins. | +| **High-sensitivity**: salary, ID numbers | `requiredPermissions` on the field itself, plus `maskingRule` where a partial value is needed. | The capability gate is applied after the sets are merged, so no field row, `viewAllFields`, View All or Modify All re-opens the field. | + +```typescript +// On the object: the gate travels with the field. +fields: { + salary: { type: 'currency', requiredPermissions: ['hr.view_compensation'] }, + id_number: { type: 'text', requiredPermissions: ['hr.view_identity'], maskingRule: 'id_card' }, +} + +// On the permission set whose holders read both in full. +definePermissionSet({ + name: 'hr_specialist', + systemPermissions: ['hr.view_compensation', 'hr.view_identity'], + objects: { employee: { allowRead: true, allowEdit: true } }, +}); +``` + +A caller who does not hold the capability gets `salary` stripped from every +record and reads `id_number` as its masked value. A write to either field is +refused. + +## `viewAllFields`: a set that reads every field + +`viewAllFields: true` on a set's object entry casts a read vote on every field +of that object, fields added later included. Use it for admin-like sets that +must read everything: + +```typescript +definePermissionSet({ + name: 'sales_manager', + objects: { crm_account: { allowRead: true, allowEdit: true, viewAllFields: true } }, + // The set's own row beats its own bit: its holders do not read this field. + fields: { 'crm_account.partner_margin': { readable: false } }, +}); +``` + +- **Read only.** It never casts an edit vote. An edit comes from the default + (a field no set names follows the object grant) or from an explicit + `editable: true` row. +- **A set's own row beats it.** A `readable: false` row in the same set keeps + that field hidden for that set. Another set's `viewAllFields` still reads + the field, because grants union across sets. +- **A field vote only.** It grants no object access, so pair it with + `allowRead`. It widens no record: that is `viewAllRecords`. +- **On the `'*'` entry** it votes on every object the set does not name + itself, private objects (`access.default: 'private'`) included. A `'*'` + entry without View All or Modify All gives no access to a private object, + but its `viewAllFields` still votes on that object's fields. So it re-opens + a field that is hidden by the set which does grant the object. +- **A capability gate still applies.** It does not lift a field's + `requiredPermissions` or a masking rule. +- **High-privilege.** A set that carries it cannot be bound to the `everyone` + or `guest` audience. +- **Authored in metadata.** Studio's permission matrix has no control for the + bit. It keeps the key when it saves a set that already carries it. + ## Field Permissions in Permission Sets Field permissions are keyed `.` and use `readable` / `editable`, @@ -156,9 +242,9 @@ roll-up is not a computed field in this sense: it does not follow the fields it aggregates, so mask it on its own where a set must not see it. The record the engine echoes for a public-form submission carries no computed field that reads through a -reference. View All and Modify All lift a permission set's `readable: -false`, not a capability gate or a masking rule, so their holders are -withheld a computed field over such a field too. To let a permission +reference. View All, Modify All and `viewAllFields` lift a permission set's +`readable: false`, not a capability gate or a masking rule, so their holders +are withheld a computed field over such a field too. To let a permission set's holders read a computed field, grant that set read on every field the expression reads, unmasked: the capability a field's `requiredPermissions` names also lifts a masking rule it gates, and a @@ -198,16 +284,20 @@ only constrain fields they explicitly enumerate, and field grants union most-permissively across a user's sets (one set's `readable: true` out-votes another set's `false`). Until a subtractive muting layer lands (ADR-0066 ⑧), a `{ readable: false }` rule masks the field only as long -as **no other set the user holds** declares it `readable: true` or holds +as **no other set the user holds** declares it `readable: true`, carries +`viewAllFields` on that object, or holds View All (`viewAllRecords`, reads every field of the object) or Modify All (`modifyAllRecords`, reads and edits every field) on that object, and the set that declares it does not itself hold Modify All on that object: -the set's own View All leaves its `readable: false` binding, while its +the set's own View All or `viewAllFields` leaves its `readable: false` +binding, while its own Modify All still reads and edits every field of the object, its own rows included (`security-superuser-field-mask-inert` warns on such a row), -until the field-axis split (#34365) — so -protect sensitive fields by granting them only in the sets that need -them, and treat a sensitive field on a broadly-granted object as a +until v19, when View All and Modify All stop voting on fields — so +gate a high-sensitivity field with `requiredPermissions` +([Choosing by sensitivity](#choosing-by-sensitivity)), grant a +position-dependent field only in the sets that need +it, and treat a sensitive field on a broadly-granted object as a review smell — see the [FLS posture warning](/docs/permissions/authorization#combination-semantics-the-fixed-order). Declared rules themselves are enforced fail-closed: a masked field is diff --git a/content/docs/permissions/permissions-matrix.mdx b/content/docs/permissions/permissions-matrix.mdx index 55337203528..eb59d5ca2a8 100644 --- a/content/docs/permissions/permissions-matrix.mdx +++ b/content/docs/permissions/permissions-matrix.mdx @@ -159,7 +159,7 @@ Field-level security controls visibility and editability of individual fields pe | `opportunity.amount` | Visible, Editable | Visible, Editable | Visible, Editable | Visible | Visible | | `opportunity.margin` | Visible, Editable | Visible, Editable | Hidden | Hidden | Hidden | -**View All / Modify All reach every field.** The Sales Manager column follows from section 2: `sales_manager_access` holds `viewAllRecords` on `contact` and `modifyAllRecords` on `opportunity`, and a set holding View All on an object reads every field of it that its own field rules do not hide, while Modify All reads and edits every field (ADR-0066 D2 ⑧ as amended). Field rules in other sets cannot hide `contact.ssn` from that manager. To keep a field from someone, withhold it in a set that grants the object without Modify All, and give them no other set that reads the field. +**View All / Modify All reach every field.** The Sales Manager column follows from section 2: `sales_manager_access` holds `viewAllRecords` on `contact` and `modifyAllRecords` on `opportunity`, and a set holding View All on an object reads every field of it that its own field rules do not hide, while Modify All reads and edits every field (ADR-0066 D2 ⑧ as amended). Field rules in other sets cannot hide `contact.ssn` from that manager. To keep a field from someone, withhold it in a set that grants the object without Modify All, and give them no other set that reads the field. From v19 these two bits stop reaching fields: a set that should read every field carries `viewAllFields`, and a high-sensitivity field is gated by `requiredPermissions` on the field itself ([Field-level security](/docs/permissions/field-level-security#choosing-by-sensitivity)). ### FLS States diff --git a/packages/core/src/security/superuser-field-vote-33828.test.ts b/packages/core/src/security/superuser-field-vote-33828.test.ts index 4921fc77476..c05f3e41072 100644 --- a/packages/core/src/security/superuser-field-vote-33828.test.ts +++ b/packages/core/src/security/superuser-field-vote-33828.test.ts @@ -14,7 +14,11 @@ */ import { describe, it, expect } from 'vitest'; -import { buildEffectiveFieldPermissions, superuserFieldVote } from './effective-object-permissions.js'; +import { + buildEffectiveFieldPermissions, + buildEffectiveObjectPermissions, + superuserFieldVote, +} from './effective-object-permissions.js'; describe('a set\'s own readable: false row and that set\'s own super-user vote', () => { const viewAll = ( @@ -129,3 +133,28 @@ describe('[field-axis split, ruling 6912661484] viewAllFields: a read vote throu } }); }); + +describe('[field-axis split, ruling 6912661484] a wildcard viewAllFields is posture-blind: it votes on a private object\'s fields and grants no object', () => { + // `vault` is private-posture, `deal` is public. The wildcard set carries a + // plain read grant and the bit: no super-user bit, so its `'*'` does not + // cover a private object. + const schemas = [{ name: 'vault', access: { default: 'private' } }, { name: 'deal' }]; + const wildcard = { objects: { '*': { allowRead: true, viewAllFields: true } } }; + // Another set grants `vault` by name and hides one field of it. + const hider = { objects: { vault: { allowRead: true } }, fields: { 'vault.pin': { readable: false, editable: false } } }; + + it('the object axis: the wildcard grants the public object and nothing on the private one', () => { + const objects = buildEffectiveObjectPermissions([wildcard], { allSchemas: () => schemas }); + expect(objects.deal?.allowRead).toBe(true); + expect(objects.vault).toBeUndefined(); + }); + + it('the field axis: the same wildcard still casts its read vote on the private object\'s field', () => { + expect(superuserFieldVote([wildcard], 'vault', 'pin')).toEqual({ readable: true, editable: false }); + // Control: without the bit the field stays hidden, so the vote below is the bit's. + expect(buildEffectiveFieldPermissions([{ objects: { '*': { allowRead: true } } }, hider])).toEqual({ + 'vault.pin': { readable: false, editable: false }, + }); + expect(buildEffectiveFieldPermissions([wildcard, hider])).toEqual({ 'vault.pin': { readable: true, editable: false } }); + }); +}); diff --git a/packages/plugins/plugin-security/src/fls-own-field-mask-33828.test.ts b/packages/plugins/plugin-security/src/fls-own-field-mask-33828.test.ts index e6eb7a39aa4..3064c64976c 100644 --- a/packages/plugins/plugin-security/src/fls-own-field-mask-33828.test.ts +++ b/packages/plugins/plugin-security/src/fls-own-field-mask-33828.test.ts @@ -332,3 +332,21 @@ describe('[ruling 6912661484, step 2] no behaviour change: the built-in admin se expect(merge([withBit(variant), APP_MASK])).not.toEqual(merge([variant, APP_MASK])); }); }); + +describe('[ruling 6912661484] a wildcard viewAllFields is posture-blind: it votes on a private object\'s fields and grants no object · getFieldPermissions', () => { + it('the wildcard does not cover the object when it is private, and its read vote on the fields stands', () => { + // The object axis honours the posture: a plain `'*'` (no View All, no + // Modify All) covers a public object and not a private one. + expect(evaluator.checkObjectPermission('find', OBJ, [WILDCARD_VIEW_ALL_FIELDS], { isPrivate: false })).toBe(true); + expect(evaluator.checkObjectPermission('find', OBJ, [WILDCARD_VIEW_ALL_FIELDS], { isPrivate: true })).toBe(false); + // The field axis takes no posture: the bit votes on every field of the + // object, so it re-opens what the set that DOES grant the object hides. + // Control first: a plain wildcard leaves the fields hidden. The row-blind + // merge is pinned beside it in core's `superuser-field-vote-33828.test.ts`. + const plainWildcard = set({ name: 'wildcard_plain', objects: { '*': { allowRead: true } } }); + const hidden = merge([plainWildcard, APP_MASK]); + for (const f of MASKED) expect(hidden[f], f).toEqual({ readable: false, editable: false }); + const fp = merge([WILDCARD_VIEW_ALL_FIELDS, APP_MASK]); + for (const f of MASKED) expect(fp[f], f).toEqual({ readable: true, editable: false }); + }); +}); diff --git a/packages/spec/src/security/permission.zod.ts b/packages/spec/src/security/permission.zod.ts index af6b27b20df..084001d4f9b 100644 --- a/packages/spec/src/security/permission.zod.ts +++ b/packages/spec/src/security/permission.zod.ts @@ -744,7 +744,8 @@ const ObjectPermissionBaseSchema = lazySchema(() => strictObject( * set does not name explicitly (the same lookup the super-user bits take). * * Today `viewAllRecords` / `modifyAllRecords` still vote on every field - * too, so on a set that carries either bit this key changes nothing; the + * too, so on an object entry that carries either bit (the set's own entry + * for the object, else its `'*'` entry) this key changes nothing; the * built-in admin sets carry it so they keep their field visibility when * those two bits stop voting on fields. * @@ -1083,11 +1084,14 @@ const FIELD_PERMISSION_ROLLUP_REASON_ON_HIDDEN = * condition matches, the entry votes as declared; on any other row the entry * is absent, so the most-permissive merge * (`PermissionEvaluator.getFieldPermissions`) is unchanged. Beside the - * declaring sets, a set holding the super-user bypass on the object votes on - * every field of it, on every row (ADR-0066 ⑧ note of 2026-11-02, ruling of - * record 6573563853): `viewAllRecords` votes `readable: true`, - * `modifyAllRecords` votes `readable: true` and `editable: true`; View All - * never grants an edit. One exception (ADR-0066 ⑧ note of 2026-11-15): a set + * declaring sets, a set holding the super-user bypass on the object, or + * carrying `viewAllFields` on it, votes on every field of it, on every row + * (ADR-0066 ⑧ note of 2026-11-02, ruling of record 6573563853; the field-axis + * split, ruling of record 6912661484): `viewAllRecords` votes + * `readable: true`, and so does `viewAllFields` (under the same exception as + * View All, below), `modifyAllRecords` votes `readable: true` and + * `editable: true`; View All and View All Fields + * never grant an edit. One exception (ADR-0066 ⑧ note of 2026-11-15): a set * holding View All without Modify All casts no read vote on a field its OWN * entry declares `readable: false`, so that row binds the set's own holders; * another set's vote, and the Modify All vote, are as before. Otherwise union diff --git a/scripts/check-skills-token-ratchet.mjs b/scripts/check-skills-token-ratchet.mjs index c3bd8ab5f32..d0aa8dd9769 100644 --- a/scripts/check-skills-token-ratchet.mjs +++ b/scripts/check-skills-token-ratchet.mjs @@ -1337,8 +1337,25 @@ export const CEILINGS = new Map([ // `origin/main` the file was 16164 bytes (4041 tokens, headroom 0); the // LANDED file is 16272 bytes -> 4068 tokens, ceiling +27, pinned AT the // measurement, zero headroom. - // ceil($(wc -c < skills/objectstack-data/rules/security.md) / 4) == ceil(16272 / 4) - ['skills/objectstack-data/rules/security.md', 4068], + // 4068 -> 4292 (card #36053, the Skills-docs follow-up of the field-axis + // split, ruling of record 6912661484): the three permission axes in the + // ruled model's words (object permission, record scope, fields); + // `viewAllFields` as "reads every field" (a read vote on every field, never + // an edit vote; the set's own `readable: false` row beats it; no object + // access and no record; on `'*'` it also votes on a private-posture object's + // fields; authored in metadata); the three sensitivity tiers; "from v19" + // View All / Modify All open no field; and `maskingRule` beside a field's + // `requiredPermissions` — none of which the file taught, so an author + // granted View All to open fields. Same standing ruling, tap A, verbatim and + // untranslated: 「A:先削重复,余额按实测提高」 (record 6513306068). PAID DOWN + // FIRST, 274 bytes: the `when` section's "Locks, never grants" bullet (140; + // the choice rule above it already says the other sets keep their grant, + // and the new section states the union rule) and the recipe URL (134; the + // docs anchor the same bullet keeps links it). On `origin/main` the file was + // 16272 bytes (4068 tokens, headroom 0); the LANDED file is 17168 bytes -> + // 4292 tokens, ceiling +224, pinned AT the measurement, zero headroom. + // ceil($(wc -c < skills/objectstack-data/rules/security.md) / 4) == ceil(17168 / 4) + ['skills/objectstack-data/rules/security.md', 4292], // 3024 -> 3109 (2026-08-31 app-repo-principles raise, see the block above). // Severity Levels listed the three values and left the CHOICE unstated: a // block rests on a judgement a person made, so a machine-inferred signal — a diff --git a/skills/objectstack-data/evals/hooks-security-seeds-datasources.json b/skills/objectstack-data/evals/hooks-security-seeds-datasources.json index 467f6ca1b72..eda61fa36fa 100644 --- a/skills/objectstack-data/evals/hooks-security-seeds-datasources.json +++ b/skills/objectstack-data/evals/hooks-security-seeds-datasources.json @@ -356,6 +356,26 @@ "must_contain": ["hook-body-does-not-compile", "ctx.input"], "must_not_contain": [] } + }, + { + "id": 36, + "prompt": "Our `crm_auditor` permission set must read every field of `crm_account`, including fields we add later, and edit none. Auditors also hold `sales_consultant`, which hides `crm_account.collected_total`. They reach only the accounts already shared with them: no wider record access. Write the `crm_auditor` set.", + "expected_output": "`definePermissionSet({ name: 'crm_auditor', objects: { crm_account: { allowRead: true, viewAllFields: true } } })`. `viewAllFields` is the field axis: a read vote on every field of the object, fields added later included, and never an edit vote, so no `allowEdit` and no `editable` row is needed to keep it read-only. Across sets the most permissive answer wins, so its vote reads `collected_total` although `sales_consultant` hides it. It grants no object access (hence `allowRead` beside it) and widens no record, so the auditors' record reach stays what sharing gives them. Not View All or Modify All: those are the record axis (they would hand the auditors every account), and from v19 they open no field. No per-field `readable: true` rows either: a row covers one field and misses the ones added later.", + "files": [], + "assertions": { + "must_contain": ["viewAllFields: true", "allowRead: true", "crm_account"], + "must_not_contain": ["viewAllRecords: true", "modifyAllRecords: true", "allowEdit: true"] + } + }, + { + "id": 37, + "prompt": "In our HR app, `employee.salary` and `employee.id_number` must stay closed to everyone except HR specialists. Department managers hold a set with Modify All on `employee`, and they must not see either field in full. Everyone who can read an employee should still see the ID number partially masked, to confirm identity.", + "expected_output": "The gate goes on the fields, not in a permission set: `salary: { type: 'currency', requiredPermissions: ['hr.view_compensation'] }` and `id_number: { type: 'text', requiredPermissions: ['hr.view_identity'], maskingRule: 'id_card' }` on `employee`, and the `hr_specialist` set grants both capabilities in `systemPermissions: ['hr.view_compensation', 'hr.view_identity']`. `requiredPermissions` is strictest-wins over every field row, `viewAllFields`, View All and Modify All, so the managers' Modify All does not re-open either field: a caller without the capability gets `salary` stripped on read and reads `id_number` as its partial value (the `maskingRule`), and a write to either is denied. A permission set's `readable: false` row on `employee.salary` would not do: field rows union across sets, and another set's vote on the field (a `readable: true` row, `viewAllFields`, View All or Modify All) re-opens it.", + "files": [], + "assertions": { + "must_contain": ["requiredPermissions", "maskingRule", "systemPermissions"], + "must_not_contain": ["'employee.salary': { readable: false"] + } } ] } diff --git a/skills/objectstack-data/rules/security.md b/skills/objectstack-data/rules/security.md index 6708b473eae..f61468f616d 100644 --- a/skills/objectstack-data/rules/security.md +++ b/skills/objectstack-data/rules/security.md @@ -20,9 +20,12 @@ export const salesUser = definePermissionSet({ ``` - `permissionSets:` is **refused at load** (`Unrecognized key(s) on this stack definition`, naming the key). -- Bits: `allowCreate` / `allowRead` / `allowEdit` / `allowDelete`, plus - `allowTransfer` (ownership change), `viewAllRecords` / `modifyAllRecords` - (super-user, bypass sharing). +- **Three axes.** Object permission: `allowCreate` / `allowRead` / + `allowEdit` / `allowDelete` (plus `allowTransfer`, ownership change) decide + whether the caller can use the object at all. Record scope: + `viewAllRecords` / `modifyAllRecords` (super-user, bypass sharing) widen + which records the caller reaches; from v19 they open no field (use + `viewAllFields`). Fields: § Field visibility. - **`isDefault: true` = the `everyone` baseline (ADR-0090 D5).** A published package declares **exactly one**, anchor-safe: `describeAnchorForbiddenBits(set, 'everyone')` (`@objectstack/spec/security`) returns `null`, else lint @@ -199,6 +202,25 @@ rowLevelSecurity: [ member directory and holds no business unit, and every org-wide default is owner-only for it: rows reach it **only** through the explicit grants above. +## Field visibility and `viewAllFields` + +Fields are visible by default: a field no set names follows the object grant, +and across sets the most permissive answer wins. Write only exceptions: + +- **Ordinary:** nothing. +- **Position-dependent:** `fields` rows in the sets that differ. +- **High-sensitivity** (salary, ID numbers): `requiredPermissions` on the + field (§ Sensitive fields). + +"Reads every field" is `viewAllFields: true` on the object entry +(`crm_account: { allowRead: true, viewAllFields: true }`), for admin-like sets: + +- A read vote on every field, later ones included; never an edit vote. +- The set's own `readable: false` row beats it. +- It grants no object access and no record. On `'*'` it also votes on the + fields of private-posture objects, which a plain `'*'` does not grant. +- Metadata only: Studio's matrix keeps the key, has no control for it. + ## Field permissions — a row-conditioned edit lock (`when`) A set's `fields` entry (`'OBJECT.FIELD': { readable, editable }`) may carry @@ -223,15 +245,10 @@ fields: { no relation reach (refused at `os validate` / publish). - **Pre-image.** An update is judged on the stored row, so a write cannot unlock itself by moving `status` back; an insert on the row as sent. -- **Locks, never grants.** On unmatched rows the entry is absent; another held - set's `editable: true` still wins (most-permissive merge). - Docs: https://objectstack.ai/docs/permissions/field-level-security#row-conditioned-edit-locks-when - and the recipe https://objectstack.ai/docs/permissions/access-recipes#data-lock-fields-for-a-position-once-a-record-reaches-a-stage ## Sensitive fields — `secret` type + `requiredPermissions` -`maskingRule` is **live** (FieldMasker). Two more channels: - **`type: 'secret'` (ADR-0100): query a credential only for presence.** A `secret` / `password` column is never a filter, sort, group-by or import `matchFields` key (`400 INVALID_FIELD`; an import row naming it fails). Search never scans it: keep it out of @@ -246,18 +263,14 @@ where: { api_key: { $null: false } } // ObjectQL, hook `query.filter` filter: [{ field: 'api_key', operator: 'is_not_null' }] // list view ``` -**Per-field access gating — `requiredPermissions` (ADR-0066 D3).** The field -is **masked on read and denied on write** unless -the caller holds ALL listed capabilities — strictest-wins -over permission-set field grants. +**High-sensitivity fields — `requiredPermissions` (ADR-0066 D3).** The field +is **stripped on read and denied on write** unless the caller holds ALL listed +capabilities (a set's `systemPermissions`): strictest-wins over every field +row, `viewAllFields`, View All and Modify All. With `maskingRule`, a caller +without them reads the partial value. ```typescript -fields: { - ssn: { - type: 'text', - requiredPermissions: ['view_pii'], - }, -} +id_number: { type: 'text', requiredPermissions: ['hr.view_identity'], maskingRule: 'id_card' }, ``` ## Multi-tenancy