Description
Current State
The permission system is MovaLab's most critical subsystem (~40 permissions, context-aware checks, caching). The types exist in lib/permissions.ts and lib/rbac-types.ts but lack JSDoc comments, making it hard for new contributors to understand the permission model.
Files to document
lib/permissions.ts - The ~40 permission enum values
lib/rbac-types.ts - PermissionContext, UserWithRoles, etc.
lib/permission-checker.ts - Core permission evaluation functions
Desired Outcome
/**
* Permission to view projects the user is assigned to.
* Context-aware: Requires user to be in project_assignments table.
* Override: VIEW_ALL_PROJECTS bypasses assignment check.
*/
VIEW_PROJECTS = 'view_projects',
/**
* Context for permission evaluation. When checking project permissions,
* include projectId to verify user assignment.
*
* @example
* hasPermission(user, Permission.EDIT_PROJECT, { projectId: 'uuid' })
*/
export interface PermissionContext {
projectId?: string;
accountId?: string;
departmentId?: string;
}
How to get started
- Read
CLAUDE.md section "Permission System Deep Dive" to understand the model
- Start with
lib/permissions.ts - document each permission enum
- Document which permissions have "ALL" overrides
- Add @example tags showing proper usage
Acceptance Criteria
Description
Current State
The permission system is MovaLab's most critical subsystem (~40 permissions, context-aware checks, caching). The types exist in
lib/permissions.tsandlib/rbac-types.tsbut lack JSDoc comments, making it hard for new contributors to understand the permission model.Files to document
lib/permissions.ts- The ~40 permission enum valueslib/rbac-types.ts- PermissionContext, UserWithRoles, etc.lib/permission-checker.ts- Core permission evaluation functionsDesired Outcome
How to get started
CLAUDE.mdsection "Permission System Deep Dive" to understand the modellib/permissions.ts- document each permission enumAcceptance Criteria
lib/permissions.tshave JSDoc commentslib/rbac-types.tshave JSDoc commentslib/permission-checker.tshave JSDoc with @example