$ fssg build --deterministic --validate |

Why AI Provider Adapters Must Not Repair Semantics

FACET

An AI provider adapter should be boring.

It should receive a compiled contract, translate that contract into one provider's wire format, and stop. It should not infer a missing field, rename a tool, merge messages, invent a default, retry a rejected request, or “help” the upstream system satisfy an undocumented API rule.

This sounds restrictive because adapters are usually where integration teams put compatibility fixes. In an ordinary SDK, that can be convenient. In a contract-driven AI system, it is dangerous. The moment an adapter repairs meaning, the provider payload stops being a rendering of the compiled program. It becomes a second, hidden program.

FACET makes this boundary explicit: Canonical JSON is the source of truth; provider adapters are behaviorally passive mappings. I think this is one of the least glamorous and most important parts of the architecture.

Translation and interpretation are different operations

Consider a compiled tool declaration:

{
  "name": "read_repository_file",
  "arguments": {
    "path": "src/runtime.rs"
  },
  "policy_hash": "…"
}

A translator can map field names and nesting into a provider's documented request schema. The declared tool remains one tool. The message remains one message. Explicit nulls remain explicit. The operation can be tested as a pure function:

provider_payload = adapter(canonical_json)

An interpreter does more. It may shorten the tool name because a provider rejects it, drop an optional field, inject a system message, split a call into two turns, or select a fallback model. Each change may look locally reasonable. Collectively, they move decisions across the compilation boundary.

That creates two authorities:

  1. the compiler says what should execute;
  2. the adapter quietly decides what can actually execute.

When those authorities diverge, the canonical artifact is no longer sufficient to explain the request.

The semantic-delta test

I use a simple review question for adapter code:

Can this branch change the meaning, authority, order, or identity of the compiled request?

If the answer is yes, the branch does not belong in the adapter.

A useful classification looks like this:

Adapter behavior Mapping or decision? Correct location
Rename a JSON field required by the provider schema Mapping Adapter
Rename a declared tool to satisfy a provider constraint Decision Compiler target profile
Serialize a canonical enum into the provider's documented spelling Mapping Adapter
Add a default timeout that was absent from the contract Decision Contract/compiler
Return a typed error for an unsupported field Failure boundary Adapter
Drop the unsupported field and continue Semantic repair Reject
Convert one canonical message into one provider message Mapping Adapter
Merge adjacent messages because the API prefers it Decision Compiler target profile

The distinction is not based on how many lines of code a change requires. A one-line omission can alter policy or replay identity. A long serializer can remain semantically passive.

Move provider constraints upstream

Provider differences are real. Tool-name rules, message ordering, streaming behavior, schema subsets, and content-part formats do not disappear because the architecture prefers purity.

The answer is not to discover those differences late. The answer is to make provider targeting an explicit compilation input.

.facet source
  + target: provider_x
  + profile: strict_tools_v3
        ↓
resolution and type checking
        ↓
provider constraints validated upstream
        ↓
Canonical JSON
        ↓
pure adapter mapping

This gives incompatibility a stable place and time. If a declared tool name cannot be represented for a selected target, compilation can fail before inference. If a provider cannot preserve a message boundary required by the contract, the target profile can reject the program. The adapter does not improvise after every earlier gate has passed.

This extends the argument in Canonical JSON as an AI intermediate representation: an intermediate representation is useful only if downstream lowering cannot silently rewrite its semantics. It also complements FACET Policy as Executable Authorization. An adapter that can add or reshape a tool call sits below authorization while retaining the power to evade its exact decision.

Failure is part of the interface

A passive adapter needs a strong error contract. When a provider rejects a payload or changes undocumented behavior, the adapter should return a typed failure without mutating Canonical JSON, poisoning caches, or rewriting conversation history.

That preserves three separate facts:

compiled contract: valid
adapter mapping: produced payload P
provider response: rejected P with error E

A self-healing adapter tends to collapse them:

provider rejected P
adapter changed P into P2
request eventually succeeded

Success hides the most useful diagnostic fact: the selected target profile and the provider's actual behavior no longer agree. The repair converts a compatibility defect into invisible configuration drift.

Failing loudly is not a refusal to handle change. It is a demand to handle change at the correct layer: update the target profile, compiler rule, contract version, or adapter version; then produce a new canonical decision and test it.

Golden tests protect the boundary

FACET's adapter requirements call for exact golden tests: Canonical JSON in, provider payload out. The architecture also requires deterministic mapping, version declarations, and forward incompatibility by default.

The valuable property of a golden test is not merely snapshot convenience. It fixes the adapter's permitted semantic surface. A review can ask:

  • Did the same canonical input produce byte-identical output?
  • Did one canonical tool remain one provider tool?
  • Were explicit fields preserved rather than inferred away?
  • Did unsupported input fail deterministically?
  • Does the adapter declare which canonical version it understands?

Negative fixtures matter as much as successful snapshots. An adapter proves passivity partly by demonstrating what it refuses to repair.

What this mechanism does not guarantee

This boundary does not make model inference deterministic. It does not prove that every provider implements its documented API consistently. It does not remove the need for integration tests against real endpoints.

It guarantees something narrower: provider-specific translation cannot legitimately become an unrecorded decision layer. The FACET specification defines the rule, and the current repositories provide the architecture and requirements; this article does not claim independent adoption, comparative performance, or production superiority.

That limitation is healthy. Formal boundaries should state exactly what they contain.

The adapter should have no opinions

AI infrastructure accumulates accidental intelligence in the worst places: serializer hooks, middleware, retry handlers, SDK wrappers, and provider adapters. Each helper begins as a patch for one integration. Soon the system cannot answer a basic question: which artifact actually describes what we sent?

My answer is uncompromising. Compile decisions upstream. Preserve one canonical artifact. Make vendor constraints explicit. Let the adapter translate and fail.

The compiler may have opinions. The policy guard must have opinions. The provider will certainly have opinions.

The adapter should have none.

Sources

FACET AI CLI Terminal
facet@ai:~$