Safeguard Work-Order Agent Ecosystem

Spec · Validator

← Back to outcome

Agent Spec — Validator

Status: implemented Source: src/agents/validator.mjs Owner interface: validate(order, classification, routing, ctx) -> validation

Purpose

The safety boundary of the ecosystem. Decide whether an order is safe to action automatically, must be handed to a human, or should be rejected — and record exactly why. The validator is deliberately conservative: when in doubt it returns NEEDS_REVIEW so a human handles the exception.

Interface

validate(order, classification, routing, ctx) -> {
  status:      'VALID' | 'NEEDS_REVIEW' | 'REJECT'
  violations:  Array<{ code, severity: 'blocking'|'review', detail }>
  checks:      Record<string, boolean>
  fingerprint: string   // stable hash for duplicate detection
}

ctx = { seen: Map<fingerprint, lastTimestampMs>, config } carries the duplicate-detection memory and threshold overrides.

Rules

#RuleViolation codeSeverityEffect
1Location/zone resolvableMISSING_LOCATIONblockingREJECT
2Description present (≥10 chars)MISSING_DESCRIPTIONblockingREJECT
3Region mappable for routingUNRESOLVED_REGIONreviewNEEDS_REVIEW
4Category confidence ≥ threshold (0.55)LOW_CATEGORY_CONFIDENCEreviewNEEDS_REVIEW
5Priority confidence ≥ threshold (0.55)LOW_PRIORITY_CONFIDENCEreviewNEEDS_REVIEW
6Estimated cost ≤ auto-approval limit ($5,000)OVER_COST_LIMITreviewNEEDS_REVIEW
7Not a duplicate within 24h windowDUPLICATEreviewNEEDS_REVIEW

Disposition: any blocking violation → REJECT; else any review violation → NEEDS_REVIEW; else VALID.

Thresholds (configurable via ctx.config)

minCategoryConfidence = 0.55
minPriorityConfidence = 0.55
autoApprovalCostLimit = 5000
duplicateWindowMs     = 24h

These are policy knobs, not magic constants. Raising minCategoryConfidence trades a higher auto-action rate for fewer over-escalations and vice-versa.

Verified guarantees (verify.mjs)

  • 100% of missing-location orders are blocked from auto-dispatch.
  • 100% of seeded duplicates are detected and held.
  • 100% of over-cost-limit orders are held for human approval.
  • Exception-detection recall = 1.0; false-auto-action rate = 0.0 on the

synthetic corpus (see proof/LIMITATIONS.md for scope).