← Back to Pull requests

Checkpoint sync state on all cancellation types, not just DeadlineExceeded #738

Closed
unknown closed this pull request without merging on Jul 23, 2026 15:28 UTC
View on GitHub
unknown unknown commented on Mar 16, 2026 15:46 UTC
Author

Summary

  • Checkpoint sync state when the context is cancelled for any reason (SIGTERM, etc.), not just DeadlineExceeded

  • Use a background context with 30s timeout for the checkpoint since the caller's context is already cancelled

  • Broaden cleanup error handler to treat any context cancellation as ErrSyncNotComplete
  • Problem

    When a sync worker receives SIGTERM, the sync context is cancelled but context.Cause() returns a cancellation error, not DeadlineExceeded. The default: branch in both sequentialSync and parallelSync exited without checkpointing, losing all progress since the last periodic checkpoint. This forced a full re-sync of those pages on the next attempt.

    Changes

  • pkg/sync/parallel_syncer.go: Both sequentialSync and parallelSync now checkpoint in the default: cancellation case using context.WithTimeout(context.Background(), 30*time.Second)

  • pkg/sync/syncer.go: Cleanup error handler uses runCtx.Err() != nil instead of errors.Is(err, context.DeadlineExceeded) to catch all cancellation types
  • Notes

    This is a rewrite of #694 against current main. The original PR couldn't be rebased because the sync loop was refactored into sequentialSync/parallelSync methods. Supersedes #694.

    Note: pkg/sync has a pre-existing test timeout on main (not introduced by this PR).

    🤖 Generated with Claude Code

    Diff: 175 lines (+131 / -44) across 2 files Reviewer: arreyder Review duration: 185741m
    All Vouch review confidence checks passed
    Residual risk 0.14 = Change Risk (0.35) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.35 · 175 lines diff across 2 files
    0.35
    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.309
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #738"
    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: 35.4% (MEDIUM) · Higher = larger blast radius
    35.4%
    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: 14.0% · Safe to merge
    14.0%