Skip to content

v1.1.3 — Fix quota-aware auto rotation

Choose a tag to compare

@vaskoyudha vaskoyudha released this 04 Apr 20:09
· 15 commits to main since this release

What's Fixed

Smart rotation in auto mode now works correctly.

The QUOTA_AWARE_ROTATION flag was silently lost when cmd_auto() spawned a subprocess via flock. The subprocess re-entered load_config(), which sourced config.sh and reset the flag to 0 — so get_next_available() always fell through to round-robin instead of selecting the lowest-usage account.

Root Cause

  • cmd_auto() set QUOTA_AWARE_ROTATION=1 in the parent shell
  • with_lock ran flock -x ... -c "codex-rotate __internal_auto_preflight" — a new subprocess
  • The new subprocess called main() → load_config() → source config.sh → QUOTA_AWARE_ROTATION=0

Fix

  • cmd_auto() now exports CODEX_ROTATE__QUOTA_AWARE=1 as an environment variable
  • load_config() checks this env var after sourcing config.sh and restores QUOTA_AWARE_ROTATION=1

What's New

  • BATS test proving auto mode selects the lowest-usage account over the highest-usage one

Stats

  • 71/71 BATS tests pass
  • ShellCheck clean
  • npm install -g codex-rotate to upgrade