code wiki / _hdl_build / nx_ad_bill.nx
nx_ad_bill.nx
buildroot/runtime/_hdl_build/nx_ad_bill.nx
about
nx_ad_bill.nx -- LIB: the billing FSM for the "Brought to you by" performance ad engine
(ADS-008, CALLOUT-004). NO-WAVE applied to revenue: a charge exists ONLY as a function of a
real meter verdict + real, store-resident prices. DEFAULT STATE = NO CHARGE. Reads prices from
the SOVEREIGN STORE (adpricing:, ADS-006), never TSV.
THE BILL (reads ONLY the meter verdict -- nx_ad_meter ADS-007):
UNMEASURABLE -> REFUSED (no GREEN meter verdict: cannot bill what we cannot measure)
UNDER -> $0 (we did not perform -- the default)
PERFORM -> perform_fee
EXCEED -> perform_fee + exceed_bonus (flat fee + ONE flat capped bonus)
HARD CEILING: the most a campaign can ever be billed in a period = perform_fee + exceed_bonus
(budgetable, never a runaway invoice -- "relationship over a quick buck"). TAMPER/HONESTY:
any PENDING price (perform_fee/exceed_bonus = -1, sponsor co-spec ADS-005 not yet set) -> REFUSED.
Fail-closed on an unknown verdict. license_tier: ORIGINAL
dependencies 3 imports · 4 importers
imports: nx_ad_meter.nxnx_ad_store.nxnx_syscalls.nx
imported by: nx_ad_bill_gate.nxnx_ad_h2h.nxnx_ad_offering.nxnx_ad_offering_gate.nx
structs
| none |
consts
| 20 | const AB_REFUSED: i64 = 0 - 1 // no GREEN meter verdict / unpriceable -> NO CHARGE (the default) |
functions
| 24 | func ab_perform_fee_of(price_key: *u8) -> i64 |
| 32 | func ab_exceed_bonus_of(price_key: *u8) -> i64 |
| 41 | func ab_charge(verdict: i64, perform_fee: i64, exceed_bonus: i64) -> i64 called by 1: main |
| 54 | func ab_period_ceiling(perform_fee: i64, exceed_bonus: i64) -> i64 called by 1: main |