Summary
The audit flagged src/lib/auth/roles.ts ships 6 roles × 8 categories but has no training-specific permissions. Add a permission.training category with the granular actions the orchestrator / WS / server endpoints actually need.
Context
- Roles currently cover generic content + account actions but nothing granular enough for training flows.
- Without these perms, every route would have to inline if (user.role === 'admin') checks; centralising them in ROLE_DEFINITIONS is consistent with the rest of the codebase.
Scope
- Add the permission.training category with the 8 actions below.
- Extend ROLE_DEFINITIONS with the requested role grants.
- Export a static matrix snapshot for tests.
Files
- src/lib/auth/roles.ts (extend ROLE_DEFINITIONS and category map)
- src/lib/auth/tests/training-permissions.test.ts (new) — coverage of every granted/revoked combination
New permissions
- manage:fine_tuning — create / cancel / monitor fine-tune jobs
- start:training_jobs — submit jobs for execution
- read:training_jobs — view job status
- cancel:training_jobs — cancel running jobs
- manage:training_sessions — create / update fishbowl sessions
- read:own_training_sessions — view own sessions
- write:training_feedback — submit coaching feedback
- manage:training_data — merge / prepare datasets
Role grants
- admin — full set
- researcher — start:training_jobs, read:training_jobs, manage:training_data
- therapist — read:own_training_sessions, write:training_feedback
Dependencies
- BLOCKED-BY: none.
- BLOCKS:
Acceptance checklist
Related (Linear auto-links bare ticket IDs)
Parent: #4296.
This ticket blocks: #4460 (dataset routes auth) and #4464 (WebSocket hardening). Internal reference: #4463 (UI unification, uses these perms).
Audit anchors
Summary
The audit flagged src/lib/auth/roles.ts ships 6 roles × 8 categories but has no training-specific permissions. Add a permission.training category with the granular actions the orchestrator / WS / server endpoints actually need.
Context
Scope
Files
New permissions
Role grants
Dependencies
Acceptance checklist
Related (Linear auto-links bare ticket IDs)
Parent: #4296.
This ticket blocks: #4460 (dataset routes auth) and #4464 (WebSocket hardening). Internal reference: #4463 (UI unification, uses these perms).
Audit anchors