Files
Kevin Wang 00dc5eab3f feat(catalog): price every AnyAPI row off measured charges, not the rate card
`cost.value` is both the shelf price a buyer compares and the amount treg
reserves, and reading it off `pricing.from.maxUsd` - the CHEAPEST source's
price at the input maximum - got both jobs wrong. Checked against 60 days of
AnyAPI's own request ledger, 121 of the 307 listed rows sat BELOW the p90
charge really billed (ebay.search listed $0.0005 against a $0.03795 median:
the cheap source almost never wins), and 40 sat far above what anyone pays
(instagram.hashtag_analytics listed $0.0385 against a $0.00297 p90, because
a per-result SKU was priced at an input maximum nobody sends). It also
drifted every time a source was quarantined and `pricing.from` recomputed.

So `cost.value` is now the p90 of what AnyAPI actually charged for that SKU
over the trailing 60 days, exported to scripts/data/anyapi_measured_charges.json
the same way justoneapi_prices.json carries that vendor's price sheet. 217 of
the 307 rows have at least 5 charged calls to measure and take the measured
price; the other 90 keep the rate card's cheapest-source figure and say so in
their own note. `reported_charge` stays on every row either way - `costUsd` is
the only number that knows which source served and how many rows came back.

This deliberately REVERSES the rationale of the earlier commits on this branch,
which held `cost.value` at the price at the input maximum so the reserve could
never fall short. The listing now optimises for the shelf price being what a
buyer actually pays, and accepts that roughly one call in ten settles above the
reserve - which is what domain/money/settlement.py:133-134 already designs for:
the charge may exceed the reserve, the ledger takes the difference from the
balance, and the next reserve is the gate. Measured over the same 60 days under
the OLD, much worse prices, that overrun came to $18.66 on $695.05 settled, 2.7%.

`cost.source` is `observed` on a measured row, this catalog's existing word for
a price seen being billed rather than read off a page, and stays `rate_card_api`
on the fallback. `source_url` still points at the per-SKU rate card either way.
2026-09-09 16:34:52 -07:00
..