1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
//! What code is this server (#123).
//!
//! # The gap this closes
//!
//! A running server could not be asked what code it was. The only build
//! identity anywhere was a startup log line carrying `CARGO_PKG_VERSION` — a
//! crate version, which cannot distinguish two builds from different commits of
//! the same version, and which is gone from the terminal by the time anyone
//! needs it.
//!
//! That was measured, not supposed. On 2026-07-31 a live server's running image
//! was found to differ from every preserved copy of "the same" binary — a
//! different inode and a different size — and there was no way to establish
//! which revision was actually serving. The mistake available at that moment
//! was to restart it and call the result a restoration. **An artefact's
//! identity is its content, never its path**; a path is a label recording where
//! a file used to be. This is the one identity a server can state about itself.
//!
//! # 🔴 A STATUS CODE CANNOT VERIFY THIS ENDPOINT EXISTS
//!
//! The server mounts an ops-console SPA whose catch-all serves the app shell for
//! any unmatched path, so that client-side routing works. A consequence, found
//! the hard way on a live probe: **`GET /version` returns `200` on a server that
//! has no such route** — the fallback answered, with `text/html`.
//!
//! So a probe that checks only the status code would report this endpoint
//! present on every image ever built, including the ones it exists to
//! distinguish. **An instrument that cannot fail is not an instrument.**
//!
//! Any probe for build identity must therefore assert on the BODY:
//!
//! ```text
//! curl -s http://host/build | jq -e .commit # fails on an image without it
//! ```
//!
//! not on `%{http_code}`. [`BuildIdentity`] is `application/json` with a
//! required `commit` field precisely so that check is available and cheap. The
//! same discipline as grepping an artifact for its own verdict rather than
//! trusting a summarised exit.
use Serialize;
/// The stamped absence, and the one word every unestablished field carries.
///
/// A word rather than an empty string or a `null`: an empty value reads as a
/// formatting bug at the far end, where "unknown" reads as the measurement it
/// is. Nothing here is ever defaulted to something that looks like an answer.
const UNKNOWN: &str = "unknown";
/// The source revision this binary was built from, stamped by `build.rs`.
/// The stamped epoch rendered as RFC 3339, or `"unknown"`.
///
/// The build script carries an integer across the boundary rather than a
/// formatted string, so it needs no date dependency of its own; this is where
/// that integer becomes readable. A value that does not parse, or does not
/// name a real instant, degrades to the same honest absence as never having
/// been established — the three are indistinguishable to an operator and
/// pretending otherwise would invent precision.