Skip to content

Add CLIProxyAPI cost attribution - #2457

Open
EClinick wants to merge 68 commits into
steipete:mainfrom
EClinick:task/ec/codex-proxy-attribution
Open

Add CLIProxyAPI cost attribution#2457
EClinick wants to merge 68 commits into
steipete:mainfrom
EClinick:task/ec/codex-proxy-attribution

Conversation

@EClinick

@EClinick EClinick commented Jul 25, 2026

Copy link
Copy Markdown
Contributor

Summary

  • attribute Claude Code sessions routed through CLIProxyAPI using endpoint, installation, inventory, and request-log evidence
  • price confirmed proxied GPT usage in Codex totals while preserving route, backend, and auth provenance
  • surface proxy attribution in the spend dashboard and collect bounded CLIProxyAPI telemetry
  • serialize destructive telemetry collection and preserve full dashboard and synthetic-project attribution identities
  • keep proxy telemetry present for scoped callers while loading it exactly once beside account-scoped dashboard sources
  • persist each destructive queue batch before the next pop and surface cache-write failures
  • enforce the 366-day telemetry retention cutoff even when the proxy queue is empty
  • preserve request-log attribution beyond the newest 500 files
  • load the siloed proxy source for Claude-only dashboard configurations
  • retain Claude-only proxy spend through forced-refresh reconciliation
  • skip telemetry cache rewrites when an empty queue poll leaves the cache unchanged
  • filter expired telemetry during cache reads even when collection is unavailable
  • make request-log attribution loading cancellation-aware in full and cached scan paths
  • price aliased proxy usage from the telemetry-resolved upstream model
  • quarantine unresolved known foreign models from Claude totals while preserving confirmed non-Codex proxy attribution
  • refresh and retry proxy-only scans when a telemetry-confirmed upstream model is still unpriced
  • request refreshed pricing for the telemetry-resolved upstream model when its Claude-facing alias differs
  • resolve OpenAI-compatible proxy models across vendor catalogs after refresh instead of treating transport as vendor
  • keep global CLIProxyAPI supplemental usage out of account-scoped Codex scans
  • index retained proxy telemetry by canonical model and binary-search its bounded timestamp window
  • cache parsed CLIProxyAPI request logs by path, modification date, and size while pruning deleted paths
  • preserve explicit full-rescan semantics by bypassing the request-log cache when forced
  • resolve the default CLIProxyAPI home when hydrating cached spend through the production cache-root initializer
  • prefer timestamped request-log observations over undated fallbacks during telemetry correlation
  • migrate cost caches and add cross-provider regression coverage

Verification

  • DEVELOPER_DIR=/Applications/Xcode.app/Contents/Developer make check
  • DEVELOPER_DIR=/Applications/Xcode.app/Contents/Developer make test (725 selections, 61 groups, all passed on the first attempt)
  • swift test --filter SpendDashboardProxyAttributionTests
  • DEVELOPER_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)
  • focused resolver and fetcher suites together (40 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)
  • focused resolver, proxy-source, and dashboard-controller suites (47 tests)
  • focused SpendDashboardTokenProvenanceTests, SpendDashboardControllerTests, CostUsageCacheTests, and CostUsageScannerClaudeFableTests

Remaining proof

  • A redacted live CLIProxyAPI-routed Claude Code run has not been collected in this PR. Automated tests use isolated fixtures and stubbed queue clients; they do not claim production-account or Keychain validation.

Copilot AI review requested due to automatic review settings July 25, 2026 23:59

Copilot AI 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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@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: 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".

Comment thread Sources/CodexBarCore/CLIProxyAPIAttributionResolver.swift
Comment thread Sources/CodexBarCore/CLIProxyAPIUsageTelemetry.swift Outdated
Comment thread Sources/CodexBar/SpendDashboardModel.swift Outdated
Comment thread Sources/CodexBarCore/CostUsageFetcher.swift
@clawsweeper clawsweeper Bot added 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. P2 Normal priority bug or improvement with limited blast radius. merge-risk: 🚨 compatibility 🚨 Merging this PR could break existing users, config, migrations, defaults, or upgrades. merge-risk: 🚨 other 🚨 Merging this PR has meaningful risk outside the owned taxonomy. labels Jul 26, 2026
@clawsweeper

clawsweeper Bot commented Jul 26, 2026

Copy link
Copy Markdown

