Skip to main content

Work Order Management System — System Design Document

Classification: Internal — Engineering Date: 2026-02-13 Status: Proposed


1. Context Diagram

The WO Management System operates as a control plane subsystem within CODITECT. It mediates between four actor categories and four system boundaries.

Actors:

  • System Owners — Initiate and approve WOs for validated systems they own.
  • QA Personnel — Review and co-approve regulatory WOs.
  • IT/Operations Staff — Execute WO tasks (build workstations, configure systems).
  • Vendors — Execute external WO tasks (install applications, provide IQ/OQ).
  • CODITECT Agents — Autonomously create, execute, and transition WOs.

System Boundaries:

  • CODITECT Control Plane — Agent Orchestrator, Compliance Engine, Checkpoint Manager.
  • CODITECT Data Plane — IDE Shell (developer-facing), Agent Workers.
  • External Systems — Asset Management, Ticketing (ServiceNow), Vendor Portals.
  • Compliance Infrastructure — Audit Repository, Certificate Authority, Policy Engine.

2. Component Breakdown

2.1 WO Lifecycle Engine

Core state machine managing WO status transitions with validation, audit trail generation, and event emission.

States: draft → pending_approval → assigned → in_progress → blocked → completed → closed

Invariants:

  • No transition without audit entry (reason required for regulatory WOs).
  • completed requires all required approvals collected (System Owner + QA for regulatory).
  • in_progress requires all dependencies satisfied (DAG check).
  • blocked triggers upstream notification to Master WO agent.

2.2 WO Hierarchy Manager

Manages Master WO ↔ Linked WO relationships, dependency graphs, and progress tracking.

Responsibilities:

  • Create/link child WOs to Master WO.
  • Validate dependency DAG (no cycles).
  • Calculate critical path through linked WO dependency graph.
  • Report Master WO progress (% complete, blocked items, estimated completion).

2.3 Resource Matcher

Matches WO requirements (from Job Plans) against available resources.

Inputs: Required tools, experience levels, person count, schedule constraints. Outputs: Candidate assignment list ranked by: availability → experience rating → cost. Integration: Feeds into Agent Orchestrator's capability matching for automated assignment.

2.4 Approval Workflow Engine

Manages approval chains with electronic signature collection.

Approval types: System Owner (mandatory for regulatory), QA (mandatory for regulatory), Additional (configurable per tenant/WO type). E-signature: Hash of (approver_id + wo_id + wo_version + timestamp + role) signed with approver's key. Delegation: Supports approval delegation with audit trail of delegation chain.

2.5 Schedule Tracker

Tracks estimated vs. actual durations for WO tasks, feeds learning loop for future estimates.

Captured data: Estimated hours, actual start/end, gap analysis (business schedule, availability), billing actuals. Outputs: Per-task-type duration distributions, resource utilization rates, cost projections.

2.6 PM Automation Engine

Generates WOs automatically from preventive maintenance and calibration program schedules.

Triggers: Calendar-based (annual, quarterly, monthly), usage-based (instrument hours), event-based (calibration due). Output: Pre-populated WOs with Job Plans from templates, auto-assigned based on experience/availability.


3. Data & Control Flows

3.1 WO Creation Flow

Actor/Agent → API Gateway → WO Lifecycle Engine
→ Validate request (schema, permissions, tenant scope)
→ Create WO record (draft status)
→ Generate audit entry (CREATED)
→ Emit event: wo.created
→ If Master WO: register in hierarchy
→ If Linked WO: validate Master exists, validate DAG, create job plan
→ Return WO with generated wo_number

3.2 WO Execution Flow (Agent-Driven)

Agent Orchestrator receives Master WO
→ WO Hierarchy Manager resolves dependency graph
→ Pattern Selector chooses execution pattern:
Sequential deps → Prompt Chaining
Independent WOs → Parallelization
Mixed → Orchestrator-Workers
→ For each executable linked WO:
→ Resource Matcher finds capable agent worker
→ Model Router assigns model tier per WO task type
→ Agent Worker executes Job Plan
→ On completion: WO transitions to 'completed'
→ Approval Workflow triggers if regulatory
→ On approval: WO transitions to 'closed'
→ Master WO tracks progress
→ When all linked WOs closed: Master WO closes

3.3 Approval Flow

