MC Prevent: PR review & CI gate

Bayes is Monte Carlo’s AI teammate. It observes your agents and the data that powers them, finds what breaks, proposes and verifies fixes, and gets better at your environment over time.

MC Prevent is how Bayes catches risky data changes before they reach production:

  • PR review: Bayes reviews pull requests and posts a risk assessment comment.
  • CI merge gate: Bayes enforces a merge gate in your CI pipeline based on that assessment.

Requires the GitHub integration. For Bayes to identify affected tables when it reviews a PR, also set up dbt integrations.


PR review

Bayes reviews pull requests in your enabled repos and posts an explainable risk assessment comment. It identifies data assets affected by the PR, scores the overall risk as Low, Medium, or High, and surfaces concrete checks to complete before merging.

This PR assessment is also the source of truth for the CI merge gate. If you add the CI merge gate to GitHub Actions or CircleCI, it reads Bayes' PR assessment and applies your configured gate policy.

Turning on PR review

Bayes won't comment on any pull request until you add repos to the PR review allowlist. New installations start with an empty allowlist.

  1. Go to Settings → Integrations → GitHub.
  2. Click into the organization you want to configure.
  3. In the Edit connection drawer, open the Settings tab.
  4. Add repos under Enable PR Agent for these repos.

PR review must also be on for your account. Go to Settings → AI Agents and toggle PR Agent.

What Bayes evaluates in a PR

  • Which Monte Carlo-monitored tables are affected by the PR's file changes
  • Code review findings from the PR diff
  • Schema and contract changes, such as removed columns, renamed fields, and type changes
  • Downstream lineage and blast radius, including Key Assets
  • Asset criticality
  • Active open alerts on impacted or upstream assets
  • Monitor coverage gaps
  • Validation opportunities for dbt model SQL changes

Triggers

  • Automatically when a PR is opened in an allowlisted repo
  • On demand by creating a PR comment that says mc review (case-insensitive)

Bayes does not automatically re-review a PR on every new commit. After pushing a fix or meaningful update, comment mc review to request a fresh assessment for the new head commit.

Repo allowlist

The allowlist controls which repos Bayes reviews and comments on, per installation. Existing installations had their allowlist seeded with the repos that already have dbt projects connected to Monte Carlo. New installations start empty.

If the allowlist is empty, Bayes will not post on any PR in that installation. Commenting mc review on a non-allowlisted repo has no effect.

Programmatic access is available via the experimental getPrAgentConfig query and updatePrAgentConfig mutation on the GraphQL API.

Enabling and disabling PR review

To enable or disable PR review for your account, go to Settings → AI Agents and toggle PR Agent.

When PR review is disabled, Monte Carlo falls back to the legacy impact assessment comment if that feature is enabled on your account.

Adjusting PR review usage

You control how much PR review your account uses from Settings → AI Agents:

  • Do not restrict (default): every pull request receives a full review.
  • Limit to free usage only: every pull request still receives a free review (risk score and summary), and the account is never charged for full reviews.

You can switch between these at any time, and the change takes effect on subsequent pull requests. Limit to free usage only caps usage immediately without disabling the integration. PRs keep getting reviewed at the free level.

Free review vs. full review

A free review runs on every pull request and is never charged. It gives you a fast read on whether a change is risky and why. A full review goes further: it tells you which parts of the change are risky and what to do about them before the PR merges.

CapabilityFree reviewFull review
Runs on every pull request✅✅
Overall risk score (Low / Medium / High)✅✅
Control over how the risk score is calculated✅✅
Plain-language summary of the PR and its risk✅✅
Details of the risky parts of the change, each with a specific suggested fix—✅
Auto-generated SQL validation queries for the change—✅
Warnings about open alerts on upstream assets—✅
Suggestions for monitor coverage gaps the change exposes—✅

What the PR comment looks like

When Bayes reviews a PR, it posts a rubric-based comment with the following sections:

  • Risk title. PR Risk: Low | Medium | High, including the overall score out of 10.
  • Risk summary. A short callout explaining the main reason for the rating and the highest-risk issue to review.
  • Risk score calculations. An expandable table showing each rubric category, score, configured weight, weighted contribution, and rationale.
  • Validation Notebook. When dbt SQL changes are detected, Bayes can generate a SQL Notebook with validation queries. The comment includes the detected validation focus, model count, query count, notebook link, and required parameters.
  • Code review findings. Actionable findings from the PR diff, shown as checklist items with suggested fixes. Additional findings may be collapsed to keep the comment readable.
  • Open alerts. When relevant, active Monte Carlo alerts on modified or upstream assets.
  • Monitoring gap. Key assets in the change's blast radius that don't have Monte Carlo monitor coverage, including asset links and scope.
  • Feedback prompt. React with 👍 or 👎 on the bot comment to send feedback to Monte Carlo. Reactions are collected when the PR closes.

For very large PRs, the diff may be truncated before analysis. Bayes notes this in the comment when it happens.

Risk factor weights

You can tune how Bayes weights each risk factor when calculating the overall PR risk score.

  1. Go to Settings → Integrations → GitHub.
  2. Click into the organization you want to configure.
  3. In the Edit connection drawer, open the Settings tab.
  4. Under Risk factor weights, adjust the category percentages.
Risk factorDescriptionDefault
Code review findingsRisks intrinsic to the code changes40%
Lineage blast radiusDownstream assets that may be affected15%
Open alertsUnresolved Monte Carlo alerts on modified tables and upstream feeders15%
Monitoring gapMonitor coverage on modified, upstream, and downstream assets15%
Schema & contract changesColumn removes, renames, type changes, primary key changes, and contract breaks10%
Asset criticalityHow much the directly changed asset matters to the business5%

Weights must be whole-number percentages and must sum to 100%. Monte Carlo shows the live total while you edit, and the Normalize button rescales the current values to 100% while preserving their relative proportions.

Changes apply to new PR reviews for that GitHub installation. Existing PR comments and check runs are not recalculated automatically. Comment mc review on a PR to request a fresh assessment using the latest configuration.

Missing permissions

If the GitHub App is missing the required contents:read permission on a repo, Bayes posts a "missing permissions" comment with a link back to these docs. Re-authorize the app in GitHub → Settings → Applications → Monte Carlo to grant the permission.

Verifying PR review

Open a new pull request in an allowlisted repo. The Monte Carlo bot should post a PR Risk comment, and an MC Prevent: PR Risk Rubric check run should appear.


CI merge gate

The CI merge gate is an optional step you add to GitHub Actions or CircleCI that lets Bayes gate merges. It reads Bayes' PR risk assessment, applies your gate policy, and posts an MC Prevent: CI Gate Result check run.

When combined with GitHub branch protection rules, the CI merge gate can block PRs whose risk tier meets your configured threshold.

PR review vs. CI merge gate: when Bayes reviews a pull request, it produces the MC Prevent risk assessment. The CI merge gate is the enforcement step. Add it to your CI pipeline when you want a required check that can block merges based on the PR risk tier.

Turning on the CI merge gate

The CI merge gate requires PR review to be on for the repo.

Choose your CI platform:

Each repository includes setup instructions, examples, and parameter documentation.

To block merges, make MC Prevent: CI Gate Result a required status check in your GitHub branch protection rules.

How it works

  1. The CI merge gate runs on pull request events. Draft PRs are skipped.
  2. It calls Monte Carlo's /ci/assess API with the repo, PR number, commit SHA, and optional CI policy.
  3. Monte Carlo fetches Bayes' PR rubric assessment from GitHub.
  4. The PR risk score is mapped to a risk tier:
    • < 3.5 = low
    • < 6.5 = medium
    • >= 6.5 = high
  5. Monte Carlo compares the tier against your block-on policy and returns pass or fail.
  6. The result appears in the CI job output, step summary, and the MC Prevent: CI Gate Result check run.

If no assessment is available for the current commit, the CI merge gate can reuse the cached CI Gate verdict from a previous workflow run on the same branch.

Gate policy

Use block-on to choose which risk tiers fail CI.

SettingBehavior
low+Block low, medium, and high risk PRs
medium+Block medium and high risk PRs
high+Block only high risk PRs
noneNever block. Show results only.

When block-on is not set in CI, Monte Carlo uses the policy configured in the UI.

Configuration precedence

