Skip to main content

Module units

Module units 

Source
Expand description

Unit-conversion constants shared workspace-wide.

Every crate that mixes seconds/milliseconds or dollars/micro-dollars must use these names rather than open-coding the conversion factors — a misplaced 1_000 vs 1_000_000 was a real class of bug in earlier rounds of this review.

Constants§

COST_MICROS_MAX
Upper bound for cumulative cost_usd_micros counters, aligned with av_atif::validate::MAX_COST_USD (9e9 USD). Introduced in R69 to close R64 F3: the recovery folds in av-harness/src/worker.rs gated cost_usd_micros on av_core::error::JCS_SAFE_MAX (2^53 = ~$9.007e9 micro-scaled), while the strict ATIF validator refuses any total_cost_usd > 9e9. The $7.2M gap between the two ceilings (JCS_SAFE_MAX / USD_MICROS_PER_DOLLAR = 9,007,199 USD past 9e9) meant a hostile / drift-authenticated journal replay whose summed costs landed in the window would fold cleanly through recovery (fold says “safe”), then the very next av_atif::write_atomic call would strict-refuse the trajectory — the session became un-writable across every reconciler tick. Tightening the fold cost cap to 9e9 * USD_MICROS_PER_DOLLAR = 9e15 micros (still safely below JCS_SAFE_MAX = 9.007e15) means any cost that passes the fold also passes ATIF strict validation.
MS_PER_DAY
Milliseconds per day.
MS_PER_HOUR
Milliseconds per hour.
MS_PER_SEC
Milliseconds per second.
SECS_PER_DAY
Seconds per day.
USD_MICROS_PER_DOLLAR
USD micro-units per dollar. All internal cost bookkeeping stays in micro-USD (u64) to keep every arithmetic step in exact integers; only wire-facing serialization converts to floating point.