mur_common/build.rs
1//! Compile-time build identity. `SHORT_SHA` is the git commit the binary was
2//! built from (set by build.rs), or "unknown" for git-less builds (crates.io).
3//! Used to detect when a running agent's binary differs from the installed one.
4
5/// 12-char git sha of this build, or "unknown".
6pub const SHORT_SHA: &str = env!("MUR_GIT_SHA");
7
8/// A2A method-surface version. Bump ONLY on incompatible change to a dialed
9/// method (added method, changed params/result contract). Carried in
10/// `running.lock` AgentCard; dial refuses a method whose
11/// `method_min_proto` exceeds the peer's advertised proto.
12pub const A2A_PROTO_VERSION: u32 = 2;
13
14/// The first proto whose runtimes emit `turn/heartbeat` (spec 2026-09-12
15/// execution-limits ยง3.6). The dial gives such a peer a 90 s idle timeout.
16pub const HEARTBEAT_MIN_PROTO: u32 = 2;
17
18/// Minimum proto a peer must advertise to accept the dialed `method`. `0` means
19/// always available (never gated). Add an entry per method introduced/changed.
20pub fn method_min_proto(method: &str) -> u32 {
21 match method {
22 "channel/delegate" => 1,
23 _ => 0,
24 }
25}
26
27#[cfg(test)]
28mod tests {
29 use super::*;
30
31 #[test]
32 fn short_sha_is_set() {
33 // Either a real 12-char hex sha, or the "unknown" fallback.
34 assert!(
35 SHORT_SHA == "unknown" || SHORT_SHA.len() == 12,
36 "got {SHORT_SHA:?}"
37 );
38 }
39
40 #[test]
41 fn method_min_proto_gates_channel_delegate_only() {
42 // channel/delegate requires the proto that introduced it.
43 assert_eq!(method_min_proto("channel/delegate"), 1);
44 // Always-available methods are ungated (min 0).
45 assert_eq!(method_min_proto("message/send"), 0);
46 assert_eq!(method_min_proto("agent/card"), 0);
47 // The current proto is at least the highest gated method.
48 const { assert!(A2A_PROTO_VERSION >= 1) };
49 }
50}