Watch
0
0
Fork
You've already forked hyperhive
0

swarm-review-classifier: only an error result falls back to its subtype

This commit is contained in:
damocles 2026-11-21 13:24:24 +01:00 • committed by mara
commit ffcba2b026

View file

@ -448,15 +448,17 @@ impl Sink for ResultSink {
if event["type"] != "result" { if event["type"] != "result" {
return; return;
} }
let text = match event["result"].as_str().filter(|t| !t.is_empty()) { let text = event["result"].as_str().unwrap_or_default();
Some(text) => text,
None => event["subtype"].as_str().unwrap_or_default(),
}
.to_owned();
let outcome = if event["is_error"].as_bool().unwrap_or(false) { let outcome = if event["is_error"].as_bool().unwrap_or(false) {
Err(format!("claude reported an error: {text}")) // An error result with no text names its subtype instead.
let reported = if text.is_empty() {
event["subtype"].as_str().unwrap_or_default()
} else { } else {
Ok(text) text
};
Err(format!("claude reported an error: {reported}"))
} else {
Ok(text.to_owned())
}; };
*self *self
.result .result
@ -586,6 +588,14 @@ mod tests {
); );
} }
#[test]
fn an_empty_non_error_result_stays_empty_whatever_its_subtype() {
let sink = sink_after(&serde_json::json!({
"type": "result", "is_error": false, "subtype": "success",
}));
assert_eq!(sink.take(), Ok(String::new()));
}
#[test] #[test]
fn no_reported_error_leaves_the_exit_alone() { fn no_reported_error_leaves_the_exit_alone() {
let ok = sink_after(&serde_json::json!({ let ok = sink_after(&serde_json::json!({