Skip to content

Keep shared Codex auth read-only during usage refresh - #2944

Closed
Yuxin-Qiao wants to merge 18 commits into
steipete:mainfrom
Yuxin-Qiao:codex/codex-oauth-hardening-pr
Closed

Keep shared Codex auth read-only during usage refresh#2944
Yuxin-Qiao wants to merge 18 commits into
steipete:mainfrom
Yuxin-Qiao:codex/codex-oauth-hardening-pr

Conversation

@Yuxin-Qiao

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

Copy link
Copy Markdown
Contributor

Summary

  • Treat the native Codex auth.json as Codex CLI-owned: usage refresh never redeems or publishes a shared refresh token from CodexBar.
  • Hand stale native credentials back to the existing Codex CLI recovery path; fail closed for stale legacy/OpenCode credentials because those files have no safe writer handoff.
  • Keep optional legacy Codex/OpenCode discovery read-only and default-off, with native CODEX_HOME precedence and explicit-home isolation.
  • Resolve account scope from direct, namespaced, or organization JWT claims without logging or persisting token material.
  • Fetch app reset-credit enrichment with the winning in-memory OAuth snapshot so a stale on-disk file cannot hide credits.
  • Preserve managed-account/workspace metadata in private CodexBar storage and never rewrite the CLI-owned auth file.

Why

A generation check plus a CodexBar-only lock cannot form a compare-and-swap protocol with Codex CLI. Codex CLI can replace auth.json between a read and a rename, and a refresh response can rotate the refresh token. The safe boundary is therefore read-only shared-file access: Codex CLI owns native refresh and persistence, while CodexBar uses the winning credentials only in memory.

Validation

  • swift test --filter CodexOAuthCredentialReadTests — 27 passed.
  • swift test --filter CodexOAuthResetCreditFetchTests — 6 passed.
  • swift test --filter CodexOAuthTests — 33 passed.
  • make check — passed; SwiftFormat 0 files and SwiftLint 0 violations.
  • Full make test — 864 selections in 72 groups; 72/72 passed, 0 failures, 0 retries, and 0 timeouts.
  • CI run 31901455472: Linux x64, Linux arm64, Linux musl, lint, and path-change jobs passed. The only failed job is the aggregate Draft gate because macOS tests are intentionally deferred for Draft PRs; no product/test failure was reported.

Safety evidence

  • Stale native probes return the CLI-recovery disposition and never call the OAuth refresh endpoint.
  • Stale legacy/OpenCode probes return the read-only disposition and never call a refresh endpoint.
  • Fresh external access tokens can be used without mutating their source file.
  • App reset-credit requests use the same credential snapshot that produced usage.
  • Focused tests verify file bytes, mode, and size remain unchanged; all evidence is redacted and contains no credential values.

Scope

This PR is intentionally limited to OAuth source ownership, refresh safety, account identity propagation, reset-credit consistency, and portability. It does not change Codex CLI's credential format or claim that CodexBar can safely persist another application's rotated token.

Documentation follow-up (2026-08-16)

  • Head: c7ab5e509.
  • Removed the stale implementation-guide example that refreshed a shared token and saved it to auth.json.
  • The guide now uses the usage-only credential loader and documents Codex CLI ownership for native refresh, with read-only failure for stale external sources.
  • Validation after the documentation fix: make check passed (SwiftFormat 0 files; SwiftLint 0 violations) and git diff --check passed. The previous final-head make test run remains 864/864 across 72/72 groups.

Organization fallback follow-up (2026-08-16)

  • Head: 47d03bedc.
  • Fixed the late P2: JWT organization fallback now skips blank/whitespace IDs and selects the first usable organization ID.
  • Added regression coverage for blank first entries followed by a valid organization.
  • Validation: swift test --filter CodexOAuthCredentialReadTests (28 passed), swift test --filter CodexOAuth (89 tests across 7 suites passed), make check passed, and full make test passed (864/864 selections; 72/72 groups; 0 failures, retries, or timeouts).

Account ID normalization follow-up (2026-08-16)

  • Head: 15acee507.
  • Fixed the P2 where whitespace-only tokens.account_id values were treated as present and could suppress valid JWT organization fallback; direct account IDs are now normalized with the same nonEmpty rule as JWT claims.
  • Added regression coverage proving a whitespace-only direct claim falls back to the first usable OpenAI organization ID.
  • Validation: swift test --filter CodexOAuth (90 tests across 7 suites passed), make check passed (SwiftFormat 0 files; SwiftLint 0 violations), and full make test passed (864/864 selections; 72/72 groups; 0 failures, retries, or timeouts).

OAuth guide flow follow-up (2026-08-16)

  • Head: 273c9a40c.
  • Removed the stale OAuth-only implementation excerpt that did not show freshness handling or the Codex CLI recovery path.
  • Replaced it with the current source-aware flow: native CODEX_HOME precedence, opt-in external discovery, CLI-owned stale-native recovery, fail-closed stale external sources, and snapshot reuse for reset-credit enrichment.
  • Validation: make check passed (SwiftFormat 0 files; SwiftLint 0 violations), git diff --check passed, and no product code changed in this follow-up.

OAuth guide ownership cleanup follow-up (2026-08-16)

  • Head: 87b2b36d.
  • Removed the remaining shared-refresh implementation snippets, including the old credential-save sample, direct refresh transport sample, and testing/error instructions that suggested mutating auth.json.
  • Replaced them with the current CLI-owned recovery contract and isolated fixture-based validation guidance.
  • Validation: make check passed (SwiftFormat 0 files; SwiftLint 0 violations), git diff --check passed, and no product code changed in this follow-up.

CI classification (2026-08-16)

  • CI run 31914012226 passed changes/lint, Linux arm64, musl, and GitGuardian, but Linux x64 Swift tests exited with signal 11 inside the existing QuickJS plugin test path.
  • This is classified as a runner/test-environment flake rather than a regression from this docs-only commit: the failure is an unrelated parallel QuickJS crash, while local make check passed and no product code changed.

Reset-credit snapshot follow-up (2026-08-16)

  • Head: d58b1beb4.
  • Fixed the P1: OAuth results now carry a transient codexResetCreditsAttempted marker when reset-credit enrichment was attempted with the winning in-memory credential snapshot. Generic UsageStore enrichment no longer rereads auth.json after that attempt fails; reset-credit-only OAuth results fail closed instead of mixing accounts.
  • Added regressions for regular OAuth usage and reset-credit-only OAuth usage proving no generic auth reload; preserved unmarked generic rescue behavior.
  • Validation: swift test --filter CodexResetCreditOutcomeTests (11 passed), swift test --filter CodexOAuth (90 tests across 7 suites passed), swift test --filter ProviderArchitectureGatekeeperTests (38 passed), make check, and full make test (864/864 selections; 72/72 groups; 0 failures, retries, or timeouts).

Documentation and CI follow-up (2026-08-16)

  • Head: 7204480e7.
  • Fixed the P2 documentation conflict in docs/codex.md: managed workspace selection is private CodexBar metadata and never edits or republishes auth.json.
  • Validation: make check passed (SwiftFormat 0 files; SwiftLint 0 violations) and git diff --check passed.
  • CI run 31920850771: changes, lint, Linux x64/arm64, Linux musl, and GitGuardian passed. The only failed job is the aggregate Draft gate because macOS Swift tests are intentionally deferred for Draft PRs; the job log reports macOS Swift tests are required but deferred, not a product failure.
  • No live-account provider probe was run by this automation: repository policy requires explicit authorization before reading a real account or sending a real usage request. The remaining maintainer-side proof request is therefore kept explicit rather than represented as fixture evidence.

Real native runtime evidence (2026-08-16)

  • A copy of the installed native auth.json was placed in an isolated owner-only temporary CODEX_HOME; the original file was not used as a writable target.
  • Command: HOME=<isolated-home> CODEX_HOME=<isolated-codex-home> swift run --skip-build CodexBarCLI usage --provider codex --source oauth --format text --no-credits --no-color.
  • Result: exit 0; the real OAuth usage path returned redacted usage output (weekly 19% left, credits 0 left, plan Plus). No access token, refresh token, or account email is included here.
  • File-integrity evidence: the isolated auth.json SHA-256 was equal before and after the request; owner-only mode and size (0600, 4013 bytes) were unchanged. The original native auth.json was not modified.
  • --no-credits kept this proof scoped to the usage request; no reset-credit enrichment or refresh/persistence path was invoked. This is real fresh-native usage proof, not a claim of stale CLI recovery or external-source proof.
  • The installed OpenCode auth file has no openai OAuth entry, and the native token contains a direct account claim, so real external-source and organization-only fallback traces remain unavailable without fabricating credentials. Those maintainer decisions stay explicit.

Managed workspace CLI-recovery follow-up (2026-08-16)

  • Head: 91ed021fc.
  • Fixed the P1: when a managed workspace account is selected, the stale-native CodexOAuthNativeRefreshCLIStrategy now reports itself unavailable, because the Codex CLI app-server has no supported way to receive CodexBar's selected workspace account header. Recovery can no longer substitute the auth.json workspace for the user-selected workspace.
  • Added a regression covering stale native credentials with a selected managed workspace proving the recovery strategy is unavailable; ordinary native recovery without a managed workspace remains unchanged.
  • Validation: swift test --filter CodexOAuth (91 tests across 7 suites passed), swift test --filter ProviderArchitectureGatekeeperTests (38 passed), make check passed (SwiftFormat 0 files; SwiftLint 0 violations), and full make test passed (865 selections; 73/73 groups; 0 failures, retries, or timeouts).

@clawsweeper

clawsweeper Bot commented Aug 15, 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 merge-risk: 🚨 auth-provider 🚨 Merging this PR could break OAuth, tokens, provider routing, model choice, or credentials. merge-risk: 🚨 security-boundary 🚨 Merging this PR could weaken sandboxing, authorization, credentials, or sensitive data. 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. labels Aug 15, 2026
@clawsweeper

clawsweeper Bot commented Aug 15, 2026

Copy link
Copy Markdown

Codex review: needs changes before merge. Reviewed August 16, 2026, 1:20 AM ET / 05:20 UTC.

ClawSweeper review

What this changes

The PR makes Codex usage refresh read shared OAuth files without rewriting them, adds stale-native CLI recovery, and stores managed workspace selection privately in CodexBar.

Merge readiness

⚠️ Needs maintainer review before merge - 7 items remain

Keep open: the PR’s managed-workspace guard is bypassed by Automatic mode, which can still fall through to the unguarded Codex CLI strategy after an OAuth failure. The shared-auth ownership work is not on current main, so the PR remains necessary after this P1 repair and an owner decision on opt-in external credential discovery.

Priority: P1
Reviewed head: 91ed021fcbd6f9a716a28d2b7b3a8cbfaf7d8060
Owner decision: Required. See Decision needed.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) Strong live read-only native-file proof is present, but the managed-workspace fallback defect blocks merge.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (terminal): The PR body provides a redacted real native OAuth usage run with before/after hash, mode, and size evidence for the isolated auth file; the remaining blocker is a source-proven routing defect.
Patch quality 🦐 gold shrimp (3/6) Security review found an item that needs attention.

Verification

Check Result Evidence
Real behavior Verified Sufficient (terminal): The PR body provides a redacted real native OAuth usage run with before/after hash, mode, and size evidence for the isolated auth file; the remaining blocker is a source-proven routing defect.
Evidence reviewed 5 items Current main lacks the new ownership path: Current main resolves explicit OAuth to OAuth alone and Automatic mode to OAuth then CLI; it contains no guarded native-refresh strategy, so the requested shared-file ownership behavior is not already implemented.
Automatic-mode workspace bypass: The PR head retains [oauth, cli] for Automatic mode, while its workspace guard exists only on the explicit-OAuth recovery strategy. A fallback therefore reaches the unguarded CLI strategy.
Pipeline follows fallback to the next strategy: The shared fetch pipeline continues to the next listed strategy whenever the prior strategy returns shouldFallback, confirming that the direct CLI entry is reachable.
Findings 1 actionable finding [P1] Block Automatic CLI recovery for scoped workspaces
Security Needs attention Automatic fallback can substitute workspace scope: The unguarded CLI fallback can use CLI-owned account state after OAuth fails under a selected managed workspace.

How this fits together

CodexBar reads Codex credentials to fetch usage and reset-credit data, then presents it under the selected account or workspace. This change separates shared-file ownership from CodexBar-owned workspace metadata before a usage snapshot reaches the app.

flowchart LR
  A[Codex auth file] --> B[Credential reader]
  C[Managed workspace metadata] --> D[OAuth usage request]
  B --> D
  D --> E{Credential or request fails?}
  E -->|stale native| F[Codex CLI recovery]
  E -->|other| G[Surface OAuth error]
  F --> H[Usage snapshot]
  D --> H
Loading

Decision needed

Question Recommendation
Should Automatic mode ever invoke the Codex CLI when CodexBar has a selected managed workspace but the CLI cannot accept that workspace scope? Fail closed for scoped workspaces: Suppress Automatic CLI fallback whenever a managed workspace is selected and surface the OAuth failure instead.

Why: Current source exposes no supported mechanism to pass CodexBar’s selected workspace identity to the CLI, so only an owner can choose between fail-closed behavior and intentional scope substitution.

Before merge

  • Block Automatic CLI recovery for scoped workspaces (P1) - Automatic mode still returns [oauth, cli]; after a fallback-eligible OAuth error, the second strategy bypasses the new workspace guard. It can therefore use the workspace in auth.json rather than the selected managed workspace, so guard the Automatic CLI path and add a regression.
  • Resolve security concern: Automatic fallback can substitute workspace scope - The unguarded CLI fallback can use CLI-owned account state after OAuth fails under a selected managed workspace.
  • Resolve merge risk (P1) - Automatic-mode recovery can display or reject data for the workspace in auth.json when the user selected a different managed workspace.
  • Resolve merge risk (P1) - The new default-off external OAuth setting deliberately permits cross-application session use when enabled, so its consent boundary needs explicit owner approval.
  • Resolve merge risk (P1) - GitHub currently reports this branch as dirty; refresh it against current main after the routing repair.
  • Complete next step (P2) - A concrete P1 routing bypass has a narrow source-level repair and focused validation path.

Findings

  • [P1] Block Automatic CLI recovery for scoped workspaces — Sources/CodexBarCore/Providers/Codex/CodexProviderDescriptor.swift:145
  • [high] Automatic fallback can substitute workspace scope — Sources/CodexBarCore/Providers/Codex/CodexProviderDescriptor.swift:145
Agent review details

Security

Needs attention: The PR improves shared-token handling, but its remaining Automatic fallback can cross the selected workspace boundary.

Review metrics

Metric Value Why it matters
Patch surface 27 files; production +552/-91, tests +939/-37, docs +82/-363 Credential loading, provider routing, account metadata, and regression coverage all change together, making fallback correctness merge-critical.

Merge-risk options

Maintainer options:

  1. Guard all Automatic CLI fallbacks (recommended)
    Make Automatic-mode CLI recovery unavailable for selected managed workspaces and add a regression proving the chosen scope is never replaced by the CLI account.
  2. Accept workspace substitution
    Merge with an explicit product decision that Automatic mode may report the Codex CLI workspace instead of the selected managed workspace.
Copy recommended automerge instruction
@clawsweeper automerge

Special instructions:
Fail closed for Automatic-mode Codex CLI fallback when managed workspace scope is selected; add coverage for stale native OAuth recovery.

Technical review

Best possible solution:

Apply the managed-workspace scope rule to every Automatic-mode CLI fallback, preserve the OAuth error when scope cannot be carried, and land the optional external-source setting only with explicit approval of its default-off consent contract.

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

Yes—source inspection establishes that an Automatic-mode OAuth fallback advances to the unguarded CLI strategy under a selected managed workspace; a focused pipeline regression can reproduce it without real credentials.

Is this the best way to solve the issue?

No—the explicit-OAuth guard does not cover the equivalent Automatic fallback. The narrow safe repair is to make that fallback workspace-aware or preserve the OAuth error.

Full review comments:

  • [P1] Block Automatic CLI recovery for scoped workspaces — Sources/CodexBarCore/Providers/Codex/CodexProviderDescriptor.swift:145
    Automatic mode still returns [oauth, cli]; after a fallback-eligible OAuth error, the second strategy bypasses the new workspace guard. It can therefore use the workspace in auth.json rather than the selected managed workspace, so guard the Automatic CLI path and add a regression.
    Confidence: 0.99

Overall correctness: patch is incorrect
Overall confidence: 0.99

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦞 diamond lobster and patch quality is 🦐 gold shrimp.
  • add status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action. Sufficient (terminal): The PR body provides a redacted real native OAuth usage run with before/after hash, mode, and size evidence for the isolated auth file; the remaining blocker is a source-proven routing defect.
  • remove status: 👀 ready for maintainer look: Current PR status label is status: ⏳ waiting on author.
  • remove rating: 🐚 platinum hermit: Current PR rating is rating: 🦐 gold shrimp, so this older rating label is no longer current.

Label justifications:

  • P1: A normal Automatic refresh can use a different workspace than the one the user selected.
  • merge-risk: 🚨 compatibility: Existing managed-account users can receive a different workspace result after upgrading.
  • merge-risk: 🚨 auth-provider: The fallback switches between OAuth credentials and the Codex CLI account source.
  • merge-risk: 🚨 security-boundary: The change crosses shared credential ownership and must not substitute the selected account scope.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦞 diamond lobster and patch quality is 🦐 gold shrimp.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action. Sufficient (terminal): The PR body provides a redacted real native OAuth usage run with before/after hash, mode, and size evidence for the isolated auth file; the remaining blocker is a source-proven routing defect.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR body provides a redacted real native OAuth usage run with before/after hash, mode, and size evidence for the isolated auth file; the remaining blocker is a source-proven routing defect.

Evidence

Security concerns:

  • [high] Automatic fallback can substitute workspace scope — Sources/CodexBarCore/Providers/Codex/CodexProviderDescriptor.swift:145
    The unguarded CLI fallback can use CLI-owned account state after OAuth fails under a selected managed workspace.
    Confidence: 0.99

Acceptance criteria:

  • [P1] swift test --filter CodexOAuth.
  • [P1] swift test --filter ProviderArchitectureGatekeeperTests.
  • [P1] make check.

What I checked:

Likely related people:

  • Peter Steinberger: Recent current-main Codex provider work covers descriptor routing and OAuth usage behavior. (role: recent area contributor; confidence: high; commits: 105a808a4fe9, 0e453c4a5b2a; files: Sources/CodexBarCore/Providers/Codex/CodexProviderDescriptor.swift, Sources/CodexBarCore/Providers/Codex/CodexOAuth/CodexOAuthCredentials.swift)
  • Ratul Sarna: Historical commit aa0c180 introduced the Codex OAuth CLI fallback that this change must keep scope-safe. (role: introduced fallback behavior; confidence: high; commits: aa0c1809a300; files: Sources/CodexBarCore/Providers/Codex/CodexProviderDescriptor.swift)

Rank-up moves

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

  • Guard the Automatic CLI fallback for selected managed workspaces.
  • Add a focused Automatic-mode stale-native regression and refresh the branch against main.

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 (23 earlier review cycles; latest 8 shown)
  • reviewed 2026-08-15T21:22:03.781Z sha 47d03be :: needs changes before merge. :: [P2] Treat whitespace-only account IDs as absent
  • reviewed 2026-08-15T22:23:30.770Z sha 15acee5 :: found issues before merge. :: [P2] Align the OAuth implementation plan with the recovery flow
  • reviewed 2026-08-15T23:13:30.730Z sha 273c9a4 :: found issues before merge. :: [P2] Remove the remaining shared-refresh implementation examples
  • reviewed 2026-08-16T00:16:21.061Z sha 87b2b36 :: found issues before merge. :: [P1] Preserve the OAuth snapshot after reset-credit failures
  • reviewed 2026-08-16T02:06:49.451Z sha d58b1be :: needs real behavior proof before merge. :: [P2] Clarify that workspace selection never edits auth.json
  • reviewed 2026-08-16T02:27:14.994Z sha 7204480 :: needs real behavior proof before merge. :: none
  • reviewed 2026-08-16T02:47:32.221Z sha 7204480 :: needs real behavior proof before merge. :: [P1] Preserve managed workspace scope during CLI recovery
  • reviewed 2026-08-16T03:30:05.320Z sha 91ed021 :: needs maintainer review before merge. :: none

@clawsweeper clawsweeper Bot added P1 Urgent regression or broken agent/channel workflow affecting real users now. and removed P2 Normal priority bug or improvement with limited blast radius. labels Aug 15, 2026
@Yuxin-Qiao Yuxin-Qiao changed the title Harden Codex OAuth credential discovery and refresh Keep shared Codex auth read-only during usage refresh Aug 15, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Aug 15, 2026

Copy link
Copy Markdown

🦞👀
Exact review queued.

Re-review progress:

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Aug 15, 2026

Copy link
Copy Markdown

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

@clawsweeper clawsweeper Bot added merge-risk: 🚨 compatibility 🚨 Merging this PR could break existing users, config, migrations, defaults, or upgrades. proof: sufficient Contributor real behavior proof is sufficient. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. labels Aug 15, 2026
@clawsweeper clawsweeper Bot added status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. and removed proof: sufficient Contributor real behavior proof is sufficient. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Aug 15, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper clawsweeper Bot added status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. and removed status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. labels Aug 16, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

Follow-up pushed at 7204480e7: corrected docs/codex.md so managed workspace selection is explicitly private CodexBar metadata and never edits or republishes auth.json. make check and git diff --check passed. CI run 31920850771 passed all product jobs; the only failure is the Draft macOS-deferred aggregate policy gate. I did not run a live-account provider probe because repository policy requires explicit authorization; the remaining real-setup proof and external OAuth/privacy approval stay visible as maintainer decisions.

@clawsweeper

clawsweeper Bot commented Aug 16, 2026

Copy link
Copy Markdown

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

Added redacted real-native runtime evidence to the PR body: an isolated copy of the installed native auth file successfully served a real OAuth usage request through the CLI, while the copied auth file's SHA-256, owner-only mode, and size remained unchanged. No token or account email is included. External-source and stale CLI-recovery proof remain explicitly marked unavailable rather than fabricated.

@clawsweeper

clawsweeper Bot commented Aug 16, 2026

Copy link
Copy Markdown

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

Fixed the P1 at 91ed021fc: stale-native CLI recovery now fails closed when a managed workspace is selected, because the Codex CLI cannot receive the selected workspace account header. Added a regression proving the recovery strategy is unavailable in that case; ordinary native recovery without a managed workspace is unchanged. swift test --filter CodexOAuth (91), gatekeeper (38), make check, and full make test (865 selections; 73/73 groups; 0 failures/retries/timeouts) passed.

@clawsweeper

clawsweeper Bot commented Aug 16, 2026

Copy link
Copy Markdown

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

@clawsweeper clawsweeper Bot added proof: sufficient Contributor real behavior proof is sufficient. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. labels Aug 16, 2026
@Yuxin-Qiao
Yuxin-Qiao marked this pull request as ready for review August 16, 2026 04:35
@clawsweeper

clawsweeper Bot commented Aug 16, 2026

Copy link
Copy Markdown

🦞👀
ClawSweeper picked this up.

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

@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: 91ed021fcb

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

Comment on lines +478 to 479
case .notFound, .unreadable, .missingTokens, .nativeRefreshRequired, .readOnlySource:
return 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.

P1 Badge Block auto CLI recovery for scoped workspaces

When the default source mode is .auto and a managed workspace's native credential becomes stale, .nativeRefreshRequired returns true here and the pipeline advances to the ordinary CodexCLIUsageStrategy from the auto strategy list. That strategy bypasses CodexOAuthNativeRefreshCLIStrategy.isAvailable, including its codexWorkspaceID == nil guard, so the CLI can return the workspace stored in auth.json rather than the selected managed workspace (or have the result rejected as an account mismatch). Apply the workspace-scope guard to auto fallback as well, or route auto recovery through the guarded strategy.

Useful? React with 👍 / 👎.

@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. labels Aug 16, 2026
@steipete

Copy link
Copy Markdown
Owner

Thanks @Yuxin-Qiao — this landed via #2970, which carried all 18 of your commits onto current main, resolved the conflicts, and fixed two review findings (managed-workspace CLI scope leakage and a stale external OAuth fallback). Closing as superseded; the changelog credits you.

Finesssee added a commit to nesszer/Win-CodexBar that referenced this pull request Aug 18, 2026
…n-zero history, Antigravity dashboard lanes, Claude OAuth revoked detection

steipete#2946 Codex routed models pricing — codex_routed_provider() + strip_route_prefix()
    in cost_pricing.rs; deepseek/, kimi/, opencode/ routes price against
    matching models.dev provider; unknown provider/ prefixes return None.
steipete#2944 Codex auth.json read-only during refresh — codex_external_oauth_sources_allowed
    setting (default OFF); is_external_oauth + last_refresh fields on
    CodexCredentials; enforce_external_oauth_gate (8-day staleness window).
steipete#2932 Codex known-zero history — known_zero field on CostSummary; set in both
    cache-debounce and full-scan paths (history_coverage_established &&
    sessions_count == 0); knownZero JSON field + CLI text update.
steipete#2963 Antigravity dashboard lanes — quota-bucket dedup in parse_user_status;
    models sharing the same (remaining_fraction, reset_time) collapse to one
    lane.
steipete#2516 Claude revoked vs missing OAuth — ProviderError::OAuthRevoked variant;
    revocation detection (401/403 with revoked/invalid_grant/token_revoked);
    15-min CLI result cache (LazyLock<Mutex<Option<CachedCliResult>>>);
    fetch_via_auto returns cached CLI result when OAuth revoked, and stale
    cache when all live sources fail.
Finesssee added a commit to nesszer/Win-CodexBar that referenced this pull request Aug 18, 2026
…n-zero history, Antigravity dashboard lanes, Claude OAuth revoked detection

steipete#2946 Codex routed models pricing — codex_routed_provider() + strip_route_prefix()
    in cost_pricing.rs; deepseek/, kimi/, opencode/ routes price against
    matching models.dev provider; unknown provider/ prefixes return None.
steipete#2944 Codex auth.json read-only during refresh — codex_external_oauth_sources_allowed
    setting (default OFF); is_external_oauth + last_refresh fields on
    CodexCredentials; enforce_external_oauth_gate (8-day staleness window).
steipete#2932 Codex known-zero history — known_zero field on CostSummary; set in both
    cache-debounce and full-scan paths (history_coverage_established &&
    sessions_count == 0); knownZero JSON field + CLI text update.
steipete#2963 Antigravity dashboard lanes — quota-bucket dedup in parse_user_status;
    models sharing the same (remaining_fraction, reset_time) collapse to one
    lane.
steipete#2516 Claude revoked vs missing OAuth — ProviderError::OAuthRevoked variant;
    revocation detection (401/403 with revoked/invalid_grant/token_revoked);
    15-min CLI result cache (LazyLock<Mutex<Option<CachedCliResult>>>);
    fetch_via_auto returns cached CLI result when OAuth revoked, and stale
    cache when all live sources fail.
Finesssee added a commit to nesszer/Win-CodexBar that referenced this pull request Aug 18, 2026
* Port upstream 0.50.1: Cursor rename + Ollama cookie stripping (steipete#2951, steipete#2949)

* Port upstream 0.50.1: OpenCode Go session+weekly pace in CLI (steipete#2957)

* Port upstream 0.50.1: chart axis label centering (steipete#2974)

* Port upstream 0.50.1: Kiro re-authenticate via kiro-cli login (steipete#2340)

* Port upstream 0.50.1: serve identity follows app redaction per-request (steipete#2960)

* Port upstream 0.50.1: Codex routed pricing, auth.json read-only, known-zero history, Antigravity dashboard lanes, Claude OAuth revoked detection

steipete#2946 Codex routed models pricing — codex_routed_provider() + strip_route_prefix()
    in cost_pricing.rs; deepseek/, kimi/, opencode/ routes price against
    matching models.dev provider; unknown provider/ prefixes return None.
steipete#2944 Codex auth.json read-only during refresh — codex_external_oauth_sources_allowed
    setting (default OFF); is_external_oauth + last_refresh fields on
    CodexCredentials; enforce_external_oauth_gate (8-day staleness window).
steipete#2932 Codex known-zero history — known_zero field on CostSummary; set in both
    cache-debounce and full-scan paths (history_coverage_established &&
    sessions_count == 0); knownZero JSON field + CLI text update.
steipete#2963 Antigravity dashboard lanes — quota-bucket dedup in parse_user_status;
    models sharing the same (remaining_fraction, reset_time) collapse to one
    lane.
steipete#2516 Claude revoked vs missing OAuth — ProviderError::OAuthRevoked variant;
    revocation detection (401/403 with revoked/invalid_grant/token_revoked);
    15-min CLI result cache (LazyLock<Mutex<Option<CachedCliResult>>>);
    fetch_via_auto returns cached CLI result when OAuth revoked, and stale
    cache when all live sources fail.

* Port upstream 0.50.1: Mistral PAYG spend, cost-summary display style, per-provider accent color

Item 1 — Mistral PAYG current-month API spend (steipete#2821, steipete#2947):
- Add MonthlyPlan variant to MetricPreference enum
- Add currency_symbol field to CostSnapshot with with_currency_symbol builder
- Set currency_symbol from Mistral billing API response
- Add MonthlyPlan to bridge label/parse, tray selected_metric_percent (None = no bar)
- Show formatted cost amount in provider_status_label for MonthlyPlan
- Add format_cost_amount helper in bridge.rs
- Add Mistral monthly spend row in MenuCardDetails
- Add monthlyPlan option to MenuBarMetricSection for Mistral

Item 2 — Menu cost-summary display style per provider (steipete#2976):
- Add CostSummaryDisplayStyle enum (Compact/Detailed/Hidden) in types.rs
- Add cost_summary_display_style field to Settings + Default + RawSettings round-trip
- Add to SettingsSnapshot bridge + SettingsUpdate + apply in Tauri commands
- Add bridge label/parse functions
- Apply in MenuCardDetails: hidden hides cost section, compact shows used/limit only
- Update describeCard to filter hasCost for hidden style
- Add Select control in UsageSpendTab

Item 3 — Per-provider accent color override (steipete#2972):
- Add accent_color field to ProviderConfig
- Add brand_color(ProviderId) function in provider.rs (mirrors frontend registry)
- Add accent_color/set_accent_color/effective_accent_color accessors in Settings
- Add set/get/get_effective Tauri commands + normalize_hex_accent_color validator
- Add providerAccentColors map to SettingsSnapshot bridge
- Add setProviderAccentColor/getProviderAccentColor/getProviderEffectiveAccentColor to tauri.ts
- Create AccentColorSection component (hex input, color picker, reset button)
- Inject --provider-accent CSS variable on MenuCard article and ChartsSection
- Update menu-metric__bar-fill and chart colors to use --provider-accent fallback
- Update chartPalette providerCostColor/providerCreditsColor fallback chain
- Pass providerAccentColors through TrayPanel/PopOutPanel/ProvidersTab/ProviderDetailPane

Also:
- Add 11 new locale keys to all 7 .ftl files + keys.ts
- Add costSummaryDisplayStyle + providerAccentColors to all test mock SettingsSnapshot
- Update chartPalette tests for --provider-accent fallback

* Resolve merge conflicts and fix gate checks

* Thermo-nuclear: extract ollama cookies, codex pricing, simplify accent color

* fix: correct serde attribute placement on currency_symbol after rebase
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merge-risk: 🚨 auth-provider 🚨 Merging this PR could break OAuth, tokens, provider routing, model choice, or credentials. merge-risk: 🚨 compatibility 🚨 Merging this PR could break existing users, config, migrations, defaults, or upgrades. merge-risk: 🚨 security-boundary 🚨 Merging this PR could weaken sandboxing, authorization, credentials, or sensitive data. P1 Urgent regression or broken agent/channel workflow affecting real users now. proof: sufficient Contributor real behavior proof is sufficient. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants