Skip to content

Recalculate stale accounting snapshots on launch#7

Merged
Backtthefuture merged 1 commit into
mainfrom
codex/recalculate-on-accounting-revision
Jul 21, 2026
Merged

Recalculate stale accounting snapshots on launch#7
Backtthefuture merged 1 commit into
mainfrom
codex/recalculate-on-accounting-revision

Conversation

@Backtthefuture

Copy link
Copy Markdown
Owner

What changed

  • Detect a persisted Codex accounting revision older than the current collector immediately after loading the snapshot.
  • Start recalibration before snapshot-age and automatic-refresh checks, including when periodic refresh is disabled.
  • Keep the existing migration validation and old-snapshot preservation behavior if recalibration fails.
  • Add a pure startup refresh policy with coverage for legacy, older, current, future, and empty snapshots.
  • Update the Agent dashboard render fixture so it does not accidentally trigger a real migration.
  • Bump the app and release documentation from 0.1.44 to 0.1.45.

Root cause

After upgrading to 0.1.44, the app loaded a revision-4 snapshot generated 24 seconds earlier. Startup only checked snapshot age, so it waited for the 300-second timer before running the revision-8 collector. During that window the UI displayed the old inflated 543,213,648-token total instead of the recalibrated value around 188 million.

User impact

When a future collector accounting revision changes, TokenStep now starts recalculation immediately on launch and shows its normal syncing state instead of waiting several minutes with stale accounting. Current-revision snapshots and empty/new installations do not enter a refresh loop.

Validation

  • ./script/test_usage_recalibration_migration.sh
  • ./script/test_codex_cumulative_collector.sh
  • ./script/test_ccswitch_proxy_collector.sh
  • isolated startup refresh policy harness
  • ./script/render_agent_work_card.sh
  • full TokenStep and helper build
  • generated bundle verified as CFBundleShortVersionString=0.1.45 and CFBundleVersion=0.1.45
  • git diff --check

Local SwiftPM XCTest execution is unavailable because this machine only has Command Line Tools and its PackageDescription linkage is incomplete; GitHub Actions on macOS-15 will run the full XCTest suite.

@Backtthefuture
Backtthefuture marked this pull request as ready for review July 21, 2026 08:04
@Backtthefuture
Backtthefuture merged commit a44b2e9 into main Jul 21, 2026
1 check passed
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