Skip to content

Commit 70db6d0

Browse files
committed
fix(plugin-auth): the SSO delete-revoke names the grant's organization as its tenant
The grant removal on deleting an SSO group mapping now carries the system context with the grant's organization as tenant, as the sign-in's own grant writes do. The tenant-audit census and its page are recounted for the new write site. Co-authored-by: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01ADHkmNwrm1hJ9e7eLARM7n
1 parent da13e59 commit 70db6d0

3 files changed

Lines changed: 28 additions & 26 deletions

File tree

‎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 |

‎packages/plugins/plugin-auth/src/idp-group-mapping-admin.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,8 @@ async function revokeSsoProjectedGrants(
289289
const writer: IDataEngine = withSystemContext(engine);
290290
const users = new Set<string>();
291291
for (const grant of Array.isArray(grants) ? (grants as Record<string, unknown>[]) : []) {
292-
await writer.delete(GRANT_OBJECT, { where: { id: text(grant.id) } });
292+
// The grant's organization is the write's tenant, as on the sign-in's own writes.
293+
await writer.delete(GRANT_OBJECT, { where: { id: text(grant.id) }, context: { isSystem: true, tenantId: organizationId } });
293294
users.add(text(grant.user_id));
294295
}
295296
return { reprojected: true, reconciledUsers: users.size };

0 commit comments

Comments
 (0)