Skip to content

Refresh managed Codex credentials without losing workspace scope - #3379

Open
Yuxin-Qiao wants to merge 2 commits into
steipete:mainfrom
Yuxin-Qiao:codex/refresh-managed-codex-auth
Open

Refresh managed Codex credentials without losing workspace scope#3379
Yuxin-Qiao wants to merge 2 commits into
steipete:mainfrom
Yuxin-Qiao:codex/refresh-managed-codex-auth

Conversation

@Yuxin-Qiao

@Yuxin-Qiao Yuxin-Qiao commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

Summary

  • delegate stale or 401-rejected native auth renewal to the Codex app-server inside the selected CODEX_HOME
  • give token renewal a dedicated 30-second network timeout instead of the ordinary 3-second RPC budget
  • reload the rotated credentials and retry the direct OAuth usage request with the selected managed-workspace account header
  • preserve HTTP 403 as a workspace-access denial so it never rotates credentials or enters CLI recovery
  • coalesce concurrent refreshes for the same home and never consume unscoped CLI usage during recovery

Why

Managed Codex profiles remain signed in in separate native credential stores, but CodexBar previously disabled CLI recovery whenever a managed workspace was selected. That avoided showing usage for the wrong workspace, but it also left inactive accounts stuck once their auth.json aged or the backend rejected the access token.

This separates credential renewal from usage retrieval: the credential-owning app-server handles account/read with refreshToken enabled, then CodexBar reloads the exact native store and performs its existing account-scoped OAuth request. Only HTTP 401 is evidence for rejected bearer credentials; HTTP 403 stays fail-closed as a selected-workspace authorization error. The refresh request gets 30 seconds because it can perform network token renewal, while ordinary local RPC reads keep their 3-second budget.

Verification

Current head 796d070fd74cee91cb0bd45a34df55b5bf9029b0, rebased onto 30f881aee0e8dce08690d8eb971a2a44ef1285be:

  • focused Codex OAuth expiry, managed-workspace recovery, OAuth, fallback, and architecture suites: 98 tests passed
  • make check: passed; SwiftFormat clean and SwiftLint reported 0 violations
  • make test: 1009/1009 selections, 85/85 groups successful on the first pass, 0 failures, 0 retries, 0 timeouts
  • git diff --check: passed
  • current-head CI: passed, including lint, Linux x64/ARM64, Linux musl, both macOS test shards, aggregate gate, and GitGuardian

Current-head regression validation used isolated temporary CODEX_HOME fixtures and stub transports; no additional real auth files or Keychain entries were read or changed.

Real behavior evidence and remaining boundary

An explicitly authorized live selected-home check on pre-rebase head 6ba56a88e observed a real HTTP 401. The credential-owning app-server renewed the selected home's native credentials, the auth file rotated with mode 0600 preserved, and the workspace-scoped retry succeeded. No credentials, identities, or private endpoints are included.

The authorized cross-account negative attempt did send the selected workspace header, but the service returned 2xx. It therefore does not prove the HTTP 403 terminal path. This PR does not claim real 403 evidence; a genuinely forbidden workspace or maintainer-approved negative target is still needed to demonstrate that no refresh or usage publication occurs after a real 403.

Provider-auth sign-off remains requested per VISION.md.

@clawsweeper

clawsweeper Bot commented Sep 2, 2026

Copy link
Copy Markdown

🦞👀
ClawSweeper picked this up.

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

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@clawsweeper clawsweeper Bot added P2 Normal priority bug or improvement with limited blast radius. merge-risk: 🚨 auth-provider 🚨 Merging this PR could break OAuth, tokens, provider routing, model choice, or credentials. 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 Sep 2, 2026
@clawsweeper

clawsweeper Bot commented Sep 2, 2026

Copy link
Copy Markdown

Codex review: needs real behavior proof before merge. Reviewed September 8, 2026, 11:28 AM ET / 15:28 UTC.

ClawSweeper review

What this changes

Refresh native Codex credentials through the selected account’s CLI store, then retry workspace-scoped usage requests while keeping permission denials terminal.

Merge readiness

Blocked before merge - 7 items remain

The managed credential recovery remains useful and absent from main. One cancellation defect blocks merge; the earlier timeout and permission-error findings are fixed. Provider-auth approval and denied-workspace proof remain outstanding.

Priority: P2
Reviewed head: 06baadaaffcfb1728c6a65e325e8bc6043ccf021
Owner decision: Required. See Decision needed.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) Useful scoped recovery with reported live success, but cancellation and the remaining auth boundary prevent merge readiness.
Proof confidence 🦐 gold shrimp (3/6) Needs stronger real behavior proof before merge: Authority-chain proof required: the reported real selected-home 401 renewal, preserved file permissions, and scoped retry are positive evidence. Because renewal persists bearer authority and retries workspace access, the attempted negative case returning 2xx does not establish that a denied or revoked workspace produces no successful usage publication or further recovery after a 403. 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 🦐 gold shrimp (3/6) 1 actionable review finding remain.

Verification

Check Result Evidence
Real behavior Needs proof Needs stronger real behavior proof before merge: Authority-chain proof required: the reported real selected-home 401 renewal, preserved file permissions, and scoped retry are positive evidence. Because renewal persists bearer authority and retries workspace access, the attempted negative case returning 2xx does not establish that a denied or revoked workspace produces no successful usage publication or further recovery after a 403. 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 9 items Applicable repository policy: Read the complete root AGENTS.md; no nested AGENTS.md or maintainer-note files were discovered. VISION.md requires sign-off for provider-auth behavior changes. No builds, tests, or live credential probes were run during this read-only review.
Introduced renewal task loses caller cancellation: The shared coordinator creates an unstructured task and awaits its value without cancellation handling or waiter accounting. The renewal request has a dedicated 30-second timeout.
Replacement refresh waits for canceled predecessor: ProviderRefreshCoordinator cancels predecessor tasks, while UsageStore waits for their completion before starting replacement work. The new renewal task therefore delays replacement refreshes despite cancellation.
Findings 1 actionable finding [P2] [P2] Preserve cancellation when coalescing credential renewal
Security None None.

How this fits together

CodexBar reads account credentials to retrieve provider usage for its menu bar and CLI. This recovery path asks the Codex app-server to renew credentials, then resumes the normal workspace-scoped HTTP request.

flowchart TD
 A[Selected account and workspace] --> B[OAuth usage request]
 B --> C{Authentication result}
 C -->|Expired or rejected token| D[Selected home credential renewal]
 D --> E[Reload native credentials]
 E --> B
 C -->|Permission denied| F[Terminal error]
 C -->|Success| G[Scoped usage publication]
Loading

Decision needed

Question Recommendation
Approve automatic native credential renewal for managed Codex homes once cancellation and denied-workspace validation are resolved? Approve scoped renewal conditionally: Accept the owner-CLI renewal design after cancellation repair and convincing denied-workspace evidence.

Why: VISION.md reserves provider-auth behavior changes for sign-off, and this patch permits persistent token renewal where managed recovery was previously disabled.

Before merge

  • Add real behavior proof - Needs stronger real behavior proof before merge: Authority-chain proof required: the reported real selected-home 401 renewal, preserved file permissions, and scoped retry are positive evidence. Because renewal persists bearer authority and retries workspace access, the attempted negative case returning 2xx does not establish that a denied or revoked workspace produces no successful usage publication or further recovery after a 403. 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.
  • [P2] Preserve cancellation when coalescing credential renewal (P2) - When a provider refresh is replaced, ProviderRefreshCoordinator cancels its predecessor and UsageStore waits for that predecessor to finish. This unstructured task does not receive caller cancellation, and awaiting task.value does not release a canceled waiter, so replacement work can remain blocked through initialization and the 30-second renewal timeout. Track waiters, release canceled callers promptly, and cancel renewal when no caller needs it. This is a late finding: the same code was present at the previously reviewed head.
  • Resolve merge risk (P1) - Existing managed accounts gain automatic persistent credential renewal; provider-auth approval for that behavior remains unrecorded.
  • Resolve merge risk (P1) - The denied or revoked workspace case remains unproven through the renewal-to-publication boundary; the reported negative attempt received a successful response.
  • Resolve merge risk (P1) - Cancellation behavior with multiple renewal waiters needs validation so stopping one refresh neither stalls replacement work nor interrupts another active caller.
  • Complete next step (P2) - Repair shared-renewal cancellation, complete authorized denied-workspace proof, and obtain provider-auth sign-off before merge.
  • Resolve maintainer decision - Resolve the maintainer decision shown above before merge.

Findings

  • [P2] [P2] Preserve cancellation when coalescing credential renewal — Sources/CodexBarCore/UsageFetcher.swift:1165-1171
Agent review details

Security

None.

Review metrics

Metric Value Why it matters
Production and test growth Production +108/-14; tests +167/-31 Production growth implements scoped renewal and coalescing; added tests cover scope, concurrency, and timeout behavior.

