Skip to content

feat(runtime): expose organizationId to action-body ctx (user + session) — follow-up to #3280 - #3288

Merged
os-zhuang merged 1 commit into
mainfrom
feat/action-org-identifier
Jul 19, 2026
Merged

feat(runtime): expose organizationId to action-body ctx (user + session) — follow-up to #3280#3288
os-zhuang merged 1 commit into
mainfrom
feat/action-org-identifier

Conversation

@os-zhuang

Copy link
Copy Markdown
Contributor

Follow-up to #3280 (merged in #3284). Extends the blessed organizationId org 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.organizationId in hooks. Action bodies were left behind:

  • REST dispatch (handleActions) exposed only ctx.user.tenantId (the deprecated name) and no ctx.session.
  • MCP run_action (runAction) exposed neitherctx.user was { id, name } only.

Action bodies execute trusted (the ctx.engine / ctx.api facade bypasses RLS/FLS), so a body that must scope by org has to read it from ctx — 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 the organization_id column + current_user.organizationId in RLS). ctx.user.tenantId kept as a deprecated alias with the identical value on the REST path.
  • ctx.session ({ userId, organizationId, tenantId, roles? }) via a shared buildActionSession(ec) helper mirroring the hook ctx.session shape; undefined for 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. The objectstack-ui skill now documents the action-body ctx and the organizationId read (previously undocumented).

Verification

  • @objectstack/runtime full http-dispatcher.test.ts185 passed (incl. extended action body ctx block asserting user.organizationId + new ctx.session.organizationId/deprecated-tenantId test + anonymous → no-session test); body-runner11 passed.
  • Runtime DTS typecheck ✓.
  • Gates green: check:doc-authoring, check:skill-docs, check:skill-refs, check:role-word, check:nul-bytes.

🤖 Generated with Claude Code

…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>
@vercel

vercelBot commented Jul 19, 2026

Copy link
Copy Markdown

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

ProjectDeploymentActionsUpdated (UTC)
specReadyReadyPreview, CommentJul 19, 2026 2:29pm

Request Review

@github-actionsgithub-actionsBot added documentation Improvements or additions to documentation tests tooling size/s labels Jul 19, 2026
@github-actions

Copy link
Copy Markdown
Contributor

📓 Docs Drift Check

This PR changes 1 package(s): @objectstack/runtime.

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

  • content/docs/api/index.mdx(via @objectstack/runtime)
  • content/docs/api/wire-format.mdx(via @objectstack/runtime)
  • content/docs/automation/hook-bodies.mdx(via @objectstack/runtime)
  • content/docs/concepts/north-star.mdx(via packages/runtime)
  • content/docs/data-modeling/drivers.mdx(via @objectstack/runtime)
  • content/docs/deployment/index.mdx(via @objectstack/runtime)
  • content/docs/deployment/production-readiness.mdx(via @objectstack/runtime)
  • content/docs/deployment/single-project-mode.mdx(via @objectstack/runtime)
  • content/docs/deployment/vercel.mdx(via @objectstack/runtime)
  • content/docs/getting-started/your-first-project.mdx(via @objectstack/runtime)
  • content/docs/permissions/authentication.mdx(via @objectstack/runtime)
  • content/docs/permissions/authorization.mdx(via packages/runtime)
  • content/docs/plugins/packages.mdx(via @objectstack/runtime)
  • content/docs/protocol/kernel/http-protocol.mdx(via @objectstack/runtime)
  • content/docs/protocol/kernel/index.mdx(via @objectstack/runtime)
  • content/docs/protocol/kernel/lifecycle.mdx(via @objectstack/runtime)
  • content/docs/releases/implementation-status.mdx(via @objectstack/runtime)

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.

Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentationImprovements or additions to documentationsize/steststooling

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

@os-zhuang