← Back to Pull requests

fix(doubts): load photo packages lazily so scheduled answers run #3718

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

The scheduled fact-doubt loop (#3715) runs answer-fact-doubts from the reader's bare main checkout (~/.worktrees/nuke-main, no node_modules). read-photos.mjs imported @anthropic-ai/sdk and sharp at the top, so every scheduled answer failed before reading (first fire 2026-11-22 19:05 UTC: 1 claimed, 1 failed, reason not recorded).

  • read-photos.mjs: sharp and the SDK load when used, from the checkout or else the working directory (the frame reader's pattern).

  • fact-doubt-cycle.mjs: failed answers counted by class in the summary and heartbeat; a locally refused answer is counted as refused_locally with no value.
  • Test plan


  • node --test scripts/doubts: pass

  • The stuck doubt answered launchd-style (cwd ~/nuke, script in a checkout with no node_modules): outcome not_visible, 0.95

  • Next scheduled fire answers with no hand step
  • 🤖 Generated with Claude Code

    <!-- CURSOR_SUMMARY -->
    ---

    [!NOTE]

    Medium Risk

    Changes the scheduled subscription reader’s module loading and fact-doubt cycle metrics; low blast radius but affects production automation and monitoring signals.

    > Overview

    Fixes scheduled fact-doubt answer fires dying on import when read-photos.mjs is pulled in from a bare main worktree with no node_modules. sharp and @anthropic-ai/sdk now load only when needed via a pkg() helper (dynamic import, then createRequire from the real repo cwd).

    > fact-doubt-cycle.mjs improves observability for that path: failed answers are bucketed into error_classes (sanitized infra errors vs refused_locally, with validator values kept out of the summary) and the summary now reports frames / read so a run that claims doubts but answers none surfaces as a zero-read heartbeat instead of looking healthy.

    > A unit test locks in failure classification and the frames/read counts.

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

    <!-- /CURSOR_SUMMARY -->

    Diff: 272 lines (+204 / -68) across 3 files Reviewer: cursor[bot] Review duration: 22m
    All Vouch review confidence checks passed
    Residual risk 0.18 = Change Risk (0.44) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.44 · 272 lines diff across 3 files
    0.44
    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.336
    Shallow Review Depth shallow_review_depth
    0.289
    Ai Authored ai_authored
    0.050
    Real PR Conversation Timeline
    1 comments
    "Review active on #3718"
    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: 44.5% (MEDIUM) · Higher = larger blast radius
    44.5%
    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: 17.6% · Safe to merge
    17.6%
    Repository