Skip to content

feat(roles): enterprise roles E00 — ten roles, permission catalogue, extra job roles - #503

Merged
anandtopu merged 5 commits into
mainfrom
feat/roles-e00-foundation
Nov 28, 2026
Merged

anandtopu merged 5 commits into
mainfrom
feat/roles-e00-foundation

Conversation

@anandtopu

Copy link
Copy Markdown
Contributor

Enterprise roles E00 — role and permission foundation

Adds five roles for release teams and AI agents — RELEASE_MANAGER, PROJECT_MANAGER, PRODUCT_MANAGER, DEVELOPER, AGENT — beside the five ranks, a 46-permission catalogue (backend/app/core/permissions.py), extra job roles per person and per project, and the admin screens to assign them. Every later enterprise-roles epic (E01–E10) builds on this.

No existing role changes behaviour. Ladder roles' permission sets are computed from their rank, and a job role counts as VIEWER on every guard that names no permission (fail closed). No production route is converted to require_permission yet; the new roles are inert until an administrator assigns them.

What is in it

  • Ranks vs roles: five ranks (VIEWER < TESTER < QA_ENGINEER < QA_LEAD < ADMIN); permissions.rank_index is the only ladder index (quality-gate guards backend.single-role-rank-helper and frontend.single-role-order; 70 guards).
  • Guards: require_permission(P) / require_role(X, permission=P); the project role floor holds a member to every (rank, permission) a route names; on a project write instance and project permissions intersect ("the lower of the two decides").
  • Extra job roles (D-16): users.additional_roles, project_members.additional_roles, user_invitations.additional_roles (migration 0266, nullable JSONB; the downgrade maps every new role value back to VIEWER). Users, members and invitation APIs and Settings › Users / Members & access carry them.
  • Grant ceiling: a non-admin may give a project role or extra role only when they hold all its permissions in that project; only an administrator gives RELEASE_MANAGER, PROJECT_MANAGER or PRODUCT_MANAGER (owner decision D-17); nobody changes their own role; AGENT is never given through these routes. Refusals name what is missing.
  • GET /api/v1/me/permissions?project_id= and useMyPermissions().can(...) in the SPA.
  • SSO and SCIM: a group mapped to a job role adds it as an extra role (the highest rank still sets the role); the SSO preview lists extra roles and their groups.
  • MFA: release and product managers count as QA_LEAD under a floor; new required_roles ("Also require it from"); the floor must be a rank.
  • Feature-flag role lists match extra roles; dev-login and the dev seed gain the job roles; seed_data.py seeds a TESTER (D-8).
  • Docs: user-guide/administration.md (roles), architecture/SECURITY.md, THREAT_MODEL.md, user-guide/compliance.md, CHANGELOG, reference docs.

Reviewed access matrix

backend/tests/security_role_access_matrix.json lists, for every role-gated route, the roles it admits. Any future change to a role's access shows as a diff there. tests/test_role_access_runtime.py sends real requests as each of the ten roles and checks the answers match it.

Tests changed to the new expected behaviour

test_role_hierarchy_is_five_tiers.py (five ranks, ten roles; D-1), test_mfa.py (required_roles in the policy response), test_sso_role_preview.py (preview gains additional_roles), test_timeline_note_routes.py (expects rank_index), test_operational_metric_dimensions.py's inventory via metric_dimensions.ACTOR_ROLES (every role; cardinality budget +1000 series).

