Skip to content

refactor: single-source the multi-org (OS_MULTI_ORG_ENABLED) flag resolution#2350

Merged
os-zhuang merged 1 commit into
mainfrom
refactor/single-source-multi-org-flag
Jun 26, 2026
Merged

refactor: single-source the multi-org (OS_MULTI_ORG_ENABLED) flag resolution#2350
os-zhuang merged 1 commit into
mainfrom
refactor/single-source-multi-org-flag

Conversation

@os-zhuang

Copy link
Copy Markdown
Contributor

Problem

"Is this deployment multi-org / multi-tenant?" was resolved in 10 places across 8 packages with three subtly different inline expressions:

Variant Sites
String(readEnvWithDeprecation('OS_MULTI_ORG_ENABLED','OS_MULTI_TENANT') ?? 'false').toLowerCase() !== 'false' objectql registry, plugin-dev, runtime app-plugin, cli serve (×2) + verify, cloud-connection
env.OS_MULTI_ORG_ENABLED !== undefined ? … : … (redundant explicit check) plugin-auth — /auth/config features + beforeCreateOrganization guard
bare process.env.OS_MULTI_ORG_ENABLED ?? process.env.OS_MULTI_TENANT driver-sql isMultiTenantMode() — skipped the OS_MULTI_TENANT deprecation warning every other site emits

Because the SQL driver computed the mode independently of the auth/security layer (and via a different code path), the driver's tenant-audit gate and the rest of the system could in principle disagree about whether tenant isolation is active. This is the kind of divergence single-sourcing eliminates.

Change

  • Add resolveMultiOrgEnabled() to @objectstack/types (beside readEnvWithDeprecation — the natural leaf dependency every consumer already imports) as the single source of truth.
  • Route all 10 sites through it.
  • @objectstack/driver-sql gains a direct @objectstack/types dependency (it previously read process.env directly).

Mirrors the existing resolveAuthzContext single-source pattern in @objectstack/core.

Safety

Behaviour is unchanged everywhere except the SQL driver, which now also emits the one-shot "OS_MULTI_TENANT is deprecated, rename to OS_MULTI_ORG_ENABLED" warning — making it consistent with every other site (an improvement, not a regression). The boolean semantics (raw ?? 'false', case-insensitive !== 'false') are byte-for-byte the canonical expression the 9 other sites already used.

Follow-up (not in this PR)

A lint gate forbidding new inline OS_MULTI_ORG_ENABLED / OS_MULTI_TENANT reads outside the helper (the same shape as check:authz-resolver), so the consolidation can't silently drift back.

Verification

  • Builds (incl. DTS type emission) green across all 8 affected packages + dependents
  • Tests: types 7, plugin-auth 135, driver-sql 233, objectql 710, runtime 444, cli 42, cloud-connection 9, plugin-dev 1 — all pass
  • ESLint: 0 errors on changed files

🤖 Generated with Claude Code

"Is this deployment multi-org?" was resolved in 10 sites across 8 packages
with 3 subtly different inline expressions — including a bare process.env
read in the SQL driver that skipped the OS_MULTI_TENANT deprecation warning
every other site emits, so the driver could resolve the mode independently
of the auth/security layer.

Add resolveMultiOrgEnabled() to @objectstack/types (beside
readEnvWithDeprecation) as the single source of truth and route all 10
sites through it:
- driver-sql isMultiTenantMode() (+ new @objectstack/types dep)
- plugin-auth /auth/config features + beforeCreateOrganization guard
- objectql registry, runtime app-plugin, plugin-dev
- cli serve (x2) + verify, cloud-connection

Behaviour unchanged except the SQL driver now also emits the one-shot
OS_MULTI_TENANT deprecation warning. Mirrors the resolveAuthzContext
single-source pattern in @objectstack/core.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@vercel

vercel Bot commented Jun 26, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
spec Ready Ready Preview, Comment Jun 26, 2026 2:26pm

Request Review

@github-actions github-actions Bot added documentation Improvements or additions to documentation dependencies Pull requests that update a dependency file tooling size/m labels Jun 26, 2026
@github-actions

Copy link
Copy Markdown
Contributor

📓 Docs Drift Check

This PR changes 8 package(s): @objectstack/cli, @objectstack/cloud-connection, @objectstack/objectql, @objectstack/driver-sql, @objectstack/plugin-auth, @objectstack/plugin-dev, @objectstack/runtime, @objectstack/types.

