O2: gate retry with failure log (#10)

This commit was merged in pull request #10.
This commit is contained in:
hermes committed 2026-11-12 23:21:21 +00:00
1 parent fb434c670c
commit 2f79b69977
4 files changed
+127 -41

No files matched your search

+18 -1
View File
@@ -4,7 +4,7 @@ use anyhow::{Context, Result};
use serde::{Deserialize, Serialize};
use std::path::PathBuf;
/// queued -> running -> gating -> done | failed. (retry and needs-human arrive with O2.)
/// queued -> running -> gating -> (retry: running) -> done | failed | needs-human.
#[derive(Serialize, Deserialize, Clone, Copy, PartialEq, Eq, Debug)]
#[serde(rename_all = "kebab-case")]
pub enum Status {
@@ -13,6 +13,8 @@ pub enum Status {
Gating,
Done,
Failed,
/// Gate still red after all retries: branch holds the best attempt, gate output in `ID.gate.log`.
NeedsHuman,
}
impl Status {
@@ -41,6 +43,14 @@ pub struct Run {
pub input_tokens: u64,
pub output_tokens: u64,
pub session: Option<String>,
/// hx runs so far (1 + retries).
#[serde(default)]
pub attempts: u32,
/// Budget counters, summed over all attempts.
#[serde(default)]
pub turns: u64,
#[serde(default)]
pub spent_tokens: u64,
}
pub fn now() -> u64 {
@@ -53,6 +63,10 @@ pub fn runs_dir() -> PathBuf {
crate::state_dir().join("runs")
}
pub fn gate_log_path(id: &str) -> PathBuf {
runs_dir().join(format!("{id}.gate.log"))
}
pub fn log_path(id: &str) -> PathBuf {
runs_dir().join(format!("{id}.log"))
}
@@ -144,6 +158,9 @@ mod tests {
input_tokens: 0,
output_tokens: 0,
session: None,
attempts: 0,
turns: 0,
spent_tokens: 0,
}
}