use std::fs;
use std::path::{Path, PathBuf};
pub fn rht_root() -> Option<PathBuf> {
if let Ok(path) = std::env::var("MIF_RH_PARITY_FIXTURES_ROOT") {
let path = PathBuf::from(path);
return path.is_dir().then_some(path);
}
let manifest_dir = PathBuf::from(env!("CARGO_MANIFEST_DIR"));
let candidate = manifest_dir
.join("../../../../repos/research-harness-template")
.canonicalize()
.ok()?;
candidate.is_dir().then_some(candidate)
}
pub fn write_minimal_corpus(dir: &Path) {
fs::create_dir_all(dir.join(".claude")).unwrap();
fs::create_dir_all(dir.join("packs")).unwrap();
fs::create_dir_all(dir.join("reports/edu/findings")).unwrap();
fs::write(
dir.join("harness.config.json"),
r#"{"topics":[{"id":"edu","ontologies":["edu-fixture"]}]}"#,
)
.unwrap();
fs::write(
dir.join(".claude/enabled-packs.json"),
r#"{"ontologies":[{"id":"edu-fixture","version":"0.1.0","source":"packs/edu-fixture.yaml","core":false}]}"#,
)
.unwrap();
fs::write(
dir.join("packs/edu-fixture.yaml"),
"ontology:\n id: edu-fixture\n version: \"0.1.0\"\nentity_types:\n - name: title\n schema:\n required: [name]\n properties: {name: {type: string}}\n",
)
.unwrap();
fs::write(
dir.join("reports/edu/findings/good.json"),
r#"{"@id":"f-good","entity":{"name":"Algebra I","entity_type":"title"}}"#,
)
.unwrap();
fs::write(
dir.join("reports/edu/findings/invalid.json"),
r#"{"@id":"f-invalid","entity":{"entity_type":"title"}}"#,
)
.unwrap();
fs::write(
dir.join("reports/edu/findings/untyped.json"),
r#"{"@id":"f-untyped","content":"x"}"#,
)
.unwrap();
}