Skip to content
v0.18.0stable

Versioned pricing and Project/Token Guard

Cost governance is not one global budget switch. Halro answers four separate questions in order:

  1. Price Version: how this Attempt is priced;
  2. Project controls: whether the application may start more work;
  3. Token Guard: whether this request or recent behavior is anomalous;
  4. Run budget: whether one business execution may spend more.

Price Versions are immutable and effective-dated. Bind the exact Provider, target, Region, tier, currency, token classes, and any per-request fee. Never use zero to mean “unknown”; mark a genuinely free target explicitly.

1. Establish trustworthy pricing
ItemConsole unitTypical use
InputUSD / 1M tokensOrdinary input tokens
Cache readUSD / 1M tokensProvider-reported cache hits
Short cache writeUSD / 1M tokensAnthropic 5m, OpenAI Responses 30m, or a write total without a lifetime split
Long cache writeUSD / 1M tokensAnthropic 1h or OpenAI Responses 12h
OutputUSD / 1M tokensOrdinary output and Provider-defined reasoning tokens
Fixed per requestUSD / requestMedia, Rerank, resource operations, or contract fees

Schema 43 fills both write rates from each existing tier’s ordinary input rate. Base rates and every time window can then be priced separately in a new price version. Historical settlements keep their original costs. Embeddings estimates and synthetic resource units use the ordinary input rate. Upgrade notes

When cache-write rates are inherited from ordinary input or the Provider omits a price-sensitive lifetime split, the charge may be estimated even if the tokens were reported. For partial usage, the detail view shows the estimated input and output subsets. Batch and asynchronous inference use deferred settlement. Where asynchronous video is configured, its output rate is USD per million seconds of video.

Store source type and reviewable notes. Public list, contract, internal transfer price, and temporary estimate carry different assurance. Confirm model, Region, Tier, caching rules, and units. The confirmation example catches million-token, fixed-fee, and decimal mistakes but does not replace independent recalculation. Each Attempt binds the full pre-I/O snapshot; later versions never rewrite history.

Immediate, scheduled, and time-window prices

Section titled “Immediate, scheduled, and time-window prices”
  • An immediate version cannot be deleted; supersede it with a later version.
  • A scheduled version may be canceled before activation; every new scheduled time must be after all uncanceled scheduled versions.
  • If a future version exists, do not insert an earlier “immediate” version; cancel the blocker or schedule after it.
  • Time-window pricing uses the Provider’s IANA timezone, not Project Accounting timezone; split windows across midnight.
  • Uncovered times use the version’s base rate and are never treated as free.

After restoring an old backup, a scheduled version may have crossed its effective time during downtime. The Deployment enters pricing quarantine until an administrator reviews the timeline and confirms restored pricing.

2. Use Projects for deterministic boundaries

Section titled “2. Use Projects for deterministic boundaries”
2. Use Projects for deterministic boundaries
SettingRisk protectedHow to set it
Allowed ModelsWrong environment or unapproved modelOnly required public Route aliases
Daily BudgetUnbounded daily costNormal daily use, peaks, and stop policy; it is a hard gate, not an alert
RPM / TPMRetry storms or input spikesReal peak plus justified headroom
Max concurrencyUpstream/local exhaustionCombine application, Deployment, and Provider concurrency
Input/output token limitsExcessive worst-case request costLongest business input and acceptable answer
Body/stream limitsImages or long streams occupy resourcesEncoding expansion, client and Gateway timeouts
Allowed CIDRsKey use from another networkActual application egress or controlled networks

Separate development, staging, production, owners, and cost centers into distinct Projects. Gateway Keys inherit Project boundaries and never bypass them. Daily Budget follows Accounting timezone, so a day may be 23, 24, or 25 hours. Timezone changes apply after the current period and do not rewrite UTC evidence.

Budget is reserved before Provider I/O and settled from actual or conservative usage afterward. Retries and fallbacks belong to the same visible request but can create multiple billable Attempts.

Token Guard complements, not replaces, Project rate, concurrency, and budget boundaries. Simulate real samples before binding. Fixed thresholds cover per-request tokens, per-minute tokens and cost, concurrency, error rate with minimum samples, and unique source IPs per minute.

3. Use Token Guard for abnormal behavior
ActionEffectRecommended stage
observeInitial fixed-threshold hits are recorded; repricing or policy-version rechecks may still fail closedEstablish baseline and observe recheck rejection
alertInitial hits are recorded and delivered; rechecks may still fail closedValidate thresholds, delivery, and response
temporary_blockBlocks after the configured violation countOnly after false positives and unblock flow are accepted

