Safeguard Work-Order Agent Ecosystem

Spec · Router

← Back to outcome

Agent Spec — Router

Status: implemented Source: src/agents/router.mjs Owner interface: route(classification) -> routing

Purpose

Decide *where the work goes* and *how fast it must happen*: the destination queue, crew type, vendor tier, service region, and the SLA clock.

Interface

route(classification) -> {
  queue:       string     // e.g. TRADE_HVAC, GENERAL_QUEUE
  crewType:    string     // e.g. HVAC_TECH, ELECTRICIAN
  vendorTier:  'IN_HOUSE_RAPID' | 'STANDARD_VENDOR'
  region:      Region | 'UNASSIGNED'
  slaHours:    number
  escalated:   boolean    // P1 gets an escalation flag
  reasoning:   string
}

Method (deterministic policy — not ML)

Routing is business policy and must stay inspectable and overridable by operations, so it is a table, not a model. See specs/routing-policy.md for the full table and change process.

  1. Category → { queue, crewType, baseSlaHours }.
  2. Priority compresses the SLA clock (P1→2h, P2→8h; P3/P4 keep the

category base). The effective SLA is the *minimum* of the priority cap and the category base.

  1. Region is resolved from the extracted zone via ZONE_REGION; unknown →

UNASSIGNED (the validator treats this as needing review).

  1. Vendor tier: P1/P2 → in-house rapid response; otherwise standard vendor

pool.

  1. P1 sets escalated = true.

Contract

  • Routing is a pure function of the classification — no side effects, fully

deterministic, trivially unit-testable.

  • An unresolved region never silently proceeds; it surfaces as a routing signal

the validator can act on.

Verified behaviour

PropertyResult
Region resolved correctly (where a zone exists)100%
SLA monotonic in priorityenforced by construction