You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Per-host `additionalOrgRoles` wiring was the defect pattern: five hosts boot
AuthPlugin from a stack, three of them (verify harness, DevPlugin, cloud's
ArtifactKernelFactory) at some point forgot the parameter, and the failure is
silent — app-declared roles are simply absent. cloud is also order-hostile:
it mounts AuthPlugin before the app metadata exists, so no init-time walk
could ever cover it.
AuthPlugin now derives the roles in its own kernel:ready hook — the one point
that fires after all metadata is registered in every host — via
`collectRegisteredOrgRoles` (the late-bound twin of `collectStackOrgRoles`;
same dual read as `bootstrapDeclaredPositions`: engine registry first,
metadata-service facade as fallback). Both consumers update from the derived
union:
- better-auth side: `applyConfigPatch` merges the roles; the instance is
built lazily (or reset by the patch), so the org-plugin roles map carries
the full set on next use.
- select side: `sys_invitation` / `sys_member` are re-registered with
widened `role` options under the same package id — an explicitly supported
registry path (owner contribution replaced, merge cache invalidated). No
DDL: options are validator/picker metadata, the column stays TEXT.
serve / verify harness / DevPlugin drop their wiring — deliberately, so the
dogfood invite gates only stay green if the auto-derivation works. Explicit
`additionalOrgRoles` remains as an override for roles outside stack metadata
(unioned with the derived set).
One bug found the hard way and worth recording: the hook originally acquired
the engine via `ctx.getServiceAsync('objectql')` — a method PluginContext does
not have. The optional-chain made that silently yield `undefined`, the
metadata facade still fed the better-auth half, and the select half was
skipped without an error: derivation logged success while invitations kept
failing. PluginContext's sync `getService` is the API.
Verified: dogfood app-org-role-invite + delegated-admin-invite gates green
with ZERO host wiring (10/10); org-roles unit tests 29 (5 new for
collectRegisteredOrgRoles); plugin-auth 603; full dogfood 375 passed.
0 commit comments