Skip to content

Share spend sources between Overview and dashboard - #3067

Merged
steipete merged 9 commits into
steipete:mainfrom
Chipagosfinest:agent/shared-spend-source-publications
Aug 19, 2026
Merged

Share spend sources between Overview and dashboard#3067
steipete merged 9 commits into
steipete:mainfrom
Chipagosfinest:agent/shared-spend-source-publications

Conversation

@Chipagosfinest

Copy link
Copy Markdown
Contributor

Summary

  • publish one app-scoped, immutable spend-source catalog for both Overview and Usage & Spend
  • preserve multi-account Codex identities plus available, confirmed-empty, unavailable, loading, and stale states
  • keep menu construction synchronous and cache-only while the shared controller refreshes outside AppKit tracking
  • make Overview use the dashboard's 365-day inputs, exact current ownership, configured calendar/currency, and OpenCodex enrichment without double counting
  • keep unreadable Codex accounts in the roster, reject stale account/config results, and stop the shared controller at app shutdown

Coverage and math

  • metric-specific completeness prevents unpriced sources from making subtotals look exact
  • confirmed-empty sources are known zero; unavailable/stale sources keep totals qualified
  • canonical OpenCodex Codex data can replace native Codex once when requested
  • non-Codex OpenCodex routes cannot hide native Codex spend
  • hidden native accounts cannot suppress a still-visible standalone OpenCodex total

Stack

Verification

  • swift build --target CodexBar passed after a temporary local expansion of the unavailable SwiftUI @Entry macro; tracked macro source was restored with no diff
  • SwiftFormat: 0/13 files require formatting
  • changed production and test sources pass swiftc -parse
  • git diff --check passes
  • independent adversarial review: ready, no remaining correctness blockers or warnings
  • local Swift Testing and SwiftLint execution are indeterminate under Command Line Tools (Testing module / SourceKit framework unavailable); hosted Xcode CI is the authority

Research

Architecture and primary Apple/Swift sources are recorded in docs/research/shared-spend-source-publications.md.

@clawsweeper

clawsweeper Bot commented Aug 19, 2026

Copy link
Copy Markdown

🦞👀
ClawSweeper picked this up.

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

@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: 6ee893768c

ℹ️ 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+SpendDashboardPublication.swift
Comment thread Sources/CodexBar/SpendDashboardController.swift
@Chipagosfinest

Copy link
Copy Markdown
Contributor Author

@codex review the exact current head de95d85, including the same-owner in-flight publication fix.

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

ℹ️ 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 +1481 to +1482
guard let separator = identity.firstIndex(of: "|") else { return nil }
return "codex:\(identity[..<separator])"

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 Split account identities at the final delimiter

For a profile-home Codex account whose path contains | (a valid macOS filename character), the visible account ID is profile:<path> and the configuration stores it as <id>|<cache-hash>. Splitting at the first delimiter truncates that ID, so the roster contains a phantom truncated source alongside the actual loaded codex:<id> input, inflating subscription counts and reporting incorrect availability. Parse from the final delimiter, as codexOwnershipByID already does, or represent the identity structurally.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed in 546bd90. All three identity-parsing sites (orderedSourceIDs, codexDisplayNamesByID, and codexOwnershipByID) now consistently use lastIndex(of: "|"). Added a regression test (profile-home path containing pipe preserves full account identity) that configures a pipe-containing profile-home path and asserts exactly one source with the full identity — no phantom truncated source.

@clawsweeper clawsweeper Bot added merge-risk: 🚨 compatibility 🚨 Merging this PR could break existing users, config, migrations, defaults, or upgrades. P2 Normal priority bug or improvement with limited blast radius. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Aug 19, 2026
@clawsweeper

clawsweeper Bot commented Aug 19, 2026

Copy link
Copy Markdown

Codex review: needs real behavior proof before merge. Reviewed August 19, 2026, 5:30 AM ET / 09:30 UTC.

ClawSweeper review

What this changes

This PR publishes one app-scoped spend-source catalog so the Overview menu and Usage & Spend dashboard derive their accounting from the same cached provider and account data.

Merge readiness

Blocked until real behavior proof from a real setup is added - 6 items remain

Keep open: the exact head still has a P2 account-identity parsing defect, and this broad shared-controller refactor needs maintainer sign-off plus real behavior proof.

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

Review scores

Measure Result What it means
Overall readiness 🦪 silver shellfish (2/6) The implementation has substantial focused coverage but remains blocked by one concrete correctness defect and missing current-head real behavior proof.
Proof confidence 🦪 silver shellfish (2/6) Needs real behavior proof before merge: The body supplies build and test claims, but no after-fix real app evidence for this exact branch; the prepared screenshot is from a related branch and only shows the Overview. Add redacted fresh-app output or a recording, then update the PR body for automatic re-review (or ask a maintainer for @clawsweeper re-review).
Patch quality 🦐 gold shrimp (3/6) 1 actionable review finding remain.

Verification

Check Result Evidence
Real behavior Needs proof Needs real behavior proof before merge: The body supplies build and test claims, but no after-fix real app evidence for this exact branch; the prepared screenshot is from a related branch and only shows the Overview. Add redacted fresh-app output or a recording, then update the PR body for automatic re-review (or ask a maintainer for @clawsweeper re-review).
Evidence reviewed 4 items Account IDs are serialized with a final cache delimiter: The branch constructs each identity as account ID plus a cache identity separated by |; profile-home account IDs include the user-controlled profile path.
Roster parsing still splits at the first delimiter: orderedSourceIDs truncates an account ID containing |, while the ownership parser in the same file correctly uses the final delimiter. The truncated ID is published as an additional unavailable source alongside the actual input.
Current-main spend ownership history: Current main's recent controller work is commit 85873f5, and the adjacent Overview accounting change is d353ace; both establish the active ownership trail for this subsystem.
Findings 1 actionable finding [P2] Parse account identities from the final delimiter
Security None None.

Live Verification

Command: swift run CodexBarCLI --help

Result: FAIL (failed) — execution before step 1 run: sh -lc pnpm install --ignore-scripts --frozen-lockfile failed: ! Corepack is about to download https://registry.npmjs.org/pnpm/-/pnpm-11.22.0.tgz

sh -lc pnpm install --ignore-scripts --frozen-lockfile failed: ! Corepack is about to download https://registry.npmjs.org/pnpm/-/pnpm-11.22.0.tgz

Assertions:

  • FAIL expect_output: Usage:

How this fits together

Provider token snapshots, Codex account caches, and spend settings feed a shared spend controller. It publishes immutable source states that the synchronous Overview menu and detailed dashboard both transform into their displays.

flowchart LR
A[Provider and account snapshots] --> B[Shared spend controller]
C[Spend settings and ownership] --> B
B --> D[Immutable spend publication]
D --> E[Overview menu]
D --> F[Usage and Spend dashboard]
B --> G[Background refresh and reconciliation]
Loading

Decision needed

Question Recommendation
Should CodexBar adopt this app-scoped shared spend controller after the identity fix, rather than retain a pane-owned dashboard controller with a narrower Overview projection? Adopt after repair: Accept the shared publication architecture once the account-identity defect is fixed and fresh app behavior proof shows both consumers agree.

Why: VISION.md requires sign-off for broad refactors and meaningful maintenance complexity; this architecture choice cannot be resolved from correctness evidence alone.

