Skip to content

Commit a135e65

Browse files
committed
Merge origin/main into claude/project-thread-o96evq
Claude-Session: https://claude.ai/code/session_01ADHkmPHUhgip3YbMfQh27s Co-authored-by: Claude <noreply@anthropic.com>
2 parents 28e7e92 + 8c9260f commit a135e65

25 files changed

Lines changed: 1261 additions & 147 deletions
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
---
2+
'@objectstack/metadata': patch
3+
---
4+
5+
feat(metadata): a read-only count of the history snapshots the drained-key scrub would rewrite
6+
7+
Clause-②: no
8+
Metadata-protocol: none
9+
10+
`@objectstack/metadata/migrations` gains `scrubHistoryDrainedKeys(driver, { mode: 'count' })`, the count mode of a one-time scrub of `sys_metadata_history` snapshots written before history started withholding what a connector save drains (undeclared `auth` keys).
11+
12+
- **One predicate.** A stored snapshot is counted exactly when `historySnapshotBody` — the helper both history writers already store through — would store a different body for it today. Nothing in the count names a key or a type, so the count and the write-time withholding cannot disagree, and a snapshot written since that withholding landed is never counted.
13+
- **Read-only.** It takes a driver's `find` and nothing else, pages the table by primary key, and reports the number of affected rows, the number of distinct items they belong to, and the affected rows' ids as opaque handles. A body that is not JSON, or one the snapshot helper cannot reduce, is listed beside the count, never folded into it. The result never carries a key name, a value or a body.
14+
- **Count only.** Any other mode is refused before anything is read. The rewrite of stored history runs only after the maintainer confirms the count; run the count on a copy of the database and hand its numbers over privately.
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
---
2+
'@objectstack/plugin-auth': patch
3+
'@objectstack/platform-objects': patch
4+
---
5+
6+
feat(plugin-auth): an SSO sign-in grants the ordinary permission set its IdP group is mapped to
7+
8+
Clause-②: yes (widening)
9+
Metadata-protocol: none
10+
11+
An enterprise SSO provider (OIDC or SAML, through `@better-auth/sso`) can now drive what its users may do from the groups the identity provider sends at sign-in, through the same `sys_idp_group_mapping` mappings a SCIM connection uses. There is no second mapping model.
12+
13+
- **Where the groups come from.** Set the provider's own claim mapping to fill `groups`: `mapping.extraFields: { groups: 'groups' }` for an OIDC claim named `groups`, or the attribute name an IdP uses for SAML (for example Entra ID's groups claim URI). The value may be one string or a list of strings. A provider whose mapping fills no `groups` behaves as before.
14+
- **Saving a mapping.** `POST /api/v1/auth/admin/scim/set-group-mapping` now also takes `providerId` in place of `connectionId` (exactly one of the two; both is `400 VALIDATION_FAILED` on `providerId`). The grant's organization is the provider's own `organization_id`; a provider that names none, or an unknown provider, is refused `400 VALIDATION_FAILED` on `providerId`. With SSO off the save is refused `503`. The same platform-admin gate and the same organization-boundary judgement apply: administrator sets and every set outside the organization boundary are refused, and without a security service the save is refused `503`. The row is stored with `source_kind: 'sso'` (a new option on `sys_idp_group_mapping.source_kind`) and `source_id` = the provider id.
15+
- **At each sign-in.** Every sign-in through the provider matches each group value against the provider's mappings (by `groupExternalId` when the mapping names one, which suits Entra ID's group object ids, else by exact `groupDisplayName`) and makes the user's grants follow them: a mapped group grants its set in the provider's organization, and a group the user has left loses the set at their next sign-in. A sign-in with no groups removes the grants that provider made earlier. The boundary is asked again before every grant, so a set that becomes an administrator set after its mapping was saved grants nothing, and with no security service nothing is granted. Only grants the provider made (their `reason` names the provider) are ever removed: a grant made by hand, or by SCIM, is never touched. Every write goes through the engine, so the break-glass last-administrator guard still refuses what it refuses elsewhere. If applying the mappings fails, the sign-in still succeeds and the failure is logged at `error`.
16+
- **Deleting a mapping.** `POST /api/v1/auth/admin/scim/delete-group-mapping` removes an SSO mapping and, at once, the grants its provider made of that set in that organization, unless another of the provider's mappings still names that set (then each user's next sign-in decides).

‎content/docs/permissions/tenant-audit-census.mdx‎

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ are reported as `undecidable` rather than assumed either way.
132132

133133
The same holds twice over for the context. An options argument spelled as a
134134
literal can be read; one spelled `options`, `{ ...opts }`, or handed through a
135-
forwarding shim cannot, and **57 of the 275 sites are spelled that way**. A
135+
forwarding shim cannot, and **57 of the 276 sites are spelled that way**. A
136136
context resolved from an inline literal or a local `const` can be tested for
137137
`isSystem`; one arriving from a helper call cannot.
138138

@@ -197,10 +197,10 @@ reproduce them. Where it disagrees, it disagrees on the page:
197197

198198
| carried figure | where it survives | this census |
199199
| :--- | :--- | ---: |
200-
| 175 write call sites | quoted in the merged changeset | **275** |
200+
| 175 write call sites | quoted in the merged changeset | **276** |
201201
| 24 carrying no tenant context | quoted in the merged changeset | **3** provable and tenancy-enabled; **30** more whose options argument is unreadable |
202-
| 127 of 175 statically decidable, 48 runtime-parameter-name sites | restated on the `isSystem`-scoping card | **195 of 275** decidable, **80** undecidable |
203-
| 135 (77%) silenced by the `isSystem` guard before the posture gate | the lost issue body — **no surviving corroboration** | **not reproduced**: 152 decidably elevated, 0 decidably not, 113 undecidable |
202+
| 127 of 175 statically decidable, 48 runtime-parameter-name sites | restated on the `isSystem`-scoping card | **196 of 276** decidable, **80** undecidable |
203+
| 135 (77%) silenced by the `isSystem` guard before the posture gate | the lost issue body — **no surviving corroboration** | **not reproduced**: 153 decidably elevated, 0 decidably not, 113 undecidable |
204204
| 141 and 132, two independent re-derivations | the card that filed this work | — |
205205

206206
**The differences are not reconciled, and deliberately so.** The old census's
@@ -211,17 +211,17 @@ at any commit.
211211

212212
Two structural facts do plausibly widen this reading against any hand or regex
213213
one, and both are counted in the generated tables below: the 62 sites reached
214-
through an erased (`any`) receiver, and the 71 that name their object through a
214+
through an erased (`any`) receiver, and the 72 that name their object through a
215215
`const` rather than inline. An instrument that read either the way a person does
216216
would report a smaller number and would not say so.
217217

218218
The fourth row is the one worth flagging to anyone citing it. **The 135 / 77%
219219
figure has no surviving corroboration anywhere in the tree.** This census reads
220-
152 of 275 (55%) as decidably elevated, with 113 more whose elevation is a
220+
153 of 276 (55%) as decidably elevated, with 113 more whose elevation is a
221221
run-time fact — so the claim is neither confirmed nor refuted, and the honest
222222
answer is that a static reading cannot settle it.
223223

224-
⇒ **Cite `3 / 275`, and say what it is**: the sites whose options argument was
224+
⇒ **Cite `3 / 276`, and say what it is**: the sites whose options argument was
225225
READ and holds no tenant context, against a decidably tenancy-enabled object.
226226
That is the control's provable yield surface. ⛔ Do not cite it as "the sites
227227
without tenant context" — **30 further sites** have an options argument this
@@ -233,29 +233,29 @@ cannot read, and they are neither in nor out.
233233

234234
| what | count |
235235
| :--- | ---: |
236-
| write call sites on the application surface | **275** |
237-
| …whose object name is statically decidable | 195 |
236+
| write call sites on the application surface | **276** |
237+
| …whose object name is statically decidable | 196 |
238238
| …whose object name is chosen at run time | 80 |
239-
| …against an object with tenancy ENABLED | 189 |
239+
| …against an object with tenancy ENABLED | 190 |
240240
| …against an object that declares tenancy off | 6 |
241-
| threading a tenant context | 208 |
241+
| threading a tenant context | 209 |
242242
| PROVABLY carrying none (options read, no context key) | **10** |
243243
| …of those, against a decidably tenancy-enabled object | **3** |
244244
| options argument UNREADABLE — may or may not carry one | 57 |
245245
| …of those, against a decidably tenancy-enabled object | 30 |
246-
| threading a decidably ELEVATED (`isSystem`) context | 152 |
246+
| threading a decidably ELEVATED (`isSystem`) context | 153 |
247247
| threading a context that is decidably NOT elevated | 0 |
248248
| threading a context whose elevation is a run-time fact | 113 |
249249

250250
| how the instrument reached the site | count |
251251
| :--- | ---: |
252-
| receiver carried a readable engine type | 213 |
252+
| receiver carried a readable engine type | 214 |
253253
| receiver erased, placed by the object NAME | 52 |
254254
| receiver erased, placed by an `object: string` PARAMETER | 5 |
255255
| receiver erased, placed by an `UNTYPED_RECEIVERS` row | 5 |
256256

257257
| object name spelled inline | 124 |
258-
| object name spelled through a `const` | 71 |
258+
| object name spelled through a `const` | 72 |
259259
| object name is an `object: string` parameter | 7 |
260260
| object name is some other run-time expression | 73 |
261261

@@ -307,12 +307,12 @@ holds still. They are required to be HERE and to say WHEN they were true;
307307
their values are not compared. The reasoning, and the measurement behind it,
308308
are in `scripts/check-tenant-audit-census.mjs`.
309309

310-
Measured on 2026-11-08 at `fe3aea79c`.
310+
Measured on 2026-11-08 at `da13e5987`.
311311

312312
| corpus scale (not enforced) | count |
313313
| :--- | ---: |
314-
| tracked non-test sources scanned | 1063 |
315-
| engine-shaped types recognised | 114 |
314+
| tracked non-test sources scanned | 1068 |
315+
| engine-shaped types recognised | 115 |
316316
| declared objects in the registry | 132 |
317317
| same-named calls subtracted as non-engine | 243 |
318318

‎docs/audits/2026-08-tenant-audit-write-call-sites.counts.md‎

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,17 +33,17 @@ silent, and `node scripts/tenant-audit-census.mjs --write` is the resolution.
3333

3434
| Measure | Value |
3535
|---|---:|
36-
| Write call sites | 275 |
37-
| Object name statically decidable | 195 |
36+
| Write call sites | 276 |
37+
| Object name statically decidable | 196 |
3838
| Object name chosen at run time | 80 |
39-
| Against a tenancy-enabled object | 189 |
39+
| Against a tenancy-enabled object | 190 |
4040
| Against an object declaring tenancy off | 6 |
41-
| Threading a tenant context | 208 |
41+
| Threading a tenant context | 209 |
4242
| Provably carrying none | 10 |
4343
| …and decidably tenancy-enabled | 3 |
4444
| Options argument unreadable | 57 |
4545
| …and decidably tenancy-enabled | 30 |
46-
| Threading a decidably elevated context | 152 |
46+
| Threading a decidably elevated context | 153 |
4747
| Threading a decidably non-elevated context | 0 |
4848
| Threading a context of undecidable elevation | 113 |
4949

@@ -90,12 +90,12 @@ holds still. They are required to be HERE and to say WHEN they were true;
9090
their values are not compared. The reasoning, and the measurement behind it,
9191
are in `scripts/check-tenant-audit-census.mjs`.
9292

93-
Measured on 2026-11-08 at `fe3aea79c`.
93+
Measured on 2026-11-08 at `da13e5987`.
9494

9595
| corpus scale (not enforced) | count |
9696
| :--- | ---: |
97-
| tracked non-test sources scanned | 1063 |
98-
| engine-shaped types recognised | 114 |
97+
| tracked non-test sources scanned | 1068 |
98+
| engine-shaped types recognised | 115 |
9999
| declared objects in the registry | 132 |
100100
| same-named calls subtracted as non-engine | 243 |
101101

@@ -158,6 +158,7 @@ Measured on 2026-11-08 at `fe3aea79c`.
158158
| `packages/plugins/plugin-auth/src/idp-group-mapping-admin.ts` | `delete` | `IDP_GROUP_MAPPING_OBJECT` | undecidable | PROVABLY NONE | 1 |
159159
| `packages/plugins/plugin-auth/src/idp-group-mapping-admin.ts` | `insert` | `IDP_GROUP_MAPPING_OBJECT` | undecidable | options unreadable | 1 |
160160
| `packages/plugins/plugin-auth/src/idp-group-mapping-admin.ts` | `insert` | `sys_audit_log` | enabled | elevated | 1 |
161+
| `packages/plugins/plugin-auth/src/idp-group-mapping-admin.ts` | `delete` | `sys_user_permission_set` | enabled | elevated | 1 |
161162
| `packages/plugins/plugin-auth/src/idp-locale-claim.ts` | `update` | `sys_user` | enabled | elevated | 1 |
162163
| `packages/plugins/plugin-auth/src/mcp-client-last-use.ts` | `update` | `sys_oauth_consent` | enabled | elevated | 1 |
163164
| `packages/plugins/plugin-auth/src/member-role-canonical.ts` | `update` | `MEMBER_OBJECT` | undecidable | elevated | 1 |

0 commit comments

Comments
 (0)