Merge-risk options

Maintainer options:

  1. Repair cancellation and complete scoped approval (recommended)
    Track renewal waiters, release canceled callers promptly, stop unused renewal work, and resolve the auth approval and negative-proof boundary.
  2. Pause managed renewal
    Retain main’s existing behavior while the contributor and auth owner establish the remaining lifecycle guarantees.

Technical review

Best possible solution:

Keep renewal owned by the selected Codex home, preserve workspace authorization on retry, and make shared renewal cancellation-aware under an explicitly approved provider-auth contract.

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

Yes, by source inspection: cancel a provider fetch while shared native renewal is pending, then request a replacement; it waits for the uncanceled renewal task. This path was not executed during the read-only review.

Is this the best way to solve the issue?

The owner-CLI renewal followed by scoped HTTP usage is a sound boundary, but the implementation needs waiter-aware cancellation before it is ready.

Full review comments:

  • [P2] [P2] Preserve cancellation when coalescing credential renewal — Sources/CodexBarCore/UsageFetcher.swift:1165-1171
    When a provider refresh is replaced, ProviderRefreshCoordinator cancels its predecessor and UsageStore waits for that predecessor to finish. This unstructured task does not receive caller cancellation, and awaiting task.value does not release a canceled waiter, so replacement work can remain blocked through initialization and the 30-second renewal timeout. Track waiters, release canceled callers promptly, and cancel renewal when no caller needs it. This is a late finding: the same code was present at the previously reviewed head.
    Confidence: 0.98
    Late finding: first raised on code an earlier review cycle already covered.

Overall correctness: patch is incorrect
Overall confidence: 0.96

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 928166f89947.

Labels

Label justifications:

  • P2: This is a bounded managed-account recovery improvement with a refresh cancellation defect.
  • merge-risk: 🚨 availability: Canceled renewal can hold replacement provider refreshes until the initialization and renewal budgets expire.
  • merge-risk: 🚨 auth-provider: The patch enables persistent native-token renewal for existing managed accounts and requires provider-auth approval.
  • merge-risk: 🚨 security-boundary: Workspace rejection across the newly enabled credential-renewal path lacks final-effect negative proof.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🦐 gold shrimp.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs stronger real behavior proof before merge: Authority-chain proof required: the reported real selected-home 401 renewal, preserved file permissions, and scoped retry are positive evidence. Because renewal persists bearer authority and retries workspace access, the attempted negative case returning 2xx does not establish that a denied or revoked workspace produces no successful usage publication or further recovery after a 403. 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:

  • Applicable repository policy: Read the complete root AGENTS.md; no nested AGENTS.md or maintainer-note files were discovered. VISION.md requires sign-off for provider-auth behavior changes. No builds, tests, or live credential probes were run during this read-only review. (VISION.md:19, 06baadaaffcf)
  • Introduced renewal task loses caller cancellation: The shared coordinator creates an unstructured task and awaits its value without cancellation handling or waiter accounting. The renewal request has a dedicated 30-second timeout. (Sources/CodexBarCore/UsageFetcher.swift:1166, 06baadaaffcf)
  • Replacement refresh waits for canceled predecessor: ProviderRefreshCoordinator cancels predecessor tasks, while UsageStore waits for their completion before starting replacement work. The new renewal task therefore delays replacement refreshes despite cancellation. (Sources/CodexBar/UsageStore+Refresh.swift:182, 06baadaaffcf)
  • Re-review continuity: UsageFetcher.swift is unchanged from the previous reviewed head. The cancellation concern was equally visible then and is acknowledged as a late finding. The current code retains the corrected 30-second renewal budget and terminal forbidden handling. (Sources/CodexBarCore/UsageFetcher.swift:1166, 06baadaaffcf)
  • Main and release still exclude managed recovery: Both fetched main and v0.57.0 retain the guard disabling native CLI recovery when a managed workspace is selected. The central requested recovery is therefore still missing. (Sources/CodexBarCore/Providers/Codex/CodexProviderDescriptor.swift:362, 45cda6084d64)
  • Merged related work covers only permission errors: GitHub confirms fix(codex): preserve permission errors across authenticated requests #3466 merged. Its description explicitly leaves broader managed credential renewal open, so it does not supersede this PR. (46b8840b2205)

Likely related people:

  • unknown: The claimed source-line change could not be verified from bounded local history. (role: source history unknown; confidence: low)
  • Yuxin-Qiao: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rank-up moves

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

  • Add cancellation coverage for one canceled waiter, a surviving waiter, and final-waiter subprocess teardown.
  • Provide authorized, redacted terminal output or logs showing a genuinely denied workspace and no subsequent renewal or successful usage publication; screenshots or recordings with diagnostics also count. Update the PR body for automatic re-review, or ask a maintainer to comment @clawsweeper re-review.
  • Obtain the provider-auth sign-off required by VISION.md.

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 (6 earlier review cycles)
  • reviewed 2026-09-02T07:39:44.225Z sha 39367d4 :: needs real behavior proof before merge. :: [P2] Do not refresh credentials for a rejected workspace
  • reviewed 2026-09-02T08:08:42.456Z sha 2b26282 :: needs real behavior proof before merge. :: [P1] Give credential renewal a network-sized timeout
  • reviewed 2026-09-02T09:17:09.050Z sha 4b09066 :: needs real behavior proof before merge. :: none
  • reviewed 2026-09-03T01:49:11.764Z sha 6ba56a8 :: needs real behavior proof before merge. :: none
  • reviewed 2026-09-04T14:57:51.236Z sha 796d070 :: needs real behavior proof before merge. :: none
  • reviewed 2026-09-04T15:32:26.179Z sha 796d070 :: needs real behavior proof before merge. :: none

@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: 39367d446b

ℹ️ 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 thread Sources/CodexBarCore/UsageFetcher.swift Outdated
}

func refreshAccount() async throws {
_ = try await self.request(method: "account/read", params: ["refreshToken": 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 Give credential renewal a network-sized timeout

When token renewal takes more than three seconds, as can occur on slow or proxied networks, this request inherits requestTimeoutSeconds (3 seconds by default), terminates the app-server, and leaves stale or rejected managed credentials unrecovered. I confirmed via codex app-server generate-json-schema --experimental that refreshToken: true “requests a proactive token refresh before returning,” so unlike the existing local account/read operation this can include a network round trip; use a refresh-specific timeout comparable to the existing 30-second OAuth refresh timeout and cover a delayed response.

Useful? React with 👍 / 👎.

@Yuxin-Qiao
Yuxin-Qiao force-pushed the codex/refresh-managed-codex-auth branch from 39367d4 to 2b26282 Compare September 2, 2026 08:04
@Yuxin-Qiao

Copy link
Copy Markdown
Contributor Author

Addressed the actionable 401/403 finding in the updated head:

  • HTTP 401 remains unauthorized and may enter native credential recovery.
  • HTTP 403 is now a distinct forbidden error and never falls back to CLI recovery in Auto or explicit OAuth mode.
  • The expiry-pipeline matrix verifies this for managed and unmanaged contexts.
  • Focused suites, make check, git diff --check, and the full 994-selection / 83-group suite pass locally with no retries or timeouts.

Live-account proof remains intentionally absent because AGENTS.md prohibits live provider/auth probes without an explicit request; the PR body states that boundary.

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Sep 2, 2026

Copy link
Copy Markdown

🦞👀
Exact review queued.

Re-review progress:

@Yuxin-Qiao
Yuxin-Qiao force-pushed the codex/refresh-managed-codex-auth branch from 2b26282 to 4b09066 Compare September 2, 2026 09:06
@Yuxin-Qiao

Copy link
Copy Markdown
Contributor Author

Addressed the latest P1 on head 4b090667a:

  • account/read with refreshToken: true now uses a dedicated 30-second timeout; ordinary RPC reads remain at 3 seconds.
  • Added a delayed app-server regression that waits 3.2 seconds before returning the refresh response and still succeeds.
  • Re-ran focused credential/RPC tests (16/16), the architecture gatekeeper (39/39), make check (0 SwiftLint violations across 2089 files), full make test (994 selections, 83/83 groups first-pass, 0 retries/timeouts), and git diff --check.

All auth validation remains fixture/stub based; no real auth files or Keychain entries were read. @clawsweeper re-review

@Yuxin-Qiao

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Sep 2, 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 the merge-risk: 🚨 security-boundary 🚨 Merging this PR could weaken sandboxing, authorization, credentials, or sensitive data. label Sep 2, 2026
@Yuxin-Qiao

Copy link
Copy Markdown
Contributor Author

@steipete Provider-auth sign-off requested per VISION.md. Head 4b090667a is mergeable and all CI checks are green, including both macOS shards. ClawSweeper reports no actionable code findings after the 30-second renewal timeout and delayed-response regression. Live selected-home proof remains intentionally absent because repository policy requires an explicit request before reading real auth state or running a live provider probe.

@Yuxin-Qiao
Yuxin-Qiao force-pushed the codex/refresh-managed-codex-auth branch from 4b09066 to 6ba56a8 Compare September 3, 2026 01:44
@Yuxin-Qiao

Copy link
Copy Markdown
Contributor Author

Post-rebase verification on head 6ba56a88e:\n\n- make check passed (SwiftFormat clean; SwiftLint 0 violations across 2093 files).\n- make test passed: 997/997 selections, 84/84 groups, 0 first-pass failures, 0 retries, 0 timeouts.\n- Release package and packaged CLI validation passed (0.56.3, config OK).\n- An explicitly authorized live selected-home check observed a real 401; the credential-owning app-server renewed the native credentials, the auth file rotated with mode 0600 preserved, and the production retry completed successfully. No credentials, identities, or private endpoints are included.\n- The authorized cross-account workspace negative attempt sent the selected workspace header but the service returned 2xx, so it cannot serve as a 403 proof. A genuinely unauthorized workspace or maintainer-approved negative target is still required before claiming terminal 403 behavior.\n\nProvider-auth sign-off remains requested; no 403 proof is being claimed.

@Yuxin-Qiao
Yuxin-Qiao force-pushed the codex/refresh-managed-codex-auth branch from 6ba56a8 to 796d070 Compare September 4, 2026 14:52
@Yuxin-Qiao

Copy link
Copy Markdown
Contributor Author

Current-head verification after rebase:

  • PR head 796d070fd74cee91cb0bd45a34df55b5bf9029b0 is rebased onto current main 30f881aee0e8dce08690d8eb971a2a44ef1285be.
  • Focused OAuth/recovery/fallback/architecture suites: 98 tests passed.
  • make check and git diff --check passed.
  • Full make test: 1009/1009 selections, 85/85 groups first-pass successful, 0 failures, 0 retries, 0 timeouts.
  • Current-head CI passed every job, including both macOS shards and the aggregate gate.
  • GitHub reports MERGEABLE / CLEAN.

Evidence boundary remains explicit: the previously authorized live check proved the selected-home 401 renewal and scoped retry on pre-rebase head 6ba56a88e; the cross-account negative returned 2xx, so no real 403 proof is claimed. A genuinely forbidden workspace or maintainer-approved negative target is still required for that final-effect proof. Provider-auth sign-off remains requested.

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Sep 4, 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.

steipete added a commit that referenced this pull request Sep 7, 2026
…3466)

HTTP 403 from Codex OAuth and PAT endpoints was treated as expired authentication. In Auto mode this could trigger CLI recovery for a permission denial. Preserve the status and response body as a terminal server error; HTTP 401 retains authentication recovery.

Share request status, network-error, and cancellation handling across usage, reset-credit, spend-control, and PAT requests. Requests and decoding contracts remain unchanged. Production code decreases by 64 lines.

The actual fetcher-to-pipeline regression failed before the change, including Auto selecting the CLI fallback sentinel. All 93 focused tests across five suites pass, covering OAuth/PAT endpoints, 401 controls, and terminal 403 behavior. `make check` and the full `make test` suite pass (1,028 selections across 86 groups; no retries). Independent review found no actionable P0–P2 findings. Tests use synthetic responses; no live account access is claimed.

This extracts the status distinction discussed in #3379; the broader managed credential renewal work remains open. Thanks @Yuxin-Qiao for that work. Changelog and OAuth documentation are updated.

Co-authored-by: Yuxin Qiao <104957188+Yuxin-Qiao@users.noreply.github.com>

@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: 06baadaaff

ℹ️ 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 +1166 to +1168
let task = Task {
try await operation()
}

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 Preserve cancellation while coalescing credential refreshes

When an in-flight provider refresh is superseded—for example after switching accounts or manually refreshing again—ProviderRefreshCoordinator cancels the old fetch and waits for it before starting the replacement. This unstructured Task does not inherit that cancellation, and awaiting task.value is not cancellation-aware, so the old app-server request can remain alive for the full initialization plus 30-second renewal timeout and block the replacement refresh. Make the coordinator waiter-aware so cancellation releases the canceled caller and cancels the subprocess when no other waiter still needs it.

Useful? React with 👍 / 👎.

@clawsweeper clawsweeper Bot added merge-risk: 🚨 availability 🚨 Merging this PR could cause crashes, hangs, restart loops, stalls, or process outages. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. labels Sep 8, 2026
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: 🚨 availability 🚨 Merging this PR could cause crashes, hangs, restart loops, stalls, or process outages. 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: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. 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