Add CLIProxyAPI cost attribution - #2457
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: c82dab5a6d
ℹ️ 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".
|
Codex review: needs real behavior proof before merge. Reviewed August 31, 2026, 1:26 AM ET / 05:26 UTC. ClawSweeper reviewWhat this changesThis PR adds CLIProxyAPI management-queue telemetry and local attribution so Claude Code proxy usage can be assigned to upstream providers in CodexBar spend views, exports, and shared statistics. Merge readiness⛔ Blocked until stronger real behavior proof is added - 8 items remain Keep open: the proposed optional integration has two concrete introduced blockers, including an unavoidable loss window in the destructive CLIProxyAPI queue protocol, so it is not ready to merge or close. Priority: P2 Review scores
Verification
How this fits togetherCodexBar scans local CLI and session data into cost reports, then publishes those reports to the menu-bar usage and spend dashboard. This PR adds an optional CLIProxyAPI queue input and maps its telemetry into the existing attribution, cache, and dashboard pipeline. flowchart LR
A[Claude Code session logs] --> B[Attribution resolver]
C[CLIProxyAPI management queue] --> D[Telemetry collector]
D --> E[Local cost cache]
B --> E
E --> F[Cost scanner]
F --> G[Spend dashboard and exports]
Decision needed
Why: CodexBar cannot close the server-side destructive-pop-before-response failure window by changing its pending journal alone. Before merge
Findings
Agent review detailsSecurityNeeds attention: The new loopback management-key client has an unresolved destructive-delivery boundary that can lose protected telemetry before durable receipt. Review metrics
Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Wait for a CLIProxyAPI delivery protocol that supports durable acknowledgement, then retain telemetry only after acknowledgement and add a narrow parser fix plus configured end-to-end attribution proof. Do we have a high-confidence way to reproduce the issue? Yes—source-reproducible. A queue response followed by process termination before pending-journal persistence loses records, and an alias configuration with inline comments fails the exact header comparisons. Is this the best way to solve the issue? No. The pending journal improves post-response recovery but cannot make a server-side destructive pop durable; the feature needs an acknowledged upstream delivery contract or a non-destructive design. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 354191af9937. LabelsLabel justifications:
EvidenceSecurity concerns:
What I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (164 earlier review cycles; latest 8 shown)
|
|
@codex review @clawsweeper re-review |
|
🦞👀 Command router queued. I will update this comment with the next step. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: c3bedb05f8
ℹ️ 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".
|
Follow-up fixes are pushed in 0f4bda0 and the three current review threads have been addressed. @codex review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 0f4bda0d9a
ℹ️ 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".
|
The current-head retention finding is fixed in e9b111e and its review thread is addressed. @codex review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: e9b111ef6c
ℹ️ 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".
|
@clawsweeper re-review |
|
@codex review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
Codex Review: Didn't find any major issues. Swish! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: a66dbab000
ℹ️ 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".
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 37cf61dd7e
ℹ️ 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".
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: dea4da155b
ℹ️ 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".
|
@codex review |
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. |
|
Codex Review: Didn't find any major issues. What shall we delve into next? Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: f610e5a77f
ℹ️ 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".
|
@codex review |
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 7dd482e5dd
ℹ️ 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".
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 4443b51e8d
ℹ️ 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".
| guard line.first?.isWhitespace != true else { return false } | ||
| let trimmed = line.trimmingCharacters(in: .whitespacesAndNewlines) | ||
| guard !trimmed.hasPrefix("#") else { return false } | ||
| return conflictingKeys.contains { trimmed.hasPrefix("\($0):") } |
There was a problem hiding this comment.
Ignore empty upstream lists when resolving Codex OAuth
When a valid config contains an empty root list such as codex-api-key: [] or openai-compatibility: [], this presence-only check reports a competing upstream even though none exists. For historical requests that have a matching request log and a sole Codex OAuth auth file but no retained queue telemetry, authInventoryUpstream then refuses to identify Codex; the resulting route has no upstream and is excluded from both the Claude and Codex projections. Parse whether either list actually contains an active entry before suppressing the OAuth inventory fallback.
Useful? React with 👍 / 👎.
|
@codex review |
|
ClawSweeper status: review started. I am starting a fresh review of this pull request: Add CLIProxyAPI cost attribution This is item 1/1 in the current shard. Shard 0/1. This placeholder means the worker is alive and reading the current context. I will edit this same comment with the actual review when the claws are done clicking. Crustacean status: shell secured, claws on keyboard, evidence pebbles being sorted. |
|
Codex Review: Didn't find any major issues. Breezy! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
Summary
Verification
DEVELOPER_DIR=/Applications/Xcode.app/Contents/Developer make checkDEVELOPER_DIR=/Applications/Xcode.app/Contents/Developer make test(972 selections, 81 groups, all passed on the first attempt; 0 retries/timeouts)DEVELOPER_DIR=/Applications/Xcode.app/Contents/Developer xcrun swift test --disable-sandbox --skip-build --filter 'queue client blocks hostile redirects before redirected IO'(real loopback I/O; redirected endpoint received 0 requests and 0 bearer headers)swift test --filter SpendDashboardProxyAttributionTestsDEVELOPER_DIR=/Applications/Xcode.app/Contents/Developer swift test --filter CLIProxyAPIAttributionResolverTests(24 tests)DEVELOPER_DIR=/Applications/Xcode.app/Contents/Developer swift test --filter CostUsageFetcherCacheSnapshotTests(13 tests)swift test --filter CostUsageFetcherTests(18 tests)DEVELOPER_DIR=/Applications/Xcode.app/Contents/Developer swift test --filter CostUsageFetcherUnknownModelPricingTests(7 tests)swift test --filter SpendDashboardCodexProxySourceTests(2 tests)swift test --filter SpendDashboardForceStateMachineTests(14 tests)SpendDashboardTokenProvenanceTests,SpendDashboardControllerTests,CostUsageCacheTests, andCostUsageScannerClaudeFableTestsRedirect final-effect proof
CLIProxyAPIUsageQueueClientagainst two real ephemeral loopback HTTP servers with a redacted proof token.307redirect to the capture server.