Skip to content

feat(codex): expose usage for a saved login - #132453

Merged
jesse-merhi merged 185 commits into
mainfrom
jesse/provider-profile-usage
Sep 11, 2026
Merged

jesse-merhi merged 185 commits into
mainfrom
jesse/provider-profile-usage

Conversation

@jesse-merhi

@jesse-merhi jesse-merhi commented Aug 29, 2026 •

Copy link
Copy Markdown
Member

Codex quotas already existed through the app-server reader, but Models could not request usage for a particular saved login. This adds codex.accountUsage inside the Codex plugin and reuses that reader with the selected profile. The handler loads on demand, keeping plugin discovery free of runtime dependencies.

The method returns the plan, quota windows, additional quota groups, and credit balance. It requires operator.admin, rejects API keys and other providers, and discards results when the selected credentials or caller authority change. Each request uses a temporary local app-server with ephemeral auth. Proxy launches are rejected before startup so a quota check cannot switch a shared daemon’s login. Existing provider summaries, organization billing, and auth-status behavior stay intact.

Proof

An authenticated Gateway integration exercised the real registration, reader, auth bridge, store, and child transport. Two saved logins returned different quotas and balances; read/write clients and unsupported profiles started no child. Both children exited, inherited API credentials were absent, and the native Codex home remained unchanged. A second Gateway/Unix-socket proof reproduced account switching through a proxy before the fix and verified zero spawns or daemon requests afterward. Only the external Codex executable was synthetic; this is not live OpenAI API evidence.

All 96 focused tests passed across the plugin entry, account method, registration boundary, app-server request lifecycle, and rate-limit parser after syncing main. Typechecks, lint, architecture guards, and unused-export checks passed for the lazy-loading repair. Guard-test mutation proof confirms that omitting authority forwarding fails the tests. Required CI passed on the current commit.

How to verify

With the Codex plugin enabled and saved OpenAI subscription logins, request codex.accountUsage with { agentId, profileId } as an administrator. The returned windows must belong to that profile. API-key and other-provider selections return an invalid-request error. The dependent UI is #132454.

Change breakdown

Part Files +LOC -LOC
Implementation 6 +157 -5
Tests and fixtures 3 +268 -0
Documentation 1 +9 -0
CI, config, and tooling 1 +0 -1
Total 11 +434 -6

@clawsweeper

clawsweeper Bot commented Aug 29, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
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.

@openclaw-barnacle openclaw-barnacle Bot added gateway Gateway runtime size: L maintainer Maintainer-authored PR labels Aug 29, 2026
@jesse-merhi jesse-merhi changed the title jesse/provider profile usage feat(gateway): expose per-account provider usage Aug 29, 2026
@jesse-merhi
jesse-merhi force-pushed the jesse/provider-profile-usage branch from 38c5fb7 to 99dba92 Compare August 29, 2026 07:08
@jesse-merhi
jesse-merhi force-pushed the jesse/provider-profile-roster branch from ece3de1 to 50f3432 Compare August 29, 2026 07:08
@clawsweeper clawsweeper Bot added merge-risk: 🚨 auth-provider 🚨 May break OAuth, tokens, provider routing, model choice, or credentials. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P2 Normal backlog priority with limited blast radius. 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. labels Aug 29, 2026
@clawsweeper

clawsweeper Bot commented Aug 29, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 10, 2026, 9:57 PM ET / September 11, 2026, 01:57 UTC (Revision 83).

ClawSweeper review

What this changes

Adds an administrator-only Codex plugin request that returns quotas, plan details, and credit balances for a selected saved subscription login.

Merge readiness

✅ Ready for maintainer review

Keep open: the saved-account request remains distinct from current main and supports the paired UI work. No actionable defect was found in the introduced changes.

Priority: P2
Reviewed head: 5049396549f223dcc14fb8fe8a5eca75247cda82

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused implementation with relevant regression coverage and controlled integration evidence; no blocking patch defect was identified.
Proof confidence 🌊 off-meta tidepool Not applicable: The member-author exemption applies; supplied Gateway-to-reader-to-child observations support account isolation and forbidden-client rejection using a synthetic Codex executable, without claiming live OpenAI results.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The member-author exemption applies; supplied Gateway-to-reader-to-child observations support account isolation and forbidden-client rejection using a synthetic Codex executable, without claiming live OpenAI results.
Evidence reviewed 11 items Pinned change and registration: The supplied merge-base-to-head evidence identifies the introduced changes. Registration uses operator.admin and dynamically imports the runtime handler; the previous completed review covered this same head and reported no findings.
Selection and isolation: The handler validates the agent and subscription profile, snapshots credentials, rejects proxy launches, forces local stdio and agent-home scope, and rechecks credentials and caller authority before returning results.
Guard forwarding reaches physical writes: The usage reader forwards prepared credentials and current-authority checks through isolated startup. Existing startup, login, and request owners invoke those checks before spawning or writing; isolated shutdown remains bounded.
Findings None None.
Security None None.

How this fits together

The Codex plugin connects OpenClaw to the Codex app-server. This request takes an agent and saved login, reads usage through an isolated child, and returns account-specific information to Gateway clients.

flowchart TD
  A[Gateway client] --> B[Administrator authorization]
  B --> C[Validate saved login]
  C --> D[Isolated Codex child]
  D --> E[Read account quotas]
  E --> F[Recheck current authority]
  F --> G[Account usage response]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source +152, Tests +268, Docs +9, Other -1. Total +428 across 11 files.