Monte Carlo resolves the effective policy in this order:

  1. block-on in the CI workflow or CircleCI job
  2. Per-repo override in the Monte Carlo UI
  3. Installation-wide default in the Monte Carlo UI
  4. System default: medium+

Use CI-level block-on only when a specific pipeline needs to override the central UI policy.

Configure in the Monte Carlo UI

  1. Go to Settings → Integrations → GitHub.
  2. Click into the organization you want to configure.
  3. In the Edit connection drawer, open the Settings tab.
  4. Under MC Prevent CI Configuration, set:
    • Default gate behavior: applies to all repos in the GitHub installation.
    • Per-repo overrides: exception rules for specific repos.

Per-repo overrides are useful when one repo should gate differently than the org default. For example, use high+ for an experimental repo while keeping medium+ as the default for production repos.

Remediating a failed gate

If MC Prevent blocks a PR, push the fix first, then comment mc review on the PR to have Bayes review the new head commit.

The CI merge gate uses the latest PR assessment available for the commit being checked. If Bayes finishes its review while CI is still polling, the gate can pick up the updated assessment automatically. If no assessment exists before CI times out, the previous verdict is preserved so the gate never silently downgrades. To get an updated assessment, comment mc review and rerun CI.

Override

Add the mc-override label to a PR to bypass the CI merge gate. The gate returns pass, and Monte Carlo posts a green MC Prevent: CI Gate Result check run for the current commit, so no new commit or CI re-run is required. Override activity is recorded in service logs.

Anyone who can apply labels to pull requests can override the gate. To control who can bypass it, restrict who can apply labels.

Progressive adoption

StageResult
CI step added, credentials missingPass. Skips without an API call.
Credentials configured, PR review disabled or repo not allowlistedPass after polling with no assessment
Credentials configured, PR review enabled and repo allowlistedFull risk-tier gate result

See the GitHub Action and CircleCI setup guides for how to set up credentials.

Verifying the CI merge gate

The MC Prevent: CI Gate Result check run appears on pull requests after Bayes posts its PR assessment.


Limitations

  • Bayes reviews a PR when it is opened in an allowlisted repo. It does not automatically re-review every new commit. After pushing a fix, comment mc review to request a fresh assessment for the new head commit.
  • Very large files may be skipped for full-content inspection. Bayes can still review the PR diff, but individual file reads are limited.
  • MC Prevent currently runs on GitHub only. GitLab and Azure DevOps PRs are supported for incident-chart PR overlays, but not for Bayes PR reviews or the CI merge gate.

FAQ

Q: Bayes isn't commenting on PRs in one of my repos. Why?

Check the repo allowlist: Settings → Integrations → GitHub → (org) → Edit connection → Settings → Enable PR Agent for these repos. If the repo isn't in the list, add it. The allowlist applies to both auto-triggered reviews and manual mc review comments.

Q: Can I trigger a PR review manually?

Yes. Comment mc review on any PR in an allowlisted repo to trigger a new assessment. This is useful after pushing changes to address a prior risk finding. Create the comment after the new commit is pushed so Bayes reviews the latest head commit.

Q: How do I turn PR review off?

  • For a specific repo: remove it from the allowlist at Settings → Integrations → GitHub → (org) → Edit connection → Settings.
  • For the whole account: go to Settings → AI Agents and toggle PR Agent off. You will fall back to the legacy impact assessment comment if that feature is enabled on your account.

Q: I set up the GitHub integration but didn't add the CI merge gate. Will I still get risk assessments?

Yes, on repos in the PR review allowlist. The CI merge gate is only needed if you want a pipeline gate that can block merges based on that assessment.

Q: The CI merge gate is waiting but never getting an assessment. What's happening?

The CI merge gate looks for a PR assessment from Bayes on the commit being checked. Common causes:

  • The repo is not in the PR review allowlist. Add the repo, then comment mc review on the PR to trigger an assessment.
  • Bayes has not reviewed the latest commit yet. After pushing a fix, comment mc review to request a fresh assessment for the new head commit.
  • Bayes is still reviewing the PR. The CI merge gate polls every 30 seconds for up to 5 minutes by default. If no assessment is found for the current commit, it may reuse a cached verdict from a previous commit. If no cached verdict exists, it defaults to pass.

If Bayes' PR reviews consistently take longer than the polling window, increase the max-wait input.


Did this page help you?