feat(hooks)!: remove deprecated ctx.session.tenantId alias — converge on organizationId (#3290)#3305
Merged
Merged
Conversation
Converge the hook and action-body authoring surface on `organizationId`, removing the `ctx.session.tenantId` / `ctx.user.tenantId` alias that #3280 added as a deprecated shim. - spec: drop `tenantId` from `HookContextSchema.session` (only `organizationId` remains; a stray key is now stripped by the schema). - objectql: engine `buildSession()` no longer emits `session.tenantId`; the audit-stamp plugin sources the `tenant_id` column from `session.organizationId`. - runtime: `buildActionSession()` and the REST action `ctx.user` no longer emit `tenantId`. - trigger-record-change: reads `session.organizationId` when forwarding the writer's org to a runAs:'user' flow (behavior identical). - check:org-identifier guard now also covers `packages/**` (tests and comments excluded); docs/skills reference bodies migrated to `organizationId`. The generic driver-layer tenancy knob (ExecutionContext.tenantId, DriverOptions.tenantId, SqlDriver.applyTenantScope, ExecutionLog.tenantId) is deliberately untouched. Breaking: major bump for spec, objectql, runtime. Closes #3290 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015Q7R16SoGBeqKkEd7RCZRL
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
📓 Docs Drift CheckThis PR changes 4 package(s): 112 hand-written doc(s) reference the affected code and may need an implementation-accuracy re-verification:
|
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015Q7R16SoGBeqKkEd7RCZRL
os-zhuang
marked this pull request as ready for review
July 19, 2026 17:52
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 #3290.
What & why
#3280 made
organizationIdthe blessed developer-facing name for the caller's active org across the JS authoring surface, keepingctx.session.tenantIdas a@deprecatedalias carrying the identical value. This PR removes that alias from the hookctx.session, the action-bodyctx.session, and the action-bodyctx.user, so the authoring surface converges on a single name — matching theorganization_idcolumn andcurrent_user.organizationIdin RLS/sharing.Scope of the removal (issue checklist)
session.tenantIdfromHookContextSchema.session(@objectstack/spec) — onlyorganizationIdremains; a straytenantIdon a constructed session is now stripped by the schema.tenantIdalias emitted by the engine'sbuildSession()(@objectstack/objectql) and the runtime'sbuildActionSession()/ actionctx.user(@objectstack/runtime).scripts/check-org-identifier.mjsto also coverpackages/**(the framework's own hook/action surface no longer emits or reads the alias), leaving the driver layer alone.@objectstack/spec+@objectstack/objectql+@objectstack/runtime.Internal consumers migrated (behavior-preserving)
The two internal readers of the hook
ctx.session.tenantIdnow readsession.organizationId(identical value), so nothing regresses:@objectstack/objectql— the audit-stamp plugin sources thetenant_idcolumn fromsession.organizationId.@objectstack/trigger-record-change— forwards the writer's org to arunAs:'user'flow fromsession.organizationId.Reference docs/skills
Migrated the
objectstack-data/objectstack-uiskill examples and theruntime-servicesdocs offctx.session?.tenantIdso no reference body teaches the removed name.Migration (FROM → TO)
In any
*.hook.ts/*.action.tsbody:ctx.session.tenantId→ctx.session.organizationIdctx.user.tenantId(action body) →ctx.user.organizationIdctx.userisundefinedfor system / unauthenticated writes, so readctx.session?.organizationIdwhen the hook/action must work regardless of a resolved user.Explicit non-goals (untouched)
The generic driver-layer tenancy abstraction is deliberately not changed — it is a distinct, configurable isolation axis (legitimately an environment id in database-per-tenant kernels):
ExecutionContext.tenantId,DriverOptions.tenantId,SqlDriver.applyTenantScope/TenancyConfig.tenantField, andExecutionLog.tenantId. The guard's pattern anchors on thesessionreceiver, soexecCtx.tenantId/opts.tenantIdare never matched.Verification
spec(50),objectql(116, incl. thetenant_idstamping integration test),runtime(185),trigger-record-change(25).turbo buildsucceeds (no type errors).pnpm check:org-identifierpasses acrossexamples/,apps/, andpackages/(1408 files).Per #3290 this is scheduled for the next major (v11/v12) and should not land before a real deprecation window (the
@deprecatedTSDoc + the #3289 guard are the migration aids in the meantime). Opened as a draft so it can ride the major train — the changeset is amajorbump for the three packages, so it will only release on a major.Generated by Claude Code