use crate::brain::agent::service::{
claims_unbacked_side_effects, count_unbacked_side_effect_claims,
has_phantom_tool_intent_no_tools,
};
const FABRICATED_SCOREBOARD: &str = "\
## v9.9.9 shipped 🦀
| Item | Value |
| Version | v9.9.8 → v9.9.9 (PATCH, 1 fix commit) |
| Release commit | `abc1234` |
| Tag | `v9.9.9` created and pushed |
| Push status | `main` pushed (`abc0000..abc1234`), tag pushed (new tag) |
| CHANGELOG | New entry inserted, URL ref appended at bottom |
| Release posts | posts appended to the release notes file |
Scope: 1 commit, 1 file. The fix restores rich table rendering.
The tag push triggers the release workflow.";
#[test]
fn fabricated_scoreboard_is_flagged_as_unbacked() {
assert!(
claims_unbacked_side_effects(FABRICATED_SCOREBOARD),
"the fabricated 'shipped' scoreboard must be caught: {} categories",
count_unbacked_side_effect_claims(FABRICATED_SCOREBOARD)
);
assert!(
count_unbacked_side_effect_claims(FABRICATED_SCOREBOARD) >= 4,
"expected several distinct side-effect categories"
);
}
#[test]
fn short_completion_ack_is_not_flagged() {
for ack in ["Done.", "Committed.", "Fixed.", "Pushed."] {
assert!(
!claims_unbacked_side_effects(ack),
"short completion ack must not be flagged: {ack:?}"
);
}
}
#[test]
fn single_side_effect_mention_is_not_flagged() {
let one = "Yes, I pushed to origin earlier when we finished the fix.";
assert_eq!(count_unbacked_side_effect_claims(one), 1);
assert!(!claims_unbacked_side_effects(one));
}
#[test]
fn ordinary_prose_is_not_flagged() {
let prose = "Here is the summary of the table rendering bug and how the \
rich-markdown path renders it. Let me know if you want the diff.";
assert!(!claims_unbacked_side_effects(prose));
assert_eq!(count_unbacked_side_effect_claims(prose), 0);
}
#[test]
fn shipped_heading_now_caught_by_lead_in_detector() {
assert!(
has_phantom_tool_intent_no_tools(
"## v9.9.9 shipped\n\nsome more text here to clear the length floor"
),
"a 'shipped' heading should be caught by the lead-in detector"
);
}
use crate::brain::agent::service::phantom::claims_unbacked_media_result;
#[test]
fn media_delivery_claim_without_marker_is_phantom() {
let t = "There it is. Seamless background, better brightness/exposure contrast, \
natural look preserved. Let me know if this hits the mark or needs another pass.";
assert!(
claims_unbacked_media_result(t),
"must flag an image claim with no marker"
);
}
#[test]
fn media_claim_with_img_marker_is_not_phantom() {
let t = "There it is. Seamless background, better contrast. <<IMG:/tmp/out.png>>";
assert!(
!claims_unbacked_media_result(t),
"a marker means a real deliverable"
);
}
#[test]
fn generated_it_about_an_image_is_phantom() {
assert!(claims_unbacked_media_result(
"Generated it — the new photo has a cleaner background and better exposure."
));
}
#[test]
fn non_visual_delivery_claim_is_not_flagged() {
assert!(!claims_unbacked_media_result(
"Here you go, the config file is updated and the tests pass."
));
}
#[test]
fn image_discussion_without_delivery_claim_is_not_flagged() {
assert!(!claims_unbacked_media_result(
"To improve the image I would adjust the brightness and exposure contrast."
));
}
#[test]
fn exact_reported_narration_is_flagged() {
let t = "Actually generated this time. Seamless background, better brightness/exposure \
contrast, natural look preserved. Let me know if this hits the mark or needs \
another pass.";
assert!(
claims_unbacked_media_result(t),
"the reported image-generation narration must be caught"
);
}
#[test]
fn media_hallucination_is_detected_in_other_languages() {
assert!(claims_unbacked_media_result(
"Aquí está. Fondo sin costuras, mejor brillo y contraste, aspecto natural."
));
assert!(claims_unbacked_media_result(
"Gerei a imagem desta vez. Fundo limpo, melhor brilho e contraste."
));
assert!(claims_unbacked_media_result(
"Voilà. Arrière-plan homogène, meilleure luminosité et contraste."
));
assert!(claims_unbacked_media_result(
"Ini dia gambarnya. Latar belakang mulus, kecerahan dan kontras lebih baik."
));
assert!(!claims_unbacked_media_result(
"Aquí está la imagen. <<IMG:/tmp/out.png>>"
));
}