← Back to Pull requests

feat(doubts): cap fact-doubt claims and alarm on a loop answering none #3719

Closed
unknown closed this pull request without merging on Nov 22, 2026 19:31 UTC
View on GitHub
unknown unknown commented on Nov 22, 2026 19:19 UTC
Author

The scheduled fact-doubt loop (#3715) claims doubts and answers them on the subscription. Two gaps found on its first fire (2026-11-22 19:05 UTC):

  • A claim that dies is re-claimed after 30 minutes with no limit, one subscription call each time.

  • That fire took up one doubt, failed it, and the watch stayed green.
  • One migration, 20261122201000_fact_doubt_claim_cap.sql:

  • fact_doubt_ineligibility: the 20261120070000 body (repo matches live, compared 2026-11-22) plus claimed_6_times. A doubt claimed six times is no longer offered or accepted.

  • assay_subscription_readers: the 20261122190000 body plus a failure when the fact-doubt-cycle heartbeat carries three or more zero-answer fires begun over two hours ago. The run is carried by reader-heartbeat.mjs on frames/read, which the cycle reports from #3718.
  • Live before: 0 open fact doubts at six claims.

    Test plan


  • test_fact_doubt_questions.sql on PG17 with the capped function: the whole contract plus five claims offered, sixth claimed, its answer refused with claimed_6_times, not offered again

  • test_fact_doubt_cycle_heartbeat.sql on PG17: two runs or a run begun 30 min ago pass; three over two hours fail with the failure classes

  • Live after deploy: function bodies carry the cap and the alarm; subscription-reader-watch stays green
  • 🤖 Generated with Claude Code

    <!-- CURSOR_SUMMARY -->
    ---

    [!NOTE]

    Medium Risk

    Replaces core eligibility and health-check PL/pgSQL used by the fact-doubt loop and subscription reader watch; incorrect thresholds could block legitimate doubts or miss a stuck loop.

    > Overview

    Stops the scheduled fact-doubt loop from re-claiming the same doubt forever and makes the subscription-reader watch fail when the loop keeps claiming without answering.

    > fact_doubt_ineligibility now treats a doubt as ineligible with claimed_6_times once its lifecycle records six claim events, so it is no longer offered for claim or accepted for answer after repeated failed attempts (each re-claim was another subscription call every 30 minutes).

    > assay_subscription_readers (the cron that keeps subscription-reader-watch green) now raises when the fact-doubt-cycle heartbeat shows ≥3 consecutive zero-answer fires (zero_read_fires) that started more than two hours ago, including error_classes in the error text—aligned with counters already carried by reader-heartbeat.mjs.

    > SQL contracts test_fact_doubt_questions.sql and test_fact_doubt_cycle_heartbeat.sql apply the new migration and assert the cap and zero-answer alarm thresholds.

    > <sup>Reviewed by Cursor Bugbot for commit 98d17ba93be1188997e6b1139b436914e51d89fb. Bugbot is set up for automated code reviews on this repo. Configure here.</sup>

    <!-- /CURSOR_SUMMARY -->

    Diff: 370 lines (+277 / -93) across 4 files Reviewer: cursor[bot] Review duration: 11m
    All Vouch review confidence checks passed
    Residual risk 0.17 = Change Risk (0.43) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.43 · 370 lines diff across 4 files
    0.43
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    60%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.354
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #3719"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 60.5% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 42.8% (MEDIUM) · Higher = larger blast radius
    42.8%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 60.5% · Lower = rushed or shallow review
    60.5%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 16.9% · Safe to merge
    16.9%
    Repository