Role management: backend CRUD, read models, and UI - #147
Merged
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Team management shipped without Role management alongside it -- the backend had
DefineRole/AssignRolePermission/AssignTeamRoleaggregate handlers but no HTTP/MCP routes, noDeleteRole, noRemoveRolePermissionorRemoveTeamRole, and no read model, so "can I manage roles" was still no. This closes that gap, mirroring the Team management slice's pattern throughout:RolePermissionRemoved/TeamRoleRemovedevents andDeleteRole/RemoveRolePermission/RemoveTeamRolecommands, wired intoPermissionProjectionStateandPermissionProjectorso revoking a permission or unassigning a role from a team actually takes effect in materialized grants (previously only additive assignment was reachable).KvDirectory-backed read models:RoleDirectory(list/get roles by name),RolePermissionDirectory(list a role's permissions), andRoleTeamDirectory(list the teams holding a role, materialized role-first from the sameTeamRoleAssigned/Removedeventsrbac-team-rolesalready emits, so a role's detail page doesn't need a substring-search fallback over an unrelated index).RoleCleanupReactor, mirroringTeamCleanupReactor: deleting a role removes its orphaned permission and team assignments instead of leaving them to rot./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 buildcleandotnet 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) cleanDefineRole,GetRole, andAssignRolePermission(all point reads/writes) work correctly.ListRoles/ListRolePermissions/ListRoleTeamshit the same already-tracked SCAN wire-protocol bug (Fix SCAN Limit wire-width mismatch with the fitz broker cntryl/fitz-dotnet#33) that blockedListTeamsbefore that fix -- confirmed via the server log this is the identical pre-existing upstream limitation, not a new regression