Expand description
Buy-side profitability gate for cache-miss relay legs (ADR 041).
Node-local, config-selectable. Sibling to the ADR-040 cache policies, not part
of them: cache policy decides what a node keeps; this decides what a node buys
to serve. The policy returns a per-MB buy ceiling; the node_origin buy loop does
the candidate scan and the refusal.
Structs§
- Margin
Policy - Two-regime ceiling.
amortized = (operator_bps/10_000) · n_hat · sellwithn_hat = clamp(round(discount · heat), 1, n_max). While the source has warming allowance, buy at the market pricemax(sell, amortized)(warming); once spent, buy only atamortized(grief-proof). See ADR 041 § The buy ceiling. - OffPolicy
- Disables the economic gate; only
cache.max_rate_per_mbbounds the buy. - Serve
Economics Ctx - Inputs to the buy ceiling, gathered per cache-miss.
Traits§
- Serve
Economics Policy - A node-local decision on the most the node pays upstream, per MB.
Functions§
- select_
policy - Build the configured policy. Unknown names are impossible: config validation
restricts
policyto"off"|"margin"at load; anything else here falls back toOffPolicy(safe: only the static ceiling applies).