# ListRolePermissionsByRole

## Overview

ListRolePermissionsByRole retrieves all permissions assigned to a specific role. This query supports the permission check flow in RBAC, where after resolving a user's roles, the system resolves each role's permissions to determine whether the user has the required permission for an action.

## Business Rules

- Accepts a roleId as input
- Returns all Permission records associated with the role via RolePermission join records
- Returns an empty array when the role has no permission assignments — not an error
- The role must exist; a non-existent roleId returns an error

## Process Flow

```mermaid
flowchart TD
    A[Receive roleId] --> B{Role exists?}
    B -->|No| C[Return error: ROLE_NOT_FOUND]
    B -->|Yes| D[SELECT permissions via RolePermission where roleId = input]
    D --> E{Any permissions found?}
    E -->|Yes| F[Return permission records]
    E -->|No| G[Return empty array]
```

## External Dependencies

- None

## Error Scenarios

- **ROLE_NOT_FOUND**: Specified roleId does not exist

## Test Cases

- returns all permissions assigned to role
- returns empty array when role has no permissions
- returns error when roleId does not exist
- returns multiple permissions when role has multiple permission assignments
