Loss Accounting

Counterfactual metrics quantify spend that would have been wasted without recovery, and billed-but-failed spend you still pay providers for.

Agent hint

Use for loss_avoided, projected_cost, UNFULFILLED_SPEND, dashboard billed_but_failed_cost, migration 002.

In scope

  • SDK log_event fields
  • Ingest payload fields
  • Dashboard overview metrics
  • DB migration note

Out of scope

  • ResiliencePolicy tuning — see Policy

SDK event fields

FieldDescription
outcomesuccess | failure | recovered | degraded
cost_typeIncludes unfulfilled_spend for billed-but-unusable calls
projected_costEstimated cost if primary route had succeeded
loss_avoidedCounterfactual savings from recovery (in extra_metadata too)
recovery_providerProvider used after fallback/retry
attempt_index0-based attempt number
status / error_code / latency_ms / finish_reasonProvider response metadata for analytics

Dashboard overview

  • billed_but_failed_cost — spend on unfulfilled/degraded outcomes
  • loss_avoided — aggregated counterfactual recovery value
  • recovery_rate — share of recoverable failures successfully retried
  • Savings timeline includes category reliability_savings

Backend migration

Run python -m scripts.migrate_002_reliability_fields on your deploy database before relying on reliability dashboard columns.

See also