Engine Functions
Supply has no HTTP API surface — its engines are pure, framework-free functions. You call them directly from the app (or any TypeScript runtime). This page lists each signature and its types.
All settlement engines return a canonical guardian / verdict from the shared
@onoots/core. See Compliance Guardian.
threeWayMatch
function threeWayMatch(input: ThreeWayInput): ThreeWayResult
interface ThreeWayInput {
poTotal: number
receiptTotal: number
invoiceTotal: number
tolerancePct: number // fraction of PO total, e.g. 0.05 = ±5%
}
interface ThreeWayResult {
verdict: 'auto_approve' | 'hold_dual_approval'
variance: number // invoice − PO (signed)
variancePct: number
toleranceAmount: number
withinTolerance: boolean
receiptCovers: boolean
reasons: string[]
guardian: SupplyVerdict
}Reconciles PO · Receipt · Invoice. Fail-closed: any tolerance breach or receipt
shortfall yields hold_dual_approval. See Three-Way Match.
resolveApproval
function resolveApproval(req: Requisition, policy?: SpendPolicy): ApprovalResult
interface Requisition {
amount: number
costCenter: string
budgetRemaining: number | null // null = not enforced
}
type ApprovalRoute =
| 'auto_approve' | 'manager_approval' | 'director_approval'
| 'cfo_approval' | 'blocked'
interface ApprovalResult {
route: ApprovalRoute
label: string
reasons: string[]
overBudget: boolean
restricted: boolean
verdict: SupplyVerdict
}Routes a requisition through the tiered matrix; restricted cost centers and
over-budget requests escalate one step (fail-closed). Defaults to
DEFAULT_SPEND_POLICY. See Requisition Intake.
rankQuotes
function rankQuotes(input: RfqInput): RfqResult
interface Quote {
vendor: string
price: number
leadDays: number
rating: number // 0–5
}
interface RfqInput {
quotes: Quote[]
minRating: number
priceWeight?: number // 0..1, default 0.7 (1 = price only)
}
interface RfqResult {
ranked: RankedQuote[] // RankedQuote = Quote & { eligible, score, note? }
winner: RankedQuote | null
savingsVsHighest: number
}Ranks quotes on a price/lead-time blend; vendors below minRating are ineligible.
Recommends a winner — a human raises the PO. See RFQ Sourcing.
evaluateVendor
function evaluateVendor(v: Vendor, opts?: { minRating: number }): VendorEval
interface Vendor {
name: string
category: string
rating: number // 0–5
kyc: 'verified' | 'pending' | 'failed'
sanctioned: boolean
spendYtd: number
}
interface VendorEval {
standing: 'approved' | 'pending_review' | 'blocked'
reasons: string[]
verdict: SupplyVerdict
}Resolves a vendor’s KYS standing from the core decision. minRating defaults to
3.5. See Vendor KYS.
guardSupply
function guardSupply(input: {
level: AutonomyLevel
legallyRestricted?: boolean
flags?: SupplyFlag[]
}): SupplyVerdict
interface SupplyFlag {
rule_id: string
severity: GuardianSeverity // e.g. 'warning' | 'block'
description: string
}
// SupplyVerdict.decision → 'allow' | 'prepare' | 'escalate' | 'block'The adapter to the shared @onoots/core decide(). Every engine above funnels its
domain outcome through this. See Compliance Guardian.