Verification (local, CI's package versions, Python 3.14)

  • Backend unit suite (26,199 tests, sharded): all pass except shell-script tests that time out on this Windows machine (bash takes ~5 s to start) and Windows-only multiprocess metric tests — none touch this change.
  • PostgreSQL 16: migration 0266 up / down / up; SCIM, invitation and member-scope integration tests 258/258.
  • Seven mutations of the new rules (and the D-17 rule) are each caught.
  • Frontend: vitest 12,474 pass (two timing tests pass alone); role crawl and wording specs across every person role; Users-page hermetic specs; type-check, eslint 0 errors; eager bundle 179,591 / 180,000.
  • Quality gate, ruff, mypy ratchet at baseline, reference docs check.

Pushed with SKIP_PUSH_CHECK=1 (owner approved): the local pre-push gate runs the whole backend suite serially, about 7 hours on the pushing machine, where bash takes ~5 s to start and the shell-script tests time out. Every check the gate runs was run separately above with CI's package versions.

Known follow-ups

  • The users-row-edit visual baseline changes (the Edit User form shows the extra-roles picker): regenerate the Linux baselines on this branch and review them.
  • Project export/import does not carry extra roles yet (an import gives the role only) — planned for E10.
  • usePermissions.ts is unchanged (the shell bundle has little headroom), so it reads a job role as VIEWER; per-permission answers come from useMyPermissions.

🤖 Generated with Claude Code

anandtopu and others added 3 commits November 28, 2026 10:44
…extra job roles

Adds RELEASE_MANAGER, PROJECT_MANAGER, PRODUCT_MANAGER, DEVELOPER and AGENT
beside the five ranks, a 46-permission catalogue (app/core/permissions.py)
and the plumbing every later epic uses. No existing route changes behaviour:
ladder roles' permission sets are computed from rank, and a job role counts
as VIEWER on every guard that names no permission (fail closed).

Slice 1
- UserRole gains five values; permissions.rank_index is the only ladder index
  (quality-gate guard backend.single-role-rank-helper).
- require_permission(P) / require_role(X, permission=P); the project role floor
  holds a member to every (rank, permission) a route names; writes intersect
  instance and project permissions ("the lower of the two decides").
- users.additional_roles / project_members.additional_roles (migration 0261);
  members-route grants need every permission of the role; AGENT never granted
  through the user or member routes; MFA from QA_LEAD up covers release and
  product managers.
- Reviewed per-role access matrix: tests/security_role_access_matrix.json.

Slice 2
- Users, members and invitation APIs and Settings › Users / Members & access
  carry extra roles (picker, table line); a refusal names the missing
  permissions and a project role caps what its holder hands out there.
- Owner decision D-17: only an administrator gives RELEASE_MANAGER,
  PROJECT_MANAGER or PRODUCT_MANAGER (permissions.ADMIN_ONLY_GRANTS); the
  Members tab offers a QA lead only the roles they may give.
- GET /api/v1/me/permissions + useMyPermissions().can() in the SPA.
- SSO and SCIM groups mapped to a job role add it as an extra role; the SSO
  preview lists them. MFA policy gains required_roles (floor must be a rank).
  Feature-flag role lists match extra roles.
- Dev-login and the dev seed gain the four job roles; seed_data.py seeds a
  TESTER (D-8); the role crawl and every-role-wording cover them;
  frontend.single-role-order guard (70 guards).
- Postgres: SCIM job-role groups and invited extra roles
  (integration/test_scim_groups_postgres.py, test_invitations_postgres.py).
- usePermissions.ts unchanged (eager bundle has 8 bytes of headroom); role-aware
  helpers in src/lib/roles.ts for lazy pages.

Tests changed to the new expected behaviour: test_role_hierarchy_is_five_tiers
(five ranks, ten roles; D-1), test_mfa (required_roles in the policy response),
test_sso_role_preview (additional_roles in the preview), test_timeline_note_routes
(rank_index), test_job_role_assignment_and_mfa and test_permission_catalogue (D-17).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Anand Topu <anand.goud.2020@gmail.com>
…tion

Signed-off-by: Anand Topu <anand.goud.2020@gmail.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

# Conflicts:
#	backend/app/core/deps.py
#	backend/app/services/mfa_service.py
#	docs/reference/api-index.md
#	docs/reference/api/authentication.md
#	docs/reference/api/sso-saml.md
#	docs/reference/data-dictionary.md
#	docs/reference/migrations.md
#	user-guide/compliance.md
- Migration renumbered 0261 -> 0266 (down_revision 0265): main added
  0261-0265 meanwhile; one alembic head again. Upgrade, downgrade and
  re-upgrade checked on PostgreSQL 16.
- users.update_user_profile / member routes read additional_roles with
  getattr, so a payload without the field (an older caller, a test double
  such as test_live_session_token_revocation's) keeps the extra roles.
- metric_dimensions.ACTOR_ROLES lists every UserRole value (main's
  test_operational_metric_dimensions requires it); the cardinality budget
  for testlookup_test_case_transitions_total grows 600 -> 1100 children,
  1200 -> 2200 series (total 21574 -> 22574).
- Reference docs regenerated.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Anand Topu <anand.goud.2020@gmail.com>
Comment thread backend/app/core/deps.py Resolved
anandtopu and others added 2 commits November 28, 2026 13:23
- Iterate UserRole through list(UserRole) in the new role tests, so the
  loop target is an explicit iterable (same values, same order).
- test_role_access_runtime._send passes only the placeholders a path
  template names (no surplus user_id for paths without one).

deps._ROLE_ORDER stays: test_role_hierarchy_is_five_tiers (D-1) and
test_agent_configs import it from app.core.deps.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Anand Topu <anand.goud.2020@gmail.com>
…r Role column

From the "Chart visual baselines (Linux)" run 46179752540 on this branch;
the five images that differ, reviewed before committing:
- users-row-edit (lab, signal): the Edit User form shows the Extra roles
  picker under Role / Status.
- users-erased-row (lab, paper, signal): the Role column is wider (the role
  dropdown now lists the job roles), so the row's columns shift.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Anand Topu <anand.goud.2020@gmail.com>
@anandtopu
anandtopu enabled auto-merge November 28, 2026 20:05
@anandtopu
anandtopu merged commit 0efefeb into main Nov 28, 2026
41 checks passed
@anandtopu
anandtopu deleted the feat/roles-e00-foundation branch November 28, 2026 20:28
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