← Back to Pull requests

Make `when` a curried guard: `when(pred)(sink)` #12462

Closed
unknown closed this pull request without merging on Nov 06, 2026 19:44 UTC
View on GitHub
unknown unknown commented on Nov 05, 2026 01:14 UTC
Author

Description

when was the one selector in exception_policy.cuh that took its sink as a second argument, when(pred, sink). Every other selector applies to a sink: if_isa<E>(s), if_monomorphic<E>(s), if_equal(v...)(s), thrown(s), returned(s). This PR gives when the same shape, when(pred)(sink), and removes the two-argument form.

when is now the guard class template itself. when(pred) deduces the predicate type by CTAD and is a sink in its own right; applying it to a sink yields when(pred) & sink, exactly what the two-argument function returned. The former when_t type and the free function are gone, so there is one entity instead of two. A guard can be named and applied to several sinks:

auto transient = when(is_transient);
transient(retry(3)) | transient(notify(log))

Semantics are unchanged. The predicate is stored by value, where the old forwarding-reference deduction held an lvalue predicate by reference. The predicate still takes either nothing or the const std::exception* of the failure in flight.

when has no callers outside the header's own unit tests, so the change is confined to exception_policy.cuh. All test call sites are converted and a new test covers a named guard applied to two arms.

Checklist


  • New or existing tests cover these changes.

  • The documentation is up to date with these changes.
  • 🤖 Generated with Claude Code

    Diff: 181 lines (+135 / -46) across 2 files Reviewer: caugonnet Review duration: 2549m
    All Vouch review confidence checks passed
    Residual risk 0.15 = Change Risk (0.36) × (1 − Review Confidence (0.57)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.36 · 181 lines diff across 2 files
    0.36
    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%
    56%
    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.311
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #12462"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 56.8% 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.6% (MEDIUM) · Higher = larger blast radius
    35.6%
    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: 56.8% · Lower = rushed or shallow review
    56.8%
    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: 15.4% · Safe to merge
    15.4%
    Repository