Commit 635849f
fix(runtime): wire ai_access→ai_seat synthesis into the AI route dispatch (ADR-0024) (#2334)
The per-user AI-seat gate (evaluateAgentAccess → requires the `ai_seat`
capability) reads `req.user.permissions`, but the dispatch ExecutionContext
serving `/ai/*` never carried the seat — so a SEATED user
(`sys_user.ai_access=true`) was denied: `/ai/agents` returned an EMPTY catalog
(and in-UI build/ask would 403), even though the #525 cap correctly counted
them. The synthesis lived only on plugin-hono-server's data-route resolveCtx
(which is why the cap, on the data-write path, worked but the gate did not).
Add the guarded synthesis to BOTH AI req.user construction paths:
- http-dispatcher.ts — the `/ai/*` wildcard dispatch (the ACTIVE path): build
req.user.permissions, then read sys_user.ai_access via the DEFAULT (current
per-request env) ObjectQL service and push `ai_seat` when true. NB do NOT pass
context.environmentId — in the cloud runtime that is the control-plane env
UUID, which keys a DISTINCT empty per-scope engine; the env's own sys_user is
served by the default service (this exact mismatch returned [] in testing).
- dispatcher-plugin.ts resolveRequestUser — the concrete-route mount path
(defensive; guarded read via the env kernel's `data` service).
Guarded system read → can only ever ADD access, never break auth
(absent/false/missing-column/error → no seat, unchanged).
Live-verified on a local cloud+objectos stack (OS_CLOUD_AI_SEAT_MODE=enforce):
seated ai_access=true → /ai/agents=[build,ask]; false → []; restore →
[build,ask]; cap still 400s past the licensed seat count. Unblocks flipping
OS_CLOUD_AI_SEAT_MODE=enforce.
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>1 parent 1b00ba2 commit 635849f
2 files changed
Lines changed: 56 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
971 | 971 | | |
972 | 972 | | |
973 | 973 | | |
| 974 | + | |
| 975 | + | |
| 976 | + | |
| 977 | + | |
| 978 | + | |
| 979 | + | |
| 980 | + | |
| 981 | + | |
| 982 | + | |
| 983 | + | |
| 984 | + | |
| 985 | + | |
| 986 | + | |
| 987 | + | |
| 988 | + | |
| 989 | + | |
| 990 | + | |
| 991 | + | |
| 992 | + | |
| 993 | + | |
| 994 | + | |
| 995 | + | |
974 | 996 | | |
975 | 997 | | |
976 | 998 | | |
977 | 999 | | |
978 | 1000 | | |
979 | 1001 | | |
980 | | - | |
| 1002 | + | |
981 | 1003 | | |
982 | 1004 | | |
983 | 1005 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3217 | 3217 | | |
3218 | 3218 | | |
3219 | 3219 | | |
| 3220 | + | |
| 3221 | + | |
| 3222 | + | |
| 3223 | + | |
| 3224 | + | |
| 3225 | + | |
| 3226 | + | |
| 3227 | + | |
| 3228 | + | |
| 3229 | + | |
| 3230 | + | |
| 3231 | + | |
| 3232 | + | |
| 3233 | + | |
| 3234 | + | |
| 3235 | + | |
| 3236 | + | |
| 3237 | + | |
| 3238 | + | |
| 3239 | + | |
| 3240 | + | |
| 3241 | + | |
| 3242 | + | |
| 3243 | + | |
| 3244 | + | |
| 3245 | + | |
| 3246 | + | |
| 3247 | + | |
| 3248 | + | |
| 3249 | + | |
| 3250 | + | |
| 3251 | + | |
3220 | 3252 | | |
3221 | 3253 | | |
3222 | 3254 | | |
3223 | 3255 | | |
3224 | 3256 | | |
3225 | 3257 | | |
3226 | 3258 | | |
3227 | | - | |
| 3259 | + | |
3228 | 3260 | | |
3229 | 3261 | | |
3230 | 3262 | | |
| |||
0 commit comments