← Back to Pull requests

feat: add fail-closed span citation gate #12

Closed
unknown closed this pull request without merging on Oct 14, 2026 16:11 UTC
View on GitHub
unknown unknown commented on Oct 12, 2026 05:49 UTC
Author

Summary

  • add resolve_span() for validated half-open Python string offsets

  • add span_gate() with fail-closed offset, chunk-boundary, and optional quote checks

  • document the offset adapter in the README and hosted docs
  • Closes #9.

    Validation

  • python -m pytest -q — 28 passed

  • python bench/bench_gate.py — detection rate 1.0000 over 1221; false positive rate 0.1721 over 3371

  • git diff --check
  • The chunk-straddle regression failed before the implementation because span_gate did not exist. It now proves the span is rejected as not_found rather than clipped to the supplied chunk.

    Compatibility

    quote_gate() behavior and the existing verdict vocabulary are unchanged. The new APIs are pure stdlib and retain Python 3.9-compatible syntax.

    AI assistance

    Developed with OpenAI Codex assistance. I reviewed the implementation, tests, documentation, and benchmark results before submission.

    Diff: 116 lines (+87 / -29) across 1 files Reviewer: tonydzi Review duration: 3502m
    All Vouch review confidence checks passed
    Residual risk 0.16 = 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 · 116 lines diff across 1 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
    Shallow Review Depth shallow_review_depth
    0.289
    Diff Size diff_size
    0.285
    Ai Authored ai_authored
    0.050
    Real PR Conversation Timeline
    1 comments
    "Review active on #12"
    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: 36.5% (MEDIUM) · Higher = larger blast radius
    36.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: 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.8% · Safe to merge
    15.8%