Skip to content

Commit f957754

Browse files
committed
test(service-automation): pin the connection-store doubles; re-measure the tenant-audit census
The two new engine doubles open with the update/delete dispatch asserts and join the pinned ledger. The store's write sites shrank by two (one conditional write replaces two read-then-update pairs), so the census and its prose counts are re-measured. Claude-Session: https://claude.ai/code/session_01QUs3BvFbD3DRY4t9ByMH8B Co-authored-by: Claude <noreply@anthropic.com>
1 parent d06a025 commit f957754

4 files changed

Lines changed: 52 additions & 32 deletions

File tree

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

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ what moved this page's population from 225 to 227; nothing about the two sites
9393
changed, only whether this instrument could see them.
9494

9595
**The expensive failure direction is a keyword.** Sites whose receiver the author
96-
typed `any` have no type to read, and there are 63 of them — just over a fifth
96+
typed `any` have no type to read, and there are 62 of them — just over a fifth
9797
of the population, concentrated in exactly the seed and bootstrap paths this
9898
control exists for. Scoring an unreadable receiver as "not an engine" would have
9999
dropped every one of them silently, with a clean exit and a smaller number that
@@ -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 **51 of the 257 sites are spelled that way**. A
135+
forwarding shim cannot, and **51 of the 255 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 | **257** |
200+
| 175 write call sites | quoted in the merged changeset | **255** |
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 | **179 of 257** decidable, **78** undecidable |
203-
| 135 (77%) silenced by the `isSystem` guard before the posture gate | the lost issue body — **no surviving corroboration** | **not reproduced**: 147 decidably elevated, 0 decidably not, 102 undecidable |
202+
| 127 of 175 statically decidable, 48 runtime-parameter-name sites | restated on the `isSystem`-scoping card | **177 of 255** decidable, **78** undecidable |
203+
| 135 (77%) silenced by the `isSystem` guard before the posture gate | the lost issue body — **no surviving corroboration** | **not reproduced**: 145 decidably elevated, 0 decidably not, 102 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
@@ -210,18 +210,18 @@ be stated is what this instrument counts, which is written above and re-runnable
210210
at any commit.
211211

212212
Two structural facts do plausibly widen this reading against any hand or regex
213-
one, and both are counted in the generated tables below: the 63 sites reached
214-
through an erased (`any`) receiver, and the 63 that name their object through a
213+
one, and both are counted in the generated tables below: the 62 sites reached
214+
through an erased (`any`) receiver, and the 61 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-
147 of 257 (57%) as decidably elevated, with 102 more whose elevation is a
220+
145 of 255 (57%) as decidably elevated, with 102 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 / 257`, and say what it is**: the sites whose options argument was
224+
⇒ **Cite `2 / 255`, 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 | **257** |
237-
| …whose object name is statically decidable | 179 |
236+
| write call sites on the application surface | **255** |
237+
| …whose object name is statically decidable | 177 |
238238
| …whose object name is chosen at run time | 78 |
239-
| …against an object with tenancy ENABLED | 178 |
239+
| …against an object with tenancy ENABLED | 176 |
240240
| …against an object that declares tenancy off | 1 |
241-
| threading a tenant context | 198 |
241+
| threading a tenant context | 196 |
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 | 51 |
245245
| …of those, against a decidably tenancy-enabled object | 29 |
246-
| threading a decidably ELEVATED (`isSystem`) context | 147 |
246+
| threading a decidably ELEVATED (`isSystem`) context | 145 |
247247
| threading a context that is decidably NOT elevated | 0 |
248248
| threading a context whose elevation is a run-time fact | 102 |
249249

250250
| how the instrument reached the site | count |
251251
| :--- | ---: |
252-
| receiver carried a readable engine type | 194 |
253-
| receiver erased, placed by the object NAME | 53 |
252+
| receiver carried a readable engine type | 193 |
253+
| 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 | 116 |
258-
| object name spelled through a `const` | 63 |
258+
| object name spelled through a `const` | 61 |
259259
| object name is an `object: string` parameter | 7 |
260260
| object name is some other run-time expression | 71 |
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-10-31 at `30dc6587c`.
310+
Measured on 2026-10-31 at `d06a02507`.
311311

312312
| corpus scale (not enforced) | count |
313313
| :--- | ---: |
314-
| tracked non-test sources scanned | 829 |
314+
| tracked non-test sources scanned | 830 |
315315
| engine-shaped types recognised | 96 |
316316
| declared objects in the registry | 124 |
317-
| same-named calls subtracted as non-engine | 212 |
317+
| same-named calls subtracted as non-engine | 214 |
318318

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

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

Lines changed: 8 additions & 9 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 | 257 |
37-
| Object name statically decidable | 179 |
36+
| Write call sites | 255 |
37+
| Object name statically decidable | 177 |
3838
| Object name chosen at run time | 78 |
39-
| Against a tenancy-enabled object | 178 |
39+
| Against a tenancy-enabled object | 176 |
4040
| Against an object declaring tenancy off | 1 |
41-
| Threading a tenant context | 198 |
41+
| Threading a tenant context | 196 |
4242
| Provably carrying none | 8 |
4343
| …and decidably tenancy-enabled | 2 |
4444
| Options argument unreadable | 51 |
4545
| …and decidably tenancy-enabled | 29 |
46-
| Threading a decidably elevated context | 147 |
46+
| Threading a decidably elevated context | 145 |
4747
| Threading a decidably non-elevated context | 0 |
4848
| Threading a context of undecidable elevation | 102 |
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-10-31 at `30dc6587c`.
93+
Measured on 2026-10-31 at `d06a02507`.
9494

9595
| corpus scale (not enforced) | count |
9696
| :--- | ---: |
97-
| tracked non-test sources scanned | 829 |
97+
| tracked non-test sources scanned | 830 |
9898
| engine-shaped types recognised | 96 |
9999
| declared objects in the registry | 124 |
100-
| same-named calls subtracted as non-engine | 212 |
100+
| same-named calls subtracted as non-engine | 214 |
101101

102102
## Every site
103103

@@ -205,7 +205,6 @@ Measured on 2026-10-31 at `30dc6587c`.
205205
| `packages/services/service-automation/src/connector-connections.ts` | `delete` | `sys_connector_connection` | enabled | context, elevation undecidable | 1 |
206206
| `packages/services/service-automation/src/connector-connections.ts` | `insert` | `sys_connector_connection` | enabled | context, elevation undecidable | 1 |
207207
| `packages/services/service-automation/src/connector-connections.ts` | `update` | `sys_connector_connection` | enabled | context, elevation undecidable | 1 |
208-
| `packages/services/service-automation/src/connector-connections.ts` | `update` | `sys_connector_connection` | enabled | elevated | 2 |
209208
| `packages/services/service-automation/src/connector-credentials.ts` | `delete` | `sys_connector_credential` | enabled | context, elevation undecidable | 1 |
210209
| `packages/services/service-automation/src/connector-credentials.ts` | `insert` | `sys_connector_credential` | enabled | context, elevation undecidable | 1 |
211210
| `packages/services/service-automation/src/connector-credentials.ts` | `update` | `sys_connector_credential` | enabled | context, elevation undecidable | 1 |

‎packages/services/service-automation/src/connector-connections.test.ts‎

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
// declared 503. The values below are obvious dummies.
88

99
import { afterEach, describe, expect, it } from 'vitest';
10+
import { assertEngineDeleteDispatch, assertEngineUpdateDispatch } from '@objectstack/metadata-core';
1011
import { ObjectQL } from '@objectstack/objectql';
1112
import { SqlDriver } from '@objectstack/driver-sql';
1213
import { SysSecret } from '@objectstack/platform-objects';
@@ -69,9 +70,13 @@ function interleaved(ql: ObjectQL, beforeUpdate: () => Promise<void>): Connector
6970
return {
7071
find: (o, q) => ql.find(o, q as never),
7172
insert: (o, d, opts) => ql.insert(o, d, opts as never),
72-
delete: (o, opts) => ql.delete(o, opts as never),
73+
delete: (o, opts) => {
74+
assertEngineDeleteDispatch(opts as never);
75+
return ql.delete(o, opts as never);
76+
},
7377
resolveSecretField: (o, id, f) => (ql as any).resolveSecretField(o, id, f),
7478
async update(o, d, opts) {
79+
assertEngineUpdateDispatch(d as never, opts as never);
7580
if (armed) {
7681
armed = false;
7782
await beforeUpdate();
@@ -181,8 +186,14 @@ describe('ADR-0143 D5 — a connection store that cannot be read refuses 503, ne
181186
const unreadable = (): ConnectorCredentialEngine => ({
182187
find: async () => { throw new Error('dummy driver failure naming row 42'); },
183188
insert: async () => { throw new Error('not reached'); },
184-
update: async () => { throw new Error('not reached'); },
185-
delete: async () => { throw new Error('not reached'); },
189+
update: async (_o, d, opts) => {
190+
assertEngineUpdateDispatch(d as never, opts as never);
191+
throw new Error('not reached');
192+
},
193+
delete: async (_o, opts) => {
194+
assertEngineDeleteDispatch(opts as never);
195+
throw new Error('not reached');
196+
},
186197
});
187198

188199
it.each([

‎scripts/engine-double-contract.pinned.json‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4761,6 +4761,16 @@
47614761
"verb": "update",
47624762
"pinned": 1
47634763
},
4764+
{
4765+
"file": "packages/services/service-automation/src/connector-connections.test.ts",
4766+
"verb": "delete",
4767+
"pinned": 2
4768+
},
4769+
{
4770+
"file": "packages/services/service-automation/src/connector-connections.test.ts",
4771+
"verb": "update",
4772+
"pinned": 2
4773+
},
47644774
{
47654775
"file": "packages/services/service-automation/src/flow-activation-ledger.test.ts",
47664776
"verb": "update",

0 commit comments

Comments
 (0)