From 80ede977ec488ea04f65b71cb478bacecc447b8e Mon Sep 17 00:00:00 2001 From: kgrizz-git <216068303+kgrizz-git@users.noreply.github.com> Date: Mon, 9 Nov 2026 17:53:52 -0500 Subject: [PATCH 01/15] Raise email report repo cap from 50 to 100 Align the scheduled GitHub Actions workflow with the CLI/config default of 100. Repos beyond the previous cap were excluded from the private/public Actions split and top-repository rankings; the cap still applies above 100 repos, and repo-level sections now make roughly twice as many REST calls. --- .github/workflows/email-report.yml | 2 +- CHANGELOG.md | 1 + tests/test_workflow_templates.py | 1 + 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/email-report.yml b/.github/workflows/email-report.yml index 8b751c3..02511ef 100644 --- a/.github/workflows/email-report.yml +++ b/.github/workflows/email-report.yml @@ -99,7 +99,7 @@ jobs: if [ "${{ inputs.only_private }}" = "true" ]; then args+=(--only-private) fi - profile_args=(--max-repos 50 --email-format html --warn-over 25 --warn-over 80%) + profile_args=(--max-repos 100 --email-format html --warn-over 25 --warn-over 80%) if [ ${#profile_args[@]} -gt 0 ]; then args+=("${profile_args[@]}") fi diff --git a/CHANGELOG.md b/CHANGELOG.md index 99ad94f..7817ace 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -36,6 +36,7 @@ This project follows the structure from Keep a Changelog and intends to use Sema ### Changed +- **Email report repo cap in GitHub Actions:** raised the scheduled workflow's `--max-repos` from 50 to 100 so repo-level sections cover more of the account (aligning with the CLI/config default). Repos beyond the previous cap were excluded from the private/public Actions split and top-repository rankings; the cap still applies above 100 repos, and repo-level sections now make roughly twice as many REST calls (about 210 of the 5,000/hr core quota with consumers + artifact storage). - **Shorter README:** focused the landing page on getting started and scheduled delivery; moved setup, email configuration, report/export reference, runs/drift, and development details into linked user guides under `docs/`. - **README positioning and quick start:** refreshed the project overview around automated reporting, cost visibility, actionable repository detail, and flexible outputs. Added a scheduled-email quick start; clarified the independent GitHub Actions and local macOS launchd delivery paths, token permissions, platform scope, and planned work; and aligned the package description with this positioning. diff --git a/tests/test_workflow_templates.py b/tests/test_workflow_templates.py index 36fa508..38dd833 100644 --- a/tests/test_workflow_templates.py +++ b/tests/test_workflow_templates.py @@ -18,6 +18,7 @@ def test_email_report_workflow_uses_safe_secret_names_and_dispatch_inputs(self): self.assertIn("only_public:", workflow) self.assertIn("only_private:", workflow) self.assertIn("--only-public", workflow) + self.assertIn("--max-repos 100", workflow) def test_checked_in_workflow_and_template_use_only_recipient_secret(self): for name in ("email-report.yml", "email-report.yml.template"): From 62b34488ffd0349100e193e1dd655c17c72cf205 Mon Sep 17 00:00:00 2001 From: kgrizz-git <216068303+kgrizz-git@users.noreply.github.com> Date: Mon, 9 Nov 2026 18:45:09 -0500 Subject: [PATCH 02/15] Record email-report template drift follow-up The committed email-report workflow carries a manual pip-install comment and # NOSONAR that the template does not emit, so the next setup regeneration would silently drop the Sonar suppression. --- TO_DO.md | 1 + 1 file changed, 1 insertion(+) diff --git a/TO_DO.md b/TO_DO.md index 36d6817..efd8a2b 100644 --- a/TO_DO.md +++ b/TO_DO.md @@ -30,6 +30,7 @@ - [ ] Rename internal `legacy_*` modules/symbols to “local full report” naming (`legacy_report_data` → e.g. `local_report_data`, cache `kind="legacy"`, CLI/TUI internals, tests). User-facing copy already says “local full report”; this is the code rename. Keep a thin `legacy` compatibility shim if external imports still need it. - [ ] Add tests to raise overall src coverage from the current ~76% to 80%. Update `scripts/coverage-check` default from `COVERAGE_TOTAL_MIN=75` to `80` once achieved. +- [ ] Port the manual `pip install -e .` comment + `# NOSONAR` in `.github/workflows/email-report.yml` into `email-report.yml.template` so the next setup regeneration does not silently drop the Sonar suppression. ## Configuration & Setup From 5c163c146238c0ea828d763904db60b698fd396a Mon Sep 17 00:00:00 2001 From: kgrizz-git <216068303+kgrizz-git@users.noreply.github.com> Date: Mon, 9 Nov 2026 22:25:35 -0500 Subject: [PATCH 03/15] Add API call tracking plan Plan for measuring actual GitHub REST API calls per report and reporting actual-vs-estimated usage across the email report, local full report, and exports, including a rate-limit reference line with a link to the docs. --- .../plans/2026-11-09-api-call-tracking.md | 360 ++++++++++++++++++ 1 file changed, 360 insertions(+) create mode 100644 docs/superpowers/plans/2026-11-09-api-call-tracking.md diff --git a/docs/superpowers/plans/2026-11-09-api-call-tracking.md b/docs/superpowers/plans/2026-11-09-api-call-tracking.md new file mode 100644 index 0000000..84d7fde --- /dev/null +++ b/docs/superpowers/plans/2026-11-09-api-call-tracking.md @@ -0,0 +1,360 @@ +> **Status:** IN PROGRESS + +> Line numbers cited below are accurate as of 2026-11-09; relocate by anchor (function / section title / dict key) if they drift. +> +> **Terminology:** user-facing name is **local full report** (CLI/TUI). Code modules still use `legacy_*` until the rename tracked in `TO_DO.md`. +> +> **Implementation log:** (none yet) + +# Track GitHub REST API Calls and Report Usage + +## Goal + +Count the GitHub REST API requests a report actually makes, and surface +actual-vs-estimated usage in every report surface: the email report (text and +HTML), the legacy terminal report, and all file exports (JSON, CSV, XLSX, PDF, +text). Keep the existing pre-fetch estimate for the quota guard. + +## Non-goals + +- Counting GraphQL calls (this project only uses REST). +- Re-architecting the report data model. The change should extend the existing + `api_estimate` dict, not introduce a parallel structure. +- Changing the email report's quota-guard behavior. +- Fixing the unrelated "50 of 51" truncation-message lower bound (see + Related follow-ups). + +## Current state + +- `GitHubAPI` (`src/github_usage/api.py`) has `request()` and `request_raw()`; + `get_all_pages()` calls `request_raw()` once per page. Neither counts calls. +- `http_retry.request_with_retries()` (`src/github_usage/http_retry.py`) hides + retry attempts from the caller. +- `report_data.build_report_data()` computes `estimate_api_request_count()` + before fetching (`report_optional.py:125`) and stores it as + `report["api_estimate"]`. It never measures actual usage. +- `legacy_report_data.build_legacy_report_data()` does the same with + `estimate_legacy_api_request_count()` (`legacy_report_data.py:141`). +- The email renderers only print `api_estimate["notes"]` + (`email_report_text.py:445`, `email_report_html.py:491`). The numeric fields + (`estimated_incremental_requests`, `core_remaining`, + `estimated_percent_of_remaining`) are not rendered. +- Exports serialize `data` as-is: JSON includes `api_estimate`; CSV/XLSX/PDF + have explicit section lists and currently omit it; text delegates to the + email formatter. +- `report_cache.CACHE_VERSION` is 3. Cached reports are reused without + re-fetching, so a cache hit makes 0 new API calls but still carries the + original fetch's `api_estimate`. + +## Design + +### 1. Counting layer + +Add a small request counter to `GitHubAPI` (`src/github_usage/api.py`): + +- `self.request_count: int = 0` — logical API calls (each `request()` and + `request_raw()` invocation, including each page of `get_all_pages()`). +- `self.request_log: list[dict[str, object]]` — always populated; bounded by + the report's own request count (worst case ~600-700 entries at + `max_repos=100` with all sections, tens of KB). Each entry: + `{"method": "GET", "path": "/user/repos", "status": 200}`. Record the entry + in a `finally` block with the status captured (or `None` on failure) so + failed calls stay in both the total and the breakdown. +- `self.http_attempts: int = 0` — optional stretch goal for retry attempts + (see Open questions). If deferred, label the rendered number "requests + issued (retries excluded)". +- `get_request_stats() -> dict[str, object]` — returns + `{"actual_requests": int, "actual_requests_by_resource": dict}`. + Resource categories are derived from the path with ordered matching + (billing before user, because `/users/.../billing/...` starts with `/user`): + - `billing`: `/users/{u}/settings/billing/...` (`billing.py:24,92,139,176`) + - `user`: `/user`, `/user/repos` (`report_data.py:179`) + - `rate_limit`: `/rate_limit` (`report_data.py:259`) + - `actions`: `/repos/{o}/{n}/actions/...` (`report_optional.py:70`, + `storage.py:138`, `report_workflow_minutes.py:28,38`) + - `repos`: `/repos/{o}/{n}/releases` and other repo paths + (`report_optional.py:99`, `storage.py:156`) + - `other`: anything else + Assert in tests that `sum(actual_requests_by_resource.values()) == + actual_requests`. + +Increment at the top of `request()` and `request_raw()` so failed calls are +counted too (they generally consume quota). Do not count the internal +`/rate_limit` fetch differently; it is a normal API call. `request_log` must +never enter the report dict: raw paths would bypass `redact.py`'s key-based +username/repo masking (`redact.py:31-42,72-81`) and leak the username into +file exports. + +Thread safety: no threads in `src`; GUI `@work(thread=True)` workers each +build their own client (`gui_backend.py:361`). A plain `int` is sufficient; +note the assumption in a comment. If a client is ever shared across threads, +add a `threading.Lock` then. + +### 2. Report data integration + +Add a helper in `report_data.py`: + +```python +def _api_request_stats(api) -> dict[str, object]: + stats = getattr(api, "get_request_stats", None) + if callable(stats): + return stats() + return {"actual_requests": int(getattr(api, "request_count", 0) or 0), + "actual_requests_by_resource": {}} +``` + +This keeps the `GitHubAPIClient` Protocol (`report_data.py:22`) unchanged and +avoids breaking test fakes that do not implement the new method. + +**Baseline and variance.** `estimated_incremental_requests` covers only the +optional repo-level sections (`report_optional.py:137-143`; +`legacy_report_data.py:156-161`), while the client's raw count includes every +call made before and during the builder (e.g. `/user`, `_limited_repos`, +`_rate_limit`, and for the legacy path the pre-builder `check_user_scope` / +`fetch_account_info` / `fetch_rate_limits` in `legacy_report.py:94-101`). +Comparing the raw total to the estimate is apples-to-oranges. Instead: + +- Capture `baseline = api.get_request_stats()["actual_requests"]` at the + point the estimate is computed. +- After all fetches, compute + `actual_requests = current_total - baseline` (the delta over the same span + the estimate covers) and keep `total_requests = current_total` as raw + context. +- `estimate_variance = actual_requests - estimated_incremental_requests`. + +Baseline points: +- `build_report_data`: immediately after `_rate_limit(api)` + (`report_data.py:374`). +- `build_legacy_report_data`: at entry (`legacy_report_data.py:229`), because + the legacy estimate's `account_level = 10` is intended to cover the + account-level calls that happen before/around the builder. Document the + span in the report dict (e.g. `estimate_scope`). + +Merge points (must be after the last fetch): +- `build_report_data`: immediately before + `report["insights"] = get_key_insights(report)` (`report_data.py:441`) — + after the `fetch_repo_actions_table(api, repos)` fallback at line 435. +- `build_legacy_report_data`: at the end, before line 360 — after + `copilot_premium` / `copilot_billing` / `lfs_billing` (lines 345-358). + +Add derived fields to `api_estimate`: + +- `actual_requests`: measured delta over the estimate's span. +- `total_requests`: raw client total (context only). +- `actual_requests_by_resource`: breakdown (when available). +- `estimate_variance`: `actual_requests - estimated_incremental_requests`. +- `core_remaining_before`: already present as `core_remaining`. +- `core_remaining_after`: optional; only if a post-fetch `/rate_limit` call is + made (see Open questions). If made, exclude that probe from + `actual_requests` or label it. +- `from_cache`: set by the cache-hit path (see section 3). + +Keep `estimated_incremental_requests` as the pre-fetch estimate. The email and +exports can then show both numbers. + +### 3. Cache interaction + +A cache hit must not claim the original fetch's API usage as new usage, and +must not destroy the cached measurement either. + +- Add a small `annotate_cache_hit(data)` helper (e.g. in `report_cache.py`) + that sets `data["api_estimate"]["from_cache"] = True`. Leave + `actual_requests` as the original fetch's count; renderers print + "0 new API requests (N during the original fetch)". +- Call it from all three cache-hit sites: + 1. `cli_email_report._load_or_fetch_email_data()` + 2. `legacy_report.run_legacy_report_session()` + 3. `gui_backend.run_legacy_report_data()` (`gui_backend.py:358`) — currently + returns cached data unannotated, so the GUI legacy table would label a + cache hit as a live fetch. +- Do not put the annotation inside `load_cached_report`: `test_report_cache.py:65` + asserts `loaded == data`. +- Bump `report_cache.CACHE_VERSION` from 3 to 4. Reason: the report shape + changes, and v3 snapshots would otherwise render as live fetches with 0 + actuals. `test_report_cache.py:131` already covers `CACHE_VERSION - 1` + rejection. + +### 4. Reporting surfaces + +Add a shared formatter module `src/github_usage/report_api_usage.py` with one +pure lines function plus a shared rows adapter, matching the existing +`email_actions_table_rows` convention (`_email_report_common.py:30-39`): + +- `api_usage_lines(estimate: dict) -> list[str]` +- `api_usage_rows(estimate: dict) -> list[tuple[str, str]]` derived from the + lines (label/value pairs for HTML tables, CSV, XLSX, PDF). + +Suggested content (compact): + +``` +REST API Usage +- Actual requests: 123 (estimated 120) +- Core quota remaining before: 4,877 / 5,000 +- Core rate limit: 5,000 requests/hour (authenticated) — https://docs.github.com/en/rest/using-the-rest-api/rate-limits-for-the-rest-api +- By resource: billing 20, repos 1, actions 100, rate_limit 1, other 1 +- Source: live fetch +``` + +On a cache hit: `- Source: cached report (0 new API requests; 123 during the original fetch)`. + +Surface-by-surface: + +- **Email text** (`email_report_text.py`): do NOT add a new + `_SECTION_FORMATTERS` entry — the quota notes are rendered after the loop + (`email_report_text.py:445-448`). Extend the existing "REST API Quota + Notes" block to include the usage lines above the notes. +- **Email HTML** (`email_report_html.py`): likewise extend + `_html_api_notes_block()` (`email_report_html.py:434-442`) rather than + adding a new `_SECTION_HTML_FORMATTERS` entry. Render the usage rows in the + existing `
Artifact scan truncated at " f"{artifact_storage.get('max_repos')} repositories.
" ) + errors = artifact_storage.get("errors") or {} + if errors: + parts.append("Artifact scan truncated at "
diff --git a/src/github_usage/export_pdf.py b/src/github_usage/export_pdf.py
index ae8c35f..09cc723 100644
--- a/src/github_usage/export_pdf.py
+++ b/src/github_usage/export_pdf.py
@@ -225,15 +225,17 @@ def _write_sources_page(add_section: AddSectionFn, data: dict) -> None:
def _write_artifact_storage_page(add_section: AddSectionFn, data: dict) -> None:
artifacts = data.get("artifact_storage") or {}
artifact_repos = artifacts.get("top_repos") or []
- rows = [
+ # Error rows first: add_section renders only rows[:_MAX_SECTION_ROWS], and
+ # repo rows (capped at 5 upstream) must never push errors off the page.
+ errors = artifacts.get("errors") or {}
+ rows = [(repo_name, f"skipped: {errors[repo_name]}") for repo_name in sorted(errors)]
+ rows.extend(
(
_annotated_repo_label(entry),
f"{_fmt_num(entry.get('artifact_bytes'))} bytes",
)
for entry in artifact_repos
- ]
- for repo_name in sorted(artifacts.get("errors") or {}):
- rows.append((repo_name, f"skipped: {artifacts['errors'][repo_name]}"))
+ )
if rows:
add_section("Artifact Storage", rows)
diff --git a/tests/test_email_report.py b/tests/test_email_report.py
index 8e7647a..f529001 100644
--- a/tests/test_email_report.py
+++ b/tests/test_email_report.py
@@ -693,9 +693,16 @@ def test_artifact_storage_errors_rendered_alongside_rows_text(self):
}
}
text = "\n".join(_format_artifact_storage_section(data))
- self.assertIn("org/good", text)
- self.assertIn("org/bad", text)
- self.assertIn("skipped", text)
+ self.assertIn("- org/good: 0.0 MB artifacts", text)
+ self.assertIn("- org/bad: skipped (API error 403)", text)
+
+ def test_artifact_storage_errors_only_section_text(self):
+ from github_usage.email_report_text import _format_artifact_storage_section
+
+ data = {"artifact_storage": {"top_repos": [], "errors": {"org/bad": "API error 403"}}}
+ text = "\n".join(_format_artifact_storage_section(data))
+ self.assertIn("Actions Artifact Storage", text)
+ self.assertIn("- org/bad: skipped (API error 403)", text)
def test_artifact_storage_grouped_by_visibility_html(self):
from github_usage.email_report_html import _format_html_artifact_storage_section
@@ -721,13 +728,26 @@ def test_artifact_storage_errors_rendered_alongside_rows_html(self):
"top_repos": [
{"repo": "org/good", "visibility": "public", "artifact_bytes": 1024},
],
+ "errors": {"org/a&b": "oops Artifact scan truncated at "
f"{artifact_storage.get('max_repos')} repositories.Actions Artifact Storage
", joined)
+ self.assertIn("", joined)
def test_release_assets_grouped_by_visibility_text(self):
from github_usage.email_report_text import _format_release_assets_section
diff --git a/tests/test_export_pdf.py b/tests/test_export_pdf.py
index 99dee08..edd4d77 100644
--- a/tests/test_export_pdf.py
+++ b/tests/test_export_pdf.py
@@ -203,6 +203,44 @@ def recording(title, rows):
labels = [label for label, _ in rows]
self.assertIn("org/good", labels)
self.assertIn("org/bad", labels)
+ values = dict(rows)
+ self.assertEqual(values["org/bad"], "skipped: API error 403")
+
+ def test_write_artifact_storage_page_errors_first_and_errors_only(self):
+ from fpdf import FPDF
+
+ from github_usage.export_pdf import _make_pdf_writer, _write_artifact_storage_page
+
+ pdf = FPDF()
+ pdf.set_auto_page_break(auto=True, margin=20)
+ seen = []
+
+ def recording(title, rows):
+ seen.append((title, rows))
+ add_section(title, rows)
+
+ add_section, _ = _make_pdf_writer(pdf)
+ data = {
+ "artifact_storage": {
+ "top_repos": [{"repo": f"org/repo{i}", "artifact_bytes": 1024} for i in range(5)],
+ "errors": {f"org/bad{i}": "API error 403" for i in range(26)},
+ }
+ }
+ _write_artifact_storage_page(recording, data)
+ self.assertEqual(len(seen), 1)
+ _, rows = seen[0]
+ # Error rows precede repo rows so the 30-row page cap truncates
+ # successful rows first, never silently dropping failures.
+ self.assertTrue(all(label.startswith("org/bad") for label, _ in rows[:26]))
+ self.assertTrue(all(label.startswith("org/repo") for label, _ in rows[26:]))
+
+ seen.clear()
+ _write_artifact_storage_page(
+ recording,
+ {"artifact_storage": {"top_repos": [], "errors": {"org/bad": "API error 403"}}},
+ )
+ self.assertEqual(len(seen), 1)
+ self.assertEqual(seen[0][1], [("org/bad", "skipped: API error 403")])
def test_dependency_check_at_orchestrator(self):
from github_usage import export_report
diff --git a/tests/test_report_optional.py b/tests/test_report_optional.py
index 37cfd30..b560ffd 100644
--- a/tests/test_report_optional.py
+++ b/tests/test_report_optional.py
@@ -93,6 +93,8 @@ def test_handles_empty_artifacts(self):
def test_records_per_repo_error_and_keeps_other_repos(self):
"""One repo's artifact API error must not abort the whole scan."""
api = FakeAPI()
+ # Failing repo first: the error side_effect pairs with the first repo,
+ # proving the scan continues past it (order matters here).
with mock.patch.object(
api,
"get_all_pages",
From 1a1b18b96af7867d139a9db8146ade80762dc2c8 Mon Sep 17 00:00:00 2001
From: kgrizz-git <216068303+kgrizz-git@users.noreply.github.com>
Date: Tue, 10 Nov 2026 22:03:21 -0500
Subject: [PATCH 12/15] Clarify legacy carve-out and scope labels in API
tracking plan
The _limited_repos carve-out applies to actual_requests_by_resource in the same bucket(s); scope labels are per-estimate (repo-level for email, account-level-inclusive for legacy).
---
.../plans/2026-11-09-api-call-tracking.md | 14 +++++++++-----
1 file changed, 9 insertions(+), 5 deletions(-)
diff --git a/docs/superpowers/plans/2026-11-09-api-call-tracking.md b/docs/superpowers/plans/2026-11-09-api-call-tracking.md
index 22c5b41..4f976d3 100644
--- a/docs/superpowers/plans/2026-11-09-api-call-tracking.md
+++ b/docs/superpowers/plans/2026-11-09-api-call-tracking.md
@@ -160,10 +160,13 @@ Matching windows (baseline capture points):
(`estimate_scope`) so the variance stays honest.
Carve `_limited_repos()` out of `actual_requests`: snapshot the counter
around that call (`legacy_report_data.py:234`) and subtract those
- repository-listing page fetches from the delta while retaining them in
- `total_requests`. Neither estimate models listing pagination, so a second
- `/user/repos` page at 101+ repos must not move the variance. (The email
- builder needs no carve-out: its baseline is already post-listing.)
+ repository-listing page fetches from the delta — including from
+ `actual_requests_by_resource`, in whichever bucket(s) the listing pages
+ were recorded in, so the reconciliation assertion still holds. Neither
+ estimate models listing pagination, so a second `/user/repos` page at
+ 101+ repos must not move the variance. (The email builder needs no
+ carve-out: its baseline is already post-listing, and its `actual_requests`
+ is a sum of per-repo-getter deltas rather than a window delta.)
Merge points (must be after the last fetch):
- `build_report_data`: immediately before
@@ -241,7 +244,8 @@ REST API Usage
```
The scope label comes from `estimate_scope`: email renderers qualify it as
-repo-level scope, legacy renderers as account-level-inclusive scope.
+repo-level scope (`Repo-level requests in estimate scope:`), legacy renderers
+as account-level-inclusive scope.
On a cache hit: `- Source: cached report (0 new API requests; 130 total during the original fetch)`.
From 9e5bc7c3470de8b1e468d040eae8e62c8cd1dce5 Mon Sep 17 00:00:00 2001
From: kgrizz-git <216068303+kgrizz-git@users.noreply.github.com>
Date: Tue, 10 Nov 2026 22:09:23 -0500
Subject: [PATCH 13/15] Fix 3 new SonarCloud issues in email_report_html.py
Split _format_html_artifact_storage_section into repo-row and error-row helpers (cognitive complexity 20 to 5, S3776). Replace consecutive append() calls with extend() in the Copilot section and report head (S9454 x2). Behavior-neutral; existing tests cover all three paths.
---
src/github_usage/email_report_html.py | 80 +++++++++++++++------------
1 file changed, 45 insertions(+), 35 deletions(-)
diff --git a/src/github_usage/email_report_html.py b/src/github_usage/email_report_html.py
index 07ef93f..b1e6549 100644
--- a/src/github_usage/email_report_html.py
+++ b/src/github_usage/email_report_html.py
@@ -89,9 +89,7 @@ def _format_html_copilot_section(data: dict) -> list[str]:
parts.append(f"
By model
")
- parts.append("")
+ parts.extend([_UL_CLOSE, "
By model
", ""])
for model, values in sorted(by_model.items()):
detail = copilot_model_detail_line(model, values, metering=metering).strip()
if detail.startswith("- "):
@@ -220,46 +218,54 @@ def _format_html_workflow_breakdown_section(data: dict) -> list[str]:
return html_workflow_breakdown_table(breakdown, limit=5)
+def _html_artifact_repo_rows(repos: list) -> list[str]:
+ """Render artifact repo rows as list items, grouped by visibility."""
+ groups = group_by_visibility(repos)
+ if len(groups) <= 1:
+ rows = [
+ f"
", *rows, _UL_CLOSE]
+ parts = []
+ for vis, group_rows in groups.items():
+ parts.append(f"
{html.escape(visibility_group_header(vis))}
")
+ parts.append("")
+ for row in group_rows:
+ parts.append(
+ f"
", *rows, _UL_CLOSE]
+
+
def _format_html_artifact_storage_section(data: dict) -> list[str]:
artifact_storage = data.get("artifact_storage")
if not artifact_storage:
return []
- repos = artifact_storage.get("top_repos", [])
parts = ["
Actions Artifact Storage
"]
+ repos = artifact_storage.get("top_repos", [])
if repos:
- groups = group_by_visibility(repos)
- if len(groups) <= 1:
- parts.append("")
- for row in repos:
- parts.append(
- f"
{html.escape(visibility_group_header(vis))}
")
- parts.append("")
- for row in group_rows:
- parts.append(
- f"
")
- for repo_name in sorted(errors):
- parts.append(
- f"
GitHub Usage Report for {username}
")
- parts.append(f'')
- parts.append('')
+ parts.extend(
+ [
+ f"GitHub Usage Report for {username}
",
+ f'',
+ '',
+ ]
+ )
parts.extend(_html_warning_block(data.get("warnings") or []))
for formatter in _SECTION_HTML_FORMATTERS:
if formatter is _format_html_forecast_section:
From 13c200a4781cb80c6160bbfd2764786703bc7e2a Mon Sep 17 00:00:00 2001
From: kgrizz-git <216068303+kgrizz-git@users.noreply.github.com>
Date: Tue, 10 Nov 2026 22:25:12 -0500
Subject: [PATCH 14/15] Add missing docstrings to touched renderers
Satisfies the docstring-coverage pre-merge check: one-line docstrings for the artifact/copilot section formatters and the artifact storage page writer touched by this branch.
---
src/github_usage/email_report_html.py | 2 ++
src/github_usage/email_report_text.py | 1 +
src/github_usage/export_pdf.py | 1 +
3 files changed, 4 insertions(+)
diff --git a/src/github_usage/email_report_html.py b/src/github_usage/email_report_html.py
index b1e6549..e933509 100644
--- a/src/github_usage/email_report_html.py
+++ b/src/github_usage/email_report_html.py
@@ -77,6 +77,7 @@ def _format_html_actions_section(data: dict) -> list[str]:
def _format_html_copilot_section(data: dict) -> list[str]:
+ """Format the Copilot usage section as HTML."""
copilot = data.get("copilot")
if not copilot:
return []
@@ -253,6 +254,7 @@ def _html_artifact_error_rows(errors: dict) -> list[str]:
def _format_html_artifact_storage_section(data: dict) -> list[str]:
+ """Format the Actions Artifact Storage section as HTML, including per-repo errors."""
artifact_storage = data.get("artifact_storage")
if not artifact_storage:
return []
diff --git a/src/github_usage/email_report_text.py b/src/github_usage/email_report_text.py
index 2b26488..edab6fd 100644
--- a/src/github_usage/email_report_text.py
+++ b/src/github_usage/email_report_text.py
@@ -265,6 +265,7 @@ def _format_workflow_breakdown_section(data: dict) -> list[str]:
def _format_artifact_storage_section(data: dict) -> list[str]:
+ """Format the Actions Artifact Storage section, including per-repo scan errors."""
artifact_storage = data.get("artifact_storage")
if not artifact_storage:
return []
diff --git a/src/github_usage/export_pdf.py b/src/github_usage/export_pdf.py
index 09cc723..7fefc94 100644
--- a/src/github_usage/export_pdf.py
+++ b/src/github_usage/export_pdf.py
@@ -223,6 +223,7 @@ def _write_sources_page(add_section: AddSectionFn, data: dict) -> None:
def _write_artifact_storage_page(add_section: AddSectionFn, data: dict) -> None:
+ """Write the Artifact Storage page, including per-repo scan errors."""
artifacts = data.get("artifact_storage") or {}
artifact_repos = artifacts.get("top_repos") or []
# Error rows first: add_section renders only rows[:_MAX_SECTION_ROWS], and
From 5013151c7f6440036cb976c864372ca9b54e6b49 Mon Sep 17 00:00:00 2001
From: kgrizz-git <216068303+kgrizz-git@users.noreply.github.com>
Date: Tue, 10 Nov 2026 22:25:13 -0500
Subject: [PATCH 15/15] Require pre-init baseline for GUI legacy path in plan
gui_backend.run_legacy_report_data shares _init_github_api, which issues its own GET /user on the fresh client. A builder-entry default would exclude it while the CLI window includes pre-builder calls, so the GUI caller must supply a pre-initialization (fresh-client zero) baseline for comparable counts.
---
.../plans/2026-11-09-api-call-tracking.md | 19 +++++++++++++------
1 file changed, 13 insertions(+), 6 deletions(-)
diff --git a/docs/superpowers/plans/2026-11-09-api-call-tracking.md b/docs/superpowers/plans/2026-11-09-api-call-tracking.md
index 4f976d3..3c8df25 100644
--- a/docs/superpowers/plans/2026-11-09-api-call-tracking.md
+++ b/docs/superpowers/plans/2026-11-09-api-call-tracking.md
@@ -152,12 +152,19 @@ Matching windows (baseline capture points):
(`fetch_account_info` / `fetch_rate_limits`, `legacy_report.py:99-101`).
A builder-entry baseline would miss them while the estimate counts them.
So: add an optional `baseline_stats: dict | None = None` parameter;
- `run_legacy_report_session` captures the snapshot before its first fetch
- and passes it in. The GUI path (`gui_backend.run_legacy_report_data`,
- `gui_backend.py:361-368`) makes no pre-builder fetches, so it may pass an
- equivalent snapshot or rely on the default. When `baseline_stats` is None,
- the builder snapshots at entry and records the narrower scope
- (`estimate_scope`) so the variance stays honest.
+ `run_legacy_report_session` captures the snapshot before its first
+ API-calling operation (`check_user_scope`, which GETs `/user` when no user
+ payload is passed) and passes it in. The GUI path
+ (`gui_backend.run_legacy_report_data`, `gui_backend.py:361-368`) shares
+ `_init_github_api`, which issues its own pre-builder `GET /user` on the
+ fresh client (`cli_email_report.py:83`) — so a builder-entry default
+ snapshot would exclude that call while the CLI window includes its
+ pre-builder calls. The GUI caller must therefore supply a baseline
+ captured before initialization (a fresh-client zero snapshot is
+ equivalent), never the entry default, preserving comparable counts with
+ the CLI. When `baseline_stats` is None (direct builder use), the builder
+ snapshots at entry and records the narrower scope (`estimate_scope`) so
+ the variance stays honest.
Carve `_limited_repos()` out of `actual_requests`: snapshot the counter
around that call (`legacy_report_data.py:234`) and subtract those
repository-listing page fetches from the delta — including from