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

faultfixture

package
v0.39.1 Latest Latest
Warning

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

Go to latest
Published: Oct 26, 2026 License: MIT Imports: 22 Imported by: 0

Documentation

Overview

Package faultfixture validates fault response source before normalization. It does not enable public sequence execution or provide runtime evidence.

Index

Constants

Variables

View Source
var ErrUnmatched = errors.New("configured fault has no matching response; arguments omitted")

Functions

func NativeReference

func NativeReference(manifest *models.EvidenceManifest, origin models.EvidenceOrigin, artifact string, ordinal int, content []byte, requireComplete, requireUnredacted bool) (models.EvidenceReference, error)

NativeReference verifies an actual captured array ordinal. The native caller must supply its own association; this helper never joins by name or matcher. Successful verification is not a grader, enforcement or integration verdict.

func ValidateCommandResponse

func ValidateCommandResponse(data []byte, format Format, enclosingVersion string) error

ValidateCommandResponse checks a CLI matcher and any finite source sequence. Sequence eligibility requires the explicit enclosing scenario version.

func ValidateMCPResponse

func ValidateMCPResponse(data []byte, format Format, enclosingVersion string) error

ValidateMCPResponse checks an MCP matcher and any finite source sequence. Callers must run this before serialization can erase zero/null field presence.

Types

type CommandAdapter

type CommandAdapter struct {
	// contains filtered or unexported fields
}

CommandAdapter owns an immutable, task-private command response configuration.

func NewCommandAdapter

func NewCommandAdapter(envelope Envelope, root, workspace string) (*CommandAdapter, error)

NewCommandAdapter builds every matcher and output before binding any state. Referenced fixtures must already be present in the private envelope. An empty workspace inherits the envelope's workspace when one is configured.

func (*CommandAdapter) Configuration

func (adapter *CommandAdapter) Configuration() ([]byte, error)

Configuration returns a fresh private JSON envelope for subprocess recompilation.

func (*CommandAdapter) Invoke

func (adapter *CommandAdapter) Invoke(ctx context.Context, args []string, cwd string, observer Observer, deliver func(CommandOutput) error) error

Invoke selects the first matching response, even when its sequence is exhausted. Undelivered responses never call deliver, and reservation is irreversible. The synchronous delivery callback must implement cancellation of native I/O.

type CommandOutput

type CommandOutput struct {
	Stdout   []byte
	Stderr   string
	ExitCode int
}

CommandOutput is delivered only after a configured response is ready.

type Envelope

type Envelope struct {
	Eval      []byte            `json:"eval"`
	Kind      string            `json:"kind"`
	Name      string            `json:"name"`
	Tool      string            `json:"tool,omitempty"`
	Workspace string            `json:"workspace,omitempty"`
	Responses []Fragment        `json:"responses"`
	Fixtures  map[string][]byte `json:"fixtures,omitempty"`
}

Envelope is private adapter configuration, not a public eval or evidence schema. Eval is used only for canonical scenario eligibility, not whole-eval validation.

func DecodeEnvelope

func DecodeEnvelope(data []byte) (Envelope, error)

func MaterializeCommandEnvelope

func MaterializeCommandEnvelope(envelope Envelope, baseDir string) (Envelope, error)

MaterializeCommandEnvelope validates all sources before capturing declared fixture bytes once. Recompilation can then run without reading mutable files.

type Format

type Format = models.FaultSourceFormat

type Fragment

type Fragment struct {
	Format Format `json:"format"`
	Data   []byte `json:"data"`
}

Fragment retains source presence and scalar types across private subprocesses.

type MCPAdapter

type MCPAdapter struct {
	// contains filtered or unexported fields
}

MCPAdapter is unregistered private dispatch for one server/tool owner.

func NewMCPAdapter

func NewMCPAdapter(envelope Envelope, root string) (*MCPAdapter, error)

func (*MCPAdapter) Configuration

func (adapter *MCPAdapter) Configuration() ([]byte, error)

func (*MCPAdapter) Invoke

func (adapter *MCPAdapter) Invoke(ctx context.Context, request *jsonrpc.Request, observer Observer, deliver func(*jsonrpc.Response) error) error

Invoke delivers configured fixture errors as payloads. Operational failures never become success-shaped tool results or trigger another matcher. The synchronous delivery callback must implement cancellation of native I/O.

func (*MCPAdapter) Prepare

func (adapter *MCPAdapter) Prepare(ctx context.Context, request *jsonrpc.Request, observer Observer) (*PendingMCPCall, error)

Prepare validates and reserves synchronously so a native admission reader can allocate in request order before running cancellable delivery concurrently. Observer callbacks must be prompt or cooperate with the caller's cancellation.

type Observer

type Observer func(matcher, step int, transition Transition) error

Observer closures bind only identities actually available at the native call site. The adapter never invents identities or associates SDK and MCP IDs. A step of -1 means no finite allocation; callbacks receive no argument payloads. Callbacks are synchronous; the native caller owns cancellation of callback I/O.

type PendingMCPCall

type PendingMCPCall struct {
	// contains filtered or unexported fields
}

PendingMCPCall owns an irreversible allocation admitted by Prepare. Deliver may run once; copying a pointer does not permit another delivery.

func (*PendingMCPCall) Deliver

func (pending *PendingMCPCall) Deliver(ctx context.Context, deliver func(*jsonrpc.Response) error) error

Deliver delays and emits once. Native I/O cancellation remains the caller's responsibility; successful emission cannot be undone by later cancellation.

type Transition

type Transition string
const (
	Reserved  Transition = "reserved"
	Delivered Transition = "delivered"
	Canceled  Transition = "canceled"
	Failed    Transition = "failed"
)

Jump to

Keyboard shortcuts

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