Skip to content

Commit c8e10b4

Browse files
committed
fix(plugin-auth): the SCIM credential writes spell their system context, and the census counts them
The door's audit insert and the revoke update now pass their system context as a readable literal, so the tenant-audit census reads both as decidably elevated instead of unreadable or context-free. The census artefacts are regenerated for the two new write call sites (261 -> 263) and the page's hand-written figures follow. The test file's log reader gets the parameter type tsconfig.test.json asks for. Claude-Session: https://claude.ai/code/session_016WV4cycHNJyS5MXHqaGsFE Co-Authored-By: Claude <noreply@anthropic.com>
1 parent ac688f4 commit c8e10b4

5 files changed

Lines changed: 39 additions & 35 deletions

File tree

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

Lines changed: 20 additions & 20 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 **55 of the 261 sites are spelled that way**. A
135+
forwarding shim cannot, and **55 of the 263 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 | **261** |
200+
| 175 write call sites | quoted in the merged changeset | **263** |
201201
| 24 carrying no tenant context | quoted in the merged changeset | **2** provable and tenancy-enabled; **29** more whose options argument is unreadable |
202-
| 127 of 175 statically decidable, 48 runtime-parameter-name sites | restated on the `isSystem`-scoping card | **184 of 261** decidable, **77** undecidable |
203-
| 135 (77%) silenced by the `isSystem` guard before the posture gate | the lost issue body — **no surviving corroboration** | **not reproduced**: 144 decidably elevated, 0 decidably not, 109 undecidable |
202+
| 127 of 175 statically decidable, 48 runtime-parameter-name sites | restated on the `isSystem`-scoping card | **186 of 263** decidable, **77** undecidable |
203+
| 135 (77%) silenced by the `isSystem` guard before the posture gate | the lost issue body — **no surviving corroboration** | **not reproduced**: 146 decidably elevated, 0 decidably not, 109 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 68 that name their object through a
214+
through an erased (`any`) receiver, and the 69 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-
144 of 261 (55%) as decidably elevated, with 109 more whose elevation is a
220+
146 of 263 (56%) as decidably elevated, with 109 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 `2 / 261`, and say what it is**: the sites whose options argument was
224+
⇒ **Cite `2 / 263`, 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" — **29 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 | **261** |
237-
| …whose object name is statically decidable | 184 |
236+
| write call sites on the application surface | **263** |
237+
| …whose object name is statically decidable | 186 |
238238
| …whose object name is chosen at run time | 77 |
239-
| …against an object with tenancy ENABLED | 178 |
239+
| …against an object with tenancy ENABLED | 180 |
240240
| …against an object that declares tenancy off | 6 |
241-
| threading a tenant context | 198 |
241+
| threading a tenant context | 200 |
242242
| PROVABLY carrying none (options read, no context key) | **8** |
243243
| …of those, against a decidably tenancy-enabled object | **2** |
244244
| options argument UNREADABLE — may or may not carry one | 55 |
245245
| …of those, against a decidably tenancy-enabled object | 29 |
246-
| threading a decidably ELEVATED (`isSystem`) context | 144 |
246+
| threading a decidably ELEVATED (`isSystem`) context | 146 |
247247
| threading a context that is decidably NOT elevated | 0 |
248248
| threading a context whose elevation is a run-time fact | 109 |
249249

250250
| how the instrument reached the site | count |
251251
| :--- | ---: |
252-
| receiver carried a readable engine type | 199 |
252+
| receiver carried a readable engine type | 201 |
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

257-
| object name spelled inline | 116 |
258-
| object name spelled through a `const` | 68 |
257+
| object name spelled inline | 117 |
258+
| object name spelled through a `const` | 69 |
259259
| object name is an `object: string` parameter | 7 |
260260
| object name is some other run-time expression | 70 |
261261

@@ -307,13 +307,13 @@ 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-05 at `e40e04854`.
310+
Measured on 2026-11-06 at `ac688f409`.
311311

312312
| corpus scale (not enforced) | count |
313313
| :--- | ---: |
314-
| tracked non-test sources scanned | 871 |
315-
| engine-shaped types recognised | 105 |
316-
| declared objects in the registry | 127 |
317-
| same-named calls subtracted as non-engine | 229 |
314+
| tracked non-test sources scanned | 1037 |
315+
| engine-shaped types recognised | 111 |
316+
| declared objects in the registry | 130 |
317+
| same-named calls subtracted as non-engine | 230 |
318318

319319
{/* END GENERATED: tenant-audit-census */}

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

Lines changed: 12 additions & 10 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 | 261 |
37-
| Object name statically decidable | 184 |
36+
| Write call sites | 263 |
37+
| Object name statically decidable | 186 |
3838
| Object name chosen at run time | 77 |
39-
| Against a tenancy-enabled object | 178 |
39+
| Against a tenancy-enabled object | 180 |
4040
| Against an object declaring tenancy off | 6 |
41-
| Threading a tenant context | 198 |
41+
| Threading a tenant context | 200 |
4242
| Provably carrying none | 8 |
4343
| …and decidably tenancy-enabled | 2 |
4444
| Options argument unreadable | 55 |
4545
| …and decidably tenancy-enabled | 29 |
46-
| Threading a decidably elevated context | 144 |
46+
| Threading a decidably elevated context | 146 |
4747
| Threading a decidably non-elevated context | 0 |
4848
| Threading a context of undecidable elevation | 109 |
4949

