feat(runtime): expose organizationId to action-body ctx (user + session) — follow-up to #3280#3288
Merged
Merged
Conversation
…on) — follow-up to #3280 Hooks now teach `ctx.user.organizationId` / `ctx.session.organizationId` as the blessed name for the caller's active org (#3280). Action bodies — the sibling authoring surface sharing the same sandbox runner — were left behind: the REST dispatch path exposed only `ctx.user.tenantId` (deprecated) and no `ctx.session`, and the MCP `run_action` path exposed neither. Both action-dispatch sites (`handleActions`, MCP `runAction`) now populate: - `ctx.user.organizationId` — blessed name (matches the organization_id column and current_user.organizationId in RLS); `ctx.user.tenantId` kept as a deprecated alias on the REST path. - `ctx.session` (`{ userId, organizationId, tenantId, roles? }`) via a shared `buildActionSession(ec)` helper, mirroring the hook session shape; undefined for a context-less / self-invoked call. Action bodies execute trusted (engine/api facade bypasses RLS/FLS), so a body that scopes by org must read it from ctx — now under the same name a hook author uses. objectstack-ui skill documents the action-body ctx + org read. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
📓 Docs Drift CheckThis PR changes 1 package(s): 17 hand-written doc(s) reference the affected code and may need an implementation-accuracy re-verification:
|
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.
Follow-up to #3280 (merged in #3284). Extends the blessed
organizationIdorg name from the hook surface to the sibling action-body surface, which shares the same sandbox runner.Gap
#3280 taught
ctx.user.organizationId/ctx.session.organizationIdin hooks. Action bodies were left behind:handleActions) exposed onlyctx.user.tenantId(the deprecated name) and noctx.session.run_action(runAction) exposed neither —ctx.userwas{ id, name }only.Action bodies execute trusted (the
ctx.engine/ctx.apifacade bypasses RLS/FLS), so a body that must scope by org has to read it fromctx— and it should read it under the same name a hook author uses.Change — additive, behavior-preserving
Both action-dispatch sites now populate:
ctx.user.organizationId— blessed name (matches theorganization_idcolumn +current_user.organizationIdin RLS).ctx.user.tenantIdkept as a deprecated alias with the identical value on the REST path.ctx.session({ userId, organizationId, tenantId, roles? }) via a sharedbuildActionSession(ec)helper mirroring the hookctx.sessionshape;undefinedfor a context-less / self-invoked call (parity with hooks).The sandbox body-runner already forwards
actionCtx.user/actionCtx.session, so no runner change was needed. Theobjectstack-uiskill now documents the action-bodyctxand theorganizationIdread (previously undocumented).Verification
@objectstack/runtimefullhttp-dispatcher.test.ts185 passed (incl. extendedaction body ctxblock assertinguser.organizationId+ newctx.session.organizationId/deprecated-tenantIdtest + anonymous → no-session test);body-runner11 passed.check:doc-authoring,check:skill-docs,check:skill-refs,check:role-word,check:nul-bytes.🤖 Generated with Claude Code