Skip to content

test(usage): pin checkpoint fixture clock after scan yields - #8571

Merged
lidge-jun merged 8 commits into
lidge-jun:devfrom
atinseau:codex/test-usage-checkpoint-clock
Nov 14, 2026
Merged

lidge-jun merged 8 commits into
lidge-jun:devfrom
atinseau:codex/test-usage-checkpoint-clock

Conversation

@atinseau

@atinseau atinseau commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

Summary

The checkpoint-digest test can fail with content_changed on a loaded worker after #8455. Its fourth cancellation check deliberately rewrites the ledger after verification, but an 8 ms row yield adds an earlier check and triggers the rewrite before verification. Pin the monotonic clock only in this fixture and restore it in finally; keep the scanner's elapsed-time and cancellation tests on their existing controlled clocks.

Addresses the post-merge CodeRabbit finding on #8455 and the Codex finding at #8455 (comment). Runtime scheduling, cancellation checks, the 750 ms health probe and lock-acquisition budget are unchanged. No user documentation change is needed for this test-only fix.

Verification

Current-head validation at 52435fff938f29b7969c6afec2b9ce95b9e26e43 after merging dev 873ec9b3b8ddf63f06738748d9132d779abefb42:

  • bun test tests/usage/usage-ledger-scanner.test.ts: 23 pass, 0 fail, including elapsed-time yields and post-yield cancellation.
  • bun run typecheck: no errors in 2,533 files. bun run privacy:scan, bun run structure:check and git diff --check --cached origin/dev (before this commit): pass.
  • bun test tests/ci-workflows/file-size-ratchet.test.ts: 9 pass, 0 fail.
  • The personal patch retains the same stable patch ID after the base refresh. Historical red/green at 114698a7: an advancing 9 ms clock makes the original checkpoint fixture fail with content_changed; only that fixture clock is pinned by the fix. That reproduction was not repeated for this base refresh.
  • Resource exception: scoped validation covers this followup on the new base. The shared Mac runs the live proxy; earlier broad runs were costly. The full suite and cross-platform CI were not run locally, and no manual full-CI workflow was dispatched.

Checklist

  • Scope stays focused and avoids unrelated cleanup.
  • Docs or release notes were updated when needed (no user behavior change).
  • Security-sensitive changes were reviewed for secrets, auth, and unsafe defaults (test clock only).

Review readiness checklist

  • Required local validation passed; commands, results, and any full-suite exception are documented.
  • I pushed my PR to a recent dev commit (at most 10 behind; a maintainer may still ask for the exact tip before merge).
  • I resolved all correct Codex and CodeRabbit findings.
  • My PR is ready for review.

Ready for review based on the verified local checks above. This does not attest completion of a fresh automated review or required CI.

Summary by CodeRabbit

  • Tests
    • Improved the reliability of a ledger-scanning test by isolating rewrite timing and ensuring the timing spy is restored, while retaining checks for detected content changes.

@github-actions

Copy link
Copy Markdown
Contributor

✅ Deterministic PR hygiene checks passed.

@github-actions github-actions Bot added the chore Maintenance, CI, tests, refactors, or build changes (not a user-facing bug or feature). label Nov 11, 2026
@coderabbitai

coderabbitai Bot commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The checkpoint-digest test now freezes performance.now() during the ledger rewrite scenario and restores the spy in finally. It still checks that the scan returns the original checkpoint and that a later incremental scan detects changed content.

Changes: Checkpoint digest test

Layer / File(s) Summary
Control timing in the rewrite scenario
tests/usage/usage-ledger-scanner.test.ts
The test freezes performance.now() around the rewrite-after-verification scenario and restores the spy in finally. It retains the assertions for the original checkpoint and the content_changed result.

Estimated code review effort: 2 (Simple) | ~8 minutes

Change: Other

Possibly related PRs

  • lidge-jun/opencodex#8455: Adds the 8 ms yield that allows the checkpoint-digest test timer to run before verification.

Suggested labels: chore, review-ready

Merge Risk: Minimal · up to 11469

