CodexBar icon indicating copy to clipboard operation
CodexBar copied to clipboard

Codex 0.42.0: weekly reset confetti still fires on transient zero / same-email multi-account samples

Open zhulijin1991 opened this issue 4 months ago • 2 comments

Summary

CodexBar 0.42.0 can still briefly show a Codex weekly limit as 100% remaining and play reset confetti even though the account did not reset.

This is narrower than #1986 and #1987: v0.42.0 protects Codex session reset celebrations from transient zero samples and isolates authenticated HTTP transports, but the weekly reset detector still accepts a below-threshold sample without requiring the weekly reset boundary to advance.

Environment

  • CodexBar 0.42.0 (102), official signed release
  • Codex OAuth, multiple visible accounts
  • Weekly-limit confetti enabled; session-limit confetti disabled

Observed behavior

  1. The currently selected Codex account has not reset and its real weekly remaining value is below 100%.
  2. CodexBar briefly renders 100% weekly remaining.
  3. Weekly reset confetti plays.
  4. A subsequent refresh restores the correct non-100% value.

No emails, account IDs, workspace IDs, auth fingerprints, local paths, or raw credentials are included here.

Source-level evidence

In UsageStore+PlanUtilization.swift, the reset-boundary guard applies only to session samples:

let resetBoundaryAllowsPost = descriptor.seriesName != .session
    || Self.limitResetBoundaryAdvanced(
        previous: previousState?.resetBoundary,
        current: observation.resetBoundary)

For .weekly, resetBoundaryAllowsPost is therefore always true. Any transition from usedPercent > 1 to usedPercent <= 1 can post a weekly reset event even when resetsAt has not advanced.

There is a second multi-account edge case: when a concrete token-account object is unavailable, Codex detector ownership can fall back to the Codex plan-utilization identity key, which is email-based. In the affected setup, three distinct OAuth accounts produce only two persisted Codex detector keys because two accounts have the same normalized sign-in email but distinct workspace/account identities. That lets one account seed the above-threshold baseline and another low/transient sample satisfy the crossing condition.

Relevant code:

Expected behavior

  • Weekly confetti should require a proven weekly reset boundary advance, just like the new Codex session protection.
  • Reset detector state should remain isolated by stable account/workspace/auth identity when multiple accounts share the same email.
  • A transient usedPercent == 0 response should not temporarily render a false full gauge or trigger a celebration.

Suggested regression coverage

  • Codex weekly sample changes from above threshold to zero while resetsAt is unchanged: no event.
  • Same-email Codex accounts with distinct account/workspace identities: detector baselines do not cross.
  • A real weekly reset with an advanced boundary still posts exactly once.

Related

  • #1986 fixed the transient-zero session reset path.
  • #1987 / #2019 fixed authenticated transport/cache isolation, but not detector-key or weekly-boundary isolation.

zhulijin1991 avatar Jul 11 '26 05:07 zhulijin1991

Codex review: keeping this open for maintainer follow-up; there is still a little grit to resolve. Reviewed July 11, 2026, 1:33 AM ET / 05:33 UTC.

Summary The current implementation still allows the reported false Codex weekly celebration and same-email detector collision, and no other active item owns this narrower remaining repair.

Reproducibility: yes. at source level with high confidence: an above-threshold Codex weekly state followed by a newer zero sample with the same boundary satisfies the current posting condition, and same-email snapshots can share the fallback detector key. A live OAuth reproduction was not attempted because repository policy prohibits unsolicited real-account and Keychain validation.

Root-cause cluster Relationship: canonical Canonical: https://github.com/steipete/codexbar/issues/2054 Summary: This issue is the canonical narrower follow-up for weekly boundary and fallback detector-identity gaps left after the session false-positive and authenticated transport fixes.

Members:

  • same_root_cause: https://github.com/steipete/codexbar/issues/1986 - Both concern transient low Codex samples being accepted as reset evidence, but the merged repair for the earlier report is session-specific.
  • partial_overlap: https://github.com/steipete/codexbar/issues/1987 - Both involve false multi-account quota state, while the earlier report centered on Spark mapping and authenticated transport/cache contamination.
  • partial_overlap: https://github.com/steipete/codexbar/pull/2019 - The merged PR isolates authenticated requests but does not change the verified weekly boundary bypass or email-only detector fallback.

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Next step This is a narrow, source-reproducible existing-behavior defect with clear implementation seams, focused validation, and no unresolved product or security decision.

Review details

Best possible solution:

Resolve Codex detector ownership from stable provider-account/workspace/auth provenance, require an advanced semantic weekly boundary before accepting a low sample as a reset, and prevent that rejected transient sample from replacing displayed quota state.

Do we have a high-confidence way to reproduce the issue?

Yes at source level with high confidence: an above-threshold Codex weekly state followed by a newer zero sample with the same boundary satisfies the current posting condition, and same-email snapshots can share the fallback detector key. A live OAuth reproduction was not attempted because repository policy prohibits unsolicited real-account and Keychain validation.

Is this the best way to solve the issue?

Yes directionally, but the maintainable implementation should scope boundary enforcement to Codex or providers with trustworthy reset boundaries rather than changing generic provider behavior, and it should cover both detector and displayed state.

AGENTS.md: found and applied where relevant.

Remaining risk / open question:

  • Applying a weekly boundary requirement to every provider could suppress valid celebrations where reset timestamps are absent or non-semantic; the guard should remain Codex-aware or capability-aware.
  • The celebration detector only observes recorded samples, so preventing confetti alone may not prevent the transient zero from briefly replacing the displayed weekly gauge.

Codex review notes: model internal, reasoning high; reviewed against eae19106e774.

Label changes

Label changes:

  • add P2: Current main contains a focused quota-correctness defect that produces false reset feedback but does not block setup, authentication, or core app availability.
  • add impact:ux-friction: Users can briefly see a false full weekly gauge and celebration before a subsequent refresh restores the real quota value.
  • add issue-rating: 🦞 diamond lobster: Current issue advisory state selects this label.
  • add clawsweeper:source-repro: Current issue advisory state selects this label.
  • add clawsweeper:queueable-fix: Current issue advisory state selects this label.
  • add clawsweeper:fix-shape-clear: Current issue advisory state selects this label.

Label justifications:

  • P2: Current main contains a focused quota-correctness defect that produces false reset feedback but does not block setup, authentication, or core app availability.
  • impact:ux-friction: Users can briefly see a false full weekly gauge and celebration before a subsequent refresh restores the real quota value.
Evidence reviewed

Acceptance criteria:

  • swift test --filter UsageStorePlanUtilizationCelebrationTests
  • swift test --filter CodexAccountVisibleHistoryBackfillTests
  • make check
  • make test

What I checked:

  • Weekly boundary gap: The shared detector requires reset-boundary advancement only for session series, so a newer Codex weekly sample crossing from above 1% used to 1% or less can post even when resetsAt is unchanged. (Sources/CodexBar/UsageStore+PlanUtilization.swift:490, eae19106e774)
  • Same-email fallback collision: Without a concrete token-account key, Codex plan-utilization identity falls back to a normalized-email hash, and the reset detector prefers that supplied key before raw identity fields; separate workspace principals sharing an email can therefore share detector state. (Sources/CodexBar/UsageStore+PlanUtilization.swift:798, eae19106e774)
  • Missing weekly regression: The suite verifies that an unchanged boundary suppresses a transient-zero Codex session celebration, but its weekly cases do not cover the equivalent Codex boundary condition or same-email workspace isolation. (Tests/CodexBarTests/UsageStorePlanUtilizationCelebrationTests.swift:119, eae19106e774)
  • Intentional session-only provenance: Merged pull request https://github.com/steipete/CodexBar/pull/1988 introduced boundary and baseline protection for Codex session celebrations while explicitly keeping weekly behavior unchanged. (Sources/CodexBar/UsageStore+PlanUtilization.swift:490, fc86568d15ff)
  • No canonical replacement: Repository-wide GitHub searches found this issue and the already-closed broader reports, but no open fix PR or narrower active issue for the weekly-boundary and detector-key gaps.
  • Release and current-main status: The issue reports the behavior in v0.42.0, and the same relevant source remains present at current main eae19106; subsequent main commits do not implement this repair. (Sources/CodexBar/UsageStore+PlanUtilization.swift:490, eae19106e774)

Likely related people:

  • kiranmagic7: Authored the merged Codex session boundary and baseline-preservation implementation in the same detector and regression suite. (role: introduced adjacent protection; confidence: high; commits: fc86568d15ff; files: Sources/CodexBar/UsageStore+PlanUtilization.swift, Tests/CodexBarTests/UsageStorePlanUtilizationCelebrationTests.swift)
  • steipete: Co-authored the session false-positive fix and authored several nearby reset-detector hardening and test commits. (role: recent area contributor and co-author; confidence: high; commits: fc86568d15ff, 37d50ae9449d, 22f74045f7b6; files: Sources/CodexBar/UsageStore+PlanUtilization.swift, Tests/CodexBarTests/UsageStorePlanUtilizationCelebrationTests.swift)
  • ratulsarna: Authored the Codex history persistence-keying implementation underlying the current canonical provider-account and email-hash ownership scheme. (role: Codex history identity contributor; confidence: medium; commits: 6aacc9122dc0; files: Sources/CodexBar/CodexHistoryOwnership.swift)
How this review workflow works
  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

clawsweeper[bot] avatar Jul 11 '26 05:07 clawsweeper[bot]

Additional privacy-safe live evidence from the affected machine:

I bypassed CodexBar and sent four sequential GET requests directly to https://chatgpt.com/backend-api/wham/usage, using the exact same OAuth access token and exact same ChatGPT-Account-Id header each time. A cache-busting query parameter and Cache-Control: no-cache were used.

  • Requests 1-3 returned sample A: primary used 14%, secondary used 5%, with reset boundaries A.
  • Request 4 returned sample B: primary used 3%, secondary used 1%, with different reset boundaries B.

No token, email, account ID, workspace ID, request ID, or local path is included.

This proves the immediate trigger is not only a stale local menu/widget cache: the upstream usage endpoint can return two internally consistent but different quota snapshots for identical credentials. CodexBar then accepts a single low sample, writes it to the menu/widget snapshot, and the weekly detector can interpret it as a reset.

The app-side hardening is still relevant: require stable account ownership plus reset-boundary advancement (or another confirmation sample) before displaying/celebrating a weekly reset. The current session-only transient-zero guard does not cover this weekly path.

zhulijin1991 avatar Jul 11 '26 05:07 zhulijin1991