gate4agent_build_stamp/lib.rs
1//! One build stamp for every wire handshake in this repository tree.
2//!
3//! `BUILD_STAMP` is a content hash of the working tree at compile time
4//! (see `build.rs`): it is git's own blob hashing applied to every tracked
5//! and untracked-but-not-ignored file, folded into a single 40-hex-digit
6//! id. Two binaries built from byte-identical checkouts get the same
7//! stamp; two binaries built from checkouts that differ by even one byte
8//! almost certainly do not. A crates.io build is not a checkout: it uses
9//! the stamp recorded in `published-stamp.txt` at publish time, which is
10//! the same hash a checkout of that published commit produces. It answers
11//! exactly one question at connection
12//! time -- "did this peer come from the same tree I did?" -- compared for
13//! exact equality, nothing else.
14//!
15//! It is NOT a storage-format version. A checkpoint, database schema, or
16//! any other persisted record that needs forward migration across
17//! releases gets its own explicit integer, chosen and bumped by hand, as
18//! today. Wiring `BUILD_STAMP` into a persisted header would make every
19//! unrelated source change anywhere in the tree look like a storage
20//! migration.
21pub const BUILD_STAMP: &str = env!("G4A_BUILD_STAMP");
22
23#[cfg(test)]
24mod tests {
25 use super::BUILD_STAMP;
26
27 #[test]
28 fn build_stamp_is_a_forty_hex_digit_git_hash() {
29 assert_eq!(BUILD_STAMP.len(), 40);
30 assert!(BUILD_STAMP.bytes().all(|byte| byte.is_ascii_hexdigit()));
31 }
32}