Repository navigation
feat(proxy): make the wire format a trait, not a closed enum - #106
Merged
Merged
Conversation
Provider was an enum with three variants, so a company running an in-house
gateway with its own request and response shape had to fork pasu-proxy to be
guarded at all. Everything else in this repository is replaceable behind a
trait; the one thing that decides whether pasu can sit in front of your traffic
was not.
WireFormat is that trait. Provider still exists and still ships the three
formats, but it is now one implementation rather than the definition of what a
format can be, and the proxy holds an Arc<dyn WireFormat> — it runs a format
instead of knowing which ones exist.
visit_prompt covers reading and rewriting in one method deliberately. Two that
decided separately which fields hold prose would drift, and the day they did, a
scanner would be reading a field the redactor no longer edits.
The trait existing is not the same as the seam working, so there is a test that
drives a format defined outside parse.rs all the way through — a bare `input`
string for the prompt, `{"invoke": …}` for a tool call, resembling no provider
on purpose. It is written the way an outside adapter has to be written: nothing
from parse.rs reused, no variant added, no edit inside the proxy. Both halves are
covered, because a tool-call-only trait would have silently left request
inspection unable to find the prompt.
No behaviour change for the three built-in formats.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
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.
Providerwas an enum with three variants, so a company running an in-house gateway with its own request and response shape had to fork pasu-proxy to be guarded at all.Everything else in this repository is replaceable behind a trait. The one thing that decides whether pasu can sit in front of your traffic was not.
WireFormatProviderstill exists and still ships the three formats — it is now one implementation rather than the definition of what a format can be.ProxyStateholds anArc<dyn WireFormat>: the proxy runs a format instead of knowing which ones exist.visit_promptcovers reading and rewriting in one method deliberately. Two that decided separately which fields hold prose would drift, and the day they did, a scanner would be reading a field the redactor no longer edits.The seam is tested, not just declared
tests/custom_wire_format.rsdrives a format defined outsideparse.rsall the way through the proxy — a bareinputstring for the prompt,{"invoke": …}for a tool call, resembling no provider on purpose.It is written the way an outside adapter has to be written: nothing from
parse.rsreused, no variant added, no edit inside the proxy. So if the extension point regresses to something only the built-ins can satisfy, this stops compiling.Both halves are covered — a tool-call-only trait would have silently left request inspection unable to find the prompt:
No behaviour change for the three built-in formats.
🤖 Generated with Claude Code