open-standards/jcp/jcp-rs/crates/jcp-efficiency/src
Repository files (latest commit first)
Filename Latest commit message Latest commit date
Transaction Science 1aeff331d1
Some checks failed
repository checks / lockfiles, advisories, tests in CI, workflow hygiene, spec and section references, public text (push) Failing after 2m57s
x402 v2 discovery, and the workspace lints clean again
**Discovery.** v2 §8 defines `GET /discovery/resources` — the listing that lets
an agent find a priced resource instead of being told about one — and the rail
had none. `DiscoveryQuery::apply` filters a catalogue and pages it, with three
rules that are easy to get wrong:

- The payment filters must be satisfied by the **same** requirement. A resource
  offering `upto` on one network and `exact` on another does not answer a search
  for `upto` on that other network; a client that paid on such a result would
  find no such offer.
- `total` counts everything that matched, not the page, so a client can tell a
  short page from the end of the results.
- `limit` is clamped to the protocol's 1–100 rather than honoured as given. A
  listing endpoint that returns an unbounded page on request is a denial of
  service with extra steps.

**And the lints.** `cargo clippy --workspace -D warnings` was already failing on
`main` in two crates I had not touched, which makes a clean workspace lint
useless as a signal — the next real break would have been invisible in the
noise. `jcp-flow::admit_output` takes eight independent boundary facts and gets
an allow with the reason written down, since grouping them into a struct would
name the group without removing a decision the caller has to make.
`jcp-efficiency` had a hand-rolled absolute difference and an unchecked
division, now `abs_diff` and a checked one, which also defends the multiply
above it.

Co-Authored-By: Claude Opus 5 <[email protected]>
2026-11-10 13:22:26 -05:00
..
bin efficiency/1: a partial energy figure is sealed as partial and never headlines as a task total 2026-10-20 13:58:36 -04:00
avoided.rs jcp: count the joules a cache hit did not spend, without ever calling it spend 2026-09-03 15:06:42 -04:00
dynamics.rs x402 v2 discovery, and the workspace lints clean again 2026-11-10 13:22:26 -05:00
lib.rs efficiency/1: a partial energy figure is sealed as partial and never headlines as a task total 2026-10-20 13:58:36 -04:00
trace.rs efficiency/1: a partial energy figure is sealed as partial and never headlines as a task total 2026-10-20 13:58:36 -04:00
training.rs jcp-efficiency: Seal a training run's measured energy as training/1 2026-07-22 18:43:42 -04:00