Configure violations-before-block, block TTL, and cooldown. Manual unblock is not root-cause remediation. EWMA detects deviation from history; establish absolute RPM, TPM, per-request token, and cost thresholds first, then configure warmup, evaluation window, minimum sample, and cooldown. Current EWMA alerts only and is not an automatic block boundary.

4. Add Run budgets only for business execution boundaries

Section titled “4. Add Run budgets only for business execution boundaries”

A Run budget limits the combined committed + reserved + pending cost of one execution, while the Project budget covers the business boundary. Provider retries and fallbacks consume the same Run balance. A new execution of the same Work Unit gets a new Run; do not reset a budget by relabeling a retry. Halro atomically checks both budgets before Provider I/O. Insufficient Run balance does not auto-close the Run. Unknown price cannot pass Run-budget admission even when the instance permits ordinary unknown-price requests.

Run Governance is experimental. Use it only when the application can define a stable Work Unit and Outcome Definition and can close or expire abandoned Runs.

  1. Price review: FinOps/contract owner confirms identity, units, caching, and effective time.
  2. Project hard boundaries: allowed models, output, budget, RPM, TPM, and concurrency.
  3. Observe: use Token Guard observe over normal peaks, troughs, and releases; test repricing/policy recheck rejection.
  4. Alert: validate recipient, deduplication, retry, response deadline, and recheck path.
  5. Temporary block: enable only high-confidence fixed thresholds and drill expiry/manual unblock.
  6. Run budget: pilot after the application defines real Work Unit/Run boundaries; do not derive them mechanically from HTTP requests.
6. Acceptance matrix
TestExpected result
Deployment has no effective Price VersionRefused before Provider I/O, never shown as $0.00
Explicit freeKnown zero cost with a free price snapshot
New Price VersionNew Attempts use the new snapshot; historical amounts remain
Scheduled version not activeCurrent version remains until the effective instant
Project daily budget insufficientRefused before Provider I/O; blind retry cannot help
Token Guard observeInitial fixed hit records only; higher Attempt cost or policy change can still return token_guard_blocked on recheck
Temporary block triggeredSubsequent requests reject until TTL or reviewed admin action
Run balance insufficientProject may have balance, but this Run rejects
Missing Provider Usage or ambiguous resultAttempt is estimated or unknown, never zero by default

After acceptance, expand the Attempt under Usage & Calls and verify reported tokens, price snapshot, input/output/fixed fees, estimated, and final amount.

Recover pricing clock quarantine (since v0.12.2)

Section titled “Recover pricing clock quarantine (since v0.12.2)”

wall_clock_forward_jump and wall_clock_rollback create durable quarantines; restarting does not clear them. Correct host or VM time first, then choose Review and restore pricing in the Deployment’s pricing warning. Review server UTC time, the effective immutable price, and scheduled tiers. Administrator password and enrolled MFA are required. Confirmation binds the quarantine revision, reason, and price ID, expires after five minutes, and must be refreshed after a conflict.

Offline Standalone recovery requires a stopped instance, exclusive data-directory access, the Master Key, and a consistent backup. Inspect first without --apply:

Terminal window
halro pricing recover-clock --config /etc/halro/config.yaml --deployment DEPLOYMENT_ID

Use the revision, reason, price ID, and UTC time from that inspection. The example reason below is a forward jump; it must match the inspected reason:

Terminal window
halro pricing recover-clock --config /etc/halro/config.yaml --deployment DEPLOYMENT_ID \
--apply --revision REVIEW_REVISION --reason wall_clock_forward_jump \
--price-id REVIEW_PRICE_ID --reviewed-at REVIEW_UTC_TIME

Cluster members use the authenticated Primary Admin action. Recovery records deployment_price.clock_confirm without rewriting historical pins, prices, or bills. If Audit delivery fails after commit, retain the error and restart the new binary to drain pending records; do not invent a revision and retry. Older binaries may not recognize this action, so rollback requires the pre-recovery backup.

An unchanged immutable free price with all four rates zero and no scheduled tiers may accept a forward observation gap caused by a VM pause, recording clock_forward_gap_nanos. Price transitions, metered prices, rollbacks, and existing quarantines keep their guards. After restart, verify /health/ready, quarantine state, and routing eligibility. Paid inference is not needed to establish that the recovery transaction succeeded.