Skip to main content

mts1b-githubbot

Claude-powered GitHub bot: AI issue triage + auto-fix PR + AI code review across all MTS1B repos.

Repo: github.com/MTS1B/mts1b-githubbot Layer: 7 Wave: 3 (months 8-12) Depends on: foundation, platform, llm Audience: every MTS1B contributor + maintainers

What it is

A GitHub App that watches every repo in the MTS1B org and:

  1. Triages new issues — labels, suggests duplicates, asks clarifying questions
  2. Auto-fixes simple bugs — opens a PR with the fix for review
  3. Reviews PRs — posts AI code review as a comment
  4. Suggests CI fixes — when CI fails, comments with the diff that would fix it

The bot output is advisory, not authoritative. A human maintainer always merges.

Architecture

GitHub event ──webhook──▶ mts1b-githubbot

├──▶ mts1b-llm (persona: "code_reviewer")
├──▶ mts1b-llm (persona: "bug_fixer")
└──▶ GitHub API (post comment / open PR)

Personas

Three LLM personas in mts1b-llm, used by this bot:

PersonaRole
triagerRead new issue → assign labels, link duplicates, ask for repro steps
code_reviewerReview PR diffs → flag bugs, style violations, design smells
bug_fixerRead issue + repo → propose a code change → open PR

Triage example

User opens issue:

Title: "HRP broken on small universes" Body: "Got AssertionError when running hrp_weights on 3 assets"

Bot responds:

👋 Hi @user, thanks for reporting!

Labels assigned: bug, mts1b-quantkit, allocators

Possible duplicate: #142 "HRP linkage fails for n < 4"

To help diagnose, could you share:

1. Your input array shape (`returns.shape`)?
2. The full traceback?
3. Reproduction command?

The maintainer typically responds within 24h. If urgent, ping #help in
our Discord: https://community.mts1b.investmentparadisellc.com

Code review example

PR opens. Bot comments:

🤖 AI Code Review

LGTM overall! 3 suggestions:

1. **Line 47: missing type annotation**
```python
def calculate_returns(prices): # → prices: pd.Series
return prices.pct_change().dropna()
  1. Line 89: docstring mismatch Docstring says returns dict but function returns HRPResult named tuple.

  2. Test gap: edge case missing test_hrp.py covers n >= 5 but not n < 3. Suggest adding:

    def test_hrp_too_few_assets():
    with pytest.raises(ValueError, match="need >= 4 assets"):
    hrp_weights(small_returns_df)

This review is advisory. A human maintainer will make the final call.


## Auto-fix PR example

For high-confidence simple bugs (typos, missing imports, deterministic test failures):

🤖 Auto-fix PR

I detected this looks like a simple typo bug. Opened #243 with the proposed fix.

A human maintainer will review before merging. If the fix is wrong, just close the PR and the bot will learn from the feedback.


The auto-fix is **gated** — only opens PRs for changes < 50 LoC, with passing local tests, and explicit confidence > 0.85 from the LLM.

## Module layout

mts1b_githubbot/ ├── app/ │ ├── webhook.py # FastAPI POST /github/webhook │ ├── signature.py # GitHub HMAC verification │ └── handlers/ │ ├── issue_opened.py │ ├── pull_request.py │ ├── check_suite.py │ └── ... ├── triager/ │ ├── label_classifier.py │ ├── dupe_finder.py │ └── clarify_questioner.py ├── reviewer/ │ ├── diff_analyzer.py │ └── style_checker.py ├── bug_fixer/ │ ├── repro_runner.py # tries to reproduce + fix locally │ └── pr_builder.py └── governor/ └── budget.py # daily LLM budget cap


## Budget controls

LLM calls cost money. Per-org daily budget enforced via `mts1b-llm` governor:

```yaml title="mts1b-githubbot/config.yaml"
budget:
daily_usd: 5.0
per_repo_daily_cap: 1.0
expensive_actions:
bug_fixer: 0.20 # max $0.20 per attempt
code_reviewer: 0.05
triager: 0.01

When budget exhausts: bot continues to triage cheaply but stops opening fix PRs until next day.

Safety

SafetyMechanism
Bot can't push to mainAlways opens PR, never direct commit
Bot can't mergeNo contents: write on protected branches
Bot can't change CI.github/workflows/ is in CODEOWNERS protected paths
Bot can't access secretsGitHub App, read-only on most scopes
Bot output flaggedEvery comment starts with 🤖 AI

Installation

# Initial install (one time, by org owner)
mts1b-githubbot install \
--org MTS1B \
--app-id <github_app_id> \
--private-key-path /etc/mts1b/githubbot.pem

# Verify
gh app installation list --org MTS1B
# mts1b-githubbot: installed, 29 repos

Self-hosting

The bot runs as a regular MTS1B service:

# mts1b.config
optional:
githubbot: true

After mts1b-deploy install, the webhook endpoint is at:

https://mts1b.investmentparadisellc.com/githubbot/webhook

Set this in the GitHub App config.

Build + test

pip install -e ".[dev]"
pytest -m unit
# Live test against a sandbox repo
GITHUB_APP_PRIVATE_KEY=... pytest -m live

Roadmap

VersionItems
0.1 (Wave 3)Triager + code reviewer + simple auto-fix
0.2 (Wave 3)Complex multi-file refactors with maintainer chat
0.3Documentation auto-updater (when API changes)
1.0 (LTS)Stable persona API

See also