← Back to Pull requests

fix(research): add a follow-up approval's budget once; refuse approving unpublished listings #236

Merged
abendrothj merged 8 files (501 lines) on Nov 16, 2026 23:48 UTC
View on GitHub
abendrothj abendrothj commented on Nov 13, 2026 12:03 UTC
Author

What and why

Part of #96.

  • A follow-up access request's approval now adds its query budget to the existing grant. Before, BudgetLedger::open only inserts, so the steward's budget was dropped and an exhausted grant stayed at 0. Approvals use the new BudgetLedger::top_up_once, keyed by the request, so a retry of the same approval adds nothing.

  • A retry of an approval whose grant was revoked after the approval is refused (404, audited), even if the grant has been re-granted since. Without this, the stale retry would add its budget to the newer grant. Grants record revoked_at_iso for this check. A durable grant store must keep revoked_at_iso (pinned by a unit test in grants.rs).

  • A pending request whose listing was unpublished can't be approved (404, audited); it can still be denied.
  • Still open on #96: cancelling pending requests when a dataset is deleted, which needs dataset deletion (P42). The same budget drop on direct re-grants is #235.

    How it was tested

    New tests in research_api.rs, each failing on main: follow-up approval adds its budget (limit 2 vs 5), approving for an unpublished listing is 404, and a stale retry after revoke and re-grant is 404 and adds nothing. audit_coverage.rs checks the new refusal events exactly. top_up_once has a unit test in budget.rs.

    Checklist

  • scripts/check.sh passes locally (except the all-refs secret scan fixed by #230)

  • Every new refusal has a negative test

  • Every new security decision emits a SECURITY_AUDIT_EVENT covered by audit_coverage.rs

  • Fails closed on missing configuration, key material, or attestation

  • No new cryptographic primitives; suites stay behind their type aliases

  • Synthetic or public data only (docs/DATA_POLICY.md)

  • Docs and CHANGELOG.md updated for user-visible changes

  • Architectural decision recorded in docs/adr/ if one was made (none made)
  • Diff: 501 lines (+433 / -68) across 8 files Reviewer: AxolDad Review duration: 5024m
    All Vouch review confidence checks passed
    Residual risk 0.29 = Change Risk (0.50) × (1 − Review Confidence (0.43)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.50 · 501 lines diff across 8 files
    0.50
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.02 · 1 substantive comment(s)
    0.02
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    42%
    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.372
    Shallow Review Depth shallow_review_depth
    0.344
    Real PR Conversation Timeline
    1 item
    "Review active on #236"
    general weight: 0.35
    Reviewers
    Assignees
    abendrothj abendrothj
    Labels
    risk: low confidence: 43.0% 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: 50.5% (MEDIUM) · Higher = larger blast radius
    50.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: 43.0% · Lower = rushed or shallow review
    43.0%
    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: 28.8% · Safe to merge
    28.8%