Repository navigation
feat(roles): custom roles and a permission catalog - #2867
JeremyFunk wants to merge 53 commits into
Conversation
…ions on credentials, roles UI
… reads and sync shapes
… keep their access in unattended runs
…s, built-in role holders
…, kit control cards, simpler roles pages
… widgets and query insights; restore dashboard approvals
…e digests, shares, raw-SQL alert rules and OAuth completion; demotion cleans up; orphaned holders hold nothing
… the server checks; derive denial copy
…o-role members, recommendation/service-map gating, raw SQL edits need query:sql
…iews, code review, anonymous connectors; safe role drafts; tolerant session read
…ds query:sql, unreadable role metadata fails safe, digests retry after Clerk outages, stale role codes cleared; ops doc
…y telemetry:read, drop racy webhook role clearing, bound push owner lookups, evict cache on join
…es imply telemetry:read
# Conflicts: # apps/api/test/offline-http-ports.ts # packages/backend/src/services/auth/OrgMembershipService.ts # packages/backend/src/services/digest/DigestService.ts # packages/backend/src/services/org/OrganizationDeletionService.ts
This comment has been minimized.
This comment has been minimized.
Brings main's source maps, on-call calendar feed, error grouping rules, LLM evals and incident actions onto the permission model: source_maps:upload joins the catalog (Engineer), new endpoints and MCP tools declare their permission, and the pinned-permissions migration is regenerated after main's newest so the deploy accepts it.
… reads Review follow-ups for custom roles: - Role writes hold a per-org Postgres advisory lock (RoleWriteLock), so two admins can no longer drop each other's edit or demote each other out of the last Admin. - Narrowing a role rewrites every holder even when Clerk refuses one, then fails with roles_unavailable; sending the same save again finishes them. - The Clerk webhook checks an org:custom membership against the role it names, so a role set by hand cannot revive deleted or narrowed codes. - A GET no requires or personal mark covers needs telemetry:read, so a role without it no longer reads alert rules, SLOs, keys or sources; the alert_rules, api_keys and alert_destinations shapes need it too. - The demo seed needs sources:manage; sharing a board or widget holding raw SQL needs query:sql.
…w-rbac-pr-build-banner
- Compare column marks only differences, as Added or Removed chips, with a summary beside the picker; a shared permission is no longer a second check mark next to the checkbox. - The Required by note sits on the title line, so ticking a permission no longer pushes the rows below down. - Built-in and Custom use the same quiet chip, every role's meter one tone, added rows lose the primary tint, permission codes are quieter, and the header drops the permission count the tab already shows.
This comment has been minimized.
This comment has been minimized.
- Built-in and read-only roles list a check or a dash per permission instead of disabled checkboxes, and their rows no longer hover. - Group rows drop the inner bordered box; the chevron sits in a checkbox-wide slot so group and permission names line up. - Duplicate to customize is the primary action; the meta line is the member count only, since the chip and banner already say the type. - Tabs use tabular numerals and segmented options reserve their selected weight, so counts and picks never move their neighbours. - The create dialog holds two lines for the starting role's detail, so picking one never resizes it. - The members role prompt's info icon is no longer primary. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This comment has been minimized.
This comment has been minimized.
- main's new alerts tests used adminRoles; the branch calls it adminGrants. - The Clerk webhook tests provide RolesService, which the webhook now uses. - The electric-sync shape test now expects configuration shapes to need telemetry:read.
main now requires saveBar for unsaved edits; it carries the change count, the floating pill and Mod+S.
This comment has been minimized.
This comment has been minimized.
- code_review:auto_approve stays with Admin; custom roles cannot hold it. - Sharing checks raw SQL in a stat's sparkline too (holdsRawSql), and rotating a share link takes the same query:sql check as minting one. - Unticking a permission unticks the ones it alone had ticked; one ticked by hand stays. - "1 member holds" for a single holder.
Maple review🟡 Confidence 6/10 · needs attention. Held at 6 because 140 reviewed files were not read. Custom roles replace role-rank checks across HTTP, MCP, chat and the dashboard. The five earlier findings are fixed with tests. About 130 remaining changed files (tool declarations, tests, web pages) were covered by eight fan-out passes and the earlier passes, not re-read by me.
Before merge
Fixed since the last review
Files not reviewed (140)The review ended before it read these diffs, so nothing above vouches for them.
|
Custom roles for Maple. Roles become permission sets: the four built-in roles (Analyst, Member, Engineer, Admin) are presets, and organizations can define their own roles with any of the catalog's permissions. Every check now reads a permission instead of a role rank.
What changed
packages/domain/src/policy): 52 permissions with stable codes. Built-in roles are explicit presets with the same abilities as before; on-call schedules and SLOs/budgets are split out ofalerts:manage(Engineer still holds all three).source_maps:upload(from main) is an Engineer permission.maple_roles, versioned);org:custom, with the role id and permission codes on their membership.permissions; every HTTP endpoint declaresEndpointAccess(unmarked non-GET is refused, endpoint and group rules both apply, and a GET norequiresor"personal"covers needstelemetry:read); every MCP tool declares apermission; chat approvals, electric-sync shapes, digests, share links, mobile pushes and raw SQL (query:sql) all check. The six member-level permissions that were UI-only are now enforced on the server.RoleWriteLock), so two admins can't drop each other's edit or demote each other out of the last Admin. A holder Clerk refuses doesn't stop the others; the save reports it and sending it again finishes them. The Clerk webhook checks anorg:custommembership against the role it names, so a role set by hand can't revive deleted or narrowed codes./internal/roles, admin-only writes, audited) and dashboard UI: Roles page, role editor (compare with another role, implied permissions tick themselves), create and delete (with reassign) dialogs, members-tab empty state, Members page picker with custom roles, "Needs " denial tooltips, a read-only banner on built-in roles, and every control gated on the permission the server checks.docs/custom-roles.md.Screenshots
Verification
telemetry:read), custom-role session resolution, pinned codes and demotion, RolesService (validation, versioned writes, the org lock, partial holder failures and retry, reconcile, reassign, webhook settling), MCP tool gating, chat approvals, digest/push/share filtering (raw SQL shares needquery:sql), and the roles UI scenes.Before production
org:customon the production instance, in the default role set, holding onlyorg:sys_memberships:read(done on the dev instance). Production custom roles need Clerk's B2B Authentication add-on.packages/db/drizzle/20261124232933_custom_role_pinned_permissions, dated after main's newest), applied by the prd deploy.