Kernel rig export: operand records in a gzip file beside each entry
An entry keeps what each operand body is and names <case>.bodies.json.gz, which holds the records (gzip with no timestamp, so the same records give the same bytes); the entry itself is pretty JSON. The corpus of 1202 cases is 33 MB. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DtL5M41G8Nua7HvuFPZkmJ
This commit is contained in:
Generated
+1
@@ -5754,6 +5754,7 @@ checksum = "e450f9b2ed1dff33c94c12589a87338689467b9c4f5d8a5710bd09a847d2c8a7"
|
||||
name = "xtask"
|
||||
version = "0.40.0-rc.1"
|
||||
dependencies = [
|
||||
"flate2",
|
||||
"proc-macro2",
|
||||
"quick-xml",
|
||||
"serde",
|
||||
|
||||
@@ -6,6 +6,7 @@ license.workspace = true
|
||||
publish = false
|
||||
|
||||
[dependencies]
|
||||
flate2 = "1.1"
|
||||
proc-macro2 = { workspace = true, features = ["span-locations"] }
|
||||
quick-xml = { workspace = true }
|
||||
serde = { workspace = true }
|
||||
|
||||
@@ -4,7 +4,9 @@
|
||||
//! the fix set, its expected values and the rig's result). This writes what that leaves out:
|
||||
//! an entry for each case whose process left none (a hang or a crash, so no trace), each ladder
|
||||
//! case's golden, and `DIR/manifest.json`, the counts per area and every case that is not
|
||||
//! expressible as kernel input, with its reasons.
|
||||
//! expressible as kernel input, with its reasons. An entry's operand records go to
|
||||
//! `<case>.bodies.json.gz` beside it (gzip, no timestamp, so a re-export of the same records is
|
||||
//! the same bytes); the entry keeps what each body is and names that file.
|
||||
|
||||
use std::collections::BTreeMap;
|
||||
use std::path::Path;
|
||||
@@ -43,6 +45,29 @@ fn write_json(path: &Path, v: &Value, pretty: bool) -> Result<(), String> {
|
||||
std::fs::write(path, text).map_err(|e| format!("{}: {e}", path.display()))
|
||||
}
|
||||
|
||||
/// Moves the records out of `entry`'s `bodies` into the gzip file `to`, `{"b<n>": record}`, and
|
||||
/// names it in `records`. An entry without records (written before) is left as it is.
|
||||
fn split_records(entry: &mut Value, to: &Path) -> Result<(), String> {
|
||||
use std::io::Write as _;
|
||||
let Some(bodies) = entry["bodies"].as_object_mut() else { return Ok(()) };
|
||||
let mut records = serde_json::Map::new();
|
||||
for (name, b) in bodies.iter_mut() {
|
||||
if let Some(r) = b.as_object_mut().and_then(|o| o.remove("record")) {
|
||||
records.insert(name.clone(), r);
|
||||
}
|
||||
}
|
||||
if records.is_empty() {
|
||||
return Ok(());
|
||||
}
|
||||
let text = serde_json::to_vec(&Value::Object(records)).map_err(|e| e.to_string())?;
|
||||
let mut gz = flate2::write::GzEncoder::new(Vec::new(), flate2::Compression::best());
|
||||
gz.write_all(&text).map_err(|e| e.to_string())?;
|
||||
let bytes = gz.finish().map_err(|e| e.to_string())?;
|
||||
std::fs::write(to, bytes).map_err(|e| format!("{}: {e}", to.display()))?;
|
||||
entry["records"] = json!(to.file_name().map(|n| n.to_string_lossy().to_string()));
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// What `git args` prints in this checkout.
|
||||
fn git(args: &[&str]) -> String {
|
||||
std::process::Command::new("git")
|
||||
@@ -95,7 +120,8 @@ pub(crate) fn manifest(dir: &Path, results: &[Value], golden: Option<&Value>) ->
|
||||
if let Some(e) = r.get("export_error") {
|
||||
entry["export_error"] = e.clone();
|
||||
}
|
||||
write_json(&file, &entry, false)?;
|
||||
split_records(&mut entry, &dir.join(area).join(format!("{id}.bodies.json.gz")))?;
|
||||
write_json(&file, &entry, true)?;
|
||||
}
|
||||
|
||||
// Every entry in the corpus, this run's or an earlier one's.
|
||||
|
||||
Reference in New Issue
Block a user