Skip to content

Publish Codex quota before optional enrichment - #2799

Merged
steipete merged 3 commits into
steipete:mainfrom
Yuxin-Qiao:codex/fix-codex-refresh-publish
Aug 9, 2026
Merged

Publish Codex quota before optional enrichment#2799
steipete merged 3 commits into
steipete:mainfrom
Yuxin-Qiao:codex/fix-codex-refresh-publish

Conversation

@Yuxin-Qiao

@Yuxin-Qiao Yuxin-Qiao commented Aug 9, 2026

Copy link
Copy Markdown
Contributor

Summary

  • publish newly fetched Codex core quota to an already-open card before optional Credits and OpenAI Web enrichment finishes
  • keep layout-incompatible cards honestly refreshing until the existing final menu reconciliation
  • pin the compatible core model so a later enrichment layout change cannot make the open card regress to stale quota
  • release every test-created AppKit status item through the repository cleanup wrapper

Root cause

Provider-scoped Codex refreshes kept the card frozen through core usage, status, token cost, Credits, and dashboard work. The original patch ended that freeze after core usage, but MenuCardRefreshMonitor correctly rejects a live model whose tracked layout differs from the already-hosted card. Clearing the monitor unconditionally therefore removed “Refreshing…” while leaving the old or empty fallback visible.

The monitor now owns the early-publication decision. It ends the provider-scoped loading state only when the frozen and resolved models have compatible tracked layouts, retains the published core model through the enrichment tail, and leaves incompatible cards frozen until the controller’s existing final reconciliation. Provider/account authority and the optional enrichment sequence are unchanged.

The original sequencing fixture also retained its system status item and blocked every Credits retry. It now uses the cleanup wrapper and deliberately blocks only the first enrichment call, allowing legitimate account-reconciliation retries to finish.

Synthetic behavior proof

No provider credentials, network access, or personal data were used. A compiled production-controller seam emitted this deterministic operator trace:

CODEXBAR_REFRESH_PROBE compatible enrichment=blocked refreshing=false before=88% left core=63% left
CODEXBAR_REFRESH_PROBE compatible enrichment=complete credits=25.0 dashboardCredits=25.0
CODEXBAR_REFRESH_PROBE compatible-layout-shift refreshing=false pinned=60% left reconciledRows=2
CODEXBAR_REFRESH_PROBE incompatible coreRows=2 blockedState=refreshing reconciledState=published

The three trace cases passed. A screenshot probe was not added because producing a signed visual fixture for these synthetic states would require product-only credential/menu plumbing; the controller trace exercises the same production monitor boundary directly.

Validation

  • swift test --filter StatusMenuScopedCodexRefreshTests — 2 tests passed; the former headless hang is gone
  • swift test --filter StatusMenuPersistentRefreshTests — 43 tests passed
  • focused compatible, incompatible, core-error, blocked-enrichment, and final-publication cases passed
  • make check — passed; SwiftFormat and SwiftLint reported no issues
  • make test — all 833 selections passed in 70/70 groups, with no retries or timeouts
  • final Codex autoreview of the full branch against origin/main — clean, no accepted/actionable findings

@Yuxin-Qiao
Yuxin-Qiao force-pushed the codex/fix-codex-refresh-publish branch from 9b9fa19 to 7c5a763 Compare August 9, 2026 03:20
@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. 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 Aug 9, 2026
@clawsweeper

clawsweeper Bot commented Aug 9, 2026

Copy link
Copy Markdown

Codex review: needs real behavior proof before merge. Reviewed August 9, 2026, 7:12 PM ET / 23:12 UTC.

ClawSweeper review

What this changes

This PR lets an open Codex usage card display refreshed core quota before optional Credits and OpenAI dashboard enrichment completes, while retaining refresh state for incompatible layouts.

Merge readiness

Blocked until real behavior proof from a real setup is added - 4 items remain

Keep open: the supplied current-head context resolves the earlier layout and test-cleanup findings, but the PR still lacks after-fix real CodexBar menu-card proof.

Priority: P2
Reviewed head: 1a4a1d4ea35e376f182daa3a03c4d145cab44d6b

Review scores

Measure Result What it means
Overall readiness 🦪 silver shellfish (2/6) The implementation and focused regression coverage look solid from the supplied context, but real runtime proof remains a merge gate.
Proof confidence 🦪 silver shellfish (2/6) Needs real behavior proof before merge: The posted terminal trace is a test-controlled controller seam, not an after-fix run of a real CodexBar menu card. 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.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Needs proof Needs real behavior proof before merge: The posted terminal trace is a test-controlled controller seam, not an after-fix run of a real CodexBar menu card. 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 5 items Current refresh lifecycle: Current main begins the provider refresh before fetching quota and only ends it in the task's final defer, after the Codex Credits and dashboard enrichment calls.
Current card safety boundary: Current main returns a frozen model while a manual refresh is active and rejects live models whose tracked layout differs from the hosted fallback.
Prior findings addressed: The supplied review history records the previous incompatible-layout and unreleased-status-item findings on an earlier head; the current PR description and head metadata explicitly add compatibility handling and cleanup-wrapper coverage.
Findings None None.
Security None None.

How this fits together

CodexBar refreshes provider quota into an already-open macOS menu card. The refresh monitor freezes a card while provider work runs, then chooses whether a newly resolved model can update the hosted card or needs a final menu rebuild.

flowchart LR
A[Manual refresh] --> B[Codex quota fetch]
B --> C[Refresh monitor]
C --> D{Layout compatible?}
D -->|Yes| E[Update open menu card]
D -->|No| F[Final menu rebuild]
F --> E
Loading

Before merge

  • Add real behavior proof - Needs real behavior proof before merge: The posted terminal trace is a test-controlled controller seam, not an after-fix run of a real CodexBar menu card. 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.
  • Resolve merge risk (P1) - The PR has no real after-fix CodexBar menu-card run; the synthetic controller trace cannot establish runtime behavior in the freshly built app.
  • Resolve merge risk (P1) - The local partial clone could not read the exact PR-head object, so full diff review was limited to the supplied hydrated PR context.
  • Complete next step (P2) - A contributor-supplied real menu-card run is required before a merger can assess this PR; no mechanical repair is currently specified.
Agent review details

Security

None.

Review metrics

Metric Value Why it matters
Production versus test delta production +41/-5; tests +392/-47; release notes +1 The change is test-heavy, with focused coverage for compatibility and enrichment sequencing around a small runtime-path adjustment.

Merge-risk options

Maintainer options:

  1. Decide the mitigation before merge
    Preserve the compatibility-gated early publication and add redacted fresh-bundle evidence showing an open Codex card update before optional enrichment completes.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Technical review

Best possible solution:

Preserve the compatibility-gated early publication and add redacted fresh-bundle evidence showing an open Codex card update before optional enrichment completes.

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

Yes, source-reproducible: current main begins the provider refresh before quota retrieval and clears the monitor only after the optional Codex enrichment sequence completes.

Is this the best way to solve the issue?

Yes, conditionally publishing only a layout-compatible core model is the narrowest path; real application proof is still needed to confirm the live-card result.

AGENTS.md: found and applied where relevant.

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

Labels

Label justifications:

  • P2: A manual Codex refresh can keep an open card stale until optional enrichment finishes, but the impact is bounded to this menu-card workflow.
  • rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦪 silver shellfish 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 posted terminal trace is a test-controlled controller seam, not an after-fix run of a real CodexBar menu card. 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

What I checked:

Likely related people:

  • steipete: Available history reports the largest contribution count across the refresh-monitor, controller, and related test paths, and the current PR head is authored by this contributor. (role: long-running source-area contributor and final repair author; confidence: medium; commits: 1a4a1d4ea35e; files: Sources/CodexBar/MenuCardRefreshMonitor.swift, Sources/CodexBar/StatusItemController+Actions.swift, Tests/CodexBarTests/StatusMenuPersistentRefreshTests.swift)
  • Yuxin-Qiao: Available path history includes prior contributions in the affected refresh and test area, in addition to the initial commits on this PR. (role: prior source-area contributor; confidence: medium; commits: 95d79c355760, 63c03e69c612; files: Sources/CodexBar/StatusItemController+Actions.swift, Tests/CodexBarTests/StatusMenuScopedCodexRefreshTests.swift)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Add redacted fresh-bundle screenshots, a recording, or terminal/runtime output showing an open Codex card update while optional enrichment remains pending.
  • Update the PR body with that evidence; if review does not rerun, ask a maintainer to comment @clawsweeper re-review.

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
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.

Workflow

  • 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.

History

Review history (8 earlier review cycles)
  • reviewed 2026-08-09T03:24:49.516Z sha 7c5a763 :: needs real behavior proof before merge. :: none
  • reviewed 2026-08-09T04:55:10.875Z sha 7c5a763 :: needs real behavior proof before merge. :: none
  • reviewed 2026-08-09T14:13:58.224Z sha 7c5a763 :: needs real behavior proof before merge. :: none
  • reviewed 2026-08-09T14:55:43.410Z sha 7c5a763 :: needs real behavior proof before merge. :: none
  • reviewed 2026-08-09T16:44:13.065Z sha 9f0712d :: needs real behavior proof before merge. :: [P2] Reconcile incompatible cards before clearing their refresh state | [P1] Avoid creating an unreleased live status-bar item in this test
  • reviewed 2026-08-09T17:27:40.696Z sha 9f0712d :: needs real behavior proof before merge. :: [P2] Reconcile incompatible cards before ending the refresh | [P1] Release the status item created by this test
  • reviewed 2026-08-09T18:15:16.114Z sha 9f0712d :: needs real behavior proof before merge. :: [P2] Reconcile incompatible cards before ending the refresh | [P1] Release the status item created by this test
  • reviewed 2026-08-09T22:58:21.724Z sha 1a4a1d4 :: needs real behavior proof before merge. :: none

@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. labels Aug 9, 2026
@Yuxin-Qiao
Yuxin-Qiao marked this pull request as ready for review August 9, 2026 14:10
@clawsweeper

clawsweeper Bot commented Aug 9, 2026

Copy link
Copy Markdown

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. and removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. labels Aug 9, 2026

@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: 9f0712d2de

ℹ️ 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".

account: account,
updater: DisabledUpdaterController(),
preferencesSelection: PreferencesSelection(),
statusBar: .system)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Avoid creating a live status bar in this sequencing test

This test only checks async sequencing and MenuCardRefreshMonitor, but passing .system constructs a real status item and the test never calls releaseStatusItemsForTesting(). On headless macOS test workers this can leave AppKit resources and run-loop activity alive, causing the focused test to hang; cover the behavior through a stable state seam, or use the repository cleanup wrapper if the controller is indispensable.

AGENTS.md reference: AGENTS.md:L27-L27

Useful? React with 👍 / 👎.

// before its optional credits and OpenAI Web enrichment stages below, matching the all-provider
// foreground/background split used by the full refresh path.
if provider == .codex {
self.menuCardRefreshMonitor.endManualRefresh(for: provider)

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 Rebuild incompatible cards before ending the refresh state

When the open Codex card was created without quota, or the refreshed snapshot changes its metric layout, MenuCardRefreshMonitor.model rejects the newly resolved model because it is incompatible with the card's tracked layout and continues returning the original fallback. Clearing the monitor here therefore removes the “Refreshing…” indicator without publishing the new quota; the card remains empty or stale until the later dashboard enrichment completes and triggers the final menu rebuild. Reconcile the card at this boundary, or retain the refresh state when the new quota cannot be adopted live.

Useful? React with 👍 / 👎.

@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. merge-risk: 🚨 compatibility 🚨 Merging this PR could break existing users, config, migrations, defaults, or upgrades. merge-risk: 🚨 availability 🚨 Merging this PR could cause crashes, hangs, restart loops, stalls, or process outages. merge-risk: 🚨 automation 🚨 Merging this PR could break CI, automerge, proof capture, label sync, or automation. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. merge-risk: 🚨 availability 🚨 Merging this PR could cause crashes, hangs, restart loops, stalls, or process outages. labels Aug 9, 2026
@steipete
steipete force-pushed the codex/fix-codex-refresh-publish branch from 9f0712d to 1a4a1d4 Compare August 9, 2026 22:54
@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. and removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. merge-risk: 🚨 compatibility 🚨 Merging this PR could break existing users, config, migrations, defaults, or upgrades. merge-risk: 🚨 automation 🚨 Merging this PR could break CI, automerge, proof capture, label sync, or automation. labels Aug 9, 2026
@steipete
steipete merged commit 648a948 into steipete:main Aug 9, 2026
9 checks passed
@steipete

steipete commented Aug 9, 2026

Copy link
Copy Markdown
Owner

Landed as 648a948b7ab4e7703b42be4bac1c62bfe2eb64d0.

Proof:

  • StatusMenuScopedCodexRefreshTests: 2/2 passed.
  • StatusMenuPersistentRefreshTests: 43/43 passed.
  • Full suite: 833 selections across 70 groups passed, with no retries or timeouts.
  • make check: passed.
  • Deterministic operator trace: a compatible layout published 88% → 63% while enrichment was blocked; an incompatible layout stayed honestly refreshing until reconciliation; final credits/dashboard publication completed.
  • CI run 31340560781: completed successfully for 1a4a1d4ea35e376f182daa3a03c4d145cab44d6b (lint, changes, Linux arm64/x64/musl, both macOS shards, aggregate, and security).
  • Full branch autoreview: clean.

Caveat: none in validation. The squash commit preserves Yuxin Qiao's contributor credit with the requested Co-authored-by trailer.

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: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. 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.

2 participants