docs(protocol): 重写 schema.mdx「Multi-Tenant Schemas」为平台实际租户姿势 (#5746) - #5884
Merged
Conversation
The section taught three things the platform does not do: `tenantField: tenant_id` with a hand-declared `tenant_id` lookup, a `reference: tenant` target that does not exist (the organization object is `sys_organization`), and `OS_MULTI_ORG_ENABLED` as the live switch plus a default `tenant_isolation` RLS policy as the enforcement point. Rewritten from the code: `organization_id` is registry-injected on every non-opted-out object regardless of posture (only its index is posture-gated), `tenancy.enabled: false` is the opt-out, `tenantField` carries no default (#5315) and exists only for a genuinely non-`organization_id` column, and the wall is Layer 0 (ADR-0095 D1) with the predicate chosen by `OS_TENANCY_POSTURE` (ADR-0105 D1).
|
The latest updates on your projects. Learn more about Vercel for GitHub. 1 Skipped Deployment
|
os-zhuang
marked this pull request as ready for review
August 6, 2026 11:05
This was referenced Aug 6, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #5746
content/docs/protocol/objectql/schema.mdx的「Multi-Tenant Schemas」小节整段与平台事实不符,本 PR 按代码逐条重写。文件面只有这一页(docs-only,不产出 changeset)。原文教的 vs 实际
origin/main)tenancy.tenantField: tenant_id+ 手写fields.tenant_idorganization_id;tenantField自 #5315(已合,fc5f536a1/ PR #5766)起没有默认值,未声明即undefined,由 driver 回落organization_idreference: tenanttenant对象;组织对象是sys_organization(packages/platform-objects/src/identity/sys-organization.object.ts:14),也正是注入列的referenceOS_MULTI_ORG_ENABLED=true)时,registry 才注入organization_id」tenancy.enabled: false/systemFields.tenant: false/systemFields: false/managedBy: 'better-auth'四种退出),只有该列的索引受 posture 影响:packages/objectql/src/registry.ts:421的wantTenant与indexed: opts.multiTenanttenant_isolationRLS policy 收敛读写」packages/plugins/plugin-security/src/tenant-layer.ts),先于业务 RLS 且与之 AND 合成、不共享 bypass 位OS_MULTI_ORG_ENABLED当现行开关packages/types/src/env.ts:89-122):仅当OS_TENANCY_POSTURE未设置时作为回落输入读取。现行开关是OS_TENANCY_POSTURE(ADR-0105 D1,single/group/isolated)改法(取 PM 倾向的「平台默认姿势」)
主示例不再出现
tenantField:一个租户隔离的对象关于租户什么都不用声明。随后补三段正文:tenancy.enabled: false的退出示例(平台级 catalog);tenantField只作为「租户列确实不是organization_id」的逃生舱一笔带过(workspace_id,与 spec 自身@example及content/docs/data-modeling/objects.mdx措辞一致),并写明无默认值、且声明的列不存在时被忽略;single惰性 /group为organization_id IN accessible_org_ids/isolated为按活动组织收敛),并指向已有的权威页/docs/deployment/tenancy-modes,不在本页重复解释 posture 解析规则。OS_MULTI_ORG_ENABLED在新正文里一次都不出现 —— 它的 legacy 身份与解析表在content/docs/deployment/tenancy-modes.mdx与deployment/environment-variables.mdx已经写全,本页再提只会把降级过的开关重新教一遍。校验
node scripts/check-nul-bytes.mjs(含--self-test)✅ ·check-doc-authoring✅(362 files clean)·check-role-word✅(ratchet 无新增)·docs-audit/check-audit-scope✅(178 页在 scope)packages/lint的check:doc-formula-expressions✅(self-test 11 cases + 22 个 formula 例子全绿)packages/spec的check:skill-examples✅(205 prose examples type-check)—— 本页那段os:check标记的 TS 块未被触碰,跑它是为了确认没被牵连@mdx-js/mdx单独编译改后的页面 ✅(内联代码里的organization_id = ...与跨行代码跨度都不会被当成 JSX)os:check只覆盖ts|typescript|tsx块);docs-only ⇒ 无 changeset,PR 自带skip-changeset顺手记录(未在本 PR 修)
content/docs/plugins/packages.mdx:335仍把OS_MULTI_ORG_ENABLED=true当启用 multi-org 的方式(够不到groupposture)→ 已单独开 issuecontent/docs/protocol/kernel/config-resolution.mdx通篇教context.config.setTenant()/setUserPreference()/objectstack_tenant_config表,仓库里零实现 → 已单独开 issueGenerated by Claude Code