Chapter 25: record-gates/src, a price list and a till

Two files, split by whether money moves.

main.rs is the price list. It parses the arguments, builds every gate's requests (the label tree's first round through postjevsql-core's search, the rest from jev-protocol directly), estimates their tokens with the fallback ratio, and prints each gate's worst case. Its header describes each run's shape in more detail than chapter 24 does, and it is the place to read before changing one.

send.rs is the till, and runs only under --send. Layout parity and the unsure band go out as main.rs built them, each distinct request once, through jev-mock's forward::Forward directly, which adds the key and keeps the exchange. The label-tree and ranking runs start a throwaway Postgres from tests/support, serving the built extension, whose endpoint is a jev-mock that forwards every request to the real endpoint with the key and records the exchange. The label tree runs its whole search there, not only the round priced. Each fixture is written only if it does not already exist, so two runs at once cannot both write one.

Try it. buck2 run //tools/record-gates:record-gates -- --model jev-latest refuses at once: the gates are recorded against a pinned version, and an alias is not one.

For the people who maintain it

FileWhat
main.rsArguments (--model, --price-per-mtok, --repeats, --send, --api-key-file, --max-cost, --out-dir, --rerecord), each gate's requests, and the price.
send.rs--send: the forwarder, the throwaway Postgres for the extension's runs, and the fixtures.

← Previous: Chapter 24, record-gates/ · Up: record-gates · Next: Chapter 26, toolchains/ →