Skip to content

feat(auth): env-side AI-seat marker via sys_user.ai_access + resolveCtx synthesis#2327

Merged
os-zhuang merged 2 commits into
mainfrom
feat/ai-access-field
Jun 25, 2026
Merged

feat(auth): env-side AI-seat marker via sys_user.ai_access + resolveCtx synthesis#2327
os-zhuang merged 2 commits into
mainfrom
feat/ai-access-field

Conversation

@os-zhuang

Copy link
Copy Markdown
Contributor

Part 1 of the simplified per-user AI-seat gate (pairs with cloud feat/ai-seat-simple-model; both must land together + cloud bumps .framework-sha).

What: the env DB (Turso) is single-org with only sys_user, so the AI seat is a boolean on the user — not a permission set. resolveCtx synthesizes the ai_seat capability from sys_user.ai_access, so the existing per-agent gate (evaluateAgentAccess → requires ai_seat), catalog filter, and frontend are UNCHANGED — only the seat's source moves to a user field.

Safe-by-construction (the important bit): ai_access is NOT a better-auth additionalField. sys_user is better-auth-managed and better-auth SELECTs explicit columns, so an additionalField would make getSession query a column that may not exist on every env yet → broken auth on deploy. Instead:

  • the column is owned by the objectql SysUser object def (provisioned by boot schema-sync; also makes it an editable field — the management UI is just a checkbox);
  • resolveCtx reads it via a GUARDED system query (.catch → []), so a missing column / failed read can only NO-OP — never break auth;
  • better-auth stays oblivious to the column.

Dormant by default: nothing sets ai_access until the cloud OS_CLOUD_AI_SEAT_MODE (default off) flips to provision/enforce, or a licensed objectos-ee mounts the AiSeatPlugin.

Built clean (platform-objects + plugin-auth + plugin-hono-server). Cap logic unit-verified in the cloud half (24 tests). Browser-level E2E deferred (env blocker) — merging per explicit owner decision given the safe-by-construction design.

🤖 Generated with Claude Code

os-zhuang and others added 2 commits June 25, 2026 19:57
…imple AI-seat model)

The env DB (Turso) is single-org and has only sys_user — so the AI seat is best
modeled as a boolean on the user, not a permission set. Add `ai_access` as a
better-auth additionalField (rides on the session user) and have resolveCtx
synthesize the `ai_seat` capability when it is true. The existing per-agent gate
(evaluateAgentAccess → requires ai_seat), catalog filter, and frontend are
unchanged — they now admit a user via the field with NO permission-set grant.

ADDITIVE: the permission-set path still works (a user can get ai_seat from either
source), so there is no regression while the rest of the simplification (have the
entitlement layer SET the field + retire the permission-set seed/junction/cap-
middleware + repoint the management UI) lands. Built clean (plugin-auth + hono).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…not a better-auth additionalField)

sys_user is a better-auth-MANAGED table and better-auth SELECTs explicit columns.
Declaring ai_access as a better-auth additionalField (my first cut) would make
getSession query a column that may not exist on every env yet → broken auth on
deploy. Safe-by-construction instead:
  • drop the additionalField (better-auth stays oblivious to the column);
  • own ai_access on the objectql SysUser object def → provisioned by boot
    schema-sync, and editable as a normal field (the management UI is a checkbox);
  • resolveCtx reads it via a GUARDED system query (.catch → []), so a missing
    column / failed read can only NO-OP — never break auth.

Built clean (platform-objects + plugin-auth + plugin-hono-server). Amends the
prior additionalField approach on this branch.

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

vercel Bot commented Jun 25, 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 25, 2026 1:13pm

Request Review

@github-actions

Copy link
Copy Markdown
Contributor

📓 Docs Drift Check

This PR changes 3 package(s): @objectstack/platform-objects, @objectstack/plugin-auth, @objectstack/plugin-hono-server.

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

  • content/docs/concepts/implementation-status.mdx (via @objectstack/plugin-auth, @objectstack/plugin-hono-server)
  • content/docs/concepts/packages.mdx (via @objectstack/platform-objects, @objectstack/plugin-auth, @objectstack/plugin-hono-server)
  • content/docs/concepts/setup-app.mdx (via @objectstack/platform-objects)
  • content/docs/getting-started/cli.mdx (via @objectstack/plugin-auth)
  • content/docs/guides/auth-sso.mdx (via @objectstack/plugin-auth)
  • content/docs/guides/authentication.mdx (via @objectstack/plugin-auth, @objectstack/plugin-hono-server)
  • content/docs/guides/kernel-services.mdx (via @objectstack/plugin-auth)
  • content/docs/guides/packages.mdx (via @objectstack/platform-objects, @objectstack/plugin-auth, @objectstack/plugin-hono-server)
  • content/docs/guides/plugins.mdx (via @objectstack/plugin-auth, @objectstack/plugin-hono-server)
  • content/docs/guides/production-readiness.mdx (via @objectstack/plugin-auth)
  • content/docs/releases/v9.mdx (via @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 8ba804e into main Jun 25, 2026
14 of 15 checks passed
@os-zhuang
os-zhuang deleted the feat/ai-access-field branch June 25, 2026 13:11
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.

1 participant