WO reaches 'completed' status
→ Approval Workflow Engine activates
→ Determines required approvers (System Owner, QA, additional)
→ Notifies approvers (event: wo.approval_requested)
→ Each approver reviews:
→ Approve: collect e-signature, record in wo_approvals
→ Reject: WO returns to 'in_progress' with rejection reason
→ When all required approvals collected:
→ WO transitions to 'closed'
→ Compliance Engine generates evidence package
→ Audit trail finalized

4. Scaling Model

DimensionStrategyLimit
WO volumePostgreSQL partitioning by tenant_id + created_at10M+ WOs per tenant/year
Concurrent transitionsOptimistic locking (version column) + row-level locks1000+ concurrent transitions
Audit trailAppend-only, partitioned by month, archived to cold storage after retention periodUnlimited with archival
PM automationBatch WO creation (1000 WOs per batch) with async processing100K+ instruments per tenant
Approval throughputAsync approval collection with SLA monitoring10K+ approvals/day

Horizontal scaling: The WO service is stateless — all state in PostgreSQL. Scale service replicas behind the API Gateway. Event Bus (NATS) handles distributed event delivery.


5. Failure Modes

FailureDetectionRecoveryImpact
PostgreSQL unavailableHealth check + connection pool errorsCircuit breaker opens, queues transitions, retries on recoveryWO operations paused, no data loss
Approval SLA breachSchedule Tracker monitors approval latencyEscalation notification to manager, auto-escalation chainWO blocked, schedule slip
Dependency deadlockDAG validation on creation + periodic cycle detectionBlock cycle-creating dependency, notify WO ownerPrevented at creation; detected if data corruption
Agent worker failureCircuit breaker on worker healthWO transitions to 'blocked', Master WO notified, reassignment attemptedLinked WO delayed, Master WO progress stalled
Duplicate WO creationIdempotency key on creation requestDeduplicate, return existing WONone if detected
Compliance violationCompliance Engine intercepts invalid transitionHard block, escalate to QA, generate findingWO cannot proceed until remediated

6. Observability Story

Traces (OTEL):

  • wo.lifecycle — Span from creation to closure, child spans per status transition.
  • wo.approval — Span from approval request to all signatures collected.
  • wo.dependency — Span for dependency resolution in linked WO graphs.
  • wo.agent_execution — Span linking WO to agent worker execution.

Metrics (Prometheus):

  • wo_created_total{source, regulatory, tenant} — WO creation rate.
  • wo_cycle_time_seconds{priority, source} — Creation to closure duration.
  • wo_blocked_duration_seconds{reason} — Time in blocked state.
  • wo_approval_latency_seconds{role} — Time from request to signature.
  • wo_resource_utilization{resource_type} — Persons, tools, experience capacity.

Logs (Structured JSON):

  • Every audit trail entry is also emitted as a structured log event.
  • Correlation: {tenant_id, wo_id, master_wo_id, actor_id, trace_id}.

Dashboards (Grafana):

  • WO Operations: funnel, throughput, cycle time, blocked rate.
  • Compliance Health: first-pass approval rate, finding frequency, SLA compliance.
  • Resource Planning: utilization heatmap, capacity forecast, cost attribution.

7. Platform Boundary

Framework/Platform Provides

CapabilityProvider
Multi-tenant isolation (RLS)PostgreSQL + CODITECT platform
Event bus messagingNATS / Redis Streams (CODITECT infra)
AuthN/AuthZAPI Gateway (CODITECT control plane)
Agent orchestration patternsAgent Orchestrator (CODITECT core)
Compliance policy engineCompliance Engine (CODITECT core)
Observability infrastructureOTEL + Prometheus + Grafana (CODITECT infra)
E-signature certificate authorityCompliance Infrastructure (external)

WO System Must Build

CapabilityRationale
WO state machine + lifecycle engineDomain-specific business logic
Hierarchy manager + DAG validationWO-specific dependency model
Resource matcherDomain-specific matching algorithm
Approval workflow engineRegulatory-specific approval chains
Schedule tracker + learning loopWO-specific duration modeling
PM automation engineDomain-specific schedule generation
Job plan managementWO-specific execution planning
Adapter: WO ↔ Agent OrchestratorIntegration-specific mapping
Adapter: WO ↔ Compliance EngineIntegration-specific mapping

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