Skip to main content

Module build_info

Module build_info 

Source
Expand description

Build and version tracking.

Why: A monotonic build counter pairs with semver for log correlation. What: BuildInfo struct, VERSION/GIT_HASH/PKG_NAME constants, version_string helper. Test: build_info::tests::*. Build and version tracking.

Why: We need a monotonic build counter that increments on every process start, independent of the semver version. The combined vX.Y.Z build #N string lets us correlate log lines and performance telemetry with the exact binary invocation that produced them. Keeping the counter on disk (rather than baked into the binary) lets a single cargo build produce many distinct “builds” across repeated cargo run invocations during development — which is exactly when we need the disambiguation.

What: Reads .open-mpm/state/build.json relative to the current working directory, increments the build counter (defaulting to 0 if the file is missing or malformed), and writes the result back atomically via rename(2) from a sibling .tmp file.

Test: BuildInfo::load_and_increment in an empty temp dir returns build == 1; calling it again returns build == 2; a corrupt build.json is treated as “build = 0” and replaced on the next call.

Structs§

BuildInfo
Runtime build metadata surfaced to logs, the --version flag, and downstream instrumentation.

Constants§

GIT_HASH
Short git commit hash captured at build time by build.rs.
PKG_NAME
The package name, resolved at compile time.
VERSION
Compile-time semver from Cargo.toml.

Functions§

version_string
Human-readable banner used by the CTRL REPL and --version output.