Skip to content

fix(runtime): synthesize ai_seat in resolveExecutionContext (works on sharded runtime)#2335

Merged
os-zhuang merged 1 commit into
mainfrom
fix/ai-seat-synthesis-in-exec-context
Jun 26, 2026
Merged

fix(runtime): synthesize ai_seat in resolveExecutionContext (works on sharded runtime)#2335
os-zhuang merged 1 commit into
mainfrom
fix/ai-seat-synthesis-in-exec-context

Conversation

@os-zhuang

Copy link
Copy Markdown
Contributor

Follow-up to fw#2334. The gate's ai_seat synthesis used getObjectQLService() (no-arg), which resolves the env engine on single-env local but not on the sharded multi-tenant runtime (OS_OBJECTOS_SHARDS>1) — a SEATED user got /ai/agents=[]. Caught live on staging enforce. Fix: synthesize in resolveExecutionContext, which already has the scope-correct ql (used for permission sets), so it works everywhere; drop the two heuristic spots for a single source. 🤖 Generated with Claude Code

…rrect engine)

The per-user AI-seat gate (fw#2334) synthesized `ai_seat` from sys_user.ai_access
in the AI-route dispatch via getObjectQLService() (no-arg). That resolves the env
engine on single-env local but NOT on the SHARDED multi-tenant runtime
(OS_OBJECTOS_SHARDS>1), where only the per-request scope selects the right engine
-> the lookup returned empty -> a SEATED user (ai_access=true) was denied
(/ai/agents=[]). Caught live on staging enforce.

Move the synthesis into resolveExecutionContext, which is already handed the
scope-correct `ql` engine (the same one that resolves permission sets) -> works
on local AND sharded staging/prod. ec.permissions now carries `ai_seat`, which
flows to req.user via the existing dispatch path. Drop the two earlier heuristic
spots (http-dispatcher wildcard + dispatcher-plugin resolveRequestUser) so there
is a single, correct source.

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 1:29am

Request Review

@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/concepts/cloud-artifact-api.mdx (via packages/runtime)
  • content/docs/concepts/implementation-status.mdx (via @objectstack/runtime)
  • content/docs/concepts/north-star.mdx (via packages/runtime)
  • content/docs/concepts/packages.mdx (via @objectstack/runtime)
  • content/docs/guides/api-reference.mdx (via @objectstack/runtime)
  • content/docs/guides/authentication.mdx (via @objectstack/runtime)
  • content/docs/guides/cloud-deployment.mdx (via @objectstack/runtime)
  • content/docs/guides/deployment-vercel.mdx (via @objectstack/runtime)
  • content/docs/guides/driver-configuration.mdx (via @objectstack/runtime)
  • content/docs/guides/hook-bodies.mdx (via @objectstack/runtime)
  • content/docs/guides/packages.mdx (via @objectstack/runtime)
  • content/docs/guides/plugin-chatbot-integration.mdx (via @objectstack/runtime)
  • content/docs/guides/production-readiness.mdx (via @objectstack/runtime)
  • content/docs/guides/single-project-mode.mdx (via @objectstack/runtime)
  • content/docs/protocol/objectos/http-protocol.mdx (via @objectstack/runtime)
  • content/docs/protocol/objectos/index.mdx (via @objectstack/runtime)
  • content/docs/protocol/objectos/lifecycle.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.

// sharded multi-tenant runtime, where only the per-request scope selects the
// right engine (a no-arg / wrong-scope lookup returns empty and loses the seat).
// Guarded (tryFind swallows errors) → can only ever ADD access, never break auth.
if (userId && !ctx.permissions!.includes('ai_seat')) {
@os-zhuang
os-zhuang merged commit e24ee8b into main Jun 26, 2026
16 checks passed
@os-zhuang
os-zhuang deleted the fix/ai-seat-synthesis-in-exec-context branch June 26, 2026 01:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants