Skip to content

feat(codex): show per-account usage - #1488

Merged
Wibias merged 1 commit into
lidge-jun:devfrom
Alvin0412:agent/codex-account-usage
Aug 12, 2026
Merged

feat(codex): show per-account usage#1488
Wibias merged 1 commit into
lidge-jun:devfrom
Alvin0412:agent/codex-account-usage

Conversation

@Alvin0412

@Alvin0412 Alvin0412 commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Add stable, non-PII account labels to persisted Codex Pool request attempts so usage is attributed to the account that actually served each request.
  • Extend GET /api/usage with an additive accounts breakdown containing 30-day token totals, measured-usage coverage, and API-equivalent cost estimates. Historical openai-main rows map to main; only bare legacy openai rows remain ambiguous.
  • Show the same label and 30-day usage summary on the main Codex account card and added-account cards, with localized labels and synchronized documentation.
  • Address current review feedback by preserving valid explicit labels, keeping accounts: [] in read-failure responses, documenting configured pricing overlays, and covering ordinary Responses main/pool/failover attribution in addition to compact routing.

Verification

  • bun test tests/codex-auth-api.test.ts tests/codex-account-label.test.ts tests/responses-account-label.test.ts tests/responses-compaction-routing.test.ts tests/usage-summary.test.ts tests/usage-log.test.ts tests/request-log.test.ts tests/api-usage.test.ts - 359 passed, 0 failed, 1,440 assertions.
  • cd gui && bun test tests/codex-account-pool-behaviour.test.tsx tests/codex-account-pool-pinned-badge.test.tsx - 37 passed, 0 failed, 125 assertions.
  • bun run typecheck - passed.
  • bun run privacy:scan - passed.
  • bun run lint:gui:if-changed - passed.
  • bun run doctor:gui:if-changed - passed; React Doctor reported no issues.
  • cd gui && bun run build - passed.
  • cd docs-site && bun run build - passed.
  • Final head 1fe72150 is one feature commit based directly on current dev@d6673675; its stable patch ID matches the previously reviewed f4f65bb1 patch.
  • bun run test is not green locally: 11,194 passed, 8 skipped, and 72 failed. The failures are confined to unmodified management-auth / 0.0.0.0 request paths, Compatibility Lab evidence and timing paths, and API-key attribution integration tests; no modified test file failed. The local-CI readiness box remains unchecked.

Codex account cards

Checklist

  • Scope stays focused and avoids unrelated cleanup.
  • Docs or release notes were updated when needed.
  • Security-sensitive changes were reviewed for secrets, auth, and unsafe defaults.

Review readiness checklist

This PR stays in draft until every box below is ticked. Tick all four boxes once the requirements are met:

  • All CI tests are green on my local testing.

  • I pushed my PR to the latest dev commit.

  • I resolved all correct Codex and CodeRabbit findings.

  • My PR is ready for review.

Summary by CodeRabbit

  • New Features

    • Account cards now show stable log labels, 30-day token usage, estimated API-equivalent costs, and coverage.
    • Usage reports include per-account token totals, request metrics, coverage, and cost estimates.
    • Labels distinguish main and pooled accounts without exposing identifying information.
    • Usage details refresh automatically and respect the selected language.
  • Documentation

    • Clarified usage fields, pricing, estimated-cost limitations, and ambiguous legacy records.
  • Tests

    • Added coverage for aggregation, labeling, display rendering, refresh behavior, and request attribution.

@github-actions

Copy link
Copy Markdown
Contributor

Deterministic PR hygiene checks passed.

@coderabbitai

coderabbitai Bot commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: fca618e9-e058-4dbe-92c7-821c9f46b6e9

📥 Commits

Reviewing files that changed from the base of the PR and between 0d65bc8 and 1fe7215.

📒 Files selected for processing (17)
  • docs-site/src/content/docs/guides/web-dashboard.md
  • docs-site/src/content/docs/reference/management-api.md
  • gui/src/i18n/de.ts
  • gui/src/i18n/en.ts
  • gui/src/i18n/ja.ts
  • gui/src/i18n/ko.ts
  • gui/src/i18n/ru.ts
  • gui/src/i18n/tr.ts
  • gui/src/i18n/zh-TW.ts
  • gui/src/i18n/zh.ts
  • src/server/management/logs-usage-routes.ts
  • src/server/responses/core.ts
  • src/usage/log.ts
  • src/usage/summary.ts
  • tests/api-usage.test.ts
  • tests/responses-account-label.test.ts
  • tests/usage-summary.test.ts

📝 Walkthrough

Walkthrough

Codex requests now receive stable non-PII labels. Usage summaries aggregate metrics by label, management API responses expose account breakdowns, and GUI account cards display 30-day tokens, estimated costs, and coverage.

Changes

Codex account usage attribution

Layer / File(s) Summary
Account label contracts
src/codex/account-label.ts, src/codex/auth-api.ts, src/usage/log.ts, tests/codex-auth-api.test.ts, tests/usage-log.test.ts
Account DTOs use computed labels. The main account uses "main". Usage normalization preserves valid labels and removes raw identifiers or email-like values.
Request label propagation
src/server/request-log.ts, src/server/responses/compact.ts, src/server/responses/core.ts, tests/request-log.test.ts, tests/responses-compaction-routing.test.ts, tests/responses-account-label.test.ts
Resolved labels propagate through request logs, persisted usage entries, attempts, compact requests, retries, and combo attempts.
Usage account aggregation
src/usage/summary.ts, src/server/management/logs-usage-routes.ts, tests/usage-summary.test.ts, tests/api-usage.test.ts, docs-site/src/content/docs/reference/management-api.md, structure/05_gui-and-management-api.md, docs-site/src/content/docs/guides/web-dashboard.md
Usage summaries expose account rows with token totals, coverage, ambiguity, and estimated cost. Documentation describes main and ambiguous legacy openai rows.
GUI account metrics
gui/src/hooks/useCodexAccountPool.ts, gui/src/components/codex-account-pool-cards.tsx, gui/src/components/codex-account-pool-main-card.tsx, gui/src/i18n/*, gui/tests/codex-account-pool-behaviour.test.tsx, gui/tests/codex-account-pool-pinned-badge.test.tsx
The GUI fetches and caches 30-day Codex usage, joins it by log label, formats values by locale, and renders account labels and usage metrics.

Estimated code review effort: 4 (Complex) | ~45 minutes

Sequence Diagram(s)

sequenceDiagram
  participant CodexRequest
  participant RequestLog
  participant UsageSummary
  participant ManagementAPI
  participant AccountCards

  CodexRequest->>RequestLog: record validated accountLogLabel
  RequestLog->>UsageSummary: persist labeled usage entry
  UsageSummary->>ManagementAPI: return accounts breakdown
  ManagementAPI->>AccountCards: provide 30-day account metrics
  AccountCards->>AccountCards: join rows and render localized values
Loading
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 17.39% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the primary change: displaying usage broken down by Codex account.
✨ Finishing Touches 💡 1
🛠️ Fix failing CI checks 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions

github-actions Bot commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

✅ READY

  • all PR quality gates passed; the review readiness checklist is complete.

Review readiness checklist

  • ✅ All CI tests are green on my local testing.
  • ✅ I pushed my PR to the latest dev commit.
  • ✅ I resolved all correct Codex and CodeRabbit findings.
  • ✅ My PR is ready for review.

4/4 boxes ticked.

This pull request is already Ready for Review.
The review-ready label marks this PR as ready; review automation runs independently. If no CodeRabbit review appears, comment @coderabbitai review to request one.
Maintainers: @lidge-jun @Ingwannu @Wibias

@github-actions github-actions Bot added the enhancement New feature or request label Aug 11, 2026

@Wibias Wibias left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Review against current dev@e8db4e03: two blocking attribution gaps remain.

  1. Legacy pool accounts without a persisted logLabel cannot display the new per-account usage data. core.ts correctly derives an effective label via codexAccountLogLabel(account), including the deterministic fallback, but poolAccountDto() only exposes account.logLabel when it is physically present. For a legacy row, persisted usage is therefore keyed by the fallback pXXXXXX while the GUI receives no logLabel, so useCodexAccountPool cannot join the usage row to that account card. Return the same effective label from the account DTO (or migrate/persist it) and add a regression for an existing account with no stored logLabel.

  2. Native /responses/compact is still outside the new attribution path. compact.ts resolves the actual pool/main-pool authCtx and records response usage through inspectResponseLogJson(), but it never sets logCtx.accountLogLabel when that account is selected or when the bounded alternate-account retry switches accounts. Automatic pool compact requests therefore persist as bare openai with no explicit account label, and buildAccounts() classifies this newly generated usage as legacy-ambiguous instead of the account that actually served it. Carry the effective account label through native compact, including alternate-account retry, and cover main, added-pool, and retry attribution cases.

The branch is also 17 commits behind current dev, and the current Cross-platform CI / React Doctor workflow runs are action_required with no jobs, so CI has not actually exercised this head yet.

@Alvin0412
Alvin0412 force-pushed the agent/codex-account-usage branch from 32765b9 to 0d65bc8 Compare August 12, 2026 01:29
@github-actions github-actions Bot added the intake: hygiene-blocked Deterministic PR hygiene checks failed label Aug 12, 2026
@Alvin0412

Copy link
Copy Markdown
Contributor Author

@Wibias The requested attribution gaps are addressed in 0d65bc86 and the branch is rebased onto current dev@b8a2e51b.

  • Legacy pool accounts now expose the same effective deterministic logLabel used by persisted usage, without mutating legacy config.
  • Native /responses/compact now carries the serving account label for main, added-pool, and bounded alternate-account retry paths.
  • Focused regression coverage passes (357 tests total), along with typecheck, privacy scan, GUI lint, and React Doctor.

Could you please re-review this head? Since the first fix necessarily touches src/codex/auth-api.ts, the hygiene gate also requires a maintainer to apply maintainer-sponsored after reviewing that sensitive-path change.

@Alvin0412
Alvin0412 marked this pull request as ready for review August 12, 2026 02:55
@github-actions
github-actions Bot marked this pull request as draft August 12, 2026 02:55

@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: 0d65bc8611

ℹ️ 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 src/usage/summary.ts Outdated
Comment on lines +581 to +584
function accountLabelForAttribution(provider: string, explicit: unknown): string | null {
if (baseProviderLabel(provider) !== "openai") return null;
return isCodexUsageAccountLogLabel(explicit)
? explicit

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 Honor explicit labels before inspecting provider suffixes

When an existing exact-account selector uses a custom namespace such as side -> pool-a, the persisted attempt has provider openai-side and a valid explicit accountLogLabel, but this provider check rejects it because baseProviderLabel("openai-side") is not openai. Consequently, requests through custom selectors disappear entirely from that account's dashboard totals. Validate and return the explicit label first, using provider-name inference only for legacy rows without one.

AGENTS.md reference: src/AGENTS.md:L10-L10

Useful? React with 👍 / 👎.

Comment thread src/usage/summary.ts
days: UsageDay[];
models: UsageModel[];
providers: UsageProvider[];
accounts: UsageAccount[];

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 Keep accounts in read-failure responses

If reading the usage log throws, /api/usage still returns its documented zeroed 200 response, but the catch-path object omits the newly required accounts array while retaining days, models, and providers. Clients consuming the additive response shape can therefore fail exactly when storage is temporarily unreadable; add accounts: [] to that fallback so the response remains shape-compatible.

Useful? React with 👍 / 👎.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@docs-site/src/content/docs/reference/management-api.md`:
- Around line 138-142: Update the pricing description for estimatedCostUsd in
docs-site/src/content/docs/reference/management-api.md lines 138-142 and
docs-site/src/content/docs/guides/web-dashboard.md lines 134-138 to describe
configured pricing data, including active user price overlays, rather than only
current API/list prices. Keep the surrounding API behavior and estimate
disclaimer unchanged.

In `@src/server/responses/core.ts`:
- Line 1679: Add route-level regression tests covering Responses account-label
propagation for main-pool and added-pool selection around handleResponses in
src/server/responses/core.ts:1679, and pool failover updating the final serving
account label around src/server/responses/core.ts:498-504. The compact-route
sites at src/server/responses/compact.ts:366 and
src/server/responses/compact.ts:595 require no direct changes because coverage
already exists in tests/responses-compaction-routing.test.ts:216-229 and
tests/responses-compaction-routing.test.ts:671-698.

In `@src/usage/summary.ts`:
- Around line 575-579: Update legacyCodexAccountLabel to recognize the
historical “-main” suffix and return the main-account label for openai-main
rows, while keeping only bare openai rows mapped to
LEGACY_AMBIGUOUS_ACCOUNT_LABEL and preserving legacy pool handling. Add a
regression case in tests/usage-summary.test.ts covering openai-main
classification.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 8a08ffb5-3e47-4b90-a093-59e9e1b28d45

📥 Commits

Reviewing files that changed from the base of the PR and between b8a2e51 and 0d65bc8.

⛔ Files ignored due to path filters (1)
  • docs-site/public/pr-screenshots/codex-account-usage.png is excluded by !**/*.png
📒 Files selected for processing (29)
  • docs-site/src/content/docs/guides/web-dashboard.md
  • docs-site/src/content/docs/reference/management-api.md
  • gui/src/components/codex-account-pool-cards.tsx
  • gui/src/components/codex-account-pool-main-card.tsx
  • gui/src/hooks/useCodexAccountPool.ts
  • gui/src/i18n/de.ts
  • gui/src/i18n/en.ts
  • gui/src/i18n/ja.ts
  • gui/src/i18n/ko.ts
  • gui/src/i18n/ru.ts
  • gui/src/i18n/tr.ts
  • gui/src/i18n/zh-TW.ts
  • gui/src/i18n/zh.ts
  • gui/tests/codex-account-pool-behaviour.test.tsx
  • gui/tests/codex-account-pool-pinned-badge.test.tsx
  • src/codex/account-label.ts
  • src/codex/auth-api.ts
  • src/server/request-log.ts
  • src/server/responses/compact.ts
  • src/server/responses/core.ts
  • src/usage/log.ts
  • src/usage/summary.ts
  • structure/05_gui-and-management-api.md
  • tests/api-usage.test.ts
  • tests/codex-auth-api.test.ts
  • tests/request-log.test.ts
  • tests/responses-compaction-routing.test.ts
  • tests/usage-log.test.ts
  • tests/usage-summary.test.ts

Comment thread docs-site/src/content/docs/reference/management-api.md Outdated
Comment thread src/server/responses/core.ts
Comment thread src/usage/summary.ts

@Ingwannu Ingwannu left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Re-review on exact head 0d65bc86116e3814d9ad5dbde42ba3b7d7b68340.

The two attribution gaps from the previous review are fixed: legacy pool DTOs now expose the same effective fallback label used by persisted usage, and native compact records the selected main/pool account plus the bounded alternate account after a 429/402. The focused compact coverage demonstrates those paths.

I am still requesting changes because three current-head issues remain, and the branch is now 12 commits behind dev@37139818d2d3fe7b033e958ccf87080e4be2b4b7:

  1. Historical openai-main rows are misclassified as ambiguous. legacyCodexAccountLabel() recognizes only a -pXXXXXX suffix. baseProviderLabel("openai-main") is openai, but the suffix regex misses main, so the row falls into legacy-ambiguous. This is not an unknown account: the historical provider label explicitly identifies the main account. Return main for the exact openai-main legacy shape and add a usage-summary regression; keep only bare openai ambiguous.

  2. The cost wording contradicts the estimator used by this feature. estimatedCostUsd uses the existing cost lookup, where the active user-configured providers.<name>.modelCosts overlay wins before built-in catalog/list-price fallbacks and historical entries are repriced from the current overlay. Update the Dashboard and management-API docs to describe configured display pricing and its fallback behavior rather than claiming the value is always based on current API list prices. Keep the existing non-billing/subscription disclaimer.

  3. The ordinary Responses attribution path lacks route-level regression coverage. handleResponses() now sets logCtx.accountLogLabel after initial auth and again during alternate-account retry, but the added tests cover compact only. Add focused main-pool, added-pool, and pool-failover tests through the ordinary Responses handler so a future auth/refactor cannot silently return those requests to the ambiguous bucket.

Please rebase onto the latest dev, address the three items above, rerun the focused backend/GUI checks, and request re-review. I am not applying maintainer-sponsored while the sensitive-path review still has correctness/test blockers, and I will not approve or merge this GUI-containing feature without the final owner review required by the repository's conservative UI policy.

@Alvin0412
Alvin0412 force-pushed the agent/codex-account-usage branch from 0d65bc8 to f4f65bb Compare August 12, 2026 04:25

Copy link
Copy Markdown
Contributor Author

@Ingwannu @Wibias Review blockers are addressed on the exact new head f4f65bb12f196c9a1969f28c4bf49214316a9b28, based directly on current dev@49887650eb2c7efa5c90996ec5108c8a7cfd129b.

The five current-head findings are covered as follows:

  • Historical openai-main usage maps to main; bare openai remains ambiguous.
  • Valid explicit accountLogLabel values take precedence over legacy provider-name inference.
  • The /api/usage read-failure response keeps accounts: [].
  • Dashboard and management API docs now describe configured display pricing, including active modelCosts overlays.
  • New ordinary handleResponses() regressions cover main selection, legacy added-account selection, and 429 failover to the final serving account.

Focused backend verification is 359 passed / 0 failed; focused GUI is 37 passed / 0 failed; typecheck, privacy scan, GUI lint/doctor/build, and the docs build pass. The full-suite limitation and exact prior counts remain disclosed in the PR description, so I have not attested that all local CI is green.

Please re-review this head. Since src/codex/auth-api.ts is a sensitive path, please also apply maintainer-sponsored after the security review is satisfied. The PR remains draft pending the repository readiness gate.

@Wibias Wibias left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Re-review on exact head f4f65bb12f196c9a1969f28c4bf49214316a9b28.

The earlier code blockers are fixed on this head:

  • legacy pool account DTOs now expose the same effective fallback logLabel used by persisted usage;
  • native /responses/compact carries the selected account label and updates it on bounded alternate-account retry;
  • historical openai-main rows map to main, while bare openai remains explicitly ambiguous;
  • explicit valid labels win before legacy provider-name inference, so custom account namespaces remain attributable;
  • the read-failure /api/usage shape keeps accounts: [];
  • the pricing docs now match the estimator's configured modelCosts overlay + catalog/fallback behavior;
  • ordinary Responses now has focused main-pool, added-pool, and pre-stream failover attribution coverage.

I did not find another code-level blocker in this patch.

I am still requesting changes for integration/readiness only. Current dev is 70d2e1758c180188a729dd63812703b76cfeeba6; this head is 10 commits behind with merge base 49887650eb2c7efa5c90996ec5108c8a7cfd129b. The exact-head Cross-platform CI and React Doctor runs are action_required, and the Cross-platform run contains 0 jobs, so GitHub CI has not actually exercised this head. The PR is also still draft and its own readiness checklist leaves full local CI / ready-for-review unchecked; the body records that the repository-wide local test run is not green.

Please rebase onto current dev, run the maintained CI on the resulting exact head, and request re-review. If that integrated head is green and the patch remains equivalent, I see no remaining code blocker.

@Alvin0412
Alvin0412 force-pushed the agent/codex-account-usage branch from f4f65bb to 1fe7215 Compare August 12, 2026 05:16
@Alvin0412

Copy link
Copy Markdown
Contributor Author

@Wibias @Ingwannu @lidge-jun

The patch is now rebased onto the current dev@d667367528afa2c604d19af2fc8538b965b88cf1 as exact head 1fe72150a3af6bd0a02a7b829d97ece0209e76e3. Its stable patch ID matches the previously reviewed f4f65bb1 patch, and the intervening dev commits do not overlap this PR's changed files.

Exact-head local verification:

  • focused backend: 359 passed / 0 failed / 1,440 assertions
  • focused GUI: 37 passed / 0 failed / 125 assertions
  • typecheck, privacy scan, GUI lint, React Doctor, GUI build, and docs build passed
  • repository-wide run: 11,194 passed / 8 skipped / 72 failed in unmodified management-auth/0.0.0.0, Compatibility Lab, and API-key attribution integration clusters; the PR remains draft and the local-CI readiness box remains unchecked

The Cross-platform CI and React Doctor pull-request workflows require maintainer approval for this external contributor and cannot be started by the author. Please approve those exact-head workflow runs, then re-review 1fe72150. The hygiene gate also still requires a maintainer security review and the maintainer-sponsored label for src/codex/auth-api.ts; please apply it only if that review is satisfied.

@Wibias Wibias left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Re-review on exact head 1fe72150a3af6bd0a02a7b829d97ece0209e76e3.

The previously identified code blockers are fixed on this head, and I do not find a new code-level blocker in the feature patch:

  • legacy pool DTOs expose the same effective fallback logLabel used by persisted usage, and the main account exposes main;
  • ordinary Responses assigns the selected account label, carries it into the physical attempt, and updates it when the bounded pool failover switches to the serving account;
  • the new Responses regression covers main-pool, added-pool, and pre-stream 429 failover attribution;
  • native compact retains the selected/failover label coverage from the earlier fix;
  • explicit valid accountLogLabel wins before legacy provider-name inference, so custom account namespaces remain attributable;
  • historical openai-main maps to main, pool suffixes remain attributable, and only bare legacy openai is ambiguous;
  • the /api/usage read-failure shape includes accounts: [];
  • the pricing documentation now matches the configured pricing-overlay/fallback behavior rather than claiming list-price-only estimates.

Several old bot threads are still shown as unresolved in GitHub, but the current code directly addresses their findings; I am not treating stale thread state as a blocker.

The remaining blocker is integration/readiness. Current dev is 4a299fa09352e9f3d5dd119f0d892f92d3d0bab1; this head is 1 ahead / 1 behind with merge base d667367528afa2c604d19af2fc8538b965b88cf1. The new dev commit is #1505 and overlaps src/server/responses/core.ts, so I want the exact integrated head rather than assuming the two changes remain semantically equivalent after merge. Exact-head Cross-platform CI (31566030365) and React Doctor (31566030308) are both action_required with 0 jobs, so GitHub CI has not executed this head. The PR also remains draft and its local full-suite/readiness boxes are still unchecked.

Please rebase onto current dev, run the maintained CI on that exact head, and request re-review. If the patch remains equivalent and CI executes cleanly, I see no remaining code blocker. Final owner review for the GUI change still applies separately.

@Wibias Wibias added the maintainer-sponsored Maintainer sponsors this change to an auth, workflow, release, or dependency surface label Aug 12, 2026
@github-actions github-actions Bot removed the intake: hygiene-blocked Deterministic PR hygiene checks failed label Aug 12, 2026

@Wibias Wibias left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Security-only deep review on exact head 1fe72150a3af6bd0a02a7b829d97ece0209e76e3.

I reviewed the changed trust boundaries separately from the earlier correctness review: account-label origin and generation, routing/failover propagation, request-log and usage.jsonl persistence/hydration, management API exposure, GUI rendering, malformed persisted history, collision behavior, and resource-exhaustion potential.

I found no reportable P0-P3 security finding in this patch.

  • accountLogLabel is not taken from the inbound data-plane request or upstream response. It comes from the resolved Codex pool/main-pool auth context plus configured account metadata.
  • New pool labels are random pseudonyms; legacy fallback labels are bounded pseudonyms. The wire/persistence validator accepts only main or p[0-9a-f]{6} and revalidates both top-level rows and attempts during hydration. Raw account ids, emails, access tokens, refresh tokens, ChatGPT account ids, and authorization headers are not added to the new persisted field.
  • addFinalRequestLog, addRequestLog, and sealRequestAttemptIdentity all gate persistence on that label validator. Pool failover updates the label from the final resolved physical account rather than from caller-controlled namespace text.
  • /api/usage remains behind the existing management-auth gate. The new aggregation performs no outbound I/O and uses bounded, validated labels as Map keys; the management usage reader already applies its configured byte ceiling (64 MiB default). A data-plane caller cannot manufacture unbounded distinct account labels.
  • The GUI joins usage by the bounded label and renders it through ordinary React text/<code> nodes; there is no HTML/eval sink for a stored label.
  • A 24-bit label collision can at worst merge local admin-visible accounting buckets; the label is not used for credential selection, authorization, routing, or replay identity, so this is not an auth/isolation primitive.

One integration caveat remains: this head predates current dev's #1505 reasoning-replay hardening and overlaps src/server/responses/core.ts. The final rebased head still needs review/CI to ensure the merge preserves both changes, but I see no security blocker in #1488's current patch itself.

@github-actions
github-actions Bot marked this pull request as ready for review August 12, 2026 05:52
@coderabbitai

coderabbitai Bot commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

@github-actions[bot] The readiness gate marks PR #1488 ready. I will review the current head 1fe72150a3af6bd0a02a7b829d97ece0209e76e3.


🧠 Learnings used
Learnt from: Wibias
Repo: lidge-jun/opencodex PR: 986
File: .github/workflows/enforce-pr-target.yml:631-636
Timestamp: 2026-08-04T06:41:30.089Z
Learning: For the PR readiness gate in `.github/workflows/enforce-pr-target.yml`, the required scope is to bind contributor checklist completion and maintainer notification to the exact PR head SHA, then reset them after a new head commit. Maintainer approval staleness is separate from this gate and should be enforced by GitHub branch protection, such as `dismiss-stale-reviews` or `require_last_push_approval`, when configured for `dev`.
⚠️ Action not completed

Pull request is closed.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai

coderabbitai Bot commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

@github-actions[bot] The readiness gate marks PR #1488 ready at 1fe72150a3af6bd0a02a7b829d97ece0209e76e3. I will review the current head, including the sensitive-path change in src/codex/auth-api.ts.


🧠 Learnings used
Learnt from: Wibias
Repo: lidge-jun/opencodex PR: 986
File: .github/workflows/enforce-pr-target.yml:631-636
Timestamp: 2026-08-04T06:41:30.089Z
Learning: For the PR readiness gate in `.github/workflows/enforce-pr-target.yml`, the required scope is to bind contributor checklist completion and maintainer notification to the exact PR head SHA, then reset them after a new head commit. Maintainer approval staleness is separate from this gate and should be enforced by GitHub branch protection, such as `dismiss-stale-reviews` or `require_last_push_approval`, when configured for `dev`.
⚠️ Action not completed

Pull request is closed.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@Wibias
Wibias merged commit 0da13d1 into lidge-jun:dev Aug 12, 2026
32 of 37 checks passed

Wibias commented Aug 12, 2026

Copy link
Copy Markdown
Collaborator

Thank you @Alvin0412 for the work on this PR and for addressing the review feedback.

This is useful because Codex Pool usage is now attributable to the account that actually served each request, including failover, without exposing raw account identifiers or credentials. The stable non-PII labels plus per-account token, cost, and coverage data make it much easier to understand pool behavior, compare account utilization, and diagnose rotation/quota issues directly from the dashboard and management API.

@coderabbitai

coderabbitai Bot commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

Tip

For best results, initiate chat on the files or code changes.

@github-actions[bot] The readiness gate reports READY for head 1fe72150a3af6bd0a02a7b829d97ece0209e76e3.

CodeRabbit review was already triggered for this exact head. Maintainer review and workflow approval remain separate actions.


🧠 Learnings used
Learnt from: Wibias
Repo: lidge-jun/opencodex PR: 986
File: .github/workflows/enforce-pr-target.yml:631-636
Timestamp: 2026-08-04T06:41:30.089Z
Learning: For the PR readiness gate in `.github/workflows/enforce-pr-target.yml`, the required scope is to bind contributor checklist completion and maintainer notification to the exact PR head SHA, then reset them after a new head commit. Maintainer approval staleness is separate from this gate and should be enforced by GitHub branch protection, such as `dismiss-stale-reviews` or `require_last_push_approval`, when configured for `dev`.

You are interacting with an AI system.

1 similar comment
@coderabbitai

coderabbitai Bot commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

Tip

For best results, initiate chat on the files or code changes.

@github-actions[bot] The readiness gate reports READY for head 1fe72150a3af6bd0a02a7b829d97ece0209e76e3.

CodeRabbit review was already triggered for this exact head. Maintainer review and workflow approval remain separate actions.


🧠 Learnings used
Learnt from: Wibias
Repo: lidge-jun/opencodex PR: 986
File: .github/workflows/enforce-pr-target.yml:631-636
Timestamp: 2026-08-04T06:41:30.089Z
Learning: For the PR readiness gate in `.github/workflows/enforce-pr-target.yml`, the required scope is to bind contributor checklist completion and maintainer notification to the exact PR head SHA, then reset them after a new head commit. Maintainer approval staleness is separate from this gate and should be enforced by GitHub branch protection, such as `dismiss-stale-reviews` or `require_last_push_approval`, when configured for `dev`.

You are interacting with an AI system.

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

Labels

enhancement New feature or request maintainer-sponsored Maintainer sponsors this change to an auth, workflow, release, or dependency surface review-ready

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants