Commit 65af207a92

65af207a928d0958b1a40065c6cdc74c7c86d786

parent: 97d3c9d804

Unsigned

Alicia Sykes <alicia@omg.lol> · 2026-10-10 15:55 UTC

Adds bus factor check in CI

Layout: unified · split

.github/CONTRIBUTING.md +1
@@ -305,6 +305,7 @@ Below is the full list of checks - it's basically the same as what is listed in
305305 - 🟡 **Not archived** - Repo must not be archived
306306 - 🟡 **No security alerts** - No open critical/high Dependabot alerts
307307 - 🟡 **Minimum stars** - Repo should have ≥100 stars
308 - 🟡 **Bus factor** - Flags if ≥96% of commits come from a single contributor (bots and AI excluded)
308309 - 🟡 **Spam detection** - Flags if the author opened ≥3 PRs to other awesome-* repos, or PRs across ≥7 distinct repos, in the last 2 days
309310- **Addition Info** (fyi only, no pass/fail requirements or warnings)
310311 - 🔵 **Website check** (if has `url`) - Quickly checks for basic security requirements for website
lib/checks/check-project.py +17
@@ -28,6 +28,7 @@ MIN_STARS = 100
2828INACTIVE_DAYS = 90
2929MIN_AGE_DAYS = 120
3030AI_COMMIT_RATIO = 0.8
31BUS_FACTOR_RATIO = 0.96
3132SPAM_AWESOME_THRESHOLD = 3
3233SPAM_DISTINCT_REPO_THRESHOLD = 7
3334SPAM_WINDOW_DAYS = 2
@@ -96,6 +97,9 @@ REPO_404_MSG = (
9697 "The GitHub repository linked in this submission returns a 404."
9798 " Please ensure the repo exists and is publicly accessible"
9899)
100BUS_FACTOR_MSG = (
101 "This repository has a low bus factor, as maintained by a single contributor"
102)
99103
100104
101105def load_diff(path):
@@ -202,6 +206,14 @@ def check_security_alerts(owner, repo, token):
202206 return None
203207
204208
209def check_bus_factor(owner, repo, token):
210 """Return BUS_FACTOR_MSG if a single human contributor made nearly all commits."""
211 share = utils.top_contributor_share(owner, repo, token, session=SESSION, timeout=TIMEOUT)
212 if share is not None and share >= BUS_FACTOR_RATIO:
213 return BUS_FACTOR_MSG
214 return None
215
216
205217def check_spam_prs(pr_user, token):
206218 """Return list of spam findings based on recent PR activity."""
207219 if not pr_user:
@@ -376,6 +388,11 @@ def check_repo_signals(diff, pr_user, token, pr_body=""):
376388 if finding:
377389 findings.append(finding)
378390
391 if BUS_FACTOR_MSG not in findings:
392 finding = check_bus_factor(owner, repo, token)
393 if finding:
394 findings.append(finding)
395
379396 return findings
380397
381398
lib/review-listings.py +15
@@ -18,6 +18,7 @@ Checks:
1818- github-activity: github repo was pushed recently (needs token)
1919- github-license: github repo has a license (needs token)
2020- github-fork: github repo is not a fork (needs token)
21- github-bus-factor: no single human made 98%+ of commits, bots and AI ignored (needs token)
2122- security-advisories: no open unpatched CVEs (needs API_TOKEN)
2223- android-trackers: android app has few trackers (1 info, 2+ warn) (needs API_TOKEN)
2324- ios-app: iOS app exists, is maintained and rated (missing/stale/low-rating warn) (needs API_TOKEN)
@@ -73,6 +74,7 @@ except ImportError as exc:
7374MIN_DESC = 50
7475MAX_DESC = 280
7576MAX_DESC_HARD = 420
77BUS_FACTOR_RATIO = 0.98
7678DEFAULT_WORKERS = 8
7779DEFAULT_TIMEOUT = 10
7880
@@ -421,6 +423,19 @@ def _github_license(entry: Entry, ctx: Context) -> Iterable[Finding]:
421423 yield _finding(entry, "github-license", "warn", "repository has no declared license")
422424
423425
426@check("github-bus-factor", needs_github=True)
427def _github_bus_factor(entry: Entry, ctx: Context) -> Iterable[Finding]:
428 """No single human made 98%+ of commits (bots and AI agents ignored)."""
429 owner, repo = utils.parse_github_field(entry.service.get("github"))
430 if not owner:
431 return
432 share = utils.top_contributor_share(owner, repo, ctx.token,
433 session=ctx.session, timeout=ctx.timeout)
434 if share is not None and share >= BUS_FACTOR_RATIO:
435 yield _finding(entry, "github-bus-factor", "warn",
436 f"low bus factor, {share:.0%} of commits are by a single contributor")
437
438
424439@check("security-advisories", needs_api=True)
425440def _security_advisories(entry: Entry, ctx: Context) -> Iterable[Finding]:
426441 """No open unpatched CVEs (low/medium warn, high/critical error)."""
lib/utils/__init__.py +2
@@ -35,6 +35,7 @@ try:
3535 repo_is_fork,
3636 repo_pushed_days_ago,
3737 repo_status,
38 top_contributor_share,
3839 )
3940 from .http import DEFAULT_TIMEOUT, DEFAULT_USER_AGENT, check_url, make_session
4041except ImportError as exc:
@@ -74,6 +75,7 @@ __all__ = [
7475 "repo_status",
7576 "setup_logging",
7677 "slugify",
78 "top_contributor_share",
7779 "tracker_count",
7880 "unpatched_advisories",
7981]
lib/utils/github.py +27
@@ -1,12 +1,14 @@
11"""GitHub API helpers and read-only accessors for repo metadata."""
22
33import logging
4import re
45from datetime import datetime, timezone
56
67import requests
78
89from .http import DEFAULT_TIMEOUT, make_session
910
11# List of dirty AI users, we don't count them as real people because they have no soul
1012AI_BOT_AUTHORS = [
1113 "noreply@anthropic.com",
1214 "devin-ai-integration[bot]",
@@ -14,6 +16,9 @@ AI_BOT_AUTHORS = [
1416 "noreply@cursor.com",
1517]
1618
19AI_CONTRIBUTOR_LOGINS = {"cursoragent", "openhands-agent"}
20_BOT_LOGIN_RE = re.compile(r"[-_]bot$|\[bot\]$")
21
1722
1823def parse_github_field(value):
1924 """Parse a `github` field into (owner, repo), or (None, None) on failure."""
@@ -99,6 +104,28 @@ def commit_has_bot(commit, bot_set):
99104 return False
100105
101106
107def _is_human_contributor(contributor):
108 """Return True unless a contributor is a bot, automation account or AI agent."""
109 login = (contributor.get("login") or "").lower()
110 return (contributor.get("type") == "User"
111 and login not in AI_CONTRIBUTOR_LOGINS
112 and not _BOT_LOGIN_RE.search(login))
113
114
115def top_contributor_share(owner, repo, token, session=None, timeout=DEFAULT_TIMEOUT):
116 """Share of commits (0 to 1) by the top human contributor, ignoring bots and AI"""
117 contributors = gh_get(f"/repos/{owner}/{repo}/contributors", token, session=session,
118 params={"per_page": 100}, timeout=timeout, label="contributors")
119 if not isinstance(contributors, list) or len(contributors) >= 100:
120 return None
121 try:
122 counts = [c["contributions"] for c in contributors if _is_human_contributor(c)]
123 return max(counts) / sum(counts) if counts else None
124 except Exception as exc:
125 logging.warning("[contributors] unexpected data for %s/%s: %s", owner, repo, exc)
126 return None
127
128
102129def _days_since(iso_str):
103130 if not iso_str:
104131 return None