git mv of the files and of the module directories next to them, mod declarations, #[path] attributes and the paths that name the modules, rewritten by scripts/dev/rename_mechanical.py from a reviewed name table. Two files lost one to two lines so the 400-line limit holds again (qsa_prompt_index, original_verify_expert_probe). limits-baseline.json: test fn_lines 0 -> 1 is --allow-increase for crates/deploy builtin_profiles.rs:149 (37 lines, the speed-vs-strata session's file, not touched here); the prod params census falls 108 -> 1 (w_launch, extern C ABI). Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
100 lines
4.1 KiB
Rust
100 lines
4.1 KiB
Rust
//! The `batch-NNNN.json` file of an alternation batch, assembled in four consecutive sections.
|
|
|
|
#[allow(unused_imports)]
|
|
use super::*;
|
|
|
|
impl AltRun {
|
|
/// The batch description written once, with the first round (the CPU model comes from the first processes).
|
|
pub(super) fn batch_json(
|
|
&self,
|
|
cpu_model: &str,
|
|
equality: &BTreeMap<&'static str, Outcome>,
|
|
) -> Result<String, String> {
|
|
Ok([self.batch_run(), self.batch_machine(cpu_model), self.batch_files()?, self.batch_cells(equality)].concat())
|
|
}
|
|
|
|
/// Format, counts, run directory and the hashes of the manifest and of the case input.
|
|
fn batch_run(&self) -> String {
|
|
let (a, first_round) = (&self.a, self.plan.planned.first_round);
|
|
format!(
|
|
"{{\n \"format\": \"KAB1-alt\",\n \"version\": 1,\n \"batch\": {},\n \"rounds\": {},\n \
|
|
\"first_round\": {first_round},\n \"run_started_utc\": {},\n \"case\": {},\n \"run_dir\": {},\n \
|
|
\"manifest_sha256\": {},\n \"input_sha256\": {},\n",
|
|
a.batch,
|
|
a.rounds,
|
|
jstr(&self.started),
|
|
jstr(&a.case),
|
|
jstr(&a.dir.display().to_string()),
|
|
jstr(&self.verified.manifest_sha256),
|
|
jstr(&self.case.in_sha256),
|
|
)
|
|
}
|
|
|
|
/// The pin, the pool, the machine and the seed.
|
|
fn batch_machine(&self, cpu_model: &str) -> String {
|
|
let (a, sibling_at_start) = (&self.a, self.host.sibling_at_start);
|
|
format!(
|
|
" \"pin\": {{\"logical_cpu\": {}, \"sibling_idle_at_start\": {sibling_at_start}}},\n \"pool\": \
|
|
{{\"workers\": 1}},\n \"machine\": {{\"machine_role\": {}, \"cpu_model\": {}, \"os\": {}}},\n \"seed\": \
|
|
{},\n",
|
|
a.pin,
|
|
jstr(&self.host.machine_role),
|
|
jstr(cpu_model),
|
|
jstr(&host_os()),
|
|
a.seed
|
|
)
|
|
}
|
|
|
|
/// The schedule file, the two executables with their hashes and the slice settings.
|
|
fn batch_files(&self) -> Result<String, String> {
|
|
let (a, paths) = (&self.a, &self.plan.paths);
|
|
Ok(format!(
|
|
" \"schedule\": {{\"file\": {}, \"sha256\": {}}},\n \"kab\": {{\"path\": {}, \"sha256\": {}}},\n \
|
|
\"rust_example\": {{\"path\": {}, \"sha256\": {}}},\n \"slices_per_regime\": {},\n \"slice_ms\": {},\n",
|
|
jstr(&a.schedule.display().to_string()),
|
|
jstr(&sha_hex(self.plan.planned.text.as_bytes())),
|
|
jstr(&paths.kab.display().to_string()),
|
|
jstr(&file_sha(&paths.kab)?),
|
|
jstr(&paths.own_exe.display().to_string()),
|
|
jstr(&file_sha(&paths.own_exe)?),
|
|
a.slices,
|
|
a.slice_ms.map_or("null".to_owned(), |m| jnum(m, 1))
|
|
))
|
|
}
|
|
|
|
/// The equality verdicts per tree and the cells (processes) of a round.
|
|
fn batch_cells(&self, equality: &BTreeMap<&'static str, Outcome>) -> String {
|
|
let eq = equality
|
|
.iter()
|
|
.map(|(t, o)| {
|
|
format!(
|
|
"{{\"tree\": {}, \"verdict\": \"{}\", \"mode\": \"{}\", \"compared_values\": {}, \"mismatches\": \
|
|
{}}}",
|
|
jstr(t),
|
|
if o.equal() { "EQUAL" } else { "NOT_EQUAL" },
|
|
if self.case.tolerance.is_some() { "tolerance" } else { "bitwise" },
|
|
o.compared,
|
|
o.mismatches
|
|
)
|
|
})
|
|
.collect::<Vec<_>>()
|
|
.join(", ");
|
|
let cells = self.plan.procs.iter().map(|p| self.cell_json(p)).collect::<Vec<_>>().join(", ");
|
|
format!(
|
|
" \"equality\": [{eq}],\n \"cells\": [{cells}],\n \"no_statistics\": \"this file computes no class, no \
|
|
interval and no A/A verdict (S0.10b, STRA-313)\"\n}}\n"
|
|
)
|
|
}
|
|
|
|
fn cell_json(&self, p: &Proc) -> String {
|
|
format!(
|
|
"{{\"process\": {}, \"impl\": {}, \"tree\": {}, \"env_set\": {}, \"env_scrubbed\": \"every STRATA_* and \
|
|
LELEKA_* variable of the parent\"}}",
|
|
jstr(&p.name()),
|
|
jstr(p.imp.name()),
|
|
jstr(p.tree),
|
|
json_env(&cell_env(p).into_iter().collect())
|
|
)
|
|
}
|
|
}
|