This change only stabilizes a test fixture's timing and does not alter production behavior. No actionable merge risk remains beyond normal CI.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title clearly and concisely describes the main change: pinning the checkpoint fixture clock after scan yields in the usage test.
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between de0914a and 114698a.

Files selected for processing: 1

  • tests/usage/usage-ledger-scanner.test.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.

@github-actions

github-actions Bot commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

✅ READY

  • all PR quality gates passed; the review readiness checklist is complete.

Review readiness checklist

  • ✅ Required local validation passed; commands, results, and any full-suite exception are documented.
  • ✅ I pushed my PR to a recent dev commit (at most 10 behind; a maintainer may still ask for the exact tip before merge).
  • ✅ I resolved all correct Codex and CodeRabbit findings.
  • ✅ My PR is ready for review.

✅ 4/4 boxes ticked.

This pull request is already Ready for Review.
The review-ready label marks this PR as ready; review automation runs independently.
Maintainers notified: @lidge-jun @Ingwannu

Hygiene

✅ Deterministic PR hygiene checks passed.

@github-actions
github-actions Bot marked this pull request as draft November 12, 2026 10:07
@github-actions
github-actions Bot marked this pull request as ready for review November 12, 2026 10:08
@github-actions
github-actions Bot marked this pull request as draft November 13, 2026 02:07
@github-actions
github-actions Bot marked this pull request as ready for review November 13, 2026 02:08
@github-actions
github-actions Bot marked this pull request as draft November 13, 2026 05:18
@atinseau
atinseau marked this pull request as ready for review November 13, 2026 05:19
@github-actions
github-actions Bot marked this pull request as draft November 13, 2026 08:32
@github-actions
github-actions Bot marked this pull request as ready for review November 13, 2026 08:32
@github-actions
github-actions Bot marked this pull request as draft November 13, 2026 11:35
@atinseau
atinseau marked this pull request as ready for review November 13, 2026 11:36

@Ingwannu Ingwannu left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Approved for exact head dafb1841ec6c3fc1b99f962acac44a60c00e189f targeting dev.

The one-file diff pins the monotonic clock only around the checkpoint rewrite fixture and restores it in finally. The returned digest still has to match the previously verified bytes, and the subsequent append scan still must reject content_changed; the separate elapsed-yield/cancellation cases are unchanged. I read the actual hosted test-changed log in run43418305333: the checkpoint case and the neighboring yield/cancellation/integrity controls executed successfully. The gates Typecheck step and aggregate ci are successful.

Fresh Ready/head/review/thread state is clear and the branch is within the policy ancestry limit. Other Cargo workloads occupied the shared local host, so local testing was deferred without overlapping/killing that work or raising limits. Hosted execution and author receipts are identified above. No live service/config/native-account change, scan, new cross-platform dispatch, merge or release was performed.

@github-actions
github-actions Bot marked this pull request as draft November 13, 2026 18:08
@atinseau
atinseau marked this pull request as ready for review November 13, 2026 18:08
@github-actions
github-actions Bot marked this pull request as draft November 14, 2026 00:26
@atinseau
atinseau marked this pull request as ready for review November 14, 2026 00:26
@lidge-jun

Copy link
Copy Markdown
Owner

Maintainer integration into dev (MAINTAINERS.md dev path), recorded by lidge-jun.

  • Head: 52435fff938f29b7969c6afec2b9ce95b9e26e43
  • Scope reviewed: test-only: pins performance.now in the checkpoint rewrite fixture; approved by @Ingwannu.
  • Exact-head CI: Cross-platform CI run 43534181537 success (https://github.com/lidge-jun/opencodex/actions/runs/43534181537); Catalog async contracts and PR gates pass.
  • Merge gate: scripts/ci/assert-mergeable-review.sh --maintainer-integration OK at this head.

Thanks @atinseau.

@lidge-jun
lidge-jun merged commit aa33c83 into lidge-jun:dev Nov 14, 2026
34 of 35 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

chore Maintenance, CI, tests, refactors, or build changes (not a user-facing bug or feature). review-ready

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants