← Back to Pull requests

feat(api): wire research access without key release (P43) #204

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

What and why


Implements P43 in docs/V1_PLAN.md ("Wire research access in the production binary, independently of key release"). It moves toward definition-of-done items 2 and 3 in docs/PROJECT_SCOPE.md.

Catalog, access requests, grants and budgets need no key material. They lived on ConnectorQueryService, though, and the binary builds that only when key release is configured. So in the shipped binary every catalog, access-request, grant and budget route answered 503, and nothing in the research portal past sign-in could run against it.

  • research::ResearchService holds the grant, budget and catalog stores, the default budget and k. It is its own AppState field (AppState::research). The catalog, access-request, grant and budget handlers depend only on it, and answer 503 "research access not configured" when it is missing.

  • There is one source of truth. ConnectorQueryService::with_research takes the same Arc<ResearchService>, and research_query checks and charges grants through it, so the grant a route creates is the one a research query checks and charges. The query service also takes k from it, so RESEARCH_MIN_COHORT_SIZE still reaches own-data ZK queries.

  • State construction moves out of main() into platform_api::wiring::build_state, which tests call to run the binary's exact wiring. It always builds research access from config.research over in-memory stores, and logs a startup warning that they are lost on restart (P62 makes them durable). The query, research-query and attestation routes still need key release and still answer 503 without it. Attestation stays required, and no dev key provider is used.

  • Approval-retry behaviour is unchanged. approved_budget, create_unless_revoked and the retry=true/denied audit events move to ResearchService as they were.

  • DevResearchStack::query_service and query_service_with_attestation now take the Arc<ResearchService> in place of the cohort size and default budget. Devstack and the test builders create one Arc and give it to both the query service and AppState.
  • How it was tested


    New tests in platform-api/tests/research_wiring.rs run against the binary's own wiring (build_state with only JWT_HS256_SECRET set):
  • the_binary_wires_research_access_without_a_query_service: research access is wired and the query service is not.

  • research_routes_answer_while_queries_stay_fail_closed: publish, browse, request, list requests, approve (with the listing's budget) and a direct grant all answer 200. POST /api/v1/research/query and POST /api/v1/query answer 503 "confidential query not available", and the refused research query charges nothing.

  • research_routes_refuse_without_a_research_layer: with no research service, all twelve catalog, access-request, grant and budget routes answer 503 "research access not configured".
  • Existing tests changed only in setup: they set the new field, and the research-enabled builders share one Arc. No assertions changed. The approval-retry tests, research_catalog_is_audited and the rest of audit_coverage.rs pass through the new path.

    scripts/check.sh passes in full: fmt, check and clippy (-D warnings, workspace, all targets, --locked), 447 Rust tests, the wasm and frontend steps (164 frontend tests), and the guards. platform-api also checks and lints cleanly without the dev feature.

    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
  • Diff: 492 lines (+369 / -123) across 6 files Reviewer: abendrothj Review duration: 2989m
    All Vouch review confidence checks passed
    Residual risk 0.19 = Change Risk (0.47) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.47 · 492 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%
    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.371
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #204"
    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: 47.4% (MEDIUM) · Higher = larger blast radius
    47.4%
    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: 18.7% · Safe to merge
    18.7%