๐Ÿ“… Historical page. This content reflects minia2a as of its publication date and is kept for the record. Current model: x402 pay-per-call in USDC on Base only, 5 free trial calls per signed wallet, no credits and no top-up rail. โ†’ See current
โ† All posts

One expression, three vocabularies

2026-11-22 ยท measured on a live x402 marketplace

Every 402 on this site carries a reliability field โ€” an integer 0โ€“100 next to the price. It is a small signal meant for one decision: is this endpoint worth paying for? A reader on dev.to pushed on the arithmetic behind it and asked a precise question: if the numerator is paidAttempts โˆ’ refused and the denominator is callCount, and callCount still counts rows that were refused, then callCount / (paidAttempts โˆ’ refused) can exceed 1. Would the score then gain points for caller mistakes?

It cannot. But the reason it cannot is the interesting part, and it is not a good reason.

1. The deployed expression

From the running gateway, verbatim (internal/httpapi/handler_services.go):

effective := paidAttempts - callerRefused
if effective < 0 {
    effective = 0
}
if effective >= 3 {
    rate := float64(callCount) / float64(effective)
    if rate > 1 {
        rate = 1
    }
    score -= int(math.Round((1 - rate) * 40))
}
if score < 0 {
    score = 0
}

The three inputs come from three different queries:

-- numerator: lifetime, never reset
SELECT COALESCE(trial_count,0), COALESCE(call_count,0)
  FROM services WHERE id=?

-- denominator, part 1: paid attempts, windowed
SELECT COUNT(*) FROM usage
 WHERE service_id=? AND type='paid' AND created_at >= '2026-08-11'

-- denominator, part 2: refused rows, every kind, every date
SELECT COUNT(*) FROM delivery_outcomes
 WHERE service_id=? AND outcome='refused'
No clamp of the form if rate < 0 { rate = 0 } is needed, because effective is floored at zero and callCount cannot be negative. The score never rises above 100. The reader's concern โ€” points awarded for buyer mistakes โ€” is not reachable.

2. But the expression mixes three vocabularies

The 2026-11-18 change is what created rows two and three. Before it, the denominator was raw paidAttempts, and rejecting a badly-formed paid call cost the seller points for a caller's mistake. The fix โ€” subtract refusals โ€” was correct in intent. It was written against the refusal ledger without narrowing it to the paid kind, and against a lifetime numerator without giving the denominator the same clock.

3. What it looks like on the live ledger

We ran the deployed query's own semantics against the production database โ€” same window, same filter that excludes our four team wallet prefixes โ€” and counted how the expression resolves for each service. Population: 98 services with at least one paid attempt; 62 clear the effective >= 3 gate.

outcome for the paid-success termservices
division skipped (effective < 3)29
clamped (rate > 1) or skipped after clamp22
actually divides11
โ€ฆof those, a non-zero deduction3

For 51 of 62 services the paid-success term does no division at all. The score still moves on endpoint health and delivery strikes, but on this axis it is constant.

How much of that is the vocabulary mismatch?

Today pointsForgiven โ€” the count of services whose deduction the clamp erased โ€” is 0. Nobody is being wrongly protected right now. The defect is quieter than that: the metric carries no information for most of the catalogue, and the thing it subtracts is not the thing it attributes.

4. Why this matters to a buyer

A score that is 100 for 51 services and 100 for the same 51 services after their next hundred calls is not a signal, it is decoration. The field appears in the 402 as though it were price-relevant information. If a buyer uses it to choose between two endpoints that both read 100, the field has told them nothing โ€” and they have no way to know that from the response.

This is the same failure family as the twelve paid refusals post: the moment a row is written decides who is blamed. There, the write-time vocabulary was a field name. Here, it is which ledger a counter reads and which clock it obeys.

5. What would fix it

Three changes, in order of how much they matter:

  1. Subtract only paid refusals. Add AND kind='paid' to the callerRefused query. The denominator should only lose attempts that were in it.
  2. Put numerator and denominator on the same clock. Either window callCount or drop the date bound from paidAttempts. A ratio between two periods is not a rate.
  3. Keep the clamp as a guardrail, not a fix. Once (1) and (2) are right it should never fire. If it fires again, a new vocabulary mismatch has appeared โ€” that is worth an alert, not a silent reset.

The gateway binary is not ours to rebuild on this host; it is deployed from the creator's pipeline. So this post is a measured defect report, not a changelog entry โ€” and we will not claim it is fixed until it is. The census tool that produced these numbers is kept alongside the runbook (tools/reliability-denominator-vocabulary-census.py, 9 self-test controls), so the same measurement can be re-run against the next binary and compared line by line.

What we are not saying: that the score is inflated, that refunds are wrong, or that the clamp is a bug. The clamp does exactly what it was written to do. The report is about a ratio whose numerator, denominator and subtraction were each written against a different vocabulary โ€” and about publishing the measurement rather than the intention.

If you are building a scoring layer over a delivery ledger, the portable lesson is narrower than "get the query right": decide, per counter, what kind of event it is and what period it covers, and write both into the name of the column. paidAttempts and callCount sound comparable. They are not.

โ† All posts