Before merge

  • Add real behavior proof - Needs real behavior proof before merge: The body supplies build and test claims, but no after-fix real app evidence for this exact branch; the prepared screenshot is from a related branch and only shows the Overview. Add redacted fresh-app output or a recording, then update the PR body for automatic re-review (or ask a maintainer for @clawsweeper re-review).
  • Parse account identities from the final delimiter (P2) - codexAccountIdentities stores &lt;account-id>|&lt;cache-identity>, and a profile-home account ID can itself contain |. Splitting at the first delimiter publishes a truncated unavailable source in addition to the real codex:&lt;account-id> input, so the Overview reports an inflated coverage denominator. Use the same final-delimiter rule as codexOwnershipByID and cover a pipe-containing profile path.
  • Resolve merge risk (P1) - A profile-home path containing | produces a phantom Codex source, inflating subscription coverage and showing incorrect availability.
  • Resolve merge risk (P1) - The 18-file shared-controller refactor changes active spend ownership and must be explicitly accepted as the intended architecture.
  • Resolve merge risk (P1) - No after-fix evidence demonstrates the exact branch's shared publication in both the Overview and dashboard.

Findings

  • [P2] Parse account identities from the final delimiter — Sources/CodexBar/SpendDashboardController.swift:1481-1482
Agent review details

Security

None.

Review metrics

Metric Value Why it matters
Production versus test growth production +781/-152, tests +1,119/-33 The implementation is a substantial shared-state refactor with more regression coverage than production growth.
Changed surface 18 files, +1,955/-185 The change spans menu rendering, dashboard loading, store lifecycle, and concurrency tests, so upgrade review should consider the whole flow.

Merge-risk options

Maintainer options:

  1. Preserve full account identities (recommended)
    Parse every serialized account-id|cache-identity value from its final delimiter and add a profile-home path regression before merge.
  2. Pause for architecture sign-off
    Pause the PR if maintainers do not want the new app-scoped controller to become the long-lived ownership boundary.
Copy recommended automerge instruction
@clawsweeper automerge

Special instructions:
Parse serialized Codex account identities at the final delimiter in all shared-publication consumers, add a regression for a profile-home path containing `|`, and verify no phantom source affects coverage.

Technical review

Best possible solution:

Use a structured account identity, or consistently split its serialized form at the final delimiter, add the profile-path regression, then obtain a redacted fresh-app proof before maintainers decide whether to adopt the app-scoped controller.

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

Yes, from source: configure a Codex profile-home path containing |; the resulting profile:&lt;path>|&lt;cache> identity is split at its first delimiter and creates a phantom source.

Is this the best way to solve the issue?

No. A shared publication can reduce drift, but this implementation must preserve full account identities and receive the VISION-required architecture sign-off.

Full review comments:

  • [P2] Parse account identities from the final delimiter — Sources/CodexBar/SpendDashboardController.swift:1481-1482
    codexAccountIdentities stores &lt;account-id>|&lt;cache-identity>, and a profile-home account ID can itself contain |. Splitting at the first delimiter publishes a truncated unavailable source in addition to the real codex:&lt;account-id> input, so the Overview reports an inflated coverage denominator. Use the same final-delimiter rule as codexOwnershipByID and cover a pipe-containing profile path.
    Confidence: 0.99

Overall correctness: patch is incorrect
Overall confidence: 0.99

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 453174fe13ee.

Labels

Label changes:

  • add P2: Incorrect account identity parsing can misstate a user's spend subscription coverage but has limited scope.
  • add merge-risk: 🚨 compatibility: Existing profile-home paths may legally contain |, and this branch would misinterpret those persisted account identities.
  • add rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦪 silver shellfish and patch quality is 🦐 gold shrimp.
  • add status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs real behavior proof before merge: The body supplies build and test claims, but no after-fix real app evidence for this exact branch; the prepared screenshot is from a related branch and only shows the Overview. Add redacted fresh-app output or a recording, then update the PR body for automatic re-review (or ask a maintainer for @clawsweeper re-review).

Label justifications:

  • P2: Incorrect account identity parsing can misstate a user's spend subscription coverage but has limited scope.
  • merge-risk: 🚨 compatibility: Existing profile-home paths may legally contain |, and this branch would misinterpret those persisted account identities.
  • rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦪 silver shellfish 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 body supplies build and test claims, but no after-fix real app evidence for this exact branch; the prepared screenshot is from a related branch and only shows the Overview. Add redacted fresh-app output or a recording, then update the PR body for automatic re-review (or ask a maintainer for @clawsweeper re-review).

Evidence

Acceptance criteria:

  • [P1] swift test --filter SpendDashboardPublicationTests.
  • [P1] swift test --filter SpendDashboardSourceConcurrencyTests.
  • [P1] make check.
  • [P1] make test.

What I checked:

  • Account IDs are serialized with a final cache delimiter: The branch constructs each identity as account ID plus a cache identity separated by |; profile-home account IDs include the user-controlled profile path. (Sources/CodexBar/SpendDashboardController.swift:584, de95d8554484)
  • Roster parsing still splits at the first delimiter: orderedSourceIDs truncates an account ID containing |, while the ownership parser in the same file correctly uses the final delimiter. The truncated ID is published as an additional unavailable source alongside the actual input. (Sources/CodexBar/SpendDashboardController.swift:1481, de95d8554484)
  • Current-main spend ownership history: Current main's recent controller work is commit 85873f5, and the adjacent Overview accounting change is d353ace; both establish the active ownership trail for this subsystem. (Sources/CodexBar/SpendDashboardController.swift, 85873f52eaae)
  • Prepared media is not current-head proof: The only prepared image is an Overview-only artifact from related PR head 0d75f17, so it does not show this PR's shared publication working across both surfaces.

Likely related people:

  • Yuxin Qiao: Authored the current-main in-flight dashboard refresh coalescing work that this PR extends. (role: recent spend-controller contributor; confidence: high; commits: 85873f52eaae; files: Sources/CodexBar/SpendDashboardController.swift)
  • Peter Steinberger: Authored the shipped Overview spend summary implementation and release baseline. (role: adjacent Overview owner; confidence: medium; commits: 5a2a70458d95; files: Sources/CodexBar/StatusItemController+OverviewSpend.swift)
  • Alec Gutman: Authored the merged current-main change expanding Overview spend accounting scope. (role: recent Overview accounting contributor; confidence: high; commits: d353ace608ce; files: Sources/CodexBar/SpendDashboardController.swift, Sources/CodexBar/StatusItemController+OverviewSpend.swift)

Rank-up moves

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

  • Fix final-delimiter identity parsing and add a regression for a profile-home path containing |.
  • Add redacted fresh-app proof showing the same multi-account spend state in both Overview and Usage & Spend.
  • Obtain maintainer sign-off on the app-scoped ownership architecture after the mechanical repair.

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.

Chipagosfinest and others added 8 commits August 19, 2026 09:02
codexDisplayNamesByID and orderedSourceIDs split serialized
account identities at the first pipe, but profile-home account
IDs can themselves contain pipe characters. This truncated the
ID and created phantom unavailable sources, inflating the
coverage denominator. Use lastIndex(of:) consistently with
codexOwnershipByID and add a regression for a pipe-containing
profile-home path.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@Chipagosfinest
Chipagosfinest force-pushed the agent/shared-spend-source-publications branch from de95d85 to 546bd90 Compare August 19, 2026 16:04
@Chipagosfinest

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

Rebased onto current main (includes merged #3063 and #3064). Fixed the P2 account-identity delimiter bug in 546bd90 — all three identity-parsing sites now use lastIndex(of: "|") consistently, with a regression test for pipe-containing profile-home paths.

@clawsweeper

clawsweeper Bot commented Aug 19, 2026

Copy link
Copy Markdown

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper

clawsweeper Bot commented Aug 19, 2026

Copy link
Copy Markdown

ClawSweeper status: review started.

I am starting a fresh review of this pull request: Share spend sources between Overview and dashboard 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.

The regression test added in 546bd90 shifted four
SpendDashboardController.swift gatekeeper anchors by one line.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@steipete
steipete merged commit 4029705 into steipete:main Aug 19, 2026
9 checks passed
steipete added a commit that referenced this pull request Aug 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merge-risk: 🚨 compatibility 🚨 Merging this PR could break existing users, config, migrations, defaults, or upgrades. P2 Normal priority bug or improvement with limited blast radius. 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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants