Skip to content

Commit 323902f

Browse files
bhodges-navapbcBrian Hodgesclaude
authored
refactor(metricsai)!: rename github_authors -> security_github_authors (#45)
Rename the security author setting and its env var (github_authors / METRICSAI_GITHUB_AUTHORS) to security_github_authors / METRICSAI_SECURITY_GITHUB_AUTHORS, parallel to testing_github_authors. The testing module never inherited github_authors (testing_authors falls back to its own classifier-bot default, not to github_authors), so the old name misleadingly implied a shared setting. github_repos / github_token / github_base_url keep the github_* prefix since they are genuinely shared. The --author CLI flag and --all-authors behavior are unchanged for users; only the env var / internal field name changed. Also removes metricsai/src/t, a stray file accidentally committed during the all-authors PR. BREAKING CHANGE: METRICSAI_GITHUB_AUTHORS is now METRICSAI_SECURITY_GITHUB_AUTHORS. Co-authored-by: Brian Hodges <bhodges@navapbc.com> Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 628c643 commit 323902f

8 files changed

Lines changed: 19 additions & 85 deletions

File tree

metricsai/CLAUDE.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ Conventional-Comment label (`security` vs `compliance`), plus one AWS Security H
6262
`match_all_authors`; when set, `_classify` skips the author-allowlist check (window + label
6363
gates still apply). Security-only — the `testing` module intentionally does not pass it, so
6464
it always keys off the classifier-bot author. `cli.main` warns if a non-default
65-
`github_authors` is set alongside it.
65+
`security_github_authors` is set alongside it.
6666

6767
**`testing` module** emits the `testing_classifier_*` columns from one scan of the AI
6868
test-classifier's PR comments (`fetch_classifier_comments` in `sources/github.py`): comments
@@ -94,7 +94,7 @@ paths.
9494

9595
- Pydantic v2 models/settings; extensive type hints; reStructuredText (`:param:`) docstrings;
9696
ruff + black at line length 100. Python `>=3.12`.
97-
- `github_repos` / `github_authors` settings are stored as comma-separated **strings** (to
97+
- `github_repos` / `security_github_authors` settings are stored as comma-separated **strings** (to
9898
avoid pydantic JSON-list env parsing); read them via `Settings.repos` / `.authors` or
9999
`config.csv_list`.
100100
- `tmp/` is gitignored scratch holding the original shell scripts the `security` module was

metricsai/QUICKSTART.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ All modules run by default; `--module` (repeatable) narrows. Row key = `week_end
4444
| `--url` | `METRICSAI_WEBHOOK_URL` | Apps Script `/exec` endpoint |
4545
| `--tab` | `METRICSAI_WEBHOOK_TAB` | destination sheet tab |
4646
| `--repo` (repeat) | `METRICSAI_GITHUB_REPOS` (csv) | repos to scan (required by `security`) |
47-
| `--author` (repeat) | `METRICSAI_GITHUB_AUTHORS` (csv) | AI comment authors (default `github-copilot[bot]`) |
47+
| `--author` (repeat) | `METRICSAI_SECURITY_GITHUB_AUTHORS` (csv) | security AI comment authors (default `github-copilot[bot]`) |
4848
| `--all-authors` | `METRICSAI_ALL_AUTHORS` | security: count comments from any author (ignore the allowlist) |
4949
| `--github-url` | `METRICSAI_GITHUB_BASE_URL` | Enterprise: `https://<host>/api/v3` |
5050
| `--week-ending-day` | `METRICSAI_WEEK_ENDING_DAY` | week-closing weekday (default `friday`) |

metricsai/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ All settings use the `METRICSAI_` prefix.
134134
| `METRICSAI_GITHUB_KEYCHAIN_SERVICE` | `metricsai-github` | Keychain service name for the GitHub token. |
135135
| `METRICSAI_GITHUB_BASE_URL` | `https://api.github.com` | GitHub REST base URL. For Enterprise use `https://<host>/api/v3`. (`--github-url`) |
136136
| `METRICSAI_GITHUB_REPOS` | _(none)_ | Comma-separated `owner/repo` list to scan. Required by `security`. (`--repo`) |
137-
| `METRICSAI_GITHUB_AUTHORS` | `github-copilot[bot]` | Comma-separated comment authors counted as AI-generated. (`--author`) |
137+
| `METRICSAI_SECURITY_GITHUB_AUTHORS` | `github-copilot[bot]` | Comma-separated authors the `security` module counts as AI-generated. (`--author`) |
138138
| `METRICSAI_ALL_AUTHORS` | `false` | Security scan counts comments from any author, ignoring the author allowlist. `--all-authors` |
139139
| `METRICSAI_WEEK_ENDING_DAY` | `friday` | Weekday the reporting week closes on (name or abbrev). `--week-ending-day` |
140140
| `METRICSAI_AWS_REGION` | _(boto3 default)_ | AWS region for Security Hub. Falls back to `AWS_REGION` / active profile. |
@@ -240,7 +240,7 @@ The same token is used for github.com and GitHub Enterprise (set `--github-url`
240240

241241
A comment is counted only if **all three** hold — so a manual test often shows zeros:
242242

243-
1. **Author** is in `--author` / `METRICSAI_GITHUB_AUTHORS` (default `github-copilot[bot]`).
243+
1. **Author** is in `--author` / `METRICSAI_SECURITY_GITHUB_AUTHORS` (default `github-copilot[bot]`).
244244
Comments you wrote yourself won't count unless you add your own login — or pass
245245
`--all-authors` / `METRICSAI_ALL_AUTHORS=true` to count comments from *any* author.
246246
2. **Created within the window** — the 7 days ending on `week_ending_date`. Comments from

metricsai/docs/usage.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ All settings use the `METRICSAI_` prefix and may be set in the environment.
3535
| `METRICSAI_GITHUB_KEYCHAIN_SERVICE` | `metricsai-github` | Keychain service name for the GitHub token. |
3636
| `METRICSAI_GITHUB_BASE_URL` | `https://api.github.com` | GitHub REST base URL (Enterprise: `https://<host>/api/v3`). `--github-url` |
3737
| `METRICSAI_GITHUB_REPOS` | _(none)_ | Comma-separated `owner/repo` list. Required by `security`. `--repo` |
38-
| `METRICSAI_GITHUB_AUTHORS` | `github-copilot[bot]` | Comma-separated AI comment authors. `--author` |
38+
| `METRICSAI_SECURITY_GITHUB_AUTHORS` | `github-copilot[bot]` | Comma-separated AI comment authors (security module). `--author` |
3939
| `METRICSAI_ALL_AUTHORS` | `false` | Security scan counts comments from any author, ignoring the author allowlist. `--all-authors` |
4040
| `METRICSAI_WEEK_ENDING_DAY` | `friday` | Weekday the reporting week closes on. `--week-ending-day` |
4141
| `METRICSAI_AWS_REGION` | _(boto3 default)_ | AWS region for Security Hub. |

metricsai/src/metricsai/cli.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ def _apply_overrides(settings: Settings, args: argparse.Namespace) -> Settings:
5454
if args.repo:
5555
overrides["github_repos"] = ",".join(args.repo)
5656
if args.author:
57-
overrides["github_authors"] = ",".join(args.author)
57+
overrides["security_github_authors"] = ",".join(args.author)
5858
if args.all_authors:
5959
overrides["all_authors"] = True
6060
if args.week_ending_day:
@@ -114,13 +114,13 @@ def build_parser() -> argparse.ArgumentParser:
114114
action="append",
115115
metavar="LOGIN",
116116
help="Comment author to count as AI-generated (repeatable; overrides "
117-
"METRICSAI_GITHUB_AUTHORS).",
117+
"METRICSAI_SECURITY_GITHUB_AUTHORS).",
118118
)
119119
parser.add_argument(
120120
"--all-authors",
121121
action="store_true",
122122
help="Count security-reviewer comments from any author, ignoring the --author / "
123-
"METRICSAI_GITHUB_AUTHORS allowlist (overrides METRICSAI_ALL_AUTHORS).",
123+
"METRICSAI_SECURITY_GITHUB_AUTHORS allowlist (overrides METRICSAI_ALL_AUTHORS).",
124124
)
125125
parser.add_argument(
126126
"--skip-sechub",
@@ -199,11 +199,11 @@ def main(argv: list[str] | None = None) -> int:
199199
return _store_secret(settings.webhook_keychain_service, "Enter webhook API key: ")
200200

201201
settings = _apply_overrides(settings, args)
202-
if settings.all_authors and settings.github_authors not in ("", DEFAULT_AUTHOR):
202+
if settings.all_authors and settings.security_github_authors not in ("", DEFAULT_AUTHOR):
203203
logger.warning(
204204
"--all-authors / METRICSAI_ALL_AUTHORS is set, so the configured comment "
205205
"authors (%s) are ignored for the security scan.",
206-
settings.github_authors,
206+
settings.security_github_authors,
207207
)
208208
webhook_url = args.url or (str(settings.webhook_url) if settings.webhook_url else None)
209209
try:

metricsai/src/metricsai/config.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ def csv_list(value: str | None) -> list[str]:
3232
class Settings(BaseSettings):
3333
"""Environment-backed configuration.
3434
35-
Comma-separated fields (``github_repos``, ``github_authors``) are kept as raw strings
35+
Comma-separated fields (``github_repos``, ``security_github_authors``) are kept as raw strings
3636
here and split with :func:`csv_list` at the point of use; this keeps environment
3737
parsing simple and avoids JSON-list quoting.
3838
@@ -53,13 +53,15 @@ class Settings(BaseSettings):
5353
``https://<host>/api/v3`` for GitHub Enterprise.
5454
:ivar github_repos: Comma-separated ``owner/repo`` list to scan. Required for the
5555
security module (overridable with ``--repo``).
56-
:ivar github_authors: Comma-separated comment author logins to count as AI-generated.
56+
:ivar security_github_authors: Comma-separated comment author logins counted as
57+
AI-generated by the ``security`` module. The ``testing`` module does not inherit
58+
this; it has its own ``testing_github_authors``.
5759
:ivar testing_github_repos: Comma-separated ``owner/repo`` list the ``testing`` module
5860
scans for classifier comments. Falls back to ``github_repos`` when unset.
5961
:ivar testing_github_authors: Comma-separated author logins of the test-classifier's
6062
comments. Falls back to the classifier-bot default when unset.
6163
:ivar all_authors: When ``True``, the ``security`` module counts comments from *any*
62-
author and ignores the ``github_authors`` allowlist entirely (the window and
64+
author and ignores the ``security_github_authors`` allowlist entirely (the window and
6365
Conventional-Comment label gates still apply). Does not affect the ``testing``
6466
module, which only counts the test-classifier's own structured comments. Off by
6567
default.
@@ -83,7 +85,7 @@ class Settings(BaseSettings):
8385
github_keychain_service: str = "metricsai-github"
8486
github_base_url: str = "https://api.github.com"
8587
github_repos: str = ""
86-
github_authors: str = DEFAULT_AUTHOR
88+
security_github_authors: str = DEFAULT_AUTHOR
8789
testing_github_repos: str = ""
8890
testing_github_authors: str = ""
8991
all_authors: bool = False
@@ -100,7 +102,7 @@ def repos(self) -> list[str]:
100102
@property
101103
def authors(self) -> list[str]:
102104
"""Comment authors to count, falling back to the default bot."""
103-
return csv_list(self.github_authors) or [DEFAULT_AUTHOR]
105+
return csv_list(self.security_github_authors) or [DEFAULT_AUTHOR]
104106

105107
@property
106108
def testing_repos(self) -> list[str]:

metricsai/src/t

Lines changed: 0 additions & 68 deletions
This file was deleted.

metricsai/tests/conftest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ def _clear_env(monkeypatch: pytest.MonkeyPatch) -> None:
2222
"METRICSAI_WEBHOOK_TAB",
2323
"METRICSAI_GITHUB_TOKEN",
2424
"METRICSAI_GITHUB_REPOS",
25-
"METRICSAI_GITHUB_AUTHORS",
25+
"METRICSAI_SECURITY_GITHUB_AUTHORS",
2626
"METRICSAI_GITHUB_BASE_URL",
2727
"METRICSAI_WEEK_ENDING_DAY",
2828
"METRICSAI_AWS_REGION",

0 commit comments

Comments
 (0)