Codex review: needs real behavior proof before merge. Reviewed July 30, 2026, 7:37 AM ET / 11:37 UTC.

ClawSweeper review

What this changes

Adds CLIProxyAPI request-log and telemetry attribution so Claude Code traffic routed through a proxy can be assigned to a confirmed upstream provider, priced, cached, and displayed in CodexBar’s Usage & Spend dashboard.

Merge readiness

Blocked until real behavior proof is added - 5 items remain

Keep this PR open for maintainer review and real behavior proof. The latest branch addresses the earlier data-loss and attribution findings with focused regressions, but this is a large new provider-attribution and persistent-cache feature whose production queue, credentials, and dashboard result have not yet been demonstrated in a redacted live setup.

Priority: P2
Reviewed head: 20ada6b229419ddb0764801b3ca95c44a78d5542
Owner decision: Required. See Decision needed.

Review scores

Measure Result What it means
Overall readiness 🧂 unranked krab (1/6) The patch has meaningful automated regression coverage and resolved earlier findings, but missing real behavior proof remains a merge gate for this credentialed attribution feature.
Proof confidence 🧂 unranked krab (1/6) Needs real behavior proof before merge: The PR body explicitly states that no redacted live CLIProxyAPI-routed Claude Code run has been collected; fixture tests and check output do not prove the real management-key, queue, cache, and dashboard path. 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) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Needs proof Needs real behavior proof before merge: The PR body explicitly states that no redacted live CLIProxyAPI-routed Claude Code run has been collected; fixture tests and check output do not prove the real management-key, queue, cache, and dashboard path. 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 4 items Current PR scope: The branch changes 37 files with 7,152 additions and 231 deletions across dashboard UI, provider attribution, persistent cache handling, CLI cache clearing, and regression tests.
Earlier blockers addressed: The reviewed discussion records fixes and regressions for destructive queue persistence, cache-write failure reporting, scoped dashboard loading, retention cleanup, disconnect handling, interprocess locking, and the latest telemetry-migration serialization concern.
Proof remains absent: The PR body explicitly says that no redacted live CLIProxyAPI-routed Claude Code run has been collected; its listed verification is automated tests and checks only.
Findings None None.
Security None None.

How this fits together

CodexBar scans local provider histories, applies provider pricing, and aggregates the results into its Usage & Spend dashboard. This change introduces CLIProxyAPI logs and destructive telemetry-queue records as an additional evidence source before usage is assigned to Claude or Codex totals.

flowchart LR
    A[Claude Code session history] --> C[Cost usage scanner]
    B[CLIProxyAPI logs and telemetry queue] --> D[Attribution resolver]
    C --> D
    D --> E[Provider pricing and cache]
    E --> F[Spend dashboard]
    F --> G[Attributed provider totals]
Loading

Decision needed

Question Recommendation
Should CodexBar ship CLIProxyAPI management-key telemetry collection and durable cross-provider cost attribution as a built-in core integration, with the proposed separate dashboard source and retention behavior? Sponsor the integration after proof: Accept CLIProxyAPI as a built-in integration once a redacted live run proves the collection, attribution, and display path on the current head.

Why: The patch is a new product surface rather than a repair to an established contract: it adds connection settings, collection of a destructive external telemetry queue, persisted attribution state, and changes to how historical spend is assigned across providers.

Before merge

  • Add real behavior proof - Needs real behavior proof before merge: The PR body explicitly states that no redacted live CLIProxyAPI-routed Claude Code run has been collected; fixture tests and check output do not prove the real management-key, queue, cache, and dashboard path. 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.
  • Resolve merge risk (P1) - The PR introduces destructive queue collection backed by a management key and durable attribution data; without a redacted live run, the real endpoint, authentication, queue-pop, persistence, and retry path remain unverified.
  • Resolve merge risk (P1) - Existing dashboard totals can be reclassified after upgrade when past Claude Code sessions are recognized as CLIProxyAPI-routed Codex usage, so maintainers need to accept the attribution and cache-migration semantics as intentional.
  • Resolve merge risk (P1) - The new configuration and dashboard source must continue to avoid presenting Codex account or subscription identity as Claude identity, including Claude-only configurations and disconnected integrations.
Agent review details

Security

None.

Review metrics

Metric Value Why it matters
Changed surface 37 files affected The patch spans core scanning, persistence, CLI cache clearing, settings, dashboard presentation, and tests rather than a single attribution helper.
Patch size 7,152 added, 231 removed The large implementation and 67-commit review history increase the value of end-to-end validation beyond unit coverage.
Focused coverage Multiple new resolver, collector, cache, fetcher, and dashboard suites The branch contains targeted regression coverage for earlier attribution and persistence findings, but those tests remain supplemental to live proof.

Merge-risk options

Maintainer options:

  1. Require live attribution proof before merge (recommended)
    Capture a redacted routed Claude Code run that shows the configured proxy collection, confirmed upstream attribution, and separate dashboard result while masking the management key, endpoint details, IP addresses, and account data.
  2. Accept the integration as a product decision
    A maintainer may explicitly accept the reclassification and persistent telemetry behavior after reviewing the cache migration, retention, disconnect cleanup, and provider-silo semantics.
  3. Pause the feature
    Close or defer the branch if built-in destructive telemetry collection is not an intended CodexBar responsibility.

Technical review

Best possible solution:

Land only after a maintainer sponsors the CLIProxyAPI integration boundary and the contributor supplies redacted live evidence that a routed Claude Code session is collected once, attributed to the correct upstream model, and rendered in the expected separate dashboard source without exposing credentials or account details.

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

Not applicable as a bug reproduction: this PR adds a new CLIProxyAPI integration. The contributor has supplied extensive fixture-based coverage, but the PR explicitly confirms that no real routed session has been demonstrated on the current head.

Is this the best way to solve the issue?

Unclear. The branch has addressed the concrete review defects surfaced so far, but adding management-key telemetry collection, durable attribution storage, and cross-provider reporting needs explicit maintainer sponsorship plus a redacted end-to-end demonstration before this can be judged the best product path.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 8ef86077e70a.

Labels

Label justifications:

  • P2: This is a substantial but optional Usage & Spend attribution feature with a limited provider-integration blast radius.
  • merge-risk: 🚨 compatibility: The branch changes persistent cost-cache locations and can reclassify historical Claude Code spend into a separate Codex proxy source after upgrade.
  • merge-risk: 🚨 auth-provider: CLIProxyAPI connection configuration and management-key-backed telemetry affect provider routing and credential-dependent collection.
  • merge-risk: 🚨 other: The change consumes a destructive external telemetry queue and must prove that collection, persistence, retry, and dashboard presentation agree in a real setup.
  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🦐 gold shrimp.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs real behavior proof before merge: The PR body explicitly states that no redacted live CLIProxyAPI-routed Claude Code run has been collected; fixture tests and check output do not prove the real management-key, queue, cache, and dashboard path. 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:

  • Current PR scope: The branch changes 37 files with 7,152 additions and 231 deletions across dashboard UI, provider attribution, persistent cache handling, CLI cache clearing, and regression tests. (Sources/CodexBarCore/CostUsageFetcher.swift:117, 20ada6b22941)
  • Earlier blockers addressed: The reviewed discussion records fixes and regressions for destructive queue persistence, cache-write failure reporting, scoped dashboard loading, retention cleanup, disconnect handling, interprocess locking, and the latest telemetry-migration serialization concern. (Sources/CodexBarCore/CLIProxyAPIUsageTelemetry.swift:1, 20ada6b22941)
  • Proof remains absent: The PR body explicitly says that no redacted live CLIProxyAPI-routed Claude Code run has been collected; its listed verification is automated tests and checks only. (20ada6b22941)
  • Repository review policy: AGENTS.md requires focused validation for provider/parser/settings changes, calls for screenshots or GIFs for UI changes, and requires provider data to remain siloed; the PR’s separate proxy source and attribution tests align with that boundary, but no live proof demonstrates it. (AGENTS.md:15, 8ef86077e70a)

Likely related people:

  • steipete: The feature introduces a new core integration, management-key configuration, durable telemetry storage, and provider-attribution behavior; repository ownership is the strongest available routing signal because this feature is not yet present on current main. (role: likely product and merge decision owner; confidence: low; files: Sources/CodexBar/PreferencesSpendDashboardPane.swift, Sources/CodexBarCore/CostUsageFetcher.swift)

Rank-up moves

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

  • Add a redacted terminal or live-output capture of a routed Claude Code request being collected from CLIProxyAPI.
  • Show the resulting model/upstream attribution and separate Usage & Spend dashboard row in the same redacted proof.
  • Mask management keys, endpoint details, IP addresses, account identifiers, and other private data; update the PR body afterward for automatic re-review.

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 (30 earlier review cycles; latest 8 shown)
  • reviewed 2026-07-30T01:10:42.610Z sha 2908743 :: needs real behavior proof before merge. :: [P1] Avoid unrecoverable destructive queue pops
  • reviewed 2026-07-30T01:35:54.650Z sha e728e2a :: needs real behavior proof before merge. :: [P1] Avoid unrecoverable destructive queue pops | [P2] Restart the existing collector after a failed save | [P2] Keep uniquely distinguishable concurrent proxy requests
  • reviewed 2026-07-30T01:53:41.697Z sha 6517067 :: needs real behavior proof before merge. :: [P1] Avoid unrecoverable destructive queue pops
  • reviewed 2026-07-30T02:29:30.221Z sha 3bf52d6 :: needs real behavior proof before merge. :: [P1] Avoid unrecoverable destructive queue pops
  • reviewed 2026-07-30T02:36:14.122Z sha 32d681d :: needs real behavior proof before merge. :: [P1] Replace the non-public fixture model identifier
  • reviewed 2026-07-30T02:42:06.442Z sha ff3287d :: needs real behavior proof before merge. :: [P1] Avoid unrecoverable destructive queue pops
  • reviewed 2026-07-30T03:10:41.767Z sha 8fd2dd4 :: needs real behavior proof before merge. :: [P1] Avoid unrecoverable destructive queue pops
  • reviewed 2026-07-30T11:21:54.948Z sha 71592d4 :: needs real behavior proof before merge. :: none

Copy link
Copy Markdown
Contributor Author

@codex review

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Jul 27, 2026

Copy link
Copy Markdown

🦞👀
ClawSweeper picked this up.

Command router queued. I will update this comment with the next step.

@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: 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".

Comment thread Sources/CodexBarCore/CostUsageFetcher.swift Outdated
Comment thread Sources/CodexBarCore/CLIProxyAPIUsageTelemetry.swift Outdated
Comment thread Sources/CodexBarCore/CLIProxyAPIUsageTelemetry.swift Outdated

Copy link
Copy Markdown
Contributor Author

Follow-up fixes are pushed in 0f4bda0 and the three current review threads have been addressed.

@codex review
@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Jul 27, 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 repository_dispatch).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@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: 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".

Comment thread Sources/CodexBarCore/CLIProxyAPIUsageTelemetry.swift Outdated

Copy link
Copy Markdown
Contributor Author

The current-head retention finding is fixed in e9b111e and its review thread is addressed.

@codex review
@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Jul 27, 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 repository_dispatch).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@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: 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".

Comment thread Sources/CodexBarCore/CLIProxyAPIAttributionResolver.swift Outdated
Comment thread Sources/CodexBar/SpendDashboardController.swift Outdated
@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. labels Jul 27, 2026
@EClinick

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@EClinick

Copy link
Copy Markdown
Contributor Author

@codex review

@clawsweeper

clawsweeper Bot commented Jul 27, 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 repository_dispatch).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@EClinick

Copy link
Copy Markdown
Contributor Author

@codex review

@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: 6517067c4e

ℹ️ 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/CostUsageFetcher.swift Outdated
@EClinick

Copy link
Copy Markdown
Contributor Author

@codex review

@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: 3bf52d6697

ℹ️ 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 Tests/CodexBarTests/CLIProxyAPIAttributionBatchTests.swift Outdated
EClinick added 2 commits July 29, 2026 19:32
…nto task/ec/codex-proxy-attribution

# Conflicts:
#	Sources/CodexBarCore/CostUsageFetcher.swift
@EClinick

Copy link
Copy Markdown
Contributor Author

@codex review

@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: ff3287d8eb

ℹ️ 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/Vendored/CostUsage/CostUsageScanner+Claude.swift Outdated
@EClinick

Copy link
Copy Markdown
Contributor Author

CI note for the linked Linux x64 failure (run 30506735403, job 90758093269):

The failure came from CLICardsClaudeSwapTests, specifically "fake executable receives only one read only list command." The test successfully created and chmodded its temporary cswap script, but Foundation Process.run failed before that script executed, returning the generic error NSCocoaErrorDomain 256. The missing invocation marker, one-card result, and failure exit code were all downstream assertions from that single launch failure.

This is not caused by the changes in this PR. Comparing the PR base (8ef8607) with the current head (ff3287d), the PR does not modify CLICardsClaudeSwapTests, CLIClaudeSwapCards, ClaudeSwapAccountReader, SubprocessRunner, ProcessPipeCapture, or the Linux workflow. The tests added by this PR also do not launch subprocesses or alter file-descriptor limits.

The same unchanged test passes on the current PR head, and the current Linux x64, ARM64, and musl jobs are all green. That makes the linked failure consistent with an intermittent Linux/Foundation process-launch test flake rather than a regression in the CLIProxyAPI attribution work.

The exact underlying POSIX errno is not available in the failed log because SubprocessRunner currently reduces the Foundation NSError to localizedDescription; code 256 is only the generic Cocoa read/launch error.

@EClinick

Copy link
Copy Markdown
Contributor Author

@codex review

@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: 8fd2dd4b14

ℹ️ 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/CodexBar/UsageStore+TokenCost.swift Outdated
@EClinick

Copy link
Copy Markdown
Contributor Author

@codex review

@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: 2907270dae

ℹ️ 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/CodexBar/UsageStore+CLIProxyAPI.swift Outdated
Comment thread Sources/CodexBarCore/CLIProxyAPIUsageTelemetry.swift Outdated
@EClinick

Copy link
Copy Markdown
Contributor Author

@codex review

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

ℹ️ 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/CLIProxyAPIUsageTelemetry.swift Outdated
@EClinick

Copy link
Copy Markdown
Contributor Author

@codex review

@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: 71592d4ff1

ℹ️ 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/CLIProxyAPIUsageTelemetry.swift
@EClinick

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Nice work!

Reviewed commit: 20ada6b229

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

@EClinick

Copy link
Copy Markdown
Contributor Author

@codex review

@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: fdf7763251

ℹ️ 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 +920 to +921
} else if modelProvider != .anthropic {
liveAttribution ?? row.attribution

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 Gate non-Anthropic cached attribution after disconnect

When removal leaves the Claude cache behind because cleanup fails or the app exits after committing the disconnect marker, a cached row whose Claude-facing model is itself non-Anthropic enters this fallback and restores row.attribution despite allowCachedCLIProxyAPIAttribution being false. Fresh evidence beyond the resolved thread is that this non-Anthropic branch bypasses the newly added disconnect guard, so models such as a directly selected OpenAI alias can still render the former Codex upstream after disconnect; suppress cached .cliProxyAPI attribution in this branch as well.

AGENTS.md reference: AGENTS.md:L46-L46

Useful? React with 👍 / 👎.

guard let sessionID = sessionID?.trimmingCharacters(in: .whitespacesAndNewlines),
!sessionID.isEmpty
else { return nil }
return self.observationsBySessionID[sessionID]?.first

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 Match proxy routes to individual requests

When a Claude Code session is resumed once through CLIProxyAPI and once with a direct connection, this returns the session's first proxy observation for every row sharing that session ID, without checking the row's model or timestamp. A direct row can therefore be assigned the Codex auth-inventory upstream, or marked as an unresolved proxy row and excluded from Claude totals; select a route observation compatible with the individual request instead of treating any session-level log as proof.

AGENTS.md reference: AGENTS.md:L46-L46

Useful? React with 👍 / 👎.

Comment on lines +696 to +698
for _ in 0..<self.maximumBatches {
guard !Task.isCancelled, await shouldContinue() else { return .disabled }
let poppedBatch = try await client.pop(count: self.batchSize)

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 Recheck disconnect state between destructive pops

When another CodexBar process removes the integration while this process already holds the interprocess collection lock, removal commits the disconnect marker before waiting to purge, but this loop checks only local task cancellation and Track costs. Fresh evidence beyond the prior purge and queued-collection threads is that the active lock holder can consequently perform every remaining destructive pop with its captured key before releasing the lock, after which removal deletes those newly consumed records; pass the current-configuration check into the loop and evaluate it before each subsequent pop.

Useful? React with 👍 / 👎.

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

Labels

merge-risk: 🚨 auth-provider 🚨 Merging this PR could break OAuth, tokens, provider routing, model choice, or credentials. merge-risk: 🚨 compatibility 🚨 Merging this PR could break existing users, config, migrations, defaults, or upgrades. merge-risk: 🚨 other 🚨 Merging this PR has meaningful risk outside the owned taxonomy. P2 Normal priority bug or improvement with limited blast radius. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. 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.

3 participants