Adding a deviation
A deviation is a named, declared way a backend departs from the schema it
claims, such as state_text for a backend that refuses any state but a
string. Add one only for a real non-conformance you have tested against the
backend.
- Write the rewriter in
src/semantic-router/pkg/systemonecodec: a stateless type withID(lower snake case),AppliesTo(the schemas it applies to),RewriteRequest, which edits a planned call and returns what it changed as diagnostics, andRewriteReply. Deviations run after the codec's plan, in the order a deployment lists them. - Register it in
Builtin(); the registry refuses a deviation that applies to no registered schema, and configuration refuses one that does not apply to the deployment's schema. - Test it on its own: the rewritten request byte for byte, a call it leaves alone, and, where it changes what a model reads, the families that read the rewritten form the same.
- Document it with a row in the deviations table of System One schemas: the schema, what it does and which backends need it.