Skip to content

Keep full-session estimate visible while idle#2336

Open
Zihao-Qi wants to merge 1 commit into
steipete:mainfrom
Zihao-Qi:codex/keep-session-estimate-idle
Open

Keep full-session estimate visible while idle#2336
Zihao-Qi wants to merge 1 commit into
steipete:mainfrom
Zihao-Qi:codex/keep-session-estimate-idle

Conversation

@Zihao-Qi

@Zihao-Qi Zihao-Qi commented Jul 19, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Keep a learned full-session forecast available when the current five-hour window is idle and has no reset timestamp.
  • Continue validating a current reset when one is present.
  • Continue excluding historical session windows whose reset is still in the future.
  • Refresh the idle forecast cache on minute boundaries so newly completed history becomes eligible.
  • Cover idle forecast persistence and cache invalidation with focused tests.

Why

An idle Claude five-hour window can have no resetsAt value. The forecast pipeline treated that missing reset as a hard failure even when enough completed history already existed to calculate the weekly full-session estimate. As a result, a learned estimate disappeared while idle and returned as soon as the user consumed any session quota.

The current session reset is not needed for the estimate itself. Weekly remaining quota and the learned weekly burn per completed full session are sufficient, so this change makes the reset optional without weakening the weekly-window or historical-evidence guards.

Because historical eligibility depends on the current time, idle cache keys also include a minute bucket. This avoids indefinitely reusing a stale nil or older estimate after a recorded session reset passes.

User impact

Once CodexBar has learned a full-session estimate, it remains visible during idle periods and picks up newly completed historical sessions within the menu's minute-level refresh cadence.

Validation

  • swift test --filter SessionEquivalentForecastTests — 40 tests passed.
  • make check — passed with no formatting or lint violations.
  • Independent review found no actionable issues.
  • make test was attempted earlier in development; it stopped in unrelated Claude OAuth temporary-keychain-cache tests (ClaudeOAuthCredentialsStoreTemporaryKeychainCacheTests).

@Zihao-Qi
Zihao-Qi marked this pull request as ready for review July 19, 2026 14:31

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c9079925ff

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

guard group.resetsAt < currentSessionResetsAt.addingTimeInterval(-Self.resetEquivalenceTolerance),
let precedesCurrentSession = currentSessionResetsAt.map {
group.resetsAt < $0.addingTimeInterval(-Self.resetEquivalenceTolerance)
} ?? true

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Include time in idle burn cache keys

When currentSessionResetsAt is nil, this branch makes the eligible history groups depend on now via the later group.resetsAt <= now check, but UsageStore still caches the estimator result under the same nil-reset key across menu openings. If the first idle computation happens before a recorded partial session's reset, it can cache nil or an older median; after that reset passes with no history revision, the now-completed group is still skipped because the stale cached estimate is reused.

Useful? React with 👍 / 👎.

@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. P2 Normal priority bug or improvement with limited blast radius. labels Jul 19, 2026
@clawsweeper

clawsweeper Bot commented Jul 19, 2026

Copy link
Copy Markdown

Codex review: needs real behavior proof before merge. Reviewed July 20, 2026, 11:44 AM ET / 15:44 UTC.

Summary
Makes Claude’s learned full-session forecast remain available when the current session is idle without a reset timestamp, and refreshes the idle cache on minute boundaries.

Reproducibility: no. high-confidence live reproduction is included. The source path and focused tests make the missing-reset condition reproducible from code, but no observed current-app run demonstrates the before-and-after behavior.

Review metrics: 2 noteworthy metrics.

  • Patch scope: 2 files affected; 106 added, 19 removed. The change is confined to the forecast implementation and its focused test suite, making the intended boundary straightforward to review.
  • Focused coverage: 2 new idle-forecast scenarios. The added scenarios cover persistence during an idle session and recalculation after a historical reset becomes eligible.

Merge readiness
Overall: 🧂 unranked krab
Proof: 🧂 unranked krab
Patch quality: 🐚 platinum hermit
Result: blocked until real behavior proof is added.

Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch.

Rank-up moves:

  • [P1] Add redacted after-fix evidence from a real Claude idle-session forecast flow, preferably showing the menu estimate before and after a minute-boundary refresh.
  • Triage the failed lint-build-test and build-linux-musl-cli jobs, documenting any confirmed unrelated failure.

Proof guidance:

  • [P1] Needs real behavior proof before merge: The PR supplies test/check claims but no inspectable after-fix runtime evidence; add a redacted native-app menu capture, terminal output, or runtime log that shows the idle forecast persists and refreshes. After updating the PR body, request @clawsweeper re-review if a fresh review does not start automatically. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.

