← Back to Pull requests

P27 #156

Closed
unknown closed this pull request without merging on Oct 31, 2026 19:01 UTC
View on GitHub
unknown unknown commented on Oct 31, 2026 04:21 UTC
Author

What and why

Closes #47 (P27 in docs/V1_PLAN.md: access-request approval converges after a partial failure, and never fails open).

resolve_access_request marked a request Approved before it looked up the listing and minted the grant and budget. If one of those later steps failed (a registry error, 502), the retry got 404, because resolve only acts on Pending requests. The request stayed Approved with no grant, and the comment saying retries converge was wrong.

  • Retries converge. When a request's own steward approves it again after it's already Approved, the connector-slug, listing, grant and budget steps run again (all idempotent) and the call returns 200. The request is found with the existing CatalogRegistry::list_requests_for, filtered to the calling steward and Approved status, so the trait doesn't change.

  • Order unchanged, on purpose. The approval is still recorded before the grant is minted. A partial failure can leave an Approved request without a usable grant (fail closed), never a grant behind a Pending or Denied request. Minting first would leave a live grant behind a Pending request whenever resolve failed afterwards.

  • Deny stays Pending-only. A deny after a failed approval is refused with 404, and Denied stays terminal.

  • No existence oracle. The researcher, other tenants and unknown ids still get the same 404.

  • Approving again re-activates a grant the steward has since revoked (GrantRegistry::create un-revokes), the same as a direct re-grant. Only the request's steward can do it.

  • Docs: the comment on resolve_access_request, the CatalogRegistry::resolve doc, the Catalog paragraph in docs/ARCHITECTURE.md, and a CHANGELOG.md entry under Fixed. This lands before P61, so its conformance suite can pick up the resolve contract.
  • <!-- What changed, and why. Link the issue or the step in docs/PROJECT_SCOPE.md. -->

    How it was tested

    New tests in backend/crates/platform-api/tests/research_api.rs, using stores that fail one call once (FailFirstOpen budget ledger, FailFirstCreate grant registry):

  • approval_retried_after_a_budget_failure_converges: budget open fails → 502; the request lists as approved; a research query → 429 (the grant has no ledger entry); the retry → 200 with an active grant funded with the listing's budget (25); a query → 200 with 24 remaining.

  • deny_after_a_failed_approval_is_refused: grant create fails → 502; deny → 404; the steward has no grants and a research query → 403; the retry → 200 and queries work.

  • approval_retry_by_a_non_steward_is_404: once the request is approved, approving it as the researcher, as another tenant, or with an unknown id → 404; the steward's own retry → 200.

  • approving_a_denied_request_is_404: deny, then approve → 404, and a research query → 403.
  • The catalog.rs unit test request_lifecycle_pending_idempotent_and_resolution now also checks that approving an Approved request again returns None while the request still lists as Approved for its steward. The retry relies on that contract.

    Failure paths covered: grant-registry failure, budget-ledger failure, deny after a failed approval, retry by a non-steward or with an unknown id, approve after deny.

    <!-- Tests added or changed. Name the failure paths covered. -->

    Checklist

  • scripts/check.sh passes locally

  • [X ] Every new refusal has a negative test

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

  • [ X] Fails closed on missing configuration, key material, or attestation

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

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

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

  • [ X] Architectural decision recorded in docs/adr/ if one was made
  • Diff: 481 lines (+360 / -121) across 6 files Reviewer: abendrothj Review duration: 880m
    All Vouch review confidence checks passed
    Residual risk 0.20 = Change Risk (0.47) × (1 − Review Confidence (0.57)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.47 · 481 lines diff across 6 files
    0.47
    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.370
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #156"
    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: 47.3% (MEDIUM) · Higher = larger blast radius
    47.3%
    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: 20.4% · Safe to merge
    20.4%