Repository navigation
refactor(trace): reuse the canonical usage counter type - #140444
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs maintainer review before merge. Reviewed September 6, 2026, 5:14 PM ET / 21:14 UTC. ClawSweeper reviewWhat this changesReuses OpenClaw’s canonical token-counter type across seven raw-trace declarations while preserving their five optional numeric fields. Merge readiness✅ Ready for maintainer review Useful, behavior-preserving cleanup with no actionable correctness findings. The repeated declarations remain on pinned main and in the latest release; the maintainer-owned PR should remain open for normal landing. Priority: P3 Review scores
Verification
How this fits togetherRaw-trace reporting combines agent results and transcript usage into diagnostic reply text. Its caller controls whether an authorized sender receives those diagnostics. flowchart LR
A[Agent result counters] --> D[Raw trace formatter]
B[Transcript usage] --> D
C[Canonical counter type] --> D
E[Authorized raw trace request] --> D
D --> F[Diagnostic reply text]
Before mergeNone. Agent review detailsSecurityNone. PR surfaceSource -46. Total -46 across 1 file. View PR surface stats
Review metricsNone. Technical reviewBest possible solution: Keep the trace-specific view private and derive its existing counter fields from the accounting owner without changing runtime objects. Do we have a high-confidence way to reproduce the issue? Not applicable: this PR removes repeated type declarations rather than fixing a reported runtime defect. Is this the best way to solve the issue? Yes. The private five-key Pick preserves the existing structural contract while reusing the established accounting type. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 98adc95c79d4. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (1 earlier review cycle)
|
a8e87ef to
db86fe1
Compare
|
Merged via squash.
|
* commit '294df333c58f2da104eccffc623ccb3c4d43d4d8': (1802 commits) fix: clear stale diagnostics after Gateway changes (#140426) fix: keep plugin catalogs intact after discovery timeouts (#140441) perf(tui): prepare session picker rows once per overlay (#140462) refactor(config): reuse environment substitution for write-back (#140460) refactor(discord): remove retired auto-presence templates (#140463) fix(ui): finish roster refreshes during session activity (#140459) fix(setup): match prepared credentials to the model provider (#140461) fix: keep MiniMax discovery on the selected credential (#140438) refactor(tests): remove unused parent context cache reset (#140456) fix: avoid repeated xAI OAuth refresh during discovery (#140434) perf(routing): reuse prepared event session targets (#140454) fix(media): keep deferred audio and extraction providers discoverable (#139231) refactor(codex): remove redundant app-server forwarding (#140451) fix(test): avoid false native polling timeouts (#140119) test(gateway): retain saved source in reload fixtures (#140453) fix(gateway): reduce repeated model work when listing sessions (#140414) fix(feishu): fall back to post mode over table limit (#136382) fix: use the bundle-compatible Proxyline runtime under Bun (#140411) refactor(trace): reuse the canonical usage counter type (#140444) refactor(node-host): share execution policy result fields (#140446) ...
What Problem This Solves
Raw trace reporting repeats the same five optional token counters in seven type declarations. Those copies can drift from the runtime accounting owner.
This is a cleanup contribution to the #135868 split campaign, independent of its feature stages.
Why This Change Was Made
Use a private five-key Pick of the existing NormalizedUsage type for all seven declarations. The selected properties have exactly the same names, optionality and numeric types. The type import shares an existing module import, and no executable code changes.
The full accounting type also contains context, reasoning and cost fields; those do not become new declared trace fields. Original usage objects still pass through unchanged, preserving context accounting, formatting, authorization and supported transcript artifact reads. This removes duplicated declarations rather than retiring a shipped contract.
User Impact
No user-visible behavior change. Raw trace output and its authorization rules remain unchanged.
Evidence
Judged production: one file, 599 → 553 lines; +13/−59 = −46. Tests, tooling, docs and baselines are unchanged.