Versioned pricing and Project/Token Guard
Cost governance is not one global budget switch. Halro answers four separate questions in order:
- Price Version: how this Attempt is priced;
- Project controls: whether the application may start more work;
- Token Guard: whether this request or recent behavior is anomalous;
- Run budget: whether one business execution may spend more.
1. Establish trustworthy pricing
Section titled “1. Establish trustworthy pricing”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.
| Item | Console unit | Typical use |
|---|---|---|
| Input | USD / 1M tokens | Ordinary input tokens |
| Cache read | USD / 1M tokens | Provider-reported cache hits |
| Short cache write | USD / 1M tokens | Anthropic 5m, OpenAI Responses 30m, or a write total without a lifetime split |
| Long cache write | USD / 1M tokens | Anthropic 1h or OpenAI Responses 12h |
| Output | USD / 1M tokens | Ordinary output and Provider-defined reasoning tokens |
| Fixed per request | USD / request | Media, 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.
Pricing evidence and recalculation
Section titled “Pricing evidence and recalculation”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”| Setting | Risk protected | How to set it |
|---|---|---|
| Allowed Models | Wrong environment or unapproved model | Only required public Route aliases |
| Daily Budget | Unbounded daily cost | Normal daily use, peaks, and stop policy; it is a hard gate, not an alert |
| RPM / TPM | Retry storms or input spikes | Real peak plus justified headroom |
| Max concurrency | Upstream/local exhaustion | Combine application, Deployment, and Provider concurrency |
| Input/output token limits | Excessive worst-case request cost | Longest business input and acceptable answer |
| Body/stream limits | Images or long streams occupy resources | Encoding expansion, client and Gateway timeouts |
| Allowed CIDRs | Key use from another network | Actual 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.
3. Use Token Guard for abnormal behavior
Section titled “3. Use Token Guard for abnormal behavior”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.
| Action | Effect | Recommended stage |
|---|---|---|
observe | Initial fixed-threshold hits are recorded; repricing or policy-version rechecks may still fail closed | Establish baseline and observe recheck rejection |
alert | Initial hits are recorded and delivered; rechecks may still fail closed | Validate thresholds, delivery, and response |
temporary_block | Blocks after the configured violation count | Only 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.
5. Roll out in stages
Section titled “5. Roll out in stages”- Price review: FinOps/contract owner confirms identity, units, caching, and effective time.
- Project hard boundaries: allowed models, output, budget, RPM, TPM, and concurrency.
- Observe: use Token Guard
observeover normal peaks, troughs, and releases; test repricing/policy recheck rejection. - Alert: validate recipient, deduplication, retry, response deadline, and recheck path.
- Temporary block: enable only high-confidence fixed thresholds and drill expiry/manual unblock.
- Run budget: pilot after the application defines real Work Unit/Run boundaries; do not derive them mechanically from HTTP requests.
6. Acceptance matrix
Section titled “6. Acceptance matrix”| Test | Expected result |
|---|---|
| Deployment has no effective Price Version | Refused before Provider I/O, never shown as $0.00 |
Explicit free | Known zero cost with a free price snapshot |
| New Price Version | New Attempts use the new snapshot; historical amounts remain |
| Scheduled version not active | Current version remains until the effective instant |
| Project daily budget insufficient | Refused before Provider I/O; blind retry cannot help |
Token Guard observe | Initial fixed hit records only; higher Attempt cost or policy change can still return token_guard_blocked on recheck |
| Temporary block triggered | Subsequent requests reject until TTL or reviewed admin action |
| Run balance insufficient | Project may have balance, but this Run rejects |
| Missing Provider Usage or ambiguous result | Attempt 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:
halro pricing recover-clock --config /etc/halro/config.yaml --deployment DEPLOYMENT_IDUse 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:
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_TIMECluster 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.