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 <state_dir>/build.json (caller-supplied, e.g. .trusty-code/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§

COMMIT_DATE
Date of the git commit this binary was built from (YYYY-MM-DD).
GIT_HASH
Short git commit hash captured at build time by build.rs.
LONG_VERSION
Full version string for tcode --version, e.g. 0.2.0 (b20adfca 2026-07-16).
PKG_NAME
The package name, resolved at compile time.
VERSION
Compile-time semver from Cargo.toml.

Functions§

provenance_json
Build provenance as a JSON object for embedding in machine-readable reports.
version_string
Human-readable banner used by the CTRL REPL and startup logs.