View PR surface stats
Area Files Added Removed Net
Source 6 157 5 +152
Tests 3 268 0 +268
Docs 1 9 0 +9
Config 0 0 0 0
Generated 0 0 0 0
Other 1 0 1 -1
Total 11 434 6 +428

Review metrics

Metric Value Why it matters
Gateway contract 1 new administrator-only method; 2 required selection parameters The capability is narrowly scoped to an agent and saved subscription profile without adding configuration.

Technical review

Best possible solution:

Keep account-specific quota retrieval in the Codex plugin, using the existing reader and authorization owners, with the paired UI consuming its advertised method.

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

Not applicable: this adds a saved-account request rather than repairing an established failing behavior; current-main inspection confirms the request is still absent.

Is this the best way to solve the issue?

Yes: the patch extends the existing Codex owner and reader, keeps runtime loading lazy, and preserves existing provider-summary behavior.

AGENTS.md: found and applied where relevant.

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

Labels

Label justifications:

  • P2: This is a bounded account-visibility improvement supporting the Models settings workflow.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: The member-author exemption applies; supplied Gateway-to-reader-to-child observations support account isolation and forbidden-client rejection using a synthetic Codex executable, without claiming live OpenAI results.

Evidence

What I checked:

  • Pinned change and registration: The supplied merge-base-to-head evidence identifies the introduced changes. Registration uses operator.admin and dynamically imports the runtime handler; the previous completed review covered this same head and reported no findings. (extensions/codex/src/account-usage.ts:3, 5049396549f2)
  • Selection and isolation: The handler validates the agent and subscription profile, snapshots credentials, rejects proxy launches, forces local stdio and agent-home scope, and rechecks credentials and caller authority before returning results. (extensions/codex/src/account-usage-runtime.ts:53, 5049396549f2)
  • Guard forwarding reaches physical writes: The usage reader forwards prepared credentials and current-authority checks through isolated startup. Existing startup, login, and request owners invoke those checks before spawning or writing; isolated shutdown remains bounded. (extensions/codex/src/app-server/request.ts:164, 5049396549f2)
  • Behavioral coverage: Read the account-method, request-lifecycle, and parser tests. They cover profile selection, unsupported credentials, proxy rejection, revoked authority, changed credentials, accepted refresh, precise balances, extra quota groups, and preservation of the default summary. Tests were not executed during this read-only review. (extensions/codex/src/account-usage.test.ts:150, 5049396549f2)
  • Current main still lacks the request: The pinned main reader retains the existing usage operation without this PR's prepared-auth additions. GitHub's directory listing also lacks the new account-usage modules. (extensions/codex/src/app-server/request.ts:145, d331583bbf0f)
  • Latest-release check: The v2026.9.3 Codex source directory does not contain the new saved-account request modules; no merged replacement establishing this capability was identified. (extensions/codex/src, 1391f7cd2d40)

Likely related people:

  • unknown: The claimed source-line change could not be verified from bounded local history. (role: source history unknown; confidence: low)
  • unknown: The claimed source-line change could not be verified from bounded local history. (role: source history unknown; confidence: low)

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 (82 earlier review cycles; latest 8 shown)
  • reviewed 2026-09-10T04:23:24.320Z sha 390711d :: needs maintainer review before merge. :: none
  • reviewed 2026-09-10T04:33:19.159Z sha 3dc269e :: blocked before merge. :: none
  • reviewed 2026-09-10T04:50:44.917Z sha d13be30 :: needs maintainer review before merge. :: none
  • reviewed 2026-09-10T04:58:48.169Z sha d13be30 :: needs maintainer review before merge. :: none
  • reviewed 2026-09-10T14:29:43.644Z sha d13be30 :: needs maintainer review before merge. :: none
  • reviewed 2026-09-10T14:53:39.466Z sha eef7586 :: needs maintainer review before merge. :: none
  • reviewed 2026-09-10T15:08:27.253Z sha eef7586 :: needs maintainer review before merge. :: none
  • reviewed 2026-09-11T01:46:15.736Z sha 5049396 :: needs maintainer review before merge. :: none

@jesse-merhi

Copy link
Copy Markdown
Member Author

/clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Aug 29, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
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.

Re-review progress:

@clawsweeper clawsweeper Bot added merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. labels Aug 29, 2026
@jesse-merhi
jesse-merhi force-pushed the jesse/provider-profile-roster branch from 50f3432 to 82123e6 Compare August 29, 2026 08:41
@jesse-merhi
jesse-merhi force-pushed the jesse/provider-profile-usage branch 2 times, most recently from 93cb374 to 31508fa Compare August 29, 2026 08:51
@clawsweeper clawsweeper Bot added 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 Aug 29, 2026
@jesse-merhi
jesse-merhi force-pushed the jesse/provider-profile-usage branch from 31508fa to ca8ef65 Compare August 29, 2026 09:57
@jesse-merhi

Copy link
Copy Markdown
Member Author

/clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Sep 10, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
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.

Re-review progress:

@jesse-merhi

Copy link
Copy Markdown
Member Author

/clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Sep 10, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
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.

Re-review progress:

@jesse-merhi

Copy link
Copy Markdown
Member Author

Merged via squash.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Improvements or additions to documentation extensions: codex maintainer Maintainer-authored PR P2 Normal backlog priority with limited blast radius. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: M status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants