Skip to content
Prev Previous commit
Next Next commit
workflows: drop contentless dismissed concerns instead of failing
A parallel analysis stage that emits a dismissed_concerns entry
without description or reasoning fails validate_concerns_output,
and after three validation attempts the whole stage dies under
BestEffort, losing every real concern it reported. Seen reviewing
HID: asus gamepad configuration with a flash model at low effort:
the model kept emitting the same stub until the retry budget ran
out and the resources and hardware stages failed.

A contentless dismissal asserts nothing about why the candidate
concern fails to apply, so dropping it is lossless: downstream
stages keep treating the candidate as unresolved, which is the
conservative outcome. Skip such entries in the four per-project
validators and filter them in the shared reducer so they never
reach review state or threads. Dismissals that carry content are
still required to prove themselves with verbatim locations.

Fixes: 3c83b32 ("workflows: require concrete code proof for dismissed concerns")
Signed-off-by: Denis Benato <denis.benato@linux.dev>
  • Loading branch information
NeroReflex committed Nov 7, 2026
commit c88fd543b59736af18e6b19821d73a510e49d60d
43 changes: 31 additions & 12 deletions src/workflows/gcc_patch_review.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ use crate::workflows::linux_patch_review::{
apply_planning_stage_output, apply_post_verification_stage_output,
apply_verification_stage_output, batch_inconclusive_concerns_by_severity,
build_combined_analysis_stage, build_stage_efforts_schema, collect_stage_prompts,
deduplication_stage_with_effort, extra_prompt_paths_for_items, extra_prompt_paths_for_state,
format_planning_feedback, format_post_verification_feedback,
deduplication_stage_with_effort, dismissed_concern_has_content, extra_prompt_paths_for_items,
extra_prompt_paths_for_state, format_planning_feedback, format_post_verification_feedback,
format_verification_stage_feedback, has_valid_proof_location, resolve_combined_stage_effort,
resolve_stage_effort, validate_locations_side, validate_planning_stage_efforts,
validate_post_verification_batch_items, validate_verification_stage_output,
Expand Down Expand Up @@ -601,17 +601,15 @@ fn validate_concerns_output(
.get("type")
.and_then(Value::as_str)
.is_some_and(|s| !s.trim().is_empty());
let has_desc = obj
.get("description")
.and_then(Value::as_str)
.is_some_and(|s| !s.trim().is_empty());
let has_reasoning = obj
.get("reasoning")
.and_then(Value::as_str)
.is_some_and(|s| !s.trim().is_empty());
if !has_type || !has_desc || !has_reasoning {
if !dismissed_concern_has_content(dismissed) {
// A dismissal without description or reasoning asserts nothing
// about why the candidate concern fails to apply; dropping it is
// lossless while failing the stage would lose every real concern.
continue;
}
if !has_type {
return Err(format!(
"dismissed_concerns[{idx}] must have non-empty 'type', 'description', and 'reasoning' strings."
"dismissed_concerns[{idx}] must have a non-empty 'type' string."
));
}
if let Some(locations) = obj.get("locations").and_then(Value::as_array) {
Expand Down Expand Up @@ -1330,6 +1328,27 @@ pub fn build_gcc_patch_review_workflow_with_effort(
mod tests {
use super::*;

#[test]
fn test_validate_concerns_output_drops_contentless_dismissals() {
let output = StageConcernsOutput {
concerns: Vec::new(),
dismissed_concerns: vec![serde_json::json!({"type": "stub"})],
};
assert!(validate_concerns_output(&output, &LinuxPatchReviewState::default()).is_ok());
}

#[test]
fn test_validate_concerns_output_requires_type_on_content_dismissals() {
let output = StageConcernsOutput {
concerns: Vec::new(),
dismissed_concerns: vec![serde_json::json!({
"description": "d", "reasoning": "r"
})],
};
let err = validate_concerns_output(&output, &LinuxPatchReviewState::default()).unwrap_err();
assert!(err.contains("'type'"), "{err}");
}

#[test]
fn test_gcc_analysis_stages_table() {
assert_eq!(ANALYSIS_STAGES.len(), 7);
Expand Down
100 changes: 88 additions & 12 deletions src/workflows/linux_patch_review.rs
Original file line number Diff line number Diff line change
Expand Up @@ -581,6 +581,16 @@ pub(crate) fn validate_locations_side(
Ok(())
}

/// Whether a dismissed concern carries the content the validators require:
/// non-empty `description` and `reasoning` strings.
pub fn dismissed_concern_has_content(item: &Value) -> bool {
["description", "reasoning"].iter().all(|key| {
item.get(key)
.and_then(Value::as_str)
.is_some_and(|s| !s.trim().is_empty())
})
}

fn validate_concerns_output(
output: &StageConcernsOutput,
_state: &LinuxPatchReviewState,
Expand All @@ -607,18 +617,16 @@ fn validate_concerns_output(
}

for (idx, dismissed) in output.dismissed_concerns.iter().enumerate() {
let has_desc = dismissed
.get("description")
.and_then(Value::as_str)
.is_some_and(|s| !s.trim().is_empty());
let has_reasoning = dismissed
.get("reasoning")
.and_then(Value::as_str)
.is_some_and(|s| !s.trim().is_empty());
if !has_desc || !has_reasoning {
return Err(format!(
"dismissed_concerns[{idx}] must have non-empty 'description' and 'reasoning' strings proving why the candidate concern does not apply."
));
if !dismissed.is_object() {
return Err(format!("dismissed_concerns[{idx}] must be a JSON object."));
}
if !dismissed_concern_has_content(dismissed) {
// A dismissal without description or reasoning asserts nothing
// about why the candidate concern fails to apply. Dropping it is
// lossless - downstream stages keep treating the candidate as
// unresolved - while failing the stage under BestEffort would
// discard every real concern it reported.
continue;
}
if let Some(locations) = dismissed.get("locations").and_then(Value::as_array) {
validate_locations_side(locations, "dismissed_concerns", idx)?;
Expand Down Expand Up @@ -1573,6 +1581,12 @@ pub fn append_stage_dismissed_concerns_with_prompts(
prompts: &[String],
) {
for item in src {
// Mirrors the stage validators: a dismissal without description and
// reasoning is never recorded, so review threads do not carry
// entries that assert nothing about the candidate they dismiss.
if !dismissed_concern_has_content(item) {
continue;
}
let next_id = format!("D{}", dest.len().saturating_add(1));
let mut obj = item.clone();
if let Some(map) = obj.as_object_mut() {
Expand Down Expand Up @@ -4340,6 +4354,68 @@ mod tests {
assert_eq!(f["cluster_ids"], json!(["G1"]));
}
}

#[test]
fn test_validate_concerns_output_drops_contentless_dismissals() {
let proof_location = json!({
"file": "drivers/hid/hid-asus.c",
"function_or_symbol": "asus_probe",
"side": "REVISION",
"code_snippet": "return 0;"
});
let state = LinuxPatchReviewState::default();
let output = StageConcernsOutput {
concerns: Vec::new(),
dismissed_concerns: vec![
json!({"description": "", "reasoning": "because"}),
json!({"description": "desc", "reasoning": " "}),
json!({"type": "skeleton", "locations": [proof_location.clone()]}),
json!({
"description": "lock already held by the caller",
"reasoning": "the caller holds it across the call",
"locations": [proof_location]
}),
],
};
assert!(validate_concerns_output(&output, &state).is_ok());
}

#[test]
fn test_validate_concerns_output_still_requires_dismissal_proof() {
let state = LinuxPatchReviewState::default();
let output = StageConcernsOutput {
concerns: Vec::new(),
dismissed_concerns: vec![json!({
"description": "lock already held by the caller",
"reasoning": "the caller holds it across the call"
})],
};
let err = validate_concerns_output(&output, &state).unwrap_err();
assert!(
err.contains("must include at least one entry in 'locations'"),
"{err}"
);
}

#[test]
fn test_append_stage_dismissed_concerns_drops_contentless_entries() {
let mut dest = Vec::new();
let src = vec![
json!({"description": "real", "reasoning": "why"}),
json!({"description": "", "reasoning": "why"}),
json!({"type": "stub"}),
];
append_stage_dismissed_concerns_with_prompts(
&mut dest,
&src,
"hardware",
&["g".to_string()],
);
assert_eq!(dest.len(), 1);
assert_eq!(dest[0]["id"], json!("D1"));
assert_eq!(dest[0]["stage"], json!("hardware"));
}

#[test]
fn test_each_stage_declares_whether_it_needs_the_commit_message() {
// This was a numeric range in a free function, which kept compiling
Expand Down
47 changes: 33 additions & 14 deletions src/workflows/qemu_patch_review.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@ use crate::workflows::linux_patch_review::{
apply_planning_stage_output, apply_post_verification_stage_output,
apply_verification_stage_output, batch_inconclusive_concerns_by_severity,
build_combined_analysis_stage, build_stage_efforts_schema, collect_stage_prompts,
extra_prompt_paths_for_items, extra_prompt_paths_for_state, format_planning_feedback,
format_post_verification_feedback, format_verification_stage_feedback,
has_valid_proof_location, resolve_combined_stage_effort, resolve_stage_effort,
validate_locations_side, validate_planning_stage_efforts,
dismissed_concern_has_content, extra_prompt_paths_for_items, extra_prompt_paths_for_state,
format_planning_feedback, format_post_verification_feedback,
format_verification_stage_feedback, has_valid_proof_location, resolve_combined_stage_effort,
resolve_stage_effort, validate_locations_side, validate_planning_stage_efforts,
validate_post_verification_batch_items, validate_verification_stage_output,
};

Expand Down Expand Up @@ -521,17 +521,15 @@ fn validate_concerns_output(
.get("type")
.and_then(Value::as_str)
.is_some_and(|s| !s.trim().is_empty());
let has_desc = obj
.get("description")
.and_then(Value::as_str)
.is_some_and(|s| !s.trim().is_empty());
let has_reasoning = obj
.get("reasoning")
.and_then(Value::as_str)
.is_some_and(|s| !s.trim().is_empty());
if !has_type || !has_desc || !has_reasoning {
if !dismissed_concern_has_content(dismissed) {
// A dismissal without description or reasoning asserts nothing
// about why the candidate concern fails to apply; dropping it is
// lossless while failing the stage would lose every real concern.
continue;
}
if !has_type {
return Err(format!(
"dismissed_concerns[{idx}] must have non-empty 'type', 'description', and 'reasoning' strings."
"dismissed_concerns[{idx}] must have a non-empty 'type' string."
));
}
if let Some(locations) = obj.get("locations").and_then(Value::as_array) {
Expand Down Expand Up @@ -1182,6 +1180,27 @@ pub fn build_qemu_patch_review_workflow_with_effort(
mod tests {
use super::*;

#[test]
fn test_validate_concerns_output_drops_contentless_dismissals() {
let output = StageConcernsOutput {
concerns: Vec::new(),
dismissed_concerns: vec![serde_json::json!({"type": "stub"})],
};
assert!(validate_concerns_output(&output, &LinuxPatchReviewState::default()).is_ok());
}

#[test]
fn test_validate_concerns_output_requires_type_on_content_dismissals() {
let output = StageConcernsOutput {
concerns: Vec::new(),
dismissed_concerns: vec![serde_json::json!({
"description": "d", "reasoning": "r"
})],
};
let err = validate_concerns_output(&output, &LinuxPatchReviewState::default()).unwrap_err();
assert!(err.contains("'type'"), "{err}");
}

#[test]
fn test_qemu_analysis_stages_table() {
assert_eq!(ANALYSIS_STAGES.len(), 6);
Expand Down
35 changes: 16 additions & 19 deletions src/workflows/sashiko_patch_review.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ use crate::workflows::linux_patch_review::{
apply_planning_stage_output, apply_post_verification_stage_output,
apply_verification_stage_output, batch_inconclusive_concerns_by_severity,
build_combined_analysis_stage, build_stage_efforts_schema, collect_stage_prompts,
deduplication_stage_with_effort, extra_prompt_paths_for_items, extra_prompt_paths_for_state,
format_planning_feedback, format_post_verification_feedback,
deduplication_stage_with_effort, dismissed_concern_has_content, extra_prompt_paths_for_items,
extra_prompt_paths_for_state, format_planning_feedback, format_post_verification_feedback,
format_verification_stage_feedback, has_valid_proof_location, resolve_combined_stage_effort,
resolve_stage_effort, validate_locations_side, validate_planning_stage_efforts,
validate_post_verification_batch_items, validate_verification_stage_output,
Expand Down Expand Up @@ -628,23 +628,11 @@ fn validate_concerns_output(
let Some(obj) = dismissed.as_object() else {
return Err(format!("dismissed_concerns[{idx}] must be a JSON object."));
};
let has_desc = obj
.get("description")
.and_then(Value::as_str)
.is_some_and(|s| !s.trim().is_empty());
if !has_desc {
return Err(format!(
"dismissed_concerns[{idx}] must have a non-empty 'description' string."
));
}
let has_reasoning = obj
.get("reasoning")
.and_then(Value::as_str)
.is_some_and(|s| !s.trim().is_empty());
if !has_reasoning {
return Err(format!(
"dismissed_concerns[{idx}] must have a non-empty 'reasoning' string."
));
if !dismissed_concern_has_content(dismissed) {
// A dismissal without description or reasoning asserts nothing
// about why the candidate concern fails to apply; dropping it is
// lossless while failing the stage would lose every real concern.
continue;
}
if let Some(locations) = obj.get("locations").and_then(Value::as_array) {
validate_locations_side(locations, "dismissed_concerns", idx)?;
Expand Down Expand Up @@ -1473,6 +1461,15 @@ mod tests {
use super::*;
use crate::workflows::linux_patch_review::validate_post_verification_batch_output;

#[test]
fn test_validate_concerns_output_drops_contentless_dismissals() {
let output = StageConcernsOutput {
concerns: Vec::new(),
dismissed_concerns: vec![serde_json::json!({"type": "stub"})],
};
assert!(validate_concerns_output(&output, &LinuxPatchReviewState::default()).is_ok());
}

#[test]
fn test_sashiko_analysis_stages_table() {
assert_eq!(ANALYSIS_STAGES.len(), 9);
Expand Down