Skip to content

Port upstream 0.69.0: reset Codex weekly baseline on plan change (stacked on #629) - #690

Open
Finesssee wants to merge 1 commit into
port/micro-0.65.0-codex-weekly-reset-rollingfrom
port/micro-0.69.0-codex-plan-change-baseline
Open

Finesssee wants to merge 1 commit into
port/micro-0.65.0-codex-weekly-reset-rollingfrom
port/micro-0.69.0-codex-plan-change-baseline

Conversation

@Finesssee

Copy link
Copy Markdown
Collaborator

Summary

A Codex subscription change (for example Plus to Pro) now starts a new weekly-quota baseline instead of being judged against the previous plan's published weekly window.

  • initial_decision: when the source is exact OAuth, the observation is newer than the stored one, and both the stored and fresh plans are known and differ (trimmed, case-insensitive), the account state is reset (published weekly, pending candidate, credit inventory). preserve_weekly therefore no longer pins the previous plan's weekly window.
  • confirmation_decision: a near-zero weekly confirmation now requires the initial and confirmation plans to match (normalized; unknown vs known counts as different). A nonzero confirmation can still publish its own plan.
  • codex_reset_backfill (backfill_slot_window): skipped for Codex when both cached and fresh plan_name are known and differ, so the old plan's reset times are not copied onto the new plan.
  • Unknown or blank plans never reset the baseline.

Stacked on #629 (weekly_reset.rs and its tests).

Upstream reference

Ported / Deferred

  • Ported: the plan-change half of fix(codex): retry auth reads and reset quota baselines on plan changes steipete/CodexBar#4088 (item 6b): weekly-reset baseline, confirmation plan equality, and backfill guard.
  • Deferred to the separate PR port/micro-0.69.0-codex-auth-publication-retry: credential-file publication retry (item 6a).
  • Not applicable locally: upstream's UsageStore+TokenAccounts multi-snapshot backfill filter (no equivalent path in the Windows shell; the single cached-snapshot backfill guard covers it).
  • Windows difference: the reset baseline is the persisted per-account weekly-reset state (AccountState), so the whole state is reset rather than separate in-memory snapshots.

Validation

Cargo run with +1.98.0, target slot-4, E-core pinned.

  • cargo +1.98.0 fmt --all: clean
  • cargo +1.98.0 clippy --workspace --all-targets -- -D warnings: pass
  • cargo +1.98.0 test -p codexbar weekly_reset -- --test-threads=4: 21 passed, 0 failed (7 new)
  • cargo +1.98.0 test -p codexbar providers::codex -- --test-threads=4: 61 passed, 0 failed
  • cargo +1.98.0 test -p codexbar-desktop-tauri backfill -- --test-threads=4: 8 passed, 0 failed (2 new)

New fixtures: Plus to Pro upgrade with an 80%-used published weekly (baseline reset, confirmation publishes); same-plan near-zero refresh (baseline kept); unknown/blank/stale/non-OAuth (baseline kept); pending candidate discarded on plan change; near-zero confirmation with a changed or unknown plan preserved; nonzero confirmation publishes its own plan; backfill skipped only when both plans known and differ.

Affected areas

  • Rust backend (rust/src/providers/codex)
  • Tauri shell (commands/providers.rs, values only)
  • Frontend, tray, settings, float bar (none)

Note: commands/providers.rs was already over 1000 lines (1429); this adds about 52 lines including tests.

UI proof

Not applicable (values only; no UI surface changed).

@coderabbitai

coderabbitai Bot commented Sep 29, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Advanced

Run ID: ba122382-81ce-4da7-88fe-df127f06c0f4

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

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.

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