Module serve_env

Module serve_env 

Source
Expand description

2026-09-26: The METRALE_* environment a gate’s server is measured under.

A serve lever is a METRALE_* variable that is not a harness variable. Levers are not recipe keys, so they do not appear in the argv a leased server is fingerprinted by. Instead the recipe declares the levers it is measured under (its env: block, with the gate’s BENCH.toml [benchmarks.serve_env] pin on top), and reconcile refuses a lever in the harness’s own environment that nothing declared, and a declared lever it carries at another value. The set is fingerprinted into the serve identity (serve_identity) and disclosed on the gate record (gate::GateRecord::serve_env).

It lives in this crate so both ends share one definition: the server fingerprints its own environment for GET /serve-config, and the harness computes what that fingerprint must be.

Owner: bench (serve environment). Invariants:

  • declared returns only Runtime-class levers with non-empty values.
  • reconcile succeeds only when every present lever is declared at the declared value; its env is then the declaration, whole.

Structs§

Reconciled
2026-09-26: What the harness must do to serve declared from an environment that already holds present.

Constants§

PREFIX
2026-09-26: The prefix every lever carries.

Functions§

declared
2026-09-26: Validate one declaration (a recipe’s env: block or a BENCH.toml [benchmarks.serve_env] table) into the lever set it means.
fingerprint
2026-09-26: The SHA-256 of a lever set: name=value in key order, each NUL-terminated, so A=1 B=2 and A=1B=2 differ and the empty set has one fixed digest.
is_lever
2026-09-26: Whether name is a serve lever: any METRALE_* name that is not a harness variable.
levers
2026-09-26: The levers in an environment, from any (name, value) iterator.
merge_declared
2026-09-26: The recipe’s declaration under the gate entry’s pin; the pin wins on a clash.
process_levers
2026-09-26: The levers of this process: what the server fingerprints, and what the harness reconciles against the recipe before it serves.
reconcile
2026-09-26: Reconcile the recipe’s declaration with the harness’s own levers (process_levers).