← Back to Pull requests

:bug: Verify commit-pinned results in `scorecard mcp` #5420

Closed
unknown closed this pull request without merging on Nov 18, 2026 11:35 UTC
View on GitHub
unknown unknown commented on Nov 05, 2026 13:34 UTC
Author

What kind of change does this PR introduce?

Bug fix: normalize commit-pinned lookups in scorecard mcp and verify the commit the REST API returns.

  • PR title follows the guidelines defined in our pull request documentation
  • What is the current behavior?

    For requests that pass commit:

  • Uppercase SHAs pass validation but go to ?commit= unchanged. The REST API matches only lowercase SHAs, so they 404.

  • A 404 for the requested commit becomes the generic not-found error, which says the repository has no published results and may not have opted in, even when results for the latest commit exist.

  • When the API omits repo.commit, the result reports the requested commit as resolved, and a returned repo.commit that differs from the request goes unnoticed.
  • What is the new behavior (if this is a feature change)?

  • The provider lowercases the SHA before the request.

  • A 404 for a pinned commit returns a commit-specific error that says to omit commit to get the latest published results.

  • A pinned response whose repo.commit is missing or differs from the request is rejected, so a result never reports a commit the API didn't confirm.
  • Tests for the changes have been added (for bug fixes/features)
  • Which issue(s) this PR fixes

    Fixes #5403

    Special notes for your reviewer

    Rebased onto main. The last commit makes the commit-specific not-found message point to the latest results, since #5403 notes they may exist when the pinned commit has none.

    Rejecting a pinned response without repo.commit, rather than returning it with an empty commit, is a deliberate choice: without it the provenance can't be verified.

    go test ./cmd/internal/mcp/... passes, and golangci-lint v2.15.0 reports 0 issues on ./cmd/internal/mcp/provider/. Against api.scorecard.dev, the uppercase SHA from #5403 (2EF237F4…) now returns the result for 2ef237f4…, an unscanned commit returns the commit-specific error, and an unpinned request still returns the latest result.

    Does this PR introduce a user-facing change?

    ``release-note
    scorecard mcp lowercases commit SHAs before querying published results, reports a missing result for a pinned commit separately from a repository with no results, and rejects results whose commit doesn't match the requested one.
    ``

    Diff: 299 lines (+224 / -75) across 3 files Reviewer: justaugustus Review duration: 18600m
    All Vouch review confidence checks passed
    Residual risk 0.16 = Change Risk (0.40) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.40 · 299 lines diff across 3 files
    0.40
    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.341
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #5420"
    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: 40% (MEDIUM) · Higher = larger blast radius
    40%
    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: 15.8% · Safe to merge
    15.8%
    Repository