Skip to content

Automate changes with MetergraphBot

MetergraphBot is a GitHub App that turns an approved recommendation into a pull request in your own repository. Installing it is optional. Recommendations and their evidence are there whether or not it ever touches your code, and you can always implement a change by hand.

A person approves. A person reviews. A person merges. MetergraphBot never merges anything.

When you approve a recommendation in the dashboard, MetergraphBot creates a branch, commits the change and the evidence behind it, and opens exactly one pull request per recommendation. Re-running lands on the same deterministic branch rather than piling up duplicates. If a route regresses, it can also open an issue.

The pull request goes to your repository, using the installation you granted. This is the one integration in Metergraph that is genuinely per-workspace.

PermissionWhy
contents:writeCreate the branch and commit the code change and evidence files
issues:writeOpen an issue when a route regresses
pull_requests:writeOpen the pull request, reusing the same deterministic branch

Nothing else. It requests these scopes for the repositories you select, and no others.

  1. MetergraphBot can only propose a change to a file it can locate. That needs the repository on the captured rows, which the SDK sends from version 0.4 onward. Set it once:

    .env
    METERGRAPH_REPOSITORY=your-org/your-repo

    Or init(repository="your-org/your-repo"). Without it the SDK warns at startup and keeps capturing, but a recommendation built from those traces cannot be delivered.

  2. Install MetergraphBot from its GitHub App page and choose all repositories or only selected ones, the same choice GitHub offers for any App. It acts only on what you grant.

  3. Register the installation with your workspace

    Section titled “Register the installation with your workspace”

    Installing on GitHub is one half. Metergraph also has to record which installation belongs to which repository in your workspace, verify it, and release any deliveries that were waiting on it:

    Owner or member, authenticated by your dashboard session
    curl -X POST https://app.metergraph.dev/v1/github-installations \
    -H "Content-Type: application/json" \
    -H "Cookie: metergraph_session=..." \
    -d '{"repository": "your-org/your-repo", "installation_id": 12345678}'

    The installation id is the number in the URL of the App’s settings page for your organization.

  4. Open the recommendation, read its evidence, and approve it. Owners and members can approve; a viewer can watch the status but not approve.

The recommendation shows its delivery status, and GET /v1/recommendations/{id}/delivery-status returns the same thing to any role, viewers included.

StatusMeaning
awaiting_bot_activationApproved, waiting for a verified installation for that repository
pendingQueued for the bot
claimedThe bot is generating the pull request
retryA transient failure. The next attempt time is on the row
blockedStopped for a stated reason, which the row carries
awaiting_pr_approvalThe pull request is open and waiting for your review
recommendation_appliedThe pull request was merged
declinedClosed without merging, or cancelled

Retries back off on a fixed schedule: 30 seconds, 2 minutes, 10 minutes, 1 hour, 6 hours, then every 24 hours, and they do not give up on their own. Cancel a delivery you no longer want with POST /v1/recommendation-deliveries/{id}/cancel.

Approval returns a 409 with a reason rather than failing quietly:

ReasonWhat to do
not_recommendedThe evidence did not reach a recommendation. There is nothing to deliver
no_samplesThe analysis behind it has no source calls
legacy_protocol_tracesSome source traces came from an SDK older than v0.4 and carry no repository. Upgrade the SDK and capture again
mixed_repositoryThe source traces come from more than one repository, or from none. Metergraph will not guess which repository to change
unknown_recommendationWrong id, or it belongs to another workspace

Revoke access from the App’s page in your GitHub organization or account settings. Automation stops immediately for the repositories you remove. Recommendations, evidence and captured traces are unaffected, and pull requests already open stay open for you to merge or close.