Tenant-audit census — tenancy write call sites
A census of every write call site against a tenancy-enabled object — which pass an execution context, which pass none, and what static checks can decide.
SqlDriver.auditMissingTenant() is the platform's one diagnostic on write-side
tenancy. It warns when a write lands on a tenancy-enabled object without
options.tenantId — the shape of a seed, migration or background path that
forgot to thread the acting session.
This page is the authority for the population that control acts on: every
write call site on the application surface, what object it targets, and what
execution context it threads. Its figures are generated, not written —
rebuilt from the tree by scripts/tenant-audit-census.mjs, and
scripts/check-tenant-audit-census.mjs fails the build when what is committed
and what the tree says disagree.
The per-site rows and every package's totals live next door, one shard per
package under docs/audits/2026-08-tenant-audit-write-call-sites.counts/
(indexed by docs/audits/2026-08-tenant-audit-write-call-sites.counts.md), and
are written by the same command. The split is the one packages/spec's
strictness ledger already uses and is there for the same reason: this page has
prose worth preserving and the row tables have none, so the tables are
regenerated whole while the page keeps a small generated region.
⛔ This page states no live population figure, and no committed file states a
total across packages. Every branch that adds a write call site would rewrite
such a total, so any two of them would conflict on it.
node scripts/check-tenant-audit-census.mjs prints the census totals on every
run instead, from the census it has just taken. The figures quoted in the
history below are dated and are never regenerated.
⚠️ Why this page exists at all
The measurement this page carries used to live in a comment on an issue. That issue became unreachable — it returns 404 on unauthenticated REST, on the rendered web page and on authenticated API access alike, while its immediate neighbours answer 200 — and it took the census with it. Three open cards named that comment as their input, and nothing anywhere noticed that their input had gone.
What survived did so by luck. A changeset author had happened to quote two of the
figures in prose, so "175 write call sites, 24 of them carrying no tenant context"
is still readable on main in
.changeset/tenant-audit-update-delete-half-repairs.md — while the list of 24
that a downstream card was briefed to classify is not recoverable at all.
⇒ A census that decides a repair family's severity and a ruling's scope is not a comment. It is a re-runnable instrument plus a committed page. Losing any issue now costs nothing, and the population is re-derivable rather than quoted.
What the control does, and what a call site controls
auditMissingTenant(object, op, options, insertRows) is gated in this order:
OS_TENANT_AUDIT=0— off entirely;options.bypassTenantAudit— on anExecutionContext.isSystemwrite the engine sets it only where the object's schema puts the write out of scope: an object with no tenant field, or a federated one (ObjectQL'sbuildDriverOptions). It also sets it on a predicate write the organization wall exempted (ADR-0131 D8: the recorded Layer 0 verdict isnonewhere the wall would otherwise apply). A caller may still pass it explicitly;- a present
options.tenantId— the engine fills it fromexecCtx.tenantId; - the deployment posture — the warning is only meaningful on a walled install;
- the object having a tenant field;
- for
createandbulkCreateonly, every inserted row carrying that field — an insert is confined to the organizations its rows name. Updates, deletes and upserts are audited whatever their payload says.
The guards a caller can move are downstream of one decision at the call site: whether it threads an execution context at all. Thread a tenant-bearing one and guard 3 silences the warning; thread an elevated one and an object with a tenant column is still audited, unless the write inserts rows that name their organization (guard 6); thread none and the site is what this census counts.
How the population is decided
A site is a call to one of the three IDataEngine write doors — insert,
update, delete — on a receiver whose declared type is an engine, in tracked
non-test sources under packages/services/ and packages/plugins/.
The verb name is not the signal. .delete() alone answers some 250 call sites
in this corpus, and most of them are Map.delete, Set.delete, Headers.delete,
a crypto Hash.update, a blob-storage delete-by-key and a search-index de-index.
So the receiver is typed structurally: a declared interface or type literal counts
as an engine when it declares a write door whose first parameter is named
object / objectName / objectApiName / name and typed string — the
IDataEngine door signature. Interfaces that extend one inherit it; aliases that
narrow one (Partial<Pick<IDataEngine, …>>) carry it.
That rule is read off the TYPE, not off the type's name. The engine type
index is keyed on declaration names, so a receiver whose declared type is an
inline type literal has no name to look up — and for two sites, both writing
under { context: { isSystem: true } }, that alone subtracted a real engine
write from this population while the census printed the type text and said the
subtraction was probably wrong. The same door rule is now read off the type text
itself, so an unnamed type that states a write door places its site. That is
what moved this page's population from 225 to 227 on 2026-09-18; nothing about
the two sites changed, only whether this instrument could see them.
The expensive failure direction is a keyword. Sites whose receiver the author
typed any have no type to read — a sizeable share of the population (the gate
prints how many), concentrated in exactly the seed and bootstrap paths this
control exists for. Scoring an unreadable receiver as "not an engine" would have
dropped every one of them silently, with a clean exit and a smaller number that
reads exactly like a smaller truth. So any is not a classification here: it goes
to the unreadable pile, and the unreadable pile is placed by facts about the tree
(the argument names a declared object; the argument is a parameter declared
object: string) or by a written UNTYPED_RECEIVERS row. An unreadable
receiver that none of the three place is an error, never a default.
Tenancy itself is enabled by default — isTenancyDisabled() reads
tenancy.enabled === false and nothing else — so the object registry only has to
find the opt-outs. Across 117 declared objects — the dated, ⛔ unenforced
corpus-scale figure below — exactly two opt out (sys_api_key,
sys_sso_provider). The write call sites on this surface that target either —
plugin-auth's legacy client-secret migration, writing sys_sso_provider under
an elevated context, among them — are what the declaring tenancy off total
counts, and it is not 0 for a reason: the object is outside this control's
reach by its own declaration, not by the census failing to see the write.
A declared object here is a top-level object declaration in a
*.object.ts(x) file — export const X = ObjectSchema.create({ name: … }) —
and ⛔ never a literal nested inside one. The distinction is not cosmetic: the
same name: key spells a grid column identity (inlineColumns), a validation
rule id, an action, a list view and an index, and this name set is what places
an any-typed receiver's write call, so counting those would widen the
predicate that decides whether a site is placed at all.
⛔ What this instrument cannot decide
A site whose object name is an inline literal or a local const is statically
decidable. A site whose name is a parameter or a field — ql.insert(object, …)
inside a shared seed helper, this.objectName on a per-object service — is not,
and no amount of AST work makes it so: the object is chosen at run time. Those
are reported as undecidable rather than assumed either way.
The same holds twice over for the context. An options argument spelled as a
literal can be read; one spelled options, { ...opts }, or handed through a
forwarding shim cannot, and a sizeable share of the sites are spelled that way
(the gate prints how many). A context resolved from an inline literal or a local
const can be tested for isSystem; one arriving from a helper call cannot.
⇒ A large part of this population is undecidable in one dimension or another, and that is reported rather than smoothed over. A census that quietly guessed on those sites would publish a number in the one direction this page cannot survive — claiming completeness while short — and a gate seeded from it would then hold the page to it.
⚠️ Two over-claims this instrument made, and what they cost
Both were found by the drift gate firing on this page's own artifact, and both are recorded here rather than quietly corrected, because the numbers they moved were published first.
The elevation classifier read a spread as a denial. It walked an object
literal's named properties looking for isSystem and returned "not elevated"
when the loop ended — so { ...SYSTEM_CTX } was scored decidably NOT
elevated while every SYSTEM_CTX in the tree is { isSystem: true, … }. It
also never unwrapped as const, so a bare context: SYSTEM_CTX read as
undecidable. Fixing both, on 2026-08-31, moved 51 sites' verdicts: 45 from
undecidable to elevated, and 6 from decidably not elevated to elevated — an
inversion, on a security-relevant classification. That fix left no site on this
surface threading a context that provably lacked the flag; the gate prints
today's count of decidably-not-elevated sites.
"No tenant context" counted sites it had not read. An options argument the
walker could not parse was folded into the same bucket as one it had read and
found empty. When it was caught (2026-08-31, at a population of 215 sites), that
published 84 sites "carrying no tenant context at all" when 17 said so and
67 were simply unread — an over-claim in the alarming
direction, on the very figure this page tells other cards to cite. carries is
now three-valued, and an unreadable argument can never contribute to the
provable count.
A door rule keyed on names read an unnamed door as no door. Two receivers
typed with an inline type literal that spells insert / update with an
object: string first parameter were subtracted from the population — by the
same instrument that printed their type text on every run and called the
subtraction probably wrong. Placing them, on 2026-09-18, moved the population
225 → 227 and the elevated count 106 → 108. ⭐ It moved the provable yield surface
(9) not at all: both sites thread an elevated context, and one of them
targets a tenancy-opt-out object. The repair is to the denominator and to what
this page can be read as having examined — ⛔ not to the count anything cites as
a violation. It is pinned in both directions, because a rule that placed
every inline literal would be the same failure mirrored: an unnamed type that
states a write door places its site, one that states none is still a subtraction
that says why, and an indexed type name beside an inline literal still wins and
reports itself.
⭐ All three are the same shape as the failure this artefact exists for, wearing
different hats: one scored an unread thing as nothing to report, one scored an
unread thing as a finding, and one scored a thing it had read and printed as
outside its own population. node scripts/check-tenant-audit-census.mjs --self-test pins the first two — 18
classifier cases, 6 of which red against the old reading — driven from the
gate's own self-test rather than from a flag on the generator.
⭐ Deviations from the carried figures, untrimmed
Four figures were carried forward from the lost census. They are control inputs for this re-derivation, not targets, and this instrument was not shaped to reproduce them. Where it disagrees, it disagrees on the page:
| carried figure | where it survives | this census — read it from the gate's output |
|---|---|---|
| 175 write call sites | quoted in the merged changeset | Write call sites |
| 24 carrying no tenant context | quoted in the merged changeset | the cite: line — provable and tenancy-enabled — plus the unreadable, tenancy-enabled sites beside it |
| 127 of 175 statically decidable, 48 runtime-parameter-name sites | restated on the isSystem-scoping card | Object name statically decidable and Object name chosen at run time |
135 (77%) silenced by the isSystem guard before the posture gate | the lost issue body — no surviving corroboration | not reproduced: the decidably elevated, decidably non-elevated and undecidable-elevation figures |
| 141 and 132, two independent re-derivations | the card that filed this work | — |
The differences are not reconciled, and deliberately so. The old census's population definition is not recoverable — that is the whole reason this page exists — so no honest reading can attribute the gap to a specific cause. What can be stated is what this instrument counts, which is written above and re-runnable at any commit.
Two structural facts do plausibly widen this reading against any hand or regex
one, and both are counted in every package shard and in the gate's output: the
sites reached through an erased (any) receiver, and the ones that name their
object through a const rather than inline. An instrument that read either the
way a person does would report a smaller number and would not say so.
The fourth row is the one worth flagging to anyone citing it. The 135 / 77% figure has no surviving corroboration anywhere in the tree. This census reads a decidably elevated share and a remainder whose elevation is a run-time fact (the gate prints both), and the remainder is large enough that the claim is neither confirmed nor refuted — the honest answer is that a static reading cannot settle it.
⇒ Cite the gate's cite: line, and say what it is: the sites whose options
argument was READ and holds no tenant context, against a decidably
tenancy-enabled object, out of every write call site. That is the control's
provable yield surface. ⛔ Do not cite it as "the sites without tenant context"
— further sites have an options argument this cannot read, and they are
neither in nor out.
The measurement
⛔ This page states no population figure, and no committed file states a total
across packages: two branches that each add a write call site would both
rewrite it. The figures live per package — one shard per package under
docs/audits/2026-08-tenant-audit-write-call-sites.counts/,
each holding that package's totals and every one of its sites — and
node scripts/check-tenant-audit-census.mjs prints the census totals on every
run, from the census it has just taken. node scripts/tenant-audit-census.mjs
prints the same summary without checking anything.
Subtractions the census could NOT defend — enforced
A same-named call on something that is not a data engine is subtracted, and the
subtraction is DEFENSIBLE when this census can name why: the receiver is a node:
builtin, a value it watched being constructed, a language global, a type THIS
corpus declares and the door rule rejected, or an UNTYPED_RECEIVERS row.
⚠️ Counted in every package shard are the subtractions it can name no such fact for — the receiver carries a declared type the engine type index does not hold, and that index is built from TRACKED sources only, deliberately. An untracked, generated or dependency-owned declaration is one this census never saw, and «never saw it» must not be spelled the same way as «read it, not an engine».
⚠️ One arm here says something else again: type-text-not-round-trippable is a
receiver whose declared type THIS TOOL derived and then could not read back —
the source parsed, the re-serialisation of it did not, so the door rule could
never be read off it. That is a fault in this tool rather than a fact about the
corpus, and it is the one arm here that also fails the gate.
⛔ A shard's door-shaped count is 0 by construction, not a tally that happens to be low. An inline type literal stating a write door has no name for the engine type index to be keyed on, so the door rule is read off the type text itself and the site is PLACED — it is in the population rather than subtracted. A non-zero value there means a door-shaped receiver reached the subtraction anyway.
The corpus walked is every tracked non-test source under packages/services/
and packages/plugins/; calls to a same-named method on something that is not
a data engine were subtracted. The method behind the shards is in
docs/audits/2026-08-tenant-audit-write-call-sites.counts.md,
regenerated by the same command.
Corpus scale — present and dated, ⛔ NOT enforced
⛔ These four describe the CORPUS this census walked, not the population it
certifies, and the gate deliberately does not hold them to the tree — a source
file arriving anywhere under the two roots moves them while every verdict
holds still. They are required to be HERE and to say WHEN they were true;
their values are not compared, and --write keeps them as committed until
--write --refresh-scale re-measures them. The reasoning, and the measurement
behind it, are in scripts/check-tenant-audit-census.mjs.
Measured on 2026-11-16 at 94cb58c3d.
| corpus scale (not enforced) | count |
|---|---|
| tracked non-test sources scanned | 1186 |
| engine-shaped types recognised | 142 |
| declared objects in the registry | 137 |
| same-named calls subtracted as non-engine | 323 |
System Context (isSystem)
Every platform behaviour that ExecutionContext.isSystem changes — what an elevated write gets, what it loses, and what the flag deliberately does not do.
Profiles (removed)
Profiles were removed. Author baseline access with the everyone audience anchor, package isDefault suggestions and permission sets given via positions.