bxctl memory sync: the Honcho ledger's counts and failed items

Co-Authored-By: ornith-1.5-35b-a3b <agent@wntrmute.dev>
This commit is contained in:
2026-09-28 13:22:26 -07:00
co-authored by ornith-1.5-35b-a3b
parent fb05b26462
commit fb2afa1979
11 changed files with 445 additions and 12 deletions
+33
View File
@@ -0,0 +1,33 @@
//! What `bxctl memory sync` prints (M5c spec, section 5): how many items the ledger holds in each
//! state, and every failed item, oldest first, by its label, never by its text.
use crate::honcho::ledger::{Ledger, label};
/// The answer without `[honcho]`: not an error.
pub const NOT_CONFIGURED: &str = "honcho sync: not configured (memoryd.toml has no [honcho])";
/// The report of `ledger`: one line of counts, then, when any item failed, a heading and one line
/// per failed item: its time, its label, its kind, and its HTTP status when it had one.
pub fn report(ledger: &Ledger) -> String {
let c = ledger.counts();
let mut out = format!(
"honcho sync: {} decided: {} sent, {} waiting, {} failed, {} skipped",
c.decided, c.sent, c.waiting, c.failed, c.skipped
);
let failures = ledger.failures();
if !failures.is_empty() {
out.push_str("\nfailed, oldest first:");
for f in failures {
out.push_str(&format!(
"\n {} {} {}",
f.time.to_rfc3339(),
label(&f.item),
f.kind
));
if let Some(status) = f.status {
out.push_str(&format!(" (HTTP {status})"));
}
}
}
out
}