Repository navigation
Conversation
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 55 minutes. View limit details
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. CodeRabbit Verify
|
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: ab4c62fe30
ℹ️ 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".
| const tokens = sumTokens(group.sessions.map((session) => session.tokens)); | ||
| const providerID = root?.providerID ?? group.sessions[0]?.providerID ?? null; | ||
| const modelID = root?.modelID ?? group.sessions[0]?.modelID ?? null; |
There was a problem hiding this comment.
Preserve provider and model boundaries when grouping child usage
When a child session uses a different provider or model from its root, this sums both sessions' tokens but labels the entire fact with the root's provider/model. For example, an OpenAI root with an Anthropic child produces an OpenAI-tagged fact containing Anthropic consumption, while reconciliation still reports success. This loses the per-pool accounting required by doc/spend-rollups-design-1259.md (§Units), and downstream consumers cannot recover the breakdown from these facts. Retain the root's issue attribution while splitting usage facts by provider/model.
Useful? React with 👍 / 👎.
| const tokens = sumTokens(group.sessions.map((session) => session.tokens)); | ||
| const providerID = root?.providerID ?? group.sessions[0]?.providerID ?? null; | ||
| const modelID = root?.modelID ?? group.sessions[0]?.modelID ?? null; | ||
| const binding = root ? bindingsBySession.get(root.id) : undefined; |
There was a problem hiding this comment.
Consult exact bindings even when the root session is absent
When an exported child references a parent outside the source window, collectRootGroups retains that missing parent's ID as group.rootSessionId, but this guard prevents looking up its binding. Thus a supplied binding for that exact ID is discarded and all child usage becomes unattributed despite authoritative issue information being available. This is a realistic input because opencode-usage-export.mjs filters sessions independently by time_updated >= ?. Look up the binding using group.rootSessionId regardless of whether the root's session row exists; the missing-parent reason can still record the incomplete source context.
Useful? React with 👍 / 👎.
|
Stale-PR warden: no activity for 3 days. Resolution task: #6912 — this PR should be merged, fixed, or closed. |
Summary
Adds a pure
v1projection inpm-stack/aggregator/src/spend-attribution.ts. It conserves input, output, reasoning, cache-read, and cache-write tokens independently; failed/missing exports stay unknown (source-gap), not zero. Area is not used as a project key, and list-price estimates are not treated as dollars.Evidence
After:
bun test test/spend-attribution.test.ts— 7 pass; focused strict TypeScript check of the new module and tests — pass;git diff --check— pass.bun test: 1425 pass, 2 failures in existing/api/healthassertions intest/api-health-comments.test.ts(outside this diff). Fullbunx tsc --noEmitreports the existingtest/overview.test.tsHealthView.conflictsfixture error; the changed files pass the focused strict check.Merge Danger
Door: two-way
Blast Radius: low — new pure module and unit tests; no collector, exporter, or UI wiring changes.
Closes #4822.
Open in [code]smith · Need help on this PR? Tag
@codesmith-botwith what you need.