Repository navigation
refactor(gateway): share transcript usage aggregation - #129199
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Codex review: needs maintainer review before merge. Reviewed August 25, 2026, 5:58 AM ET / 09:58 UTC. ClawSweeper reviewWhat this changesThe PR moves JSONL-artifact and SQLite transcript usage aggregation into one Gateway helper while preserving their distinct cost, role, and token-normalization rules. Merge readinessNo blocking defect found in the shared aggregation refactor. This maintainer-authored PR remains useful, but its clean branch is behind current main and should be rebased with focused validation on the resulting head before merge. Priority: P3 Review scores
Verification
Live VerificationCommand: Result: PASS (completed) Assertions:
How this fits togetherGateway transcript readers turn JSONL artifacts and SQLite session rows into usage snapshots for session and transcript views. The shared helper consumes stored messages and produces aggregated token, context, model, and cost fields. flowchart LR
A[JSONL transcript artifact] --> C[Shared usage aggregation]
B[SQLite session rows] --> C
C --> D{Storage-specific rules}
D --> E[Usage snapshot]
E --> F[Gateway session and transcript views]
Before merge
Agent review detailsSecurityNone. PR surfaceSource -188, Tests +17, Other 0. Total -171 across 5 files. View PR surface stats
Review metrics
Stored data modelPersistent data-model change detected: Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Land one canonical aggregation owner after rebasing, while retaining explicit artifact-versus-SQLite behavior at the extraction boundary. Do we have a high-confidence way to reproduce the issue? Not applicable: this PR consolidates existing behavior rather than reporting a separate user-facing failure. Is this the best way to solve the issue? Yes: the helper keeps source-specific semantics explicit rather than forcing JSONL artifacts and SQLite rows through one undifferentiated contract. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 7a5de93228f3. LabelsLabel changes:
Label justifications:
EvidenceWhat 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 (1 earlier review cycle)
|
|
Merged via squash.
|
* refactor(gateway): share transcript usage aggregation * refactor(gateway): preserve transcript usage type ownership
What Problem This Solves
Gateway transcript readers duplicated token-usage aggregation across their JSONL artifact and SQLite-derived paths, increasing maintenance cost and making subtle intentionally different storage semantics difficult to preserve.
Why This Change Was Made
Share one canonical usage aggregation flow while preserving each storage owner's required differences: JSONL's nested nonnegative cost, trimmed API values, positive totals, and role rules; SQLite's direct cost, zero values, and untrimmed fields.
User Impact
No transcript, public artifact, raw trace, schema, protocol, or security behavior changes. Production code decreases by 192 lines; meaningful owner tests increase by 17 lines, and the changed owner's assertion baseline is tightened from 16 to 10.
Evidence