e091921b18
Prerequisites for the live FIFA A/B. Two safeguards here exist because the corresponding failure actually happened, not because it was imagined. BUILD IDENTITY. build.rs stamps commit + working-tree cleanliness; the host prints commit, tree state, profile and a fingerprint of the bundled config table at startup, into both the log and the trace. A dirty tree prints an explicit "do NOT treat results from this binary as parity evidence" warning. The previous step left four sidecars running, two serving mutated builds, and nothing in their output said so. SIDECAR LIFECYCLE (sidecar.sh). start/stop/status/check-orphans/with. Start refuses when any sidecar is already running or the port is busy. Stop kills, waits, then PROVES it: PID gone AND port free AND no stray processes, failing if any check does not hold. `with -- CMD` traps EXIT/INT/TERM so cleanup runs however the command exits. Bug found and fixed while testing it: orphan detection used `pgrep -f`, which matched any process whose command line merely mentioned the name -- including the shell running the test script. It now matches the resolved executable via /proc/PID/exe. `pgrep -x` is unusable because Linux truncates the process name to "openfut-blaze-h". BLAZE SWITCH (blaze-switch.sh). Redirects Blaze to the sidecar with a scoped NAT rule instead of editing the frozen Python oracle, whose redirector advertises a hardcoded BLAZE_PORT = 42130. Rules match only <LAN_IP>:42130; 127.0.0.1:42130 is deliberately left alone so Python stays reachable on loopback and the A/B compares real Python against real Rust. Verified both directions live: LAN->Rust with the switch on, LAN->Python with it off. Bug found and fixed: `off` reported success while two rules remained active and rollback had NOT happened. It matched `--comment "tag"` with quotes this iptables does not emit -- and the verification used the SAME broken matcher, so it confirmed its own failure. A rollback that lies is worse than one that fails. Now matched on the bare tag, verified with iptables-save plus a tag-independent check that nothing still redirects the port. Second flaw fixed: `sidecar.sh stop` originally warned about a live switch and then stopped anyway, creating the exact broken state it warned about. It now REFUSES, with --force as the deliberate override. The general rule this all converges on, now stated in the README: a verification must not share the failure mode of the thing it verifies. 116 tests still passing; clippy clean; Python backend untouched and contract suite 446/446. NAT table left clean, no orphan processes. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
47 lines
1.8 KiB
Rust
47 lines
1.8 KiB
Rust
//! Stamp build identity into the binary.
|
|
//!
|
|
//! A live FIFA trace has to be attributable to an exact binary. During the
|
|
//! mutation runs for the previous step, four sidecars were left listening —
|
|
//! two of them serving deliberately broken builds — and nothing in their output
|
|
//! said so. A later A/B against one of those would have read as a genuine
|
|
//! parity failure.
|
|
//!
|
|
//! So the host prints its commit, working-tree cleanliness and profile at
|
|
//! startup, and `dirty` is the important one: a mutation-tested build is a
|
|
//! dirty build, and now it announces itself.
|
|
|
|
use std::process::Command;
|
|
|
|
fn git(args: &[&str]) -> Option<String> {
|
|
let out = Command::new("git").args(args).output().ok()?;
|
|
if !out.status.success() {
|
|
return None;
|
|
}
|
|
Some(String::from_utf8_lossy(&out.stdout).trim().to_string())
|
|
}
|
|
|
|
fn main() {
|
|
let commit = git(&["rev-parse", "--short=7", "HEAD"]).unwrap_or_else(|| "unknown".into());
|
|
|
|
// Tracked modifications only: untracked scratch files are not a build
|
|
// difference, but an edited source file certainly is.
|
|
let dirty = match git(&["status", "--porcelain", "--untracked-files=no"]) {
|
|
Some(s) if !s.is_empty() => "DIRTY",
|
|
Some(_) => "clean",
|
|
None => "unknown",
|
|
};
|
|
|
|
println!("cargo:rustc-env=OPENFUT_BUILD_COMMIT={commit}");
|
|
println!("cargo:rustc-env=OPENFUT_BUILD_DIRTY={dirty}");
|
|
|
|
// Re-stamp when HEAD moves. Working-tree edits are not tracked by cargo's
|
|
// dependency graph, so `dirty` can go stale until something forces a
|
|
// rebuild — the startup banner says which commit it was stamped from, and
|
|
// the sidecar script re-checks the working tree independently at launch.
|
|
for p in ["../.git/HEAD", "../.git/index"] {
|
|
if std::path::Path::new(p).exists() {
|
|
println!("cargo:rerun-if-changed={p}");
|
|
}
|
|
}
|
|
}
|