@@ -90,14 +90,14 @@ 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-05 at `e40e04854`.
93+
Measured on 2026-11-06 at `ac688f409`.
9494

9595
| corpus scale (not enforced) | count |
9696
| :--- | ---: |
97-
| tracked non-test sources scanned | 871 |
98-
| engine-shaped types recognised | 105 |
99-
| declared objects in the registry | 127 |
100-
| same-named calls subtracted as non-engine | 229 |
97+
| tracked non-test sources scanned | 1037 |
98+
| engine-shaped types recognised | 111 |
99+
| declared objects in the registry | 130 |
100+
| same-named calls subtracted as non-engine | 230 |
101101

102102
## Every site
103103

@@ -166,7 +166,9 @@ Measured on 2026-11-05 at `e40e04854`.
166166
| `packages/plugins/plugin-auth/src/organization-delete.ts` | `delete` | `sys_team_member` | enabled | elevated | 1 |
167167
| `packages/plugins/plugin-auth/src/organization-delete.ts` | `delete` | `sys_user_permission_set` | enabled | elevated | 1 |
168168
| `packages/plugins/plugin-auth/src/reconcile-membership.ts` | `insert` | `sys_member` | enabled | context, elevation undecidable | 1 |
169+
| `packages/plugins/plugin-auth/src/scim-connection-admin.ts` | `insert` | `sys_audit_log` | enabled | elevated | 1 |
169170
| `packages/plugins/plugin-auth/src/scim-connection-service.ts` | `insert` | `sys_scim_connection_credential` | enabled | PROVABLY NONE | 1 |
171+
| `packages/plugins/plugin-auth/src/scim-connection-service.ts` | `update` | `sys_scim_connection_credential` | enabled | elevated | 1 |
170172
| `packages/plugins/plugin-auth/src/session-tombstone.ts` | `update` | `objectName` | undecidable | options unreadable | 1 |
171173
| `packages/plugins/plugin-auth/src/sso-client-secret.ts` | `update` | `sys_sso_provider` | disabled | elevated | 1 |
172174
| `packages/plugins/plugin-auth/src/sys-session-revoke.ts` | `update` | `SystemObjectName.SESSION` | undecidable | elevated | 1 |

‎packages/plugins/plugin-auth/src/scim-connection-admin.test.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -182,11 +182,11 @@ async function auditRows(credentialId: string): Promise<Array<Record<string, unk
182182

183183
/** Every line the plugin logger and the console were handed, as one string. */
184184
function everythingLogged(): string {
185-
const calls = [
185+
const calls: unknown[][] = [
186186
...Object.values(logger).flatMap((fn) => fn.mock.calls),
187187
...consoleSpies.flatMap((spy) => spy.mock.calls),
188188
];
189-
return calls.map((args) => args.map((a) => (a instanceof Error ? `${a.message} ${a.stack}` : typeof a === 'string' ? a : JSON.stringify(a))).join(' ')).join('\n');
189+
return calls.map((args) => args.map((a: unknown) => (a instanceof Error ? `${a.message} ${a.stack}` : typeof a === 'string' ? a : JSON.stringify(a))).join(' ')).join('\n');
190190
}
191191

192192
/** The bearer and its digest appear in no audit row and no log line. */

‎packages/plugins/plugin-auth/src/scim-connection-admin.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ async function writeCredentialAudit(
215215
record_id: entry.credentialId,
216216
metadata: JSON.stringify(entry.metadata),
217217
},
218-
{ context: SYSTEM_CTX } as never,
218+
{ context: SYSTEM_CTX },
219219
);
220220
} catch (error) {
221221
// The operation already happened (a minted bearer is already in the

‎packages/plugins/plugin-auth/src/scim-connection-service.ts‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ interface RevocationEngine {
249249
query: { where: Record<string, unknown>; fields?: string[] },
250250
options?: { context?: { isSystem?: boolean } },
251251
): Promise<Record<string, unknown> | null>;
252-
update(object: string, data: Record<string, unknown>): Promise<unknown>;
252+
update(object: string, data: Record<string, unknown>, options?: { context?: { isSystem?: boolean } }): Promise<unknown>;
253253
}
254254

255255
/** What {@link revokeScimConnectionCredential} found and did. */
@@ -281,6 +281,8 @@ export async function revokeScimConnectionCredential(
281281
// Read `active` the way the verifier does: anything not affirmatively active is off.
282282
const active = (row as { active?: unknown }).active;
283283
if (active === false || active === 0 || active == null) return { outcome: 'already_revoked', credentialId: id, connectionId };
284-
await engine.update(SCIM_CREDENTIAL_OBJECT, { id, active: false });
284+
// The system context is spelled at the call, not only inherited from the
285+
// caller's wrapped engine, so the write says what it is wherever it is read.
286+
await engine.update(SCIM_CREDENTIAL_OBJECT, { id, active: false }, { context: { isSystem: true } });
285287
return { outcome: 'revoked', credentialId: id, connectionId };
286288
}

0 commit comments

Comments
 (0)