Files
peltier.io/crates/bench-runner/src/fingerprint.rs
T
Claude 52089c0451 bench: GitHub Actions CI — trust-layer checks, no-net gates, runner calibration
Closes the CI-reachable slice of the Phase 1 infra gaps:
- trust-layer job: cargo test + clippy -D warnings + fmt
- target-gates-no-net: fetches pinned targets (new targets/fetch.sh),
  regenerates + verifies corpora, runs 'just gates tokei'
  mechanically, and executes the bench workload inside a
  --network=none container (SPEC 3.1/10 no-net requirement)
- runner-calibration (informational): A/A + injection harness measures
  the shared runner's noise floor per run, evidence uploaded as an
  artifact — environments are judged empirically, not assumed
- perf-probe (informational): reports which perf event sources work

docs/infra.md maps each remaining hardware requirement (pinned cores,
governor/SMT control, separate-uid trust layer) to the bench-metal
self-hosted runner setup a human can complete in ~15 min.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EcKPWQ3MQD4NdEHwar96u2
2026-07-07 00:13:21 +00:00

52 lines
1.8 KiB
Rust

//! Environment fingerprint (SPEC §3.1, §7): every reported number carries
//! the machine state it was measured under. Collection is best-effort —
//! a field we cannot read is recorded as "unknown", never omitted.
use serde::Serialize;
use std::fs;
#[derive(Debug, Clone, Serialize)]
pub struct EnvFingerprint {
pub kernel: String,
pub cpu_model: String,
pub governor: String,
pub smt: String,
pub turbo: String,
/// ASLR handling mode actually in effect for this session (SPEC §7:
/// randomize-and-aggregate vs. fixed; document, don't assume).
pub aslr: String,
pub cpu_pinning: String,
}
fn read_trimmed(path: &str) -> String {
fs::read_to_string(path)
.map(|s| s.trim().to_string())
.unwrap_or_else(|_| "unknown".to_string())
}
impl EnvFingerprint {
pub fn collect(pinning: &str, aslr_mode: &str) -> Self {
let cpu_model = fs::read_to_string("/proc/cpuinfo")
.ok()
.and_then(|s| {
s.lines()
.find(|l| l.starts_with("model name"))
.and_then(|l| l.split(':').nth(1))
.map(|v| v.trim().to_string())
})
.unwrap_or_else(|| "unknown".to_string());
Self {
kernel: read_trimmed("/proc/sys/kernel/osrelease"),
cpu_model,
governor: read_trimmed("/sys/devices/system/cpu/cpu0/cpufreq/scaling_governor"),
smt: read_trimmed("/sys/devices/system/cpu/smt/active"),
turbo: read_trimmed("/sys/devices/system/cpu/intel_pstate/no_turbo"),
aslr: format!(
"mode={aslr_mode} randomize_va_space={}",
read_trimmed("/proc/sys/kernel/randomize_va_space")
),
cpu_pinning: pinning.to_string(),
}
}
}