prototest

package
v0.0.7 Latest Latest
Warning

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

Go to latest
Published: Oct 3, 2026 License: MIT Imports: 7 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package prototest provides explicit capability fixtures and the shared wire scenarios for Core–Runtime contract tests.

Index

Constants

View Source
const (
	DeviceID    = "runtime"
	Credential  = "synthetic-contract-credential"
	HarnessKind = "contract"
)

Handshake values. The Runtime dials with DeviceID and Credential; Core accepts that credential for DeviceID.

View Source
const (
	SessionID        = "session"
	StateKey         = "agents-api-session"
	PreparationID    = "prepare"
	RunID            = "run"
	CancelDeliveryID = "cancel"
)

Correlation values the scenarios use.

View Source
const (
	ExecutorID       = "executor"
	Handle           = "handle"
	ExpiresAt  int64 = 1_800_000_000_000
)

Placeholders for values the Runtime generates. Core's side sends them as written; the Runtime's side binds each to the value its Runtime sends.

View Source
const (
	IncompatibleVersionStatus = http.StatusUpgradeRequired
	IncompatibleVersionCode   = "incompatible_version"
)

Core rejects any other protocol version at the upgrade with this status and error code, before any dispatch.

View Source
const SilenceWindow = 50 * time.Millisecond

SilenceWindow is how long a Silence or Settle step waits for an unexpected frame.

Variables

This section is empty.

Functions

func CancellationOutcome

func CancellationOutcome() proto.DonePayload

CancellationOutcome is the continuity snapshot a cancelled Turn reports.

func Capabilities

Capabilities declares the current contract, then applies explicit overrides. List fields individually: a future field must remain unspecified until this fixture is deliberately updated, so declaration validation fails on omission.

func IncompatibleVersions

func IncompatibleVersions() []string

IncompatibleVersions are Runtime protocol versions Core rejects.

func SameFrame

func SameFrame(want, got proto.Envelope) error

SameFrame checks that got carries want's type, correlation ID and payload. Trace is diagnostic correlation and is not part of a scenario.

Types

type Action

type Action int

Action is what happens at one scenario step.

const (
	// Send: From sends Frame, and the other side receives it next.
	Send Action = iota
	// Silence: From sends nothing for SilenceWindow.
	Silence
	// Settle: the Runtime's native work settles. The Runtime sends nothing
	// before that, so no receipt precedes native settlement.
	Settle
	// Disconnect: the Runtime loses the connection while work runs. The Runtime
	// settles its native work and cleanup; Core observes no execution outcome.
	Disconnect
	// Reconnect: the Runtime connects again with the same device identity.
	Reconnect
)

type Bindings

type Bindings map[string]any

Bindings maps each placeholder to the value the Runtime under test sent for it.

func (Bindings) Match

func (b Bindings) Match(want, got proto.Envelope) error

Match checks that got is want's frame. A Runtime-assigned field binds its placeholder to the first non-empty value the Runtime sends; later frames must repeat that value.

func (Bindings) Resolve

func (b Bindings) Resolve(frame proto.Envelope) (proto.Envelope, error)

Resolve replaces bound placeholders in a Core frame with the Runtime's values.

type Peer

type Peer string

Peer is one side of the connection.

const (
	Core    Peer = "Core"
	Runtime Peer = "Runtime"
)

type Step

type Step struct {
	Action Action
	From   Peer
	Frame  proto.Envelope
}

Step is one scenario step. From and Frame apply to Send; From applies to Silence.

type WireScenario

type WireScenario struct {
	Name string
	// NativeSetupFails makes the Runtime's native Executor setup fail.
	NativeSetupFails bool
	Steps            []Step
}

WireScenario is one ordered exchange.

func WireScenarios

func WireScenarios() []WireScenario

WireScenarios returns every shared exchange.

Jump to

Keyboard shortcuts

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