agenttestify

package module
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2026 License: Apache-2.0 Imports: 11 Imported by: 1 module, 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.

README

agent-sdk-testify

Testify 录制原生 Agent 协议,并用录制回放协议,供 SDK 测试使用。仓库维护 Codex 和 Claude 的 case、官方 driver、录制材料与内置快照。消费者用自己的 SDK 执行业务操作和断言。

按任务查文档

任务 文档
从内置 case 回放 准备内置材料
回放已有 recording 导入 recording
录制自己的 SDK 交互 使用 consumer plan 录制并回放
在 Go 测试中回放 Go 库入口
用官方 SDK 录制、验证或采用材料 官方 driver 操作指南
构建工具、运行离线测试或发布 从源码构建与验证

Go 库入口

导入 github.com/zoumo/agent-sdk-testify,用 Fixture.StartMockAgent 在 Go 测试中回放。 准备 fixture、启动、半关闭与收尾顺序见Go 库回放合同。 公开类型和函数见根包源码。

从源码构建

在仓库根目录运行 make build。默认产物是 bin/agent-sdk-testify。开发规范列出依赖、linked worktree 的构建条件、离线命令与发布步骤。构建与验证

用官方 SDK 录制与验证

使用 official record 采集官方 case,用 official verify 回放并检查官方 SDK 的业务断言。官方 driver 环境、命令及采用条件见操作指南。官方 driver 操作指南

参考文档

文档索引列出 docs/ 下的指南与合同。

查阅内容 文档
CLI 职责、fixture、execution 和材料 工具设计
Go 进程内回放与执行报告 Go 库回放合同
SDK case 与验收标准 场景目录、共同验收
录制材料的身份、来源和可用状态 固定索引、内置快照
模块、测试层级和编码规则 开发规范
文档术语 术语表

Documentation

Overview

Package agenttestify is the importable library entry for SDK protocol fixture preparation, recording and replay.

Index

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 {
	MaterialID           string
	PublicationCommitted bool
	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.

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.

type ExportOptions

type ExportOptions struct {
	FixtureDir string
	Output     string
}

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.

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 Open

func Open(fixtureDir string) (*Fixture, error)

Open reads a prepared fixture without changing it.

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 optionally declare reviewed stdio startup arguments and
	// become execution metadata. All connections joining the same execution
	// must use matching declarations.
	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) Abort

func (r *MockRun) Abort() error

Abort cancels the run and closes fixture-side streams. It is idempotent.

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.

func (*MockRun) Wait

func (r *MockRun) Wait(ctx context.Context) (*MockAgentResult, error)

Wait returns the authoritative repeatable terminal result.

type MockTransport

type MockTransport string

MockTransport distinguishes a process adapter from an in-process mock.

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 are passed verbatim to Command for local consumer capture.
	// Testify omits them from generated metadata.
	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 Streams

type Streams struct {
	In  *os.File
	Out *os.File
	Err *os.File
}

Streams are caller-owned process streams used by protocol actions.

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.
testutil/builtintest
Package builtintest reads builtin recordings for installed CLI checks.
Package builtintest reads builtin recordings for installed CLI checks.
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.
tests
e2e/fixturetest
Package fixturetest resolves persisted identities for installed CLI tests.
Package fixturetest resolves persisted identities for installed CLI tests.

Jump to

Keyboard shortcuts

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