Skip to content

Commit 878b162

Browse files
claude[bot]claude
andauthored
docs(objectql): make the PLATFORM_NAMESPACE docblock describe the post-#13491 reality (#14097)
The docblock still asserted the pre-2026-08-31 invariant: that this regexp is the third write path carrying the seed loader's rule and that all three must stay in step. #13491 withdrew the wholesale namespace reading for the runtime path only, so the assertion is false — and a header stating a false invariant is worse than one stating none, because the next author reasons from a coupling that no longer holds. Rewritten to describe reality rather than deleted: the coupling existed and was broken DELIBERATELY, and deleting the passage would leave three near-identical regexps that read as drift. The runtime side's per-object classification is now named by code location (the PLATFORM_OBJECT_TENANCY ledger in platform-object-tenancy.ts, read through classifyPlatformObjectTenancy / isPlatformObjectOutOfTenantAuditScope), not by issue number. Comment-only. No behaviour change, no cut logic touched. Co-authored-by: Claude <noreply@anthropic.com>
1 parent 16c6e1c commit 878b162

1 file changed

Lines changed: 39 additions & 8 deletions

File tree

packages/objectql/src/tenancy/system-write-organization.ts

Lines changed: 39 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -123,15 +123,46 @@ export const GLOBAL_TENANT = '__global__';
123123
export const DEFAULT_TENANT_FIELD = 'organization_id';
124124

125125
/**
126-
* Platform namespaces whose rows are deliberately global / cross-organization
127-
* and must never be adopted into one.
126+
* The platform-namespace NAME SHAPE — `sys_` / `cloud_` / `ai_`.
128127
*
129-
* The seed loader's rule verbatim (`/^(sys_|cloud_|ai_)/` in `seed-loader.ts`),
130-
* re-spelled here rather than imported for the reason `seed-tenancy-backfill.ts`
131-
* records about its own copy: the layers differ, the rule must not. This is the
132-
* third write path to carry it, and the three have to stay in step — a runtime
133-
* stamp that adopted a namespace the loader deliberately leaves global would
134-
* reopen the seed/runtime disagreement from the other end.
128+
* ⚠️ Since #13491 this is a name test, NOT a tenancy rule, and it is no longer
129+
* a write-path cut at all. Its only reader is
130+
* {@link isPlatformNamespaceObject}, which
131+
* {@link isPlatformObjectOutOfTenantAuditScope} (`platform-object-tenancy.ts`)
132+
* uses as a cheap pre-filter before consulting the per-object verdict. ⛔ Never
133+
* reach for it to decide whether a row stays org-less.
134+
*
135+
* ## The three copies, and why they no longer agree
136+
*
137+
* The history is kept because the divergence below is DELIBERATE, and a reader
138+
* who finds three near-identical regexps with no explanation will read it as
139+
* drift and "repair" it. Until 2026-08-31 this file WAS the third write path to
140+
* carry the seed loader's rule verbatim, re-spelled rather than imported for the
141+
* reason `seed-tenancy-backfill.ts` records about its own copy (the layers
142+
* differ, the rule must not) — and all three did have to stay in step, because
143+
* all three cut the same decision: does this write get the install's
144+
* organization stamped onto it?
145+
*
146+
* #13491's re-ruling (2026-08-31, 联案 #13497) withdrew the wholesale namespace
147+
* reading — but its scope was the RUNTIME control only. So today:
148+
*
149+
* - **the runtime write path** cuts PER OBJECT, by the hand-adjudicated
150+
* classification in `platform-object-tenancy.ts` — the
151+
* `PLATFORM_OBJECT_TENANCY` ledger, read through
152+
* {@link classifyPlatformObjectTenancy} and
153+
* {@link isPlatformObjectOutOfTenantAuditScope}, which is what
154+
* `Engine.resolveSystemInsertOrganization` calls.
155+
* - **`seed-loader.ts`** still cuts by the namespace regexp
156+
* (`/^(sys_|cloud_|ai_)/`, at its `fallbackOrgId` decision).
157+
* - **`seed-tenancy-backfill.ts`** still cuts by the namespace regexp (its own
158+
* `PLATFORM_NAMESPACE`).
159+
*
160+
* ⛔ Do NOT restore the coupling by re-cutting the seed paths per object, and
161+
* ⛔ do not re-stamp anything to match. Whether those two should follow is a
162+
* separate decision about rows they have ALREADY WRITTEN, and the re-ruling's
163+
* execution point 3 (⛔ never silently rewrite behaviour) governs every answer
164+
* to it — including "leave them as they are". Read the three together before
165+
* changing any of them.
135166
*/
136167
const PLATFORM_NAMESPACE = /^(sys_|cloud_|ai_)/;
137168

0 commit comments

Comments
 (0)