Risk before merge

  • [P1] Without a redacted live app, CLI, or runtime-log capture, reviewers cannot confirm that the forecast stays visible during a genuinely idle Claude session and refreshes after historical eligibility changes.
  • [P1] The two failed CI jobs need ordinary log triage before merge; the available context does not show whether they are environmental or patch-related.

Maintainer options:

  1. Decide the mitigation before merge
    Land a narrowly tested optional-reset forecast path only after a redacted runtime capture demonstrates the idle estimate remaining visible and a minute-boundary refresh admitting newly completed history.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Next step before merge

  • [P1] The remaining blocker is contributor-supplied real-world proof and CI-failure triage, neither of which is a safe automated code-repair task.

Security
Cleared: The two-file Swift implementation-and-test diff does not alter dependencies, build scripts, secrets, permissions, or supply-chain inputs.

Review details

Best possible solution:

Land a narrowly tested optional-reset forecast path only after a redacted runtime capture demonstrates the idle estimate remaining visible and a minute-boundary refresh admitting newly completed history.

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

No high-confidence live reproduction is included. The source path and focused tests make the missing-reset condition reproducible from code, but no observed current-app run demonstrates the before-and-after behavior.

Is this the best way to solve the issue?

Yes, conditionally: making the session reset optional while retaining reset validation when present is a narrow solution, and the minute-bucket cache refresh addresses the time-dependent historical eligibility path.

AGENTS.md: found and applied where relevant.

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

Label changes

Label justifications:

  • P2: This is a user-visible Claude usage-estimate regression with limited blast radius rather than an availability, security, or data-loss incident.
  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🐚 platinum hermit.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs real behavior proof before merge: The PR supplies test/check claims but no inspectable after-fix runtime evidence; add a redacted native-app menu capture, terminal output, or runtime log that shows the idle forecast persists and refreshes. After updating the PR body, request @clawsweeper re-review if a fresh review does not start automatically. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
Evidence reviewed

What I checked:

  • Forecast validation change: The PR makes the current session reset optional while continuing to validate it when present, so an idle session can proceed to the learned weekly forecast calculation. (Sources/CodexBar/SessionEquivalentForecast.swift:51, 8f63218a993b)
  • Cache invalidation follow-up: The current branch explicitly adds time-sensitive handling for a nil current-session reset, addressing the earlier review concern that histories becoming eligible after their reset could otherwise be hidden by a stale idle cache. (Sources/CodexBar/SessionEquivalentForecast.swift:172, 8f63218a993b)
  • Focused regression coverage: The PR adds tests for preserving the forecast while idle and refreshing the idle cache after a historical session completes. (Tests/CodexBarTests/SessionEquivalentForecastTests.swift:562, 8f63218a993b)
  • Proof remains absent: The PR body reports focused tests and checks, but provides no inspectable after-fix app capture, terminal output, redacted runtime log, or linked artifact for the changed idle Claude forecast behavior. (8f63218a993b)
  • Current check state: GitHub context reports successful macOS test shards but failed lint-build-test and build-linux-musl-cli jobs; the supplied context does not establish whether either failure is unrelated to this patch. (8f63218a993b)

Likely related people:

  • Zihao-Qi: The supplied PR metadata attributes the current forecast and cache-invalidation changes to this contributor; current-main ownership could not be established from the available read-only review metadata. (role: proposed implementation author; confidence: low; commits: 8f63218a993b; files: Sources/CodexBar/SessionEquivalentForecast.swift, Tests/CodexBarTests/SessionEquivalentForecastTests.swift)
What the crustacean ranks mean
  • 🦀 challenger crab: rare, exceptional readiness with strong proof, clean implementation, and convincing validation.
  • 🦞 diamond lobster: very strong readiness with only minor maintainer review expected.
  • 🐚 platinum hermit: good normal PR, likely mergeable with ordinary maintainer review.
  • 🦐 gold shrimp: useful signal, but proof or patch confidence is still limited.
  • 🦪 silver shellfish: thin signal; proof, validation, or implementation needs work.
  • 🧂 unranked krab: not merge-ready because proof is missing/unusable or there are serious correctness or safety concerns.
  • 🌊 off-meta tidepool: rating does not apply to this item.

Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

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.
Review history (3 earlier review cycles)
  • reviewed 2026-07-19T16:33:10.352Z sha 0c3021f :: needs real behavior proof before merge. :: none
  • reviewed 2026-07-19T17:10:44.315Z sha 0c3021f :: needs real behavior proof before merge. :: none
  • reviewed 2026-07-20T15:02:55.293Z sha 8f63218 :: needs real behavior proof before merge. :: none

@Zihao-Qi
Zihao-Qi force-pushed the codex/keep-session-estimate-idle branch from 0c3021f to 8f63218 Compare July 20, 2026 14:59
@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. and removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. labels Jul 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

P2 Normal priority bug or improvement with limited blast radius. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant