Skip to content

Role management: backend CRUD, read models, and UI - #147

Merged
smiggleworth merged 4 commits into
mainfrom
feature/role-management
Sep 19, 2026
Merged

smiggleworth merged 4 commits into
mainfrom
feature/role-management

Conversation

@smiggleworth

Copy link
Copy Markdown
Contributor

Summary

Team management shipped without Role management alongside it -- the backend had DefineRole/AssignRolePermission/AssignTeamRole aggregate handlers but no HTTP/MCP routes, no DeleteRole, no RemoveRolePermission or RemoveTeamRole, and no read model, so "can I manage roles" was still no. This closes that gap, mirroring the Team management slice's pattern throughout:

  • New RolePermissionRemoved/TeamRoleRemoved events and DeleteRole/RemoveRolePermission/RemoveTeamRole commands, wired into PermissionProjectionState and PermissionProjector so revoking a permission or unassigning a role from a team actually takes effect in materialized grants (previously only additive assignment was reachable).
  • Three new KvDirectory-backed read models: RoleDirectory (list/get roles by name), RolePermissionDirectory (list a role's permissions), and RoleTeamDirectory (list the teams holding a role, materialized role-first from the same TeamRoleAssigned/Removed events rbac-team-roles already emits, so a role's detail page doesn't need a substring-search fallback over an unrelated index).
  • RoleCleanupReactor, mirroring TeamCleanupReactor: deleting a role removes its orphaned permission and team assignments instead of leaving them to rot.
  • Full HTTP + MCP surface for all of the above, and a /roles, /roles/{roleId} UI (create/delete roles; add/remove permissions and team grants) following the same pages/routing pattern as Teams.

Known limitation carried into this slice (same as Teams): team grants and members are shown by raw ID, not name -- no identity directory exists yet.

Test plan

  • dotnet build clean
  • dotnet test -- 175/177 passing (the 2 failures are pre-existing, broker-dependent integration tests that need a live Fitz broker, unrelated to this change)
  • npm run client:check (typecheck + lint + test + build) clean
  • Regenerated the TS API client from a fresh OpenAPI export to pick up the new Role routes
  • Manual end-to-end verification against a real local Fitz broker: DefineRole, GetRole, and AssignRolePermission (all point reads/writes) work correctly. ListRoles/ListRolePermissions/ListRoleTeams hit the same already-tracked SCAN wire-protocol bug (Fix SCAN Limit wire-width mismatch with the fitz broker cntryl/fitz-dotnet#33) that blocked ListTeams before that fix -- confirmed via the server log this is the identical pre-existing upstream limitation, not a new regression

Team management shipped without Role management alongside it -- the
backend had DefineRole/AssignRolePermission/AssignTeamRole aggregate
handlers but no HTTP/MCP routes, no DeleteRole, no RemoveRolePermission
or RemoveTeamRole, and no read model, so "can I manage roles" was
still no. This closes that gap, mirroring the Team management slice's
pattern throughout:

- New RolePermissionRemoved/TeamRoleRemoved events and
  DeleteRole/RemoveRolePermission/RemoveTeamRole commands, wired into
  PermissionProjectionState and PermissionProjector so revoking a
  permission or unassigning a role from a team actually takes effect
  in materialized grants (previously only additive assignment was
  reachable).
- Three new KvDirectory-backed read models: RoleDirectory (list/get
  roles by name), RolePermissionDirectory (list a role's permissions),
  and RoleTeamDirectory (list the teams holding a role, materialized
  role-first from the same TeamRoleAssigned/Removed events
  rbac-team-roles already emits, so a role's detail page doesn't need
  a substring-search fallback over an unrelated index).
- RoleCleanupReactor, mirroring TeamCleanupReactor: deleting a role
  removes its orphaned permission and team assignments instead of
  leaving them to rot.
- Full HTTP + MCP surface for all of the above, and a /roles,
  /roles/{roleId} UI (create/delete roles; add/remove permissions and
  team grants) following the same pages/routing pattern as Teams.

Verified end to end against a real Fitz broker: DefineRole, GetRole,
and AssignRolePermission (all point reads/writes) work correctly.
ListRoles/ListRolePermissions/ListRoleTeams hit the same already-
tracked SCAN wire-protocol bug (cntryl/fitz-dotnet#33) that blocked
ListTeams before that fix -- not a new regression, the identical
pre-existing upstream limitation surfacing on a new read path.
Adding Role's MCP tools in Program.cs broke
TeamMcpScenarioTests.ShouldListTeamToolsAndDenyAnUnprivilegedCall,
which asserted an exact tool list scoped to Team alone. Renamed to
RbacMcpScenarioTests and updated the expected list to the full RBAC
surface (Team + Role); the exact-match style is kept deliberately so
future tool registrations force a visible review here rather than
silently drifting.
@smiggleworth
smiggleworth merged commit f42e9c6 into main Sep 19, 2026
4 checks passed
@smiggleworth
smiggleworth deleted the feature/role-management branch September 19, 2026 10:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant