fix: preserve billing dimensions and journal usage for replay - #5765
ramapitecusment wants to merge 9 commits into
Conversation
|
This pull request targeted The base branch has been automatically changed to |
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: bd2e42c1c1
ℹ️ 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".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 10cc498888
ℹ️ 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".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 771f30123e
ℹ️ 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".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 84b18c0e4c
ℹ️ 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".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 0a77686175
ℹ️ 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".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 30c7821850
ℹ️ 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".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 1386ec7d23
ℹ️ 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".
|
@luispater @sususu98 I have extracted a first independently reviewable correction into #5817: three production lines to preserve DeepSeek cache-hit usage in the existing schema, with response/SSE regression tests. It reproduces on current dev and does not depend on this PR's journal or SDK additions. The earlier #3802 proposal is linked there to make the overlap explicit. This PR combines several different decisions, so I am moving it to draft while separating them. Proposed review order:
Would you prefer the journal/delivery portion as an optional feature, or should that remain in the desktop collector? Guidance on that boundary would help avoid asking you to review an architecture you do not want. The current implementation and its tests remain here as a reference; #5817 can be merged independently. |
Usage events lose billing dimensions and can disappear between the in-memory queue and the desktop collector. Several direct, streaming and media paths also bypass accounting, causing undercounting and making explicitly reported zero usage indistinguishable from absent measurements.
This change preserves the accounting evidence needed for per-event valuation and provides replayable delivery:
The change also fixes text-only normalization of translated image tool results while preserving multimodal behavior.
Validation
Regression tests were verified failing before the corresponding fixes and passing afterward, including source/protocol attribution, zero/unknown usage, billing-only streams, journal replay and privacy, mixed-subscriber overflow, video polling identity, and WebSocket image/terminal usage. Independent streaming-parser checks cover JSON grammar, reads split at every byte, exact large integers, duplicate keys, malformed/truncated input, reader errors and bounded allocation for large skipped values.
go test ./...passes.go build -o test-output ./cmd/server && rm test-outputpasses.Delivery and limits
The journal is a single-consumer local spool; unacknowledged files do not expire. Old collectors do not ACK it, so disk usage must be monitored until upgraded. Storage failures are surfaced, and neither unwritable storage nor usage never reported upstream can be reconstructed. Opaque WebRTC and arbitrary plugin traffic are not claimed to be fully measured. Realtime projection retains at most 256 KiB of accounting metadata with a nesting limit of 256; full text/audio content is skipped without a frame-size accounting cutoff. See
docs/usage-accounting.mdfor the source matrix and contract.Companion desktop PR #253 consumes this contract and implements per-event valuation, replay deduplication, provider-specific prices and explicit unknown-cost coverage. The desktop release must pin a core release containing this change.