Module serve_identity

Module serve_identity 

Source
Expand description

2026-09-26: What makes one met serve “the same server” as another: the bytes of the binary, the arguments it was started with, and its METRALE_* serve levers.

A benchmark that reuses a server somebody else started must know it is measuring what it would have started itself, or its record names a config it never ran. The server publishes the identity as digests (GET /serve-config), never as the arguments themselves, because an argv can carry --auth-token. Both sides compute the digests with the functions here.

The environment is part of the identity because levers are not recipe keys: two servers with different levers can have byte-identical argv. The digest is serve_env::fingerprint over serve_env::process_levers(), which covers every METRALE_* variable except the harness class. The harness computes the expected digest from the lever set the recipe declares. The reuse check errs toward refusing: refusing a reusable server costs one server start, while reusing a wrong one corrupts a record.

Owner: bench (serve identity). Invariants:

  • Every digest this module computes is 64 lowercase hex characters; this_process reports unavailable: … as binary_sha256 when the executable cannot be read.

Structs§

ServeIdentity
2026-09-26: What GET /serve-config answers.

Functions§

argv_fingerprint
2026-09-26: The SHA-256 of a server’s arguments (everything after the program name), each NUL-terminated so ["a b"] and ["a", "b"] differ.
env_is_unknown
2026-09-26: Whether a reported lever digest carries no information: the empty string, which a report without ServeIdentity::env_sha256 parses to. A real digest is 64 hex characters even for an empty lever set.
file_sha256
2026-09-26: The SHA-256 of a file’s bytes; used as a binary’s identity.
this_process
2026-09-26: The identity of this process, computed once: the digests of its executable, its arguments after the program name and its levers, and its pid.