Skip to content

refactor(token_usage): move functions to TokenUsageProvider directly#330

Merged
shaneutt merged 1 commit into
praxis-proxy:mainfrom
alexsnaps:token-refactor
Jul 15, 2026
Merged

refactor(token_usage): move functions to TokenUsageProvider directly#330
shaneutt merged 1 commit into
praxis-proxy:mainfrom
alexsnaps:token-refactor

Conversation

@alexsnaps

@alexsnaps alexsnaps commented Jul 10, 2026

Copy link
Copy Markdown
Member

See #284

But, tl;dr, there is no need to have TokenUsageProvider be Clone or Copy (and copy it all over the place). This closes the door to eventually add state seamlessly in the future. Finally, both the methods where methods all along, so made them that, using &self

@alexsnaps
alexsnaps requested review from a team and leseb July 10, 2026 13:57
@praxis-bot-app

Copy link
Copy Markdown

Please add a description to this PR explaining what it does and why. See our coding conventions.

@alexsnaps
alexsnaps force-pushed the token-refactor branch 2 times, most recently from a51f2bf to d902ac9 Compare July 10, 2026 14:01

@praxis-bot praxis-bot left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Review: refactor(token_usage): move functions to TokenUsageProvider directly

Clean mechanical refactoring. Reviewed all four changed files in full plus the unchanged consumer filters/src/token_count/tests.rs to verify no implicit Copy/Clone dependencies were missed.

What was checked

  • Correctness: match *self correctly dereferences &Self for enum pattern matching. All callers updated from free-function syntax to method syntax. The pub(super) visibility on parse_anthropic_event / parse_bedrock_event is the minimum needed for the impl TokenUsageProvider block in the parent module.
  • Caller completeness: Searched all code references to extract_token_usage, extract_streaming_tokens, and TokenUsageProvider across the repo. Every code-level caller is covered by the diff. The only remaining references to the old free functions are in docs/proposals/ design documents (not compiled).
  • Implicit Copy consumers: filters/src/token_count/tests.rs (not in the diff) passes TokenUsageProvider by value into make_filter() and the run_*_extraction helpers. These are moves, not copies, so they compile without Copy. Confirmed by all 17 CI checks passing.
  • API surface: Removing Clone, Copy, and the two public free functions is a breaking change, but appropriate for a 0.1.0 crate where all consumers are workspace-internal.
  • Test coverage: The test changes are purely syntactic (free function calls to method calls). No tests were added or removed, which is correct since no behavior changed.
  • Convention compliance: File ordering, section separators, doc comments, visibility, and import grouping all conform to workspace conventions.

Severity table

Severity Count
Critical 0
Large 0
Medium 0

No findings. The refactoring is correct, complete, and consistent.

@shaneutt
shaneutt merged commit bc35f0d into praxis-proxy:main Jul 15, 2026
17 checks passed
@github-project-automation github-project-automation Bot moved this from Review to Done in AI Gateway - Model Serving Jul 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants