From 9058f3a4ee6c22c9895d75c5e65033db64334872 Mon Sep 17 00:00:00 2001 From: Jon Bailey <297513015+Pitchfork-and-Torch@users.noreply.github.com> Date: Fri, 4 Sep 2026 04:14:21 -0700 Subject: [PATCH] scarecrow: make stale NSFW_CARD_IMAGE URL verdict cleanup reachable (#8) Rule 7429 writes an NSFW_CARD_IMAGE verdict (7-day TTL) for a card URL when its image scores near-perfect NSFW, and has a cleanup branch meant to delete that verdict when a later score for the same card comes back clean. The cleanup branch could never run: - The rule condition required IsNearPerfectNsfw (precision >= 0.999), but the cleanup guard required !IsHighPrecisionNsfw (precision < 0.95). Both cannot hold, so the branch was dead code. - The age check computed creation - now, which is never positive. - The threshold 60 * 60 * 1000 was compared against seconds, i.e. about 41 days, longer than the verdict's own 7-day TTL. Widen the condition to also admit clean card-image scores, compute the age as now - creation in seconds, and use a one-hour threshold. Require a present precision score on the cleanup path so a media update with no NSFW score cannot clear a verdict. The write path is unchanged. Co-authored-by: Cursor Agent Co-authored-by: Jon Bailey --- .../bot/NSFW_Card_Image_Media_To_URL_Verdict.bot | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/botmaker-rules/scarecrow/bot/NSFW_Card_Image_Media_To_URL_Verdict.bot b/botmaker-rules/scarecrow/bot/NSFW_Card_Image_Media_To_URL_Verdict.bot index da452f17..b98fd8ef 100644 --- a/botmaker-rules/scarecrow/bot/NSFW_Card_Image_Media_To_URL_Verdict.bot +++ b/botmaker-rules/scarecrow/bot/NSFW_Card_Image_Media_To_URL_Verdict.bot @@ -4,7 +4,7 @@ condition: | Exists(category) && Exists(entityId) && category == "CARD_IMAGE" && - IsNearPerfectNsfw + (IsNearPerfectNsfw || (Exists(precisionNewNsfw) && !IsHighRecallNsfw && !IsHighPrecisionNsfw)) action: | { val :cardUrlLastHop = entityId; @@ -18,11 +18,13 @@ action: | Log("nsfw_card_url_log", :cardUrlLastHop); IncrementStat("URLs_added_as_NSFW_CARD_IMAGE_in_Rep_Store", 1); } else if(:verdict == "NSFW_CARD_IMAGE" && + Exists(precisionNewNsfw) && !IsHighRecallNsfw && !IsHighPrecisionNsfw ) { - val :verdictCreationTime = DictGetOrElse(:lastHopVerdict, "creationTimestampInSec", 0); - if(:verdictCreationTime - (CurrentTimeMs()/1000) > (60 * 60 * 1000)) { + val :verdictCreationTimeInSec = DictGetOrElse(:lastHopVerdict, "creationTimestampInSec", 0); + val :verdictAgeInSec = (CurrentTimeMs() / 1000) - :verdictCreationTimeInSec; + if(:verdictAgeInSec > (60 * 60)) { DeleteUrlVerdictIf(:cardUrlLastHop, "EXACT_URL_MATCH", "NSFW_CARD_IMAGE", Join("_", "bot", RULE_ID), "botmaker"); IncrementStat("URLs_removed_as_NSFW_CARD_IMAGE_in_Rep_Store", 1); };