38 hand-written doc(s) reference the affected code and may need an implementation-accuracy re-verification:

  • content/docs/concepts/cloud-artifact-api.mdx (via packages/cli, packages/cloud-connection, packages/runtime)
  • content/docs/concepts/core/plugins.mdx (via @objectstack/driver-sql)
  • content/docs/concepts/core/services.mdx (via @objectstack/objectql)
  • content/docs/concepts/implementation-status.mdx (via @objectstack/cli, @objectstack/objectql, @objectstack/driver-sql, @objectstack/plugin-auth, @objectstack/runtime)
  • content/docs/concepts/metadata-lifecycle.mdx (via @objectstack/objectql)
  • content/docs/concepts/north-star.mdx (via packages/runtime)
  • content/docs/concepts/packages.mdx (via @objectstack/cli, @objectstack/objectql, @objectstack/plugin-auth, @objectstack/plugin-dev, @objectstack/runtime, @objectstack/types)
  • content/docs/concepts/terminology.mdx (via @objectstack/driver-sql)
  • content/docs/getting-started/cli.mdx (via @objectstack/cli, @objectstack/plugin-auth)
  • content/docs/getting-started/glossary.mdx (via @objectstack/driver-sql)
  • content/docs/getting-started/quick-start.mdx (via @objectstack/cli)
  • content/docs/guides/api-reference.mdx (via @objectstack/runtime)
  • content/docs/guides/auth-sso.mdx (via @objectstack/plugin-auth)
  • content/docs/guides/authentication.mdx (via @objectstack/cli, @objectstack/objectql, @objectstack/plugin-auth, @objectstack/runtime)
  • content/docs/guides/client-sdk.mdx (via @objectstack/cli)
  • content/docs/guides/cloud-deployment.mdx (via @objectstack/runtime)
  • content/docs/guides/deployment-vercel.mdx (via @objectstack/objectql, @objectstack/runtime)
  • content/docs/guides/driver-configuration.mdx (via @objectstack/driver-sql, @objectstack/runtime)
  • content/docs/guides/formula.mdx (via packages/objectql)
  • content/docs/guides/hook-bodies.mdx (via packages/cli, @objectstack/runtime)
  • content/docs/guides/kernel-services.mdx (via @objectstack/objectql, @objectstack/plugin-auth)
  • content/docs/guides/objectql-migration.mdx (via @objectstack/objectql)
  • content/docs/guides/packages.mdx (via @objectstack/cli, @objectstack/objectql, @objectstack/driver-sql, @objectstack/plugin-auth, @objectstack/plugin-dev, @objectstack/runtime, @objectstack/types)
  • content/docs/guides/plugin-chatbot-integration.mdx (via @objectstack/runtime)
  • content/docs/guides/plugins.mdx (via @objectstack/objectql, @objectstack/plugin-auth)
  • content/docs/guides/production-readiness.mdx (via @objectstack/plugin-auth, @objectstack/runtime)
  • content/docs/guides/project-scoping.mdx (via @objectstack/cli)
  • content/docs/guides/runtime-services/data-service.mdx (via packages/cli)
  • content/docs/guides/runtime-services/index.mdx (via packages/cli)
  • content/docs/guides/single-project-mode.mdx (via @objectstack/runtime)
  • content/docs/guides/skills.mdx (via packages/cli)
  • content/docs/protocol/objectos/http-protocol.mdx (via @objectstack/runtime)
  • content/docs/protocol/objectos/index.mdx (via @objectstack/objectql, @objectstack/driver-sql, @objectstack/runtime)
  • content/docs/protocol/objectos/lifecycle.mdx (via @objectstack/driver-sql, @objectstack/runtime)
  • content/docs/protocol/objectos/plugin-spec.mdx (via @objectstack/cli)
  • content/docs/protocol/objectos/realtime-protocol.mdx (via @objectstack/cli)
  • content/docs/protocol/objectql/state-machine.mdx (via @objectstack/objectql)
  • content/docs/releases/v9.mdx (via @objectstack/objectql, @objectstack/plugin-auth)

Advisory only. To re-verify, run the docs-accuracy-audit workflow scoped to these files:
node scripts/docs-audit/affected-docs.mjs origin/main → pass the list as args.docs.

@os-zhuang os-zhuang merged commit 795b6d1 into main Jun 26, 2026
17 checks passed
@os-zhuang os-zhuang deleted the refactor/single-source-multi-org-flag branch June 26, 2026 14:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dependencies Pull requests that update a dependency file documentation Improvements or additions to documentation size/m tooling

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant