Skip to content
项目

关于

🤖 Hydra Maintainer— A FastAPI-based GitHub automation bot that streamlines maintainer workflows with PR health scoring, reviewer recommendations, issue management, and a live analytics dashboard.

网站与应用开发

这些数字如何统计

实测星标增长

24小时
0
7天
+1
15天
+2
1个月
正在收集历史

各周期内的星标净变化,周期相互重叠,并非每日新增。缺失的测量保持空白。星标代表关注度,不代表软件质量。

README.md

原文
hydra-maintainer logo

hydra-maintainer

A self-hostable, open-source automation platform for open-source maintainers.

PR health scoring · reviewer recommendation · contributor progression tracking · optional AI-assisted review · persistent audit trail · REST API

Python 3.11+ License: MIT CI FastAPI GitHub Marketplace

Live dashboard · Project site · Marketplace listing


No SaaS lock-in. No vendor hosting your repository data. Your bot, your database, your rules.

The problem

Every healthy open-source project eventually runs into the same bottleneck: a small number of unpaid maintainers doing manual, repetitive triage — checking DCO sign-off, screening first-time contributors, chasing stale issues, deciding who's ready to become a committer, recommending a reviewer who actually knows the file being changed. None of this is written down anywhere; it lives in a maintainer's head until they burn out and it's lost.

The tools that exist to help fall into two camps:

  • Commercial SaaS bots (Mergify, CodeRabbit, Greptile, etc.) — capable, but closed-source. Your repository data, review history, and contributor metrics live on someone else's servers, behind a subscription that can change price or disappear.
  • Single-purpose OSS bots (probot apps, stale-bot, welcome-bot) — free and self-hostable, but each solves one narrow problem with no shared data model, no persistent history, and nothing that helps a project reason about its own contributor pipeline over time.

Nobody has a self-hosted, open-source system that treats maintainer-ops as a whole — with a real database, an audit trail, and a data model for how contributors grow inside a project, not just whether a single PR passes a gate.

What it does

hydra-maintainer is a GitHub App (FastAPI + SQLAlchemy async + Postgres/SQLite) that runs entirely on infrastructure you control. It was built for and tested against the Hiero (Linux Foundation Decentralized Trust) ecosystem, and generalizes to any GitHub-hosted open-source project via a single per-repo YAML config file.

Capability What it does
Onboarding Detects first-time contributors, posts a welcome checklist, validates account age / public-repo count before /assign, round-robins mentor assignment
PR quality gates DCO sign-off, GPG signature, test-file presence, linked-issue requirement, branch naming pattern, max file count — auto-labelled quality: ✅ / ❌, with a posted Quality Gate Report
PR health scoring Every PR scored 0–100 across 6 configurable, weighted signals (tests, linked issue, description, DCO, approvals, diff size), posted as a live-updating scorecard
Reviewer assignment Automatically requests reviewers on newly opened, non-draft PRs using a repo-local .github/reviewers.yml availability file and configurable round-robin or random selection
Reviewer recommendation Suggests reviewers based on recent file-history overlap, logged with a reason and confidence score; posts a comment-only recommendation rather than requesting a review
AI-assisted review (optional) Structured review (summary, verdict, line comments, severity) via the Anthropic SDK — disabled by default, never required
Contributor progression Tracks merged PRs, reviews given, months active; computes eligibility for junior-committer → committer → maintainer; celebrates merge milestones (1st, 5th, 10th, 25th, 50th)
Issue management Daily stale scan (cron), auto-unassign on inactivity, label-based escalation to specific teams
Live dashboard Real-time metrics, score-distribution and signal pass-rate charts, audit log, contributor progression table — auto-refreshes every 30s
REST API (/api/v1) Query every stored record — audit log, PR health, contributor snapshots, stale-action history, aggregate repo stats
Persistent audit trail Every bot action (label, comment, assign, close) is written to Postgres/SQLite with a reason — nothing is silent, everything is queryable later
Security HMAC-SHA256 webhook signature verification with constant-time comparison; the bot is completely silent in any repo without an explicit config file

Includes unit and integration tests (pytest-asyncio, httpx, respx, in-memory SQLite) covering the project's workflows and REST API.

Seen in the wild

hydra-maintainer runs live against real pull requests. A few things it posts automatically:

  • A PR health scorecard breaking down exactly which signals passed and which didn't, with a plain-language nudge on what to fix.
  • A Quality Gate Report blocking review requests until required gates (like a linked closing issue) are satisfied.
  • Reviewer suggestions based on who last touched the changed files, posted as a lightweight comment rather than a forced review request.
  • An AI Code Review pass — a scored, verdict-labelled summary — clearly marked as automated, always followed by human review.
  • /assign handling with an instant confirmation comment and eligibility check.

Why it's different

hydra-maintainer Mergify CodeRabbit / Greptile probot / stale-bot / welcome-bot
License / hosting MIT, self-hosted Closed-source SaaS Closed-source SaaS Open source, but stateless
Where your data lives Your own Postgres/SQLite Vendor's servers Vendor's servers N/A (no persistence)
Contributor role progression ✅ built-in model ❌ ❌ ❌
PR health scoring ✅ weighted & configurable Partial (merge rules only) ❌ ❌
AI review ✅ optional, off by default ❌ ✅ always-on, vendor-locked ❌
Audit trail + REST API ✅ Limited to their UI ❌ ❌
Cost Free, run anywhere Paid tiers Paid tiers Free

Architecture

app/
├── main.py                     # FastAPI app + lifespan
├── config/
│   ├── schema.py                # Pydantic v2 config schema + validation
│   └── loader.py                # YAML loader with TTL cache
├── db/
│   ├── database.py              # Async SQLAlchemy engine
│   └── models.py                # AuditLog, PRHealthScore, ContributorSnapshot, StaleActionLog, ReviewerRecommendation
├── github/
│   ├── client.py                # Async GitHub App HTTP client
│   └── webhooks.py               # HMAC-verified webhook router
├── workflows/
│   ├── onboarding.py             # First-time contributor flows
│   ├── pullrequest.py            # Quality gates + AI review + reviewer rec.
│   ├── prhealth.py               # PR health scoring
│   ├── progression.py            # Role progression + issue recommendations
│   └── issuemanagement.py        # Stale scan + escalation
├── ai/
│   └── reviewer.py                # Anthropic SDK integration (pluggable)
├── scheduler/
│   └── jobs.py                    # APScheduler cron jobs
├── api/
│   └── routes.py                  # REST API endpoints
└── utils/
    ├── audit.py, logger.py, settings.py
dashboard/
└── templates/dashboard.html       # Live metrics dashboard
tests/
├── unit/                          # workflow + schema tests
└── integration/                   # httpx + in-memory SQLite API tests

Slash commands

Command Who Description
/assign Anyone Self-assign (eligibility checked)
/unassign Anyone Remove yourself from an issue
/check-eligibility Contributors View role progression breakdown
/label <name> Committers+ Add a label (role-gated)
/help Anyone Show all commands

REST API

Base path: /api/v1

Endpoint Description
GET /health Service health check
GET /audit Audit log (filter by owner, repo, action, login, since)
GET /pr-health PR health score records (filter by score range, author)
GET /pr-health/stats Aggregate stats for a repo
GET /contributors Contributor snapshots (filter by role eligibility)
GET /repos/stats Full repo summary
GET /stale-log Stale action history

Quick start

# 1. Clone and install
git clone https://github.com/AnthropicBots/hiero-bot-py
cd hiero-bot-py
pip install -r requirements.txt

# 2. Configure
cp .env.example .env
# Fill in GITHUB_APP_ID, GITHUB_PRIVATE_KEY, GITHUB_WEBHOOK_SECRET

# 3. Run
uvicorn app.main:app --reload

# 4. Open dashboard
open http://localhost:8000

Contribution counters

In the GitHub App settings, grant the app read access to pull requests and subscribe to both Pull request and Pull request review events. The review subscription is configured on the GitHub App by its owner.

After the database migration, the scheduler starts backfilling each installed repository from its oldest pull requests. It processes one page per repository per pass and resumes from the last committed page after a restart or API failure. Each merged pull request counts once for its author. Each submitted review counts once per reviewer and pull request, including reviews of open pull requests. Counts use GitHub user IDs so renames do not reset them, and exclude bots and GitHub Actions accounts.

Set workflows.progression.milestone_thresholds in .github/hiero-bot.yml to choose the merge and distinct-review counts to celebrate. The defaults are 1, 5, 10, 25 and 50. The bot checks the current repository role before posting a milestone comment. Contributors with no repository permission, read access, triage access or admin access can receive milestones. Contributions from users with write or maintain access still count. Live events use committed counts during the historical import and indicate that the counts are still growing. The import never posts milestone comments. A live webhook can still trigger a milestone for a contribution the import already counted. Custom GitHub roles use their base permission. /check-eligibility checks the current role and asks the user to retry if it cannot verify the role.

Milestone comments are queued in the database with the live contribution. The bot drops a notice if the role is ineligible or cannot be verified. When the scheduler is enabled, it retries unsuccessful comment delivery and checks for the bot's original comment before posting again.

Docker

docker build -t hydra-maintainer .
docker run -p 8000:8000 --env-file .env hydra-maintainer

Tests

python -m pytest tests/unit/ tests/integration/ -q          # run unit and integration tests
python -m pytest tests/ --cov=app --cov-report=term-missing  # with coverage

Security audit

Before pushing, check dependencies for known vulnerabilities:

pip install pip-audit
pip-audit -r requirements.txt -f json -o audit-report.json
python .github/scripts/check_audit_severity.py audit-report.json

CI runs the same check and fails the build on High/Critical CVSS findings. pip-audit has no built-in severity flag — filtering is done by the script above against each finding's CVSS score.

Webhook secret rotation

To rotate GITHUB_WEBHOOK_SECRET without downtime:

  1. Set the new secret as GITHUB_WEBHOOK_SECRET and the previous secret as GITHUB_WEBHOOK_SECRET_OLD.
  2. Deploy the application with both secrets configured.
  3. Update the GitHub App webhook configuration to use the new secret.
  4. After the grace period, remove GITHUB_WEBHOOK_SECRET_OLD and redeploy.

During the rotation window, both the current and previous secrets are accepted.

Configuration

Add .github/hiero-bot.yml to any repo where the app is installed. Full reference: templates/hiero-bot.yml. The bot is completely silent if no config file exists — nothing runs by accident.

Use the branding and labels sections to set the welcome name, workflow labels, and mentor team. Create those labels in GitHub first. The bot logs and skips a missing label. Existing teams.mentors, difficulty_labels.intermediate, and workflows.issue_management.stale_label values are still read when their new keys are omitted.

Defaults. Once a config file exists, onboarding, PR quality gates, PR health scoring and contributor progression are on unless you set enabled: false. Issue management (stale scan, auto-close, auto-unassign) and reviewer assignment are off and must be enabled explicitly, for example workflows.issue_management.enabled: true.

Issue lifecycle

The issue-management workflow is configured per repository under workflows.issue_management in .github/hiero-bot.yml; the day counts in the template are examples, not policy.

Key Meaning
enabled false (the default) turns off the whole workflow: no unassigning, stale marking, closing or lifecycle comments.
auto_unassign_inactive_days Remove assignees after this many days without activity.
count_bot_comments_as_activity Whether comments from other bots (such as CI, Dependabot or Renovate) count as activity. Defaults to false; human comments always count.
stale_issue_days Mark an issue stale after this many days without activity.
close_stale_after_days Close a stale issue this many additional days after it was marked stale. Independent of stale_issue_days.
stale_label, exempt_labels The label applied to stale issues, and labels that exempt an issue entirely (case-insensitive).

Inactivity is measured from the last genuine activity: human comments and supported human-authored GitHub timeline events, such as label and assignment changes. Comments from other bots or apps do not count by default; set count_bot_comments_as_activity: true to include them. The bot's own lifecycle comments are identified using a hidden marker and verified GitHub App identity, so they never restart an inactivity countdown. Bot-generated timeline events are also ignored. Edits to an issue's body leave no comment or timeline event, so they are detected from the issue's last-updated time. The bot records that time after each of its own unassign and stale actions, so an edit made after one counts. GitHub gives an issue-body edit no event and no author, so an edit stamped at the same moment as the bot's own change, or made between the bot's change and its read-back within a few seconds, cannot be told apart from it and is not counted; this is a limit of the data GitHub provides, not exact tracking. Updates from other bots get a one-minute allowance.

An issue past both the unassignment and stale thresholds is unassigned and marked stale in the same scan. New activity restarts the inactivity countdowns. On an issue that is already stale, activity postpones closing by close_stale_after_days; the stale label stays until a maintainer removes it. If fetching an issue's timeline fails, that issue is skipped for the current scan and retried on a subsequent scan. Before changing anything the bot fetches the issue again and decides again, so a comment, assignment or label that arrived after the listing is respected. Unassign and stale actions are then recorded, and claimed with a lease, before the GitHub change is made; they are confirmed together with their log and audit rows once it lands, and only then announced. If the process stops or GitHub's answer is lost, a later scan takes over the action once its lease has expired and reads GitHub's history, not the issue's present state: it records the action only when this app's own event is found after the intent was written, so a change made by a person is never recorded as the bot's, and the bot's own change stays on record even if a person has since reversed it. An intent that cannot be reconciled is kept with status abandoned and a warning, never guessed at. A notice is posted only after the issue has been searched for its hidden marker, and by the one worker that holds its row. A failed notice is retried on later scans, up to 5 attempts; after that its status becomes notice_failed, an error is logged, and IssueManagementWorkflow.failed_notices() lists it and retry_failed_notices() makes it eligible again. A failed notice never resets the inactivity countdown or loses the audit record. The close period is counted from the stale label's own event, not from when its notice happened to be delivered. A database index allows at most one pending intent per issue and action type (a stale and an unassign intent can exist together); coordination between workers rests on the row leases, not on that index. Issues with a comment or timeline history long enough to have been cut off by the API client's page limit are skipped with an error rather than acted on. Each scan reads every open issue's comments and timeline, which costs API calls proportional to the number of open issues.

Environment variables

Variable Required Description
GITHUB_APP_ID ✅ From GitHub App settings
GITHUB_PRIVATE_KEY ✅ RSA private key (use \n for newlines)
GITHUB_WEBHOOK_SECRET ✅ Webhook secret set in App settings
ANTHROPIC_API_KEY AI review only Anthropic API key
DATABASE_URL ❌ Default: sqlite+aiosqlite:///./hiero_bot.db
PORT ❌ Default: 8000
LOG_LEVEL ❌ debug/info/warn/error
LOG_FORMAT ❌ auto / json / text (default: auto; JSON in production, text in dev)
ENVIRONMENT ❌ development / production

The dashboard and protected REST API endpoints use GitHub OAuth with signed, database-backed sessions. Configure GITHUB_OAUTH_CLIENT_ID, GITHUB_OAUTH_CLIENT_SECRET, SESSION_SECRET_KEY, and TOKEN_ENCRYPTION_KEY before exposing the application publicly.

Ecosystem & standing

Originally built and validated against repositories in the Hiero ecosystem under Linux Foundation Decentralized Trust. The author is an active contributor to hiero-sdk-python and other Hiero-adjacent projects, and an ECWoC'26 Top Contributor. The config format is deliberately generic (any owner/repo, any team names) so the same bot can be installed on non-Hiero, GitHub-hosted FOSS projects without modification.

Roadmap

This project is under active, ongoing development. Planned work includes multi-forge support (GitLab/Gitea/Forgejo), pluggable local/open-weight AI review backends, portable contributor-reputation credentials, and a security-hardened 1.0 release.

Funding & support

hydra-maintainer is currently a solo, unfunded open-source effort, built and maintained alongside full-time study. It is actively seeking grant support to fund the roadmap above as sustained, full-time work rather than nights-and-weekends progress. If you're a maintainer, funder, or organization interested in supporting or piloting this project, please open an issue or reach out via the links below.

Contributing

Issues and PRs are welcome. Please sign your commits (DCO) and include tests for new workflow logic — see tests/unit/ for the existing patterns before adding new ones.

Author

Mohit Yadav (@mohityadav8) — CS undergraduate (BE-CSE, Chandigarh University, 2024–2028), open-source contributor across NVIDIA/aicr, SHAP, pgmpy, hiero-sdk-python, and OWASP Nest. Portfolio: mohityadav8.github.io

License

MIT License — see LICENSE.

探索相关项目

加载中…