Help us shape the future of Go! Take the 2026 Go Developer Survey

conformance

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 11, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package conformance is the provider adapter contract as an executable table. Every first-party adapter (weft/openai, weft/anthropic, weft/google) runs Run in its own tests: offline against recorded fixtures and live behind the `live` build tag. When Run is green for an adapter, the adapter honours the contract — the suite *is* the documented adapter contract (ADR 0013).

The package lives in the root module and imports no vendor SDK: it drives the model through weft's public API only, so it can also run against wefttest models (proving the harness itself).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FixtureServer

func FixtureServer(t *testing.T, file string) *httptest.Server

FixtureServer serves the recorded responses in file, in order, one per HTTP request — the offline backbone of an adapter's conformance run. The file holds one or more responses separated by a line of the form

=== response 2 ===

(everything before the first separator is response 1). Bodies are served verbatim as text/event-stream, the wire format of every first-party adapter's streaming endpoint. A request beyond the last recorded response fails with 500 and a message naming the file, so an under-recorded script is loud, never silently green.

func NoRequestServer

func NoRequestServer(t *testing.T) *httptest.Server

NoRequestServer fails the test if any request reaches it — the backbone of the kill_switch case, which promises that a denied call makes no request at all, not merely that it returns the sentinel.

func Run

func Run(t *testing.T, caps Caps, newModel func(t *testing.T, name string) weft.Model)

Run executes every conformance case as a subtest named after its fixture key. newModel is called once per case (cases share no state) and receives the case name so it can pick its fixture recording or apply case-specific construction — max_tokens, notably, must build the adapter with its token-limit option.

func StallServer

func StallServer(t *testing.T, firstChunk string) *httptest.Server

StallServer writes firstChunk (one complete SSE event, flushed), then holds the response open until the request context ends — a stream that starts but never finishes, for the cancel_mid_stream and idle_timeout cases. The chunk bytes are vendor-specific; the behaviour is not.

Types

type Caps

type Caps struct {
	// Reasoning: the adapter emits ModelReasoningDelta and accepts a
	// ReasoningPart (with signature) back.
	Reasoning bool
	// Files: the adapter accepts a FilePart image input.
	Files bool
	// Sequential: the adapter forwards SequentialTools and the provider
	// honours the hint (emits at most one call per step).
	Sequential bool
	// Usage: the provider reports non-zero token usage. False for
	// compatible servers that never send usage — the adapter must not
	// fake numbers, so the caller declares the gap instead.
	Usage bool
	// Live: the model is reached over the network. The suite relaxes
	// determinism (a live model may make a different but valid choice;
	// those cases t.Skip rather than fail) and skips fixture-only cases
	// (idle_timeout).
	Live bool
}

Caps declares what the adapter under test supports, so the suite asserts the right behaviour instead of skipping silently.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL