Documentation
¶
Overview ¶
Package agenttestify is the importable library entry for SDK protocol fixture preparation, recording and replay.
Index ¶
- func Export(options ExportOptions) error
- type ActionResult
- type Connection
- type ConnectionReport
- type ConnectionStatus
- type ConnectionTransport
- type EmbeddedIdentity
- type ExecutionReport
- type ExecutionStart
- type ExecutionStatus
- type ExportOptions
- type FailureClass
- type Fixture
- func (f *Fixture) ExecutionReport(executionID string) (*ExecutionReport, error)
- func (f *Fixture) MockAgent(ctx context.Context, options MockAgentOptions, streams Streams) (*MockAgentResult, error)
- func (f *Fixture) RecordAgent(ctx context.Context, options RecordAgentOptions, streams Streams) (*RecordAgentResult, error)
- func (f *Fixture) StartMockAgent(ctx context.Context, options MockAgentOptions, streams StartMockAgentStreams) (*MockRun, error)
- type Limits
- type Material
- type MockAgentOptions
- type MockAgentResult
- type MockRun
- type MockTransport
- type PrepareOptions
- type RecordAgentOptions
- type RecordAgentResult
- type Route
- type Source
- type StartMockAgentStreams
- type Streams
- type ToolIdentity
- type ToolSource
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Export ¶
func Export(options ExportOptions) error
Export copies the current material package without changing the fixture.
Types ¶
type ActionResult ¶
type ActionResult struct {
FixtureID string
ExecutionID string
ConnectionID string
ConnectionStatus ConnectionStatus
ExecutionStatus ExecutionStatus
ExecutionComplete bool
Material *Material
ExecutionPath string
ReceiptPath string
ProcessReceiptPath string
ResultPath string
}
ActionResult contains the durable execution and connection evidence shared by record and mock calls. ConnectionStatus describes this call only; ExecutionStatus and ExecutionComplete describe every declared connection.
type Connection ¶
type Connection struct {
ID string
Transport ConnectionTransport
Command string
Args []string
Launcher string
}
Connection describes one route connection template.
type ConnectionReport ¶
type ConnectionReport struct {
ID string
Status ConnectionStatus
Transport MockTransport
FullConsumption bool
ClientEOF bool
NativeLaunched bool
CleanupComplete bool
ExitCode *int
Failure FailureClass
Error string
ReceiptPath string
ProcessReceiptPath string
ResultPath string
}
ConnectionReport contains one connection's durable protocol evidence.
type ConnectionStatus ¶
type ConnectionStatus string
ConnectionStatus is the durable result of one connection in an action execution.
const ( ConnectionStatusUnknown ConnectionStatus = ConnectionStatus(lifecycle.ConnectionStatusUnknown) ConnectionStatusPending ConnectionStatus = ConnectionStatus(lifecycle.ConnectionStatusPending) ConnectionStatusRunning ConnectionStatus = ConnectionStatus(lifecycle.ConnectionStatusRunning) ConnectionStatusPassed ConnectionStatus = ConnectionStatus(lifecycle.ConnectionStatusPassed) ConnectionStatusFailed ConnectionStatus = ConnectionStatus(lifecycle.ConnectionStatusFailed) )
type ConnectionTransport ¶
type ConnectionTransport string
ConnectionTransport distinguishes a launchable process connection from an in-process connection with no executable identity.
const ( ConnectionTransportProcess ConnectionTransport = lifecycle.ConnectionTransportProcess ConnectionTransportInProcess ConnectionTransport = lifecycle.ConnectionTransportInProcess )
type EmbeddedIdentity ¶
type EmbeddedIdentity struct {
Version string
Sum string
Revision string
Time string
GoVersion string
}
EmbeddedIdentity is the exact imported module identity of agent-sdk-testify.
type ExecutionReport ¶
type ExecutionReport struct {
FixtureID string
ExecutionID string
Status ExecutionStatus
Complete bool
Material Material
ExecutionSHA256 string
ExecutionPath string
Connections []ConnectionReport
}
ExecutionReport is the validated report for every connection in an execution.
type ExecutionStart ¶
type ExecutionStart struct {
FixtureID string
ExecutionID string
ConnectionID string
Material Material
ExecutionSHA256 string
ExecutionPath string
Workspace string
ProtocolCwd string
Home string
Config string
Tmp string
HistoryFiles map[string]string
Env map[string]string
NativeArgs []string
Transport MockTransport
}
ExecutionStart is the immutable overlay snapshot available before protocol I/O.
type ExecutionStatus ¶
type ExecutionStatus string
ExecutionStatus is the durable result of all declared connections in one action execution.
const ( ExecutionStatusUnknown ExecutionStatus = ExecutionStatus(lifecycle.ExecutionStatusUnknown) ExecutionStatusRunning ExecutionStatus = ExecutionStatus(lifecycle.ExecutionStatusRunning) ExecutionStatusOpen ExecutionStatus = ExecutionStatus(lifecycle.ExecutionStatusOpen) ExecutionStatusPassed ExecutionStatus = ExecutionStatus(lifecycle.ExecutionStatusPassed) ExecutionStatusFailed ExecutionStatus = ExecutionStatus(lifecycle.ExecutionStatusFailed) )
type ExportOptions ¶
ExportOptions names the fixture and a new directory outside it.
type FailureClass ¶
type FailureClass string
FailureClass is the machine-readable terminal reason for a mock run.
const ( FailureClassCanceled FailureClass = FailureClass(lifecycle.FailureClassCanceled) FailureClassAborted FailureClass = FailureClass(lifecycle.FailureClassAborted) FailureClassTransport FailureClass = FailureClass(lifecycle.FailureClassTransport) FailureClassStrictReplay FailureClass = FailureClass(lifecycle.FailureClassStrictReplay) FailureClassTimeout FailureClass = FailureClass(lifecycle.FailureClassTimeout) FailureClassCleanup FailureClass = FailureClass(lifecycle.FailureClassCleanup) FailureClassInternal FailureClass = FailureClass(lifecycle.FailureClassInternal) )
type Fixture ¶
type Fixture struct {
FixtureDir string
FixtureID string
Tool ToolIdentity
AgentType string
Source Source
HistorySeed string
ResourceRoot string
Workspace string
Home string
Config string
Tmp string
ProtocolCwd string
Env map[string]string
Routes map[string]Route
Limits Limits
Current *Material
}
Fixture is a detached, typed view of a prepared test fixture.
func Prepare ¶
func Prepare(options PrepareOptions) (*Fixture, error)
Prepare creates one fixture using the embedded library tool identity.
func (*Fixture) ExecutionReport ¶
func (f *Fixture) ExecutionReport(executionID string) (*ExecutionReport, error)
ExecutionReport regenerates a validated report for every connection in one mock execution without creating or advancing an execution.
Example ¶
package main
import (
"fmt"
)
func main() {
fmt.Println("report := fixture.ExecutionReport(executionID)")
}
Output: report := fixture.ExecutionReport(executionID)
func (*Fixture) MockAgent ¶
func (f *Fixture) MockAgent(ctx context.Context, options MockAgentOptions, streams Streams) (*MockAgentResult, error)
MockAgent replays the current recording through caller-owned streams.
func (*Fixture) RecordAgent ¶
func (f *Fixture) RecordAgent(ctx context.Context, options RecordAgentOptions, streams Streams) (*RecordAgentResult, error)
RecordAgent captures one native Agent or remote endpoint through caller-owned streams.
func (*Fixture) StartMockAgent ¶
func (f *Fixture) StartMockAgent(ctx context.Context, options MockAgentOptions, streams StartMockAgentStreams) (*MockRun, error)
StartMockAgent claims one in-process mock execution and releases replay only after the start snapshot is ready.
type Limits ¶
type Limits struct {
Timeout time.Duration
ProtocolBytes int64
StderrBytes int64
MaxFrames int64
MaxFrameBytes int64
}
Limits are the protocol and process limits captured by prepare.
type Material ¶
type Material struct {
ID string
Kind string
Action string
Provenance string
Path string
PlanSHA256 string
ManifestSHA256 string
RecordingSHA256 string
Connections []string
CreatedAt string
}
Material identifies a current recording without exposing its wire format.
type MockAgentOptions ¶
type MockAgentOptions struct {
Connection string
ExecutionID string
Timeout time.Duration
NativeArgs []string
}
MockAgentOptions selects one replay connection in a prepared fixture.
type MockAgentResult ¶
type MockAgentResult struct {
ActionResult
Execution *ExecutionReport
}
MockAgentResult identifies the execution and connection completed by a mock call.
type MockRun ¶
type MockRun struct {
Start ExecutionStart
// contains filtered or unexported fields
}
MockRun coordinates one in-process mock connection.
func (*MockRun) Done ¶
func (r *MockRun) Done() <-chan struct{}
Done closes after this connection's replay, receipt and finalization end.
func (*MockRun) FullConsumption ¶
func (r *MockRun) FullConsumption() <-chan struct{}
FullConsumption reports the one-shot safe point for SDK input half-close.
type MockTransport ¶
type MockTransport string
MockTransport distinguishes a process adapter from an in-process mock.
const ( MockTransportInProcess MockTransport = MockTransport(lifecycle.MockTransportInProcess) MockTransportProcess MockTransport = MockTransport(lifecycle.MockTransportProcess) )
type PrepareOptions ¶
type PrepareOptions struct {
FixtureDir string
Agent string
Case string
Plan string
Recording string
Model string
InitialModel string
HistorySeed string
ProtocolBytes int64
StderrBytes int64
MaxFrames int64
MaxFrameBytes int64
// EmbeddedIdentity supplies the exact module identity when a non-main test
// binary omits this module from its build dependencies.
EmbeddedIdentity *EmbeddedIdentity
}
PrepareOptions selects the immutable initial state for a new fixture.
type RecordAgentOptions ¶
type RecordAgentOptions struct {
Connection string
Command string
NativeArgs []string
URL string
TokenFile string
Timeout time.Duration
ConnectTimeout time.Duration
}
RecordAgentOptions selects one capture connection and its native or remote target.
type RecordAgentResult ¶
type RecordAgentResult struct {
ActionResult
}
RecordAgentResult identifies the execution and connection completed by a record call and, on success, the newly selected material.
type Route ¶
type Route struct {
Enabled bool
Executor string
Target string
Provenance string
Workspace string
ProtocolCwd string
Env map[string]string
RuntimeEnv []string
Connections []Connection
}
Route describes one action's isolated host environment.
type Source ¶
type Source struct {
Kind string
ID string
Path string
SHA256 string
Provenance string
DriverProfile string
}
Source identifies the initial case, plan or recording.
type StartMockAgentStreams ¶
type StartMockAgentStreams struct {
Reader io.ReadCloser
Writer io.WriteCloser
Stderr io.Writer
}
StartMockAgentStreams are closeable directional streams transferred to one in-process mock run.
type ToolIdentity ¶
type ToolIdentity struct {
Source ToolSource
Version string
Command string
Args []string
SHA256 string
Module string
ModuleSum string
ModuleRevision string
ModuleTime string
GoVersion string
}
ToolIdentity describes the code that prepared a fixture.
type ToolSource ¶
type ToolSource string
ToolSource identifies how the library or CLI entered the prepared fixture.
const ( ToolSourceExecutable ToolSource = ToolSource(lifecycle.ToolSourceExecutable) ToolSourceEmbedded ToolSource = ToolSource(lifecycle.ToolSourceEmbedded) )
Directories
¶
| Path | Synopsis |
|---|---|
|
cmd
|
|
|
agent-sdk-testify
command
Command agent-sdk-testify owns environments and process orchestration, never SDK assertions.
|
Command agent-sdk-testify owns environments and process orchestration, never SDK assertions. |
|
Package data owns the tracked catalog and material snapshots embedded in the installed binary.
|
Package data owns the tracked catalog and material snapshots embedded in the installed binary. |
|
internal
|
|
|
application
Package application is the single use-case boundary shared by the CLI and importable library adapters.
|
Package application is the single use-case boundary shared by the CLI and importable library adapters. |
|
builtin
Package builtin reads the generated material snapshot embedded in the installed binary.
|
Package builtin reads the generated material snapshot embedded in the installed binary. |
|
catalog
Package catalog projects the authoritative story and provider bindings into one run plan.
|
Package catalog projects the authoritative story and provider bindings into one run plan. |
|
command
Package command owns the single Cobra command tree, process I/O and error reporting.
|
Package command owns the single Cobra command tree, process I/O and error reporting. |
|
lifecycle
Package lifecycle owns fixture identity, environment routes, execution descriptors and finalization.
|
Package lifecycle owns fixture identity, environment routes, execution descriptors and finalization. |
|
official
Package official owns official SDK driver orchestration and its evidence.
|
Package official owns official SDK driver orchestration and its evidence. |
|
protocol/capture
Package capture records provider-independent stdio JSONL with owned process lifecycle, lossless native JSON, and explicit failure evidence.
|
Package capture records provider-independent stdio JSONL with owned process lifecycle, lossless native JSON, and explicit failure evidence. |
|
protocol/rawjson
Package rawjson validates JSON and edits selected object fields without serializing the surrounding message.
|
Package rawjson validates JSON and edits selected object fields without serializing the surrounding message. |
|
protocol/recording
Package recording owns the versioned envelope, not native protocol semantics.
|
Package recording owns the versioned envelope, not native protocol semantics. |
|
protocol/replay
Package replay implements strict native protocol consumption.
|
Package replay implements strict native protocol consumption. |
|
record
Package record owns native protocol capture in a prepared execution.
|
Package record owns native protocol capture in a prepared execution. |
|
testutil
Package testutil locates the repository root and prepares the installed tool used by process-boundary tests.
|
Package testutil locates the repository root and prepares the installed tool used by process-boundary tests. |
|
tool
Package tool contains shared process, file and JSON primitives used by the three public commands.
|
Package tool contains shared process, file and JSON primitives used by the three public commands. |
|
version
Package version owns the executable identity shared by commands and evidence.
|
Package version owns the executable identity shared by commands and evidence. |