← Back to Pull requests

fix(research): never re-activate a revoked grant on an approval retry #168

Closed
unknown closed this pull request without merging on Nov 08, 2026 10:26 UTC
View on GitHub
unknown unknown commented on Nov 01, 2026 10:07 UTC
Author

What and why

Fixes #166.

An approval that fails partway leaves the request Approved without a usable grant, and the steward retries it. A retry finishes that decision; it never makes a new one.

  • A retry never re-activates a revoked grant. The retry checks for a revoked grant and creates the grant in one registry step, GrantRegistry::create_unless_revoked, so a revoke that lands while the retry runs also holds. A retry that finds the grant revoked is refused with 404 and audited as denied (reason=revoked). First approvals and explicit re-grants still use create. A persistent GrantRegistry backend must implement create_unless_revoked as a conditional insert or a transaction.

  • A retry keeps the approved budget. The approval records its query budget on the request (approved_budget: the steward's query_budget, else the listing's included budget), and a retry opens that budget. A retry that names a different query_budget is refused with 400 and audited as denied (reason=budget).
  • Retries are audited with retry=true.

    Follow-up: #<issue> (retry an approval from the steward portal after a 502).

    How it was tested

  • platform-tenancy: create_unless_revoked_creates_then_is_idempotent, reactivation_by_create_unless_revoked_is_refused (a revoked grant stays revoked, no second grant is minted beside it, an explicit re-grant still re-activates it) and approval_records_its_budget.

  • research_api.rs: approval_retry_after_a_revoke_is_refused, half_finished_approval_retry_after_a_revoke_is_refused, approval_retry_racing_a_revoke_is_refused (a wrapper registry revokes the grant after the retry starts and before its grant step: 404, the grant stays revoked, the research query stays 403), approval_retry_with_a_different_budget_is_refused (400, budget unchanged) and approval_retry_after_a_budget_failure_keeps_the_approved_budget.

  • audit_coverage.rs: research_catalog_is_audited asserts the retry=true approval and both refused retries (reason=revoked, reason=budget).

  • scripts/check.sh passes on the rebased branch.
  • Checklist

  • scripts/check.sh passes locally

  • 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: N/A
  • Diff: 334 lines (+250 / -84) across 4 files Reviewer: abendrothj Review duration: 10098m
    All Vouch review confidence checks passed
    Residual risk 0.17 = Change Risk (0.42) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.42 · 334 lines diff across 4 files
    0.42
    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.348
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #168"
    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: 42.2% (MEDIUM) · Higher = larger blast radius
    42.2%
    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: 16.7% · Safe to merge
    16.7%