Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions metricsai/CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ A CLI that gathers AI-in-SDLC metrics from pluggable modules and POSTs one weekl

**Pipeline (`cli.py::main`):** load `Settings` (env, `METRICSAI_` prefix) → apply CLI
overrides via `settings.model_copy(update=...)` → compute `week_ending_date` (default: most
recent Thursday) → build a `RunContext` (settings, a *lazy/cached* `get_github_token`, and the
recent Friday) → build a `RunContext` (settings, a *lazy/cached* `get_github_token`, and the
week-ending date) → run the selected modules → merge their dicts into
`MetricRow(week_ending_date, metrics)` → `MetricsClient.post()` (or print on `--dry-run`).

Expand Down Expand Up @@ -100,7 +100,7 @@ paths.
are blocked, so bootstrap secrets / `aws sso login` unsandboxed first; allowlist
`api.github.com`, `securityhub.<region>.amazonaws.com`, STS/SSO, and the Apps Script host.
- Week-ending weekday is configurable (`week_ending_day` setting / `--week-ending-day` /
`METRICSAI_WEEK_ENDING_DAY`), default **Thursday**, giving a 7-day inclusive UTC window
Fri 00:00:00Z–Thu 23:59:59Z (`models.default_week_ending` / `weekday_number` /
`METRICSAI_WEEK_ENDING_DAY`), default **Friday**, giving a 7-day inclusive UTC window
Sat 00:00:00Z–Fri 23:59:59Z (`models.default_week_ending` / `weekday_number` /
`week_window`). Security Hub is single-region via boto3's default credential chain, which
already honors env `AWS_SESSION_TOKEN` for temporary creds.
4 changes: 2 additions & 2 deletions metricsai/QUICKSTART.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ uv run metricsai --list-modules
```

All modules run by default; `--module` (repeatable) narrows. Row key = `week_ending_date`
(most recent Thursday, window Fri 00:00Z–Thu 23:59:59Z; override the date with
(most recent Friday, window Sat 00:00Z–Fri 23:59:59Z; override the date with
`--week-ending YYYY-MM-DD` or the weekday with `--week-ending-day sunday`).

## Common flags / env
Expand All @@ -46,7 +46,7 @@ All modules run by default; `--module` (repeatable) narrows. Row key = `week_end
| `--repo` (repeat) | `METRICSAI_GITHUB_REPOS` (csv) | repos to scan (required by `security`) |
| `--author` (repeat) | `METRICSAI_GITHUB_AUTHORS` (csv) | AI comment authors (default `github-copilot[bot]`) |
| `--github-url` | `METRICSAI_GITHUB_BASE_URL` | Enterprise: `https://<host>/api/v3` |
| `--week-ending-day` | `METRICSAI_WEEK_ENDING_DAY` | week-closing weekday (default `thursday`) |
| `--week-ending-day` | `METRICSAI_WEEK_ENDING_DAY` | week-closing weekday (default `friday`) |
| `--skip-sechub` | `METRICSAI_SKIP_SECHUB` | skip AWS Security Hub |
| — | `METRICSAI_AWS_REGION` | Security Hub region (else boto3 default) |
| `-v` / `--debug` | — | INFO / DEBUG logging |
Expand Down
6 changes: 3 additions & 3 deletions metricsai/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,8 @@ uv run metricsai --dry-run -v # INFO logging
uv run metricsai --dry-run --debug # DEBUG logging (full payload + sources)
```

The row is keyed by `week_ending_date`, which defaults to the most recent Thursday (the
reporting week runs Friday 00:00:00Z through Thursday 23:59:59Z) and can be overridden with
The row is keyed by `week_ending_date`, which defaults to the most recent Friday (the
reporting week runs Saturday 00:00:00Z through Friday 23:59:59Z) and can be overridden with
`--week-ending YYYY-MM-DD`. Change the week-ending weekday with `--week-ending-day`
(e.g. `sunday`) or `METRICSAI_WEEK_ENDING_DAY`.

Expand Down Expand Up @@ -134,7 +134,7 @@ All settings use the `METRICSAI_` prefix.
| `METRICSAI_GITHUB_BASE_URL` | `https://api.github.com` | GitHub REST base URL. For Enterprise use `https://<host>/api/v3`. (`--github-url`) |
| `METRICSAI_GITHUB_REPOS` | _(none)_ | Comma-separated `owner/repo` list to scan. Required by `security`. (`--repo`) |
| `METRICSAI_GITHUB_AUTHORS` | `github-copilot[bot]` | Comma-separated comment authors counted as AI-generated. (`--author`) |
| `METRICSAI_WEEK_ENDING_DAY` | `thursday` | Weekday the reporting week closes on (name or abbrev). `--week-ending-day` |
| `METRICSAI_WEEK_ENDING_DAY` | `friday` | Weekday the reporting week closes on (name or abbrev). `--week-ending-day` |
| `METRICSAI_AWS_REGION` | _(boto3 default)_ | AWS region for Security Hub. Falls back to `AWS_REGION` / active profile. |
| `METRICSAI_SKIP_SECHUB` | `false` | Skip the AWS Security Hub query (GitHub metrics still gather/post). `--skip-sechub` |
| `METRICSAI_REQUEST_TIMEOUT` | `10.0` | HTTP request timeout (seconds). |
Expand Down
6 changes: 3 additions & 3 deletions metricsai/docs/usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ uv run metricsai --dry-run --debug # DEBUG logging
```

All registered modules run by default; pass `--module NAME` (repeatable) to narrow scope.
The row is keyed by `week_ending_date` (default: most recent Thursday; the query window is
the 7 days ending on it, Fri 00:00:00Z through Thu 23:59:59Z).
The row is keyed by `week_ending_date` (default: most recent Friday; the query window is
the 7 days ending on it, Sat 00:00:00Z through Fri 23:59:59Z).

## Configuration

Expand All @@ -35,7 +35,7 @@ All settings use the `METRICSAI_` prefix and may be set in the environment.
| `METRICSAI_GITHUB_BASE_URL` | `https://api.github.com` | GitHub REST base URL (Enterprise: `https://<host>/api/v3`). `--github-url` |
| `METRICSAI_GITHUB_REPOS` | _(none)_ | Comma-separated `owner/repo` list. Required by `security`. `--repo` |
| `METRICSAI_GITHUB_AUTHORS` | `github-copilot[bot]` | Comma-separated AI comment authors. `--author` |
| `METRICSAI_WEEK_ENDING_DAY` | `thursday` | Weekday the reporting week closes on. `--week-ending-day` |
| `METRICSAI_WEEK_ENDING_DAY` | `friday` | Weekday the reporting week closes on. `--week-ending-day` |
| `METRICSAI_AWS_REGION` | _(boto3 default)_ | AWS region for Security Hub. |
| `METRICSAI_SKIP_SECHUB` | `false` | Skip the AWS Security Hub query (GitHub metrics still run). `--skip-sechub` |
| `METRICSAI_REQUEST_TIMEOUT` | `10.0` | HTTP request timeout (seconds). |
Expand Down
4 changes: 2 additions & 2 deletions metricsai/src/metricsai/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,8 @@ def build_parser() -> argparse.ArgumentParser:
parser.add_argument(
"--week-ending-day",
metavar="DAY",
help="Weekday the reporting week closes on, e.g. 'thursday' (overrides "
"METRICSAI_WEEK_ENDING_DAY; default thursday).",
help="Weekday the reporting week closes on, e.g. 'friday' (overrides "
"METRICSAI_WEEK_ENDING_DAY; default friday).",
)
parser.add_argument(
"--github-url",
Expand Down
6 changes: 3 additions & 3 deletions metricsai/src/metricsai/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ class Settings(BaseSettings):
scans for classifier comments. Falls back to ``github_repos`` when unset.
:ivar testing_github_authors: Comma-separated author logins of the test-classifier's
comments. Falls back to the classifier-bot default when unset.
:ivar week_ending_day: Weekday that closes the reporting week (e.g. ``thursday`` /
``thu``). The query window is the 7 days ending on it.
:ivar week_ending_day: Weekday that closes the reporting week (e.g. ``friday`` /
``fri``). The query window is the 7 days ending on it.
:ivar aws_region: Optional AWS region for Security Hub. When unset, boto3's default
resolution (``AWS_REGION`` / active profile) is used.
:ivar skip_sechub: When ``True``, the security module skips the AWS Security Hub query
Expand All @@ -80,7 +80,7 @@ class Settings(BaseSettings):
github_authors: str = DEFAULT_AUTHOR
testing_github_repos: str = ""
testing_github_authors: str = ""
week_ending_day: str = "thursday"
week_ending_day: str = "friday"
aws_region: str | None = None
skip_sechub: bool = False
request_timeout: float = 10.0
Expand Down
2 changes: 1 addition & 1 deletion metricsai/src/metricsai/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class RunContext:
:ivar get_github_token: Lazily resolves the GitHub token on first use, so modules that
do not need it never trigger a keychain lookup or prompt. The resolved value is
cached for the duration of the run.
:ivar week_ending_date: The Thursday that closes the reporting week. Modules derive their
:ivar week_ending_date: The Friday that closes the reporting week. Modules derive their
query window from it via :func:`~metricsai.models.week_window`.
"""

Expand Down
6 changes: 3 additions & 3 deletions metricsai/src/metricsai/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
}

#: Default day on which the reporting week closes (window: that day back through 6 days
#: earlier, i.e. Fri 00:00:00Z .. Thu 23:59:59Z for the default).
DEFAULT_WEEK_ENDING_WEEKDAY = WEEKDAYS["thursday"]
#: earlier, i.e. Sat 00:00:00Z .. Fri 23:59:59Z for the default).
DEFAULT_WEEK_ENDING_WEEKDAY = WEEKDAYS["friday"]


def weekday_number(name: str) -> int:
Expand Down Expand Up @@ -73,7 +73,7 @@ def week_window(week_ending: date) -> tuple[datetime, datetime]:
class MetricRow(BaseModel):
"""One week's row of metrics destined for the spreadsheet.

:ivar week_ending_date: The Thursday that closes the reporting week; the row's key column.
:ivar week_ending_date: The Friday that closes the reporting week; the row's key column.
:ivar metrics: Mapping of spreadsheet field name to value, merged from every module.
"""

Expand Down
12 changes: 6 additions & 6 deletions metricsai/tests/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@
from metricsai.models import MetricRow, default_week_ending, week_window, weekday_number


def test_default_week_ending_returns_thursday() -> None:
# 2026-06-10 is a Wednesday; the prior Thursday is 2026-06-04.
assert default_week_ending(date(2026, 6, 10)) == date(2026, 6, 4)
def test_default_week_ending_returns_friday() -> None:
# 2026-06-10 is a Wednesday; the prior Friday is 2026-06-05.
assert default_week_ending(date(2026, 6, 10)) == date(2026, 6, 5)


def test_default_week_ending_on_thursday_is_same_day() -> None:
# 2026-06-04 is a Thursday.
assert default_week_ending(date(2026, 6, 4)) == date(2026, 6, 4)
def test_default_week_ending_on_friday_is_same_day() -> None:
# 2026-06-05 is a Friday.
assert default_week_ending(date(2026, 6, 5)) == date(2026, 6, 5)


def test_default_week_ending_configurable_weekday() -> None:
Expand Down
Loading