Skip to main content

RBAC Model: Work Order QMS

Document Type: Security & Access Control Specification
Version: 1.0 | Date: 2026-02-13
Compliance: FDA 21 CFR Part 11 §11.10(d), HIPAA, SOC 2 CC6.1


1. Role Definitions

1.1 Human Roles

RoleScopeAssignmentTypical Persona
ORIGINATORPer-WOAutomatic (creator)Lab tech, program, vendor system
ASSIGNERPer-WODesignated planner or System OwnerDepartment lead, project manager
ASSIGNEEPer-WOPerson or team executingIT technician, lab engineer, vendor
SYSTEM_OWNERPer-system/assetTenant configurationQuality manager, department head
QAPer-tenantTenant configurationQA specialist, compliance officer
VENDORPer-WO + per-vendorContract-basedExternal vendor representative
ADMINPer-tenantSuperuser designationIT administrator, platform admin
AUDITORPer-tenantRead-only complianceExternal auditor, FDA inspector

1.2 Agent Roles (CODITECT-Specific)

Agent RoleMaps to Human Role(s)Autonomy LevelHuman Checkpoint Required
AGENT_ORCHESTRATORASSIGNER (delegated)HighArchitecture decisions only
AGENT_ASSET_MGMTASSIGNEE (delegated)MediumStatus changes to production systems
AGENT_SCHEDULERASSIGNER (delegated)MediumResource conflicts
AGENT_VENDOR_COORDASSIGNER (delegated)LowAll vendor interactions
AGENT_DOCUMENTATIONASSIGNEE (delegated)MediumControlled document updates
AGENT_QA_ASSISTNone (advisory only)LowAll QA decisions require human

Critical rule: Agents NEVER hold SYSTEM_OWNER, QA, or ADMIN roles. These require human identity and e-signature.


2. Permission Matrix

2.1 Work Order Operations

OperationORIGINATORASSIGNERASSIGNEESYSTEM_OWNERQAVENDORADMINAUDITOR
Create WO (DRAFT)
Edit DRAFT fields
Transition DRAFT→PLANNED
Set assignee
Set job plan
Set schedule
Transition PLANNED→SCHEDULED
Acknowledge start (→IN_PROGRESS)✅*
Update execution details✅*
Log time entries✅*
Request review (→PENDING_REVIEW)
Approve (→APPROVED)✅**
Reject (→REJECTED)
Complete (→COMPLETED)
Cancel (→CANCELLED)
View own WOs
View all WOs (tenant)
View audit trail
Export audit data

* VENDOR: Only on WOs where they are the assigned vendor
** QA: Required for regulatory-flagged WOs; optional for non-regulatory

2.2 Separation of Duties

ConstraintRulePart 11 Reference
Self-approval prohibitionASSIGNEE cannot be APPROVER on same WO§11.10(g)
Dual approval for regulatoryBoth SYSTEM_OWNER and QA must approve§11.10(c)
Admin cannot override approvalsADMIN can cancel but not approve/reject§11.10(d)
Vendor boundaryVENDOR sees only their assigned WOsLeast privilege
Auditor read-onlyAUDITOR cannot modify any records§11.10(e)

2.3 Agent Permission Constraints

ConstraintEnforcement
Agents operate under delegated human authorityEvery agent action logged with both agent_id AND delegating_human_id
Agents cannot approve or rejectHard-coded exclusion from APPROVED/REJECTED transitions
Agents cannot cancel WOsRequires human e-signature
Agent actions are attributableAudit trail includes agent identity + human delegation chain
Agent budget limitsToken budget controller prevents runaway agent actions

3. Multi-Tenancy Isolation

3.1 Row-Level Security

-- Every table includes tenant_id
-- RLS policy ensures complete tenant isolation
CREATE POLICY tenant_isolation ON work_orders
USING (tenant_id = current_setting('app.current_tenant')::uuid);

-- Applied to ALL tables: work_orders, approvals, audit_trail,
-- job_plans, schedules, assets, persons, etc.

3.2 Cross-Tenant Rules

RuleEnforcement
No cross-tenant data accessRLS at database level
No cross-tenant role assignmenttenant_id on role_assignments table
Audit trails are tenant-scopedRLS + separate partition per tenant
ADMIN role is tenant-scopedCannot affect other tenants

4. Implementation: Permission Check Function

type Permission = 
| 'wo:create' | 'wo:edit_draft' | 'wo:assign' | 'wo:set_job_plan'
| 'wo:set_schedule' | 'wo:acknowledge_start' | 'wo:update_execution'
| 'wo:log_time' | 'wo:request_review' | 'wo:approve' | 'wo:reject'
| 'wo:complete' | 'wo:cancel' | 'wo:view_own' | 'wo:view_all'
| 'audit:view' | 'audit:export';

type Role =
| 'ORIGINATOR' | 'ASSIGNER' | 'ASSIGNEE' | 'SYSTEM_OWNER'
| 'QA' | 'VENDOR' | 'ADMIN' | 'AUDITOR'
| 'AGENT_ORCHESTRATOR' | 'AGENT_ASSET_MGMT' | 'AGENT_SCHEDULER'
| 'AGENT_VENDOR_COORD' | 'AGENT_DOCUMENTATION' | 'AGENT_QA_ASSIST';

const ROLE_PERMISSIONS: Record<Role, Permission[]> = {
ORIGINATOR: ['wo:create', 'wo:edit_draft', 'wo:view_own'],
ASSIGNER: ['wo:create', 'wo:edit_draft', 'wo:assign', 'wo:set_job_plan',
'wo:set_schedule', 'wo:request_review', 'wo:view_own'],
ASSIGNEE: ['wo:acknowledge_start', 'wo:update_execution', 'wo:log_time',
'wo:request_review', 'wo:view_own'],
SYSTEM_OWNER: ['wo:create', 'wo:edit_draft', 'wo:assign', 'wo:set_job_plan',
'wo:set_schedule', 'wo:request_review', 'wo:approve', 'wo:reject',
'wo:complete', 'wo:cancel', 'wo:view_all', 'audit:view'],
QA: ['wo:approve', 'wo:reject', 'wo:cancel', 'wo:view_all',
'audit:view', 'audit:export'],
VENDOR: ['wo:acknowledge_start', 'wo:update_execution', 'wo:log_time', 'wo:view_own'],
ADMIN: ['wo:create', 'wo:cancel', 'wo:view_all', 'audit:view', 'audit:export'],
AUDITOR: ['wo:view_all', 'audit:view', 'audit:export'],
// Agents: subset of their mapped human role
AGENT_ORCHESTRATOR: ['wo:create', 'wo:edit_draft', 'wo:assign', 'wo:set_job_plan',
'wo:set_schedule', 'wo:view_own'],
AGENT_ASSET_MGMT: ['wo:update_execution', 'wo:view_own'],
AGENT_SCHEDULER: ['wo:set_schedule', 'wo:view_own'],
AGENT_VENDOR_COORD: ['wo:view_own'],
AGENT_DOCUMENTATION: ['wo:update_execution', 'wo:view_own'],
AGENT_QA_ASSIST: ['wo:view_own'], // Advisory only, no write
};

function checkPermission(
actor: { id: string; roles: Role[]; tenant_id: string },
permission: Permission,
workOrder?: { id: string; originator_id: string; assignee_id: string; vendor_id?: string }
): boolean {
// 1. Check if any role grants the permission
const hasPermission = actor.roles.some(role =>
ROLE_PERMISSIONS[role]?.includes(permission)
);
if (!hasPermission) return false;

// 2. Scope checks for VENDOR and ASSIGNEE
if (actor.roles.includes('VENDOR') && workOrder) {
if (workOrder.vendor_id !== actor.id) return false;
}

// 3. Separation of duties
if (permission === 'wo:approve' && workOrder) {
if (workOrder.assignee_id === actor.id) return false; // Cannot self-approve
}

return true;
}

This RBAC model enforces least-privilege access aligned with FDA 21 CFR Part 11 §11.10(d) requirements for authority checks, and SOC 2 CC6.1 logical access security. Agent roles are explicitly constrained to prevent autonomous compliance decisions.


Copyright 2026 AZ1.AI Inc. All rights reserved. Developer: Hal Casteel, CEO/CTO Product: CODITECT-BIO-QMS | Part of the CODITECT Product Suite Classification: Internal - Confidential