Skip to content

[bench] stats: one weekly grouping; tokens by week in cli stats and the dashboard - #66

Merged
dburks-svg merged 3 commits into
mainfrom
bench/tokens-by-week
Sep 7, 2026
Merged

dburks-svg merged 3 commits into
mainfrom
bench/tokens-by-week

Conversation

@dburks-svg

@dburks-svg dburks-svg commented Sep 7, 2026 •

Copy link
Copy Markdown
Contributor

Gates the v2.1.0 tag. Release check R3 requires the dashboard to show the release week's median tokens per edit, and neither cli stats nor the viewer exposed tokens by week: the CLI printed tokens over all entries, and the dashboard grouped only verdicts and latency by week. Codex caught the README claiming otherwise on #65.

What

  • One grouping. utils.stats.entries_by_week groups entries by the ISO week of their timestamp, with unparseable timestamps in the unknown bucket. The verdict table and the latency table are refactored onto it with their outputs unchanged, which the existing exact-equality tests confirm.
  • tokens_by_week builds on it: per week, the same median and p90 the all-entries line prints plus the cached-rate medians, over entries that recorded usage, with empty weeks omitted rather than shown as zero.
  • Two surfaces. cli stats prints a "Tokens by week" block, one line per week. The viewer's tokens card gains a per-week table: entries, median, p90, median at cached rates.
  • README. The What It Costs section is a fixed snapshot of the chain at 2026-09-07T06:37:19Z (2,767 entries, 2,743 with usage), stated as such rather than as a live weekly value, and the reproducibility paragraph names the two interfaces that expose the weekly rows and the shared grouping behind them.

Tests

  • ISO week boundaries: Sunday 2026-01-04 closes W01 and Monday opens W02; the last days of 2025 fall in 2026-W01; New Year's Day 2027 falls in 2026-W53.
  • The unknown bucket for unparseable and missing timestamps, and that it sorts last.
  • All three weekly tables share the grouping.
  • Missing usage skipped, a week holding only malformed usage omitted, cached-rate pricing, agreement with the all-entries figures for a single week, the empty ledger.
  • The dashboard row and the CLI line, with explicit figures.

Receipts

On the live chain at the snapshot cutoff:

Week Entries with usage Median tokens 90th percentile Median at cached rates Median seconds
2026-W36, the roadmap week 1,777 34,747 42,650 33,451 63.5
2026-W37, the release week at the snapshot 118 20,383 36,811 19,085 26.6
Every entry with usage in the snapshot 2,743 34,917 44,401 33,899 61.1 (1,673 timed)

The release-week median moved from under 20,000 to just over it on the day of the snapshot as heavier edits landed; the README says it is not a settled reduction.

  • ruff check . clean; python -m mypy (strict, CI file set) clean.
  • Full suite: 1036 tests OK, 20 skipped. One of the author's own expectations was an ISO-week miscount and the test caught it.
  • Bench's own live chain verifies VALID; every hunk governed.
  • No em or en dashes added.

After merge

Tag the merge commit v2.1.0 (R6). Release notes are drafted at the same snapshot cutoff.

…he dashboard

Release check R3 requires the dashboard to show the release week's
median tokens per edit, and neither cli stats nor the viewer exposed
tokens by week: the CLI printed tokens over all entries, and the
dashboard grouped only verdicts and latency by week.

utils.stats.entries_by_week is now the one grouping every per-week
figure is built on: entries by the ISO week of their timestamp, with
unparseable timestamps in the unknown bucket. stats_by_week and
latency_by_week are refactored onto it with their outputs unchanged,
which the existing exact-equality tests confirm, and tokens_by_week
builds on it too: per week, the same median and p90 the all-entries
line prints plus the cached-rate medians, over entries that recorded
usage, with empty weeks omitted rather than shown as zero. cli stats
prints a Tokens by week block, one line per week, and the viewer's
tokens card gains a per-week table.

Tests cover the ISO week boundaries (Sunday closes W01 and Monday opens
W02; the last days of 2025 fall in 2026-W01; New Year's Day 2027 falls
in 2026-W53), the unknown bucket, all three weekly tables sharing the
grouping, missing and malformed usage, cached-rate pricing, agreement
with the all-entries figures for a single week, the empty ledger, the
dashboard row, and the CLI line.

The README's What It Costs section is refreshed as a fixed snapshot of
the chain at 2026-09-07T06:37:19Z (2,767 entries, 2,743 with usage),
stated as such rather than as a live weekly value, and the
reproducibility paragraph now names the two interfaces that expose the
weekly rows and the shared grouping behind them.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0122bFBUvdtXT245QFoYDkMf
@dburks-svg

Copy link
Copy Markdown
Contributor Author

@codex review

SonarCloud S5906 on #66: a set-subset check written as assertTrue over
a comparison reads better, and fails with the two sets shown, as
assertLessEqual.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0122bFBUvdtXT245QFoYDkMf

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 13414aece7

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread cli/commands.py
Codex review on #66: the weekly lines dropped the p90 that
tokens_by_week computes, so cli stats could not reproduce the README
table's 90th-percentile column. Each line now carries median, p90, and
the cached-rate median beside the entry count.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0122bFBUvdtXT245QFoYDkMf
@sonarqubecloud

sonarqubecloud Bot commented Sep 7, 2026

Copy link
Copy Markdown

@dburks-svg
dburks-svg merged commit b2a808c into main Sep 7, 2026
10 checks passed
@dburks-svg
dburks-svg deleted the bench/tokens-by-week branch September 7, 2026 07:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant