Skip to content

test: hold the usage snapshot burst clock fixed - #24551

Merged
nwparker merged 1 commit into
mainfrom
nwparker/test-audit-rate-limit
Oct 2, 2026
Merged

nwparker merged 1 commit into
mainfrom
nwparker/test-audit-rate-limit

Conversation

@nwparker

@nwparker nwparker commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​2 0 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​2
Prod 0 0 0 0

ELI5

A test assumed 31 disk writes would finish before the rate limiter replenished a token. On a busy machine they sometimes take longer, so the test failed even though the limiter worked correctly.

What Changed

Hold Date.now() fixed in the rate-limited usage-snapshot test while keeping real asynchronous disk writes. Assert that retrying after a reset captures exactly one additional snapshot with the original revision.

Why

The limiter replenishes one token every two seconds. Advancing a controlled clock by 100ms per report reproduced the full-suite failure (31 captures instead of 30). A fixed clock makes this a deterministic burst, instead of increasing timeouts or changing the production limit. The existing mock cleanup restores the clock after the test.

Linked Issue

N/A — maintainer test audit.

Visual Proof

N/A — test-only change.

Testing

  • I manually tested these changes locally
  • Automated tests added/updated, or explained why not below

macOS: controlled slow-burst reproduction failed as expected; the corrected reporter and burst-cap suites passed all 23 tests. Targeted lint, formatting, changed-code quality and diff checks passed. Standard repository typecheck passed during this audit. Full desktop suite rerun follows this merge; production build and non-macOS coverage remain for CI.

Review

Self-reviewed the clock scope, mock cleanup, real disk persistence and retry count/revision assertions.

Agent skill upstream boundary

  • Not applicable, or this change follows docs/reference/agent-skill-sharing-upstream-boundary.md and copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

Notes

No production, UI, SSH, mobile or platform behavior changes.

Checklist

  • This PR is small and focused
  • I explained what changed and why (ELI5, the user-facing before/after, the mechanism, and why over the alternatives)
  • Before/after screenshots or videos attached for UI changes, or N/A with reason
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
  • pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred)

@coderabbitai

coderabbitai Bot commented Oct 2, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 5 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used all 10 included reviews currently available.

Learn how review limits work.

Review configuration:

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: b909bff6-9124-4ad9-92f9-09217e6f3a39

📥 Commits

Reviewing files that changed from the base of the PR and between 1fbfb13 and d08a0a1.

📒 Files selected for processing (1)
  • src/main/usage/agent-token-usage-reporter.test.ts
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Autopilot is currently an internal CodeRabbit preview.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@nwparker
nwparker merged commit 7ad76f8 into main Oct 2, 2026
4 of 5 checks passed
@greptile-apps

greptile-apps Bot commented Oct 2, 2026 •

Copy link
Copy Markdown

RetriggerConfidence Score: 5/5

[Low risk] Test file adds a clock mock and assertion.

The test-only change appears safe to merge.

Summary

The PR fixes the clock during the usage-snapshot burst test while retaining real asynchronous disk writes, then asserts that retrying after a limiter reset produces exactly one more capture at the original revision.

Reviews (1) · Last reviewed commit: "test: hold the usage snapshot burst cloc..."

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