use io_harness::{run_with, ApproveAll, OpenRouter, Policy, Store, TaskContract, Verification};
#[tokio::main]
async fn main() -> io_harness::Result<()> {
let root = std::env::temp_dir().join("io-harness-stall-live");
std::fs::remove_dir_all(&root).ok();
let src = root.join("src");
std::fs::create_dir_all(&src)?;
std::fs::write(src.join("a.rs"), "pub fn a() -> u32 { 0 }\n")?;
let contract = TaskContract::workspace("Edit src/a.rs so a() == 7.", &root)
.with_verification(Verification::WorkspaceFileContains {
file: "src/a.rs".into(),
needle: "7".into(),
})
.with_max_steps(20)
.with_token_budget(200_000);
let policy = Policy::default()
.layer("read-only")
.allow_read("*")
.deny_write("*");
let provider = OpenRouter::from_env()?;
let store = Store::open(root.join("runs.db"))?;
let result = run_with(&contract, &provider, &store, &policy, &ApproveAll).await?;
println!("outcome: {:?}", result.outcome);
println!("step cap was: {}", contract.max_steps);
println!("stall policy: {:?}", contract.stall);
println!("\nresilience rows:");
for e in store.context_events(result.run_id)? {
if e.kind == "stalled" {
println!(" step {}: {}", e.step, e.detail.unwrap_or_default());
}
}
println!("\nsteps taken:");
for s in store.steps(result.run_id)? {
println!(" {:>2}: {}", s.step, s.decision);
}
Ok(())
}