Refactor out-of-band AI code#704
Open
shaneutt wants to merge 5 commits into
Open
Conversation
Token usage metadata is an AI inference concern, not a general-purpose filter infrastructure concern. Move set_token_usage() from the shared HttpFilterContext method to a free function in the AI token_usage module behind the AI feature flag. Signed-off-by: Shane Utt <shaneutt@linux.com>
Remove the AI-specific response_stores field from HttpFilterContext. The ResponseStoreRegistry is now injected via the general-purpose RequestExtensions type-map, preventing domain-specific fields from accumulating on the shared context struct. Signed-off-by: Shane Utt <shaneutt@linux.com>
The protocol crate's only use of this feature is plumbing the ResponseStoreRegistry into filter context. The name should reflect what the crate actually does with it, not the domain it serves. Signed-off-by: Shane Utt <shaneutt@linux.com>
Replace flat AI-specific re-exports at the filter crate root with a gated `pub mod ai` namespace. This contains growth as more AI providers are added, preventing unbounded expansion of provider-named types at the crate root. Signed-off-by: Shane Utt <shaneutt@linux.com>
Signed-off-by: Shane Utt <shaneutt@linux.com>
4ab3b23 to
f0d7307
Compare
franciscojavierarceo
approved these changes
Jun 23, 2026
leseb
requested changes
Jun 24, 2026
leseb
left a comment
Collaborator
There was a problem hiding this comment.
should the ci have a test for --no-default-features?
Comment on lines
66
to
+78
| @@ -75,7 +75,7 @@ serde = { version = "1.0.228", features = ["derive", "rc"] } | |||
| serde_json = "1.0.150" | |||
| rcgen = "0.14.8" | |||
| regex = "1.12.4" | |||
| rustls = "0.23.40" | |||
| rustls = "0.23.41" | |||
Collaborator
There was a problem hiding this comment.
unrelated to the main changes?
| }; | ||
| #[cfg(feature = "ai-inference")] | ||
| if let Some(stores) = $pipeline.response_stores() { | ||
| fctx.extensions.insert(stores.clone()); |
Collaborator
There was a problem hiding this comment.
happy to see extensions being used here :)
| ($ctx:expr, $pipeline:expr, $request:expr, $response_header:expr) => { | ||
| praxis_filter::HttpFilterContext { | ||
| ($ctx:expr, $pipeline:expr, $request:expr, $response_header:expr) => {{ | ||
| let mut fctx = praxis_filter::HttpFilterContext { |
Collaborator
There was a problem hiding this comment.
the mutation only exists under response-store so cargo clippy -p praxis-proxy-protocol --no-default-features --all-targets -- -D warnings fails. it seems that the codebase documents --no-default-features as supported for the praxis binary so we should fix that:
cargo clippy -p praxis-proxy-protocol --no-default-features --all-targets -- -D warnings
Checking nix v0.31.3
Checking praxis-proxy-tls v0.3.1 (/Users/leseb/conductor/workspaces/praxis/dhaka-v1/tls)
Checking quixotic-plecostomus-core v0.8.2
Checking quixotic-plecostomus-cache v0.8.2
Checking praxis-proxy-core v0.3.1 (/Users/leseb/conductor/workspaces/praxis/dhaka-v1/core)
Checking quixotic-plecostomus-proxy v0.8.2
Checking praxis-proxy-filter v0.3.1 (/Users/leseb/conductor/workspaces/praxis/dhaka-v1/filter)
Checking praxis-proxy-protocol v0.3.1 (/Users/leseb/conductor/workspaces/praxis/dhaka-v1/protocol)
error: variable does not need to be mutable
--> protocol/src/http/pingora/context.rs:227:13
|
227 | let mut fctx = praxis_filter::HttpFilterContext {
| ----^^^^
| |
| help: remove this `mut`
...
296 | filter_context!(self, pipeline, request, response_header)
| --------------------------------------------------------- in this macro invocation
|
= note: `-D unused-mut` implied by `-D warnings`
= help: to override `-D warnings` add `#[allow(unused_mut)]`
= note: this error originates in the macro `filter_context` (in Nightly builds, run with -Z macro-backtrace for more info)
error: variable does not need to be mutable
--> protocol/src/http/pingora/context.rs:227:13
|
227 | let mut fctx = praxis_filter::HttpFilterContext {
| ----^^^^
| |
| help: remove this `mut`
...
331 | Some(filter_context!(self, pipeline, request, response_header))
| --------------------------------------------------------- in this macro invocation
|
= note: this error originates in the macro `filter_context` (in Nightly builds, run with -Z macro-backtrace for more info)
error: could not compile `praxis-proxy-protocol` (lib) due to 2 previous errors
warning: build failed, waiting for other jobs to finish...
error: could not compile `praxis-proxy-protocol` (lib test) due to 2 previous errors
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
There were a few general-purpose where AI-specific functionality was starting to bleed in, this PR refactors that to reduce boundary blur.