statestore

package
v1.4.1 Latest Latest
Warning

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

Go to latest
Published: Apr 4, 2026 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

ErrNotFound is re-exported from runtime statestore

Functions

This section is empty.

Types

type A2AAgentInfo added in v1.3.1

type A2AAgentInfo struct {
	Name        string         `json:"name"`
	Description string         `json:"description"`
	Skills      []A2ASkillInfo `json:"skills,omitempty"`
}

A2AAgentInfo contains metadata about an A2A agent for report rendering.

type A2ASkillInfo added in v1.3.1

type A2ASkillInfo struct {
	ID          string   `json:"id"`
	Name        string   `json:"name"`
	Description string   `json:"description,omitempty"`
	Tags        []string `json:"tags,omitempty"`
}

A2ASkillInfo contains metadata about a single A2A agent skill.

type ArenaConversationState

type ArenaConversationState struct {
	runtimestore.ConversationState // Embed standard state

	// Arena-specific run metadata
	RunMetadata *RunMetadata `json:"run_metadata,omitempty"`
}

ArenaConversationState extends runtimestore.ConversationState with Arena-specific telemetry All telemetry is computed on-demand from the messages to avoid redundancy

type ArenaStateStore

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

ArenaStateStore is an in-memory state store with Arena-specific telemetry

func NewArenaStateStore

func NewArenaStateStore() *ArenaStateStore

NewArenaStateStore creates a new Arena state store

func (*ArenaStateStore) Clear added in v1.3.25

func (s *ArenaStateStore) Clear()

Clear removes all conversations from the store.

func (*ArenaStateStore) Delete

func (s *ArenaStateStore) Delete(ctx context.Context, conversationID string) error

Delete removes conversation state

func (*ArenaStateStore) DumpToJSON

func (s *ArenaStateStore) DumpToJSON(ctx context.Context, conversationID string) ([]byte, error)

DumpToJSON exports the arena state in the same format as Arena results

func (*ArenaStateStore) Fork added in v1.1.6

func (s *ArenaStateStore) Fork(ctx context.Context, sourceID, newID string) error

Fork creates a copy of the state with a new session ID This is a no-op for the arena state store as forking is handled at the pipeline level NOSONAR: Intentionally empty - forking is handled at the pipeline level

func (*ArenaStateStore) GetArenaState

func (s *ArenaStateStore) GetArenaState(ctx context.Context, conversationID string) (*ArenaConversationState, error)

GetArenaState retrieves the full Arena state including telemetry. Returns a deep copy to prevent callers from mutating internal store data.

func (*ArenaStateStore) GetResult

func (s *ArenaStateStore) GetResult(ctx context.Context, runID string) (*RunResult, error)

GetResult reconstructs a complete RunResult from stored state This replaces the need to return RunResult from executeRun

func (*ArenaStateStore) ListRunIDs

func (s *ArenaStateStore) ListRunIDs(ctx context.Context) ([]string, error)

ListRunIDs returns all stored run IDs (for batch operations)

func (*ArenaStateStore) Load

func (s *ArenaStateStore) Load(ctx context.Context, conversationID string) (*runtimestore.ConversationState, error)

Load retrieves conversation state (implements Store interface)

func (*ArenaStateStore) Save

Save stores conversation state (implements Store interface). Uses incremental cloning: only new messages (appended since the last Save) are deep-cloned. Previously stored messages are already immutable snapshots and are reused, reducing per-Save cost from O(N) to O(delta).

func (*ArenaStateStore) SaveMetadata

func (s *ArenaStateStore) SaveMetadata(ctx context.Context, conversationID string, metadata *RunMetadata) error

SaveMetadata stores Arena-specific metadata for a run ConversationID should equal RunID for Arena executions

func (*ArenaStateStore) SaveWithTrace

func (s *ArenaStateStore) SaveWithTrace(
	ctx context.Context,
	state *runtimestore.ConversationState,
	trace *pipeline.ExecutionTrace,
) error

SaveWithTrace stores conversation state with execution trace (Arena-specific method). This is called by ArenaStateStoreSaveMiddleware to directly pass the trace. LLM call traces (_llm_trace) are always attached to messages when trace data is available.

func (*ArenaStateStore) SetTrialResults added in v1.3.10

func (s *ArenaStateStore) SetTrialResults(ctx context.Context, runID string, trialResults interface{}) error

SetTrialResults stores trial aggregation results on a run's metadata.

func (*ArenaStateStore) UpdateLastAssistantMessage added in v1.1.6

func (s *ArenaStateStore) UpdateLastAssistantMessage(conversationID string, msg *types.Message)

UpdateLastAssistantMessage updates the metadata of the last assistant message. This is used by duplex mode to attach assertion results to messages after evaluation.

When conversationID is non-empty the update is O(M) on that conversation's messages. When empty it falls back to scanning all conversations (O(N*M)).

type AssertionsSummary added in v1.1.3

type AssertionsSummary struct {
	Failed  int                            `json:"failed"`
	Passed  bool                           `json:"passed"`
	Results []ConversationValidationResult `json:"results"`
	Total   int                            `json:"total"`
}

AssertionsSummary mirrors the turn-level assertions structure

type ConversationValidationResult added in v1.1.3

type ConversationValidationResult = assertions.ConversationValidationResult

ConversationValidationResult is an alias for assertions.ConversationValidationResult to avoid import cycles and maintain clean separation between statestore and assertions.

type Feedback

type Feedback struct {
	ConversationID string                 `json:"conversation_id"`
	UserID         string                 `json:"user_id"`
	Rating         int                    `json:"rating"`
	Comments       string                 `json:"comments"`
	Categories     map[string]interface{} `json:"categories"`
	Timestamp      time.Time              `json:"timestamp"`
	Tags           []string               `json:"tags"`
}

Feedback represents user feedback on conversation results This is a placeholder for future optimization features (v0.3.0)

type MediaOutput added in v1.1.0

type MediaOutput struct {
	Type       string `json:"Type"`       // "image", "audio", "video"
	MIMEType   string `json:"MIMEType"`   // e.g., "image/png", "audio/wav"
	SizeBytes  int64  `json:"SizeBytes"`  // Size in bytes
	Duration   *int   `json:"Duration"`   // Duration in seconds for audio/video
	Width      *int   `json:"Width"`      // Width in pixels for images/video
	Height     *int   `json:"Height"`     // Height in pixels for images/video
	FilePath   string `json:"FilePath"`   // Path to the media file if available
	Thumbnail  string `json:"Thumbnail"`  // Base64-encoded thumbnail for images
	MessageIdx int    `json:"MessageIdx"` // Index of the message containing this media
	PartIdx    int    `json:"PartIdx"`    // Index of the part within the message
}

MediaOutput represents media content produced during a run

type RunMetadata

type RunMetadata struct {
	RunID      string                 `json:"run_id"`
	PromptPack string                 `json:"prompt_pack,omitempty"`
	Region     string                 `json:"region"`
	ScenarioID string                 `json:"scenario_id"`
	ProviderID string                 `json:"provider_id"`
	Params     map[string]interface{} `json:"params,omitempty"`
	Commit     map[string]interface{} `json:"commit,omitempty"`
	StartTime  time.Time              `json:"start_time"`
	EndTime    time.Time              `json:"end_time"`
	Duration   time.Duration          `json:"duration"`
	Error      string                 `json:"error,omitempty"`

	// Self-play metadata
	SelfPlay      bool              `json:"self_play,omitempty"`
	PersonaID     string            `json:"persona_id,omitempty"`
	AssistantRole *SelfPlayRoleInfo `json:"assistant_role,omitempty"`
	UserRole      *SelfPlayRoleInfo `json:"user_role,omitempty"`

	// Optimizer/feedback metadata
	UserFeedback *Feedback `json:"user_feedback,omitempty"`
	SessionTags  []string  `json:"session_tags,omitempty"`

	// Session recording path (if recording is enabled)
	RecordingPath string `json:"recording_path,omitempty"`

	// Conversation-level assertions (evaluated after conversation completes)
	ConversationAssertionResults []ConversationValidationResult `json:"conv_assertions_results,omitempty"`

	// A2A agent metadata (populated from config for report rendering)
	A2AAgents []A2AAgentInfo `json:"a2a_agents,omitempty"`

	// TrialResults holds aggregated statistics when a scenario is run with Trials > 1.
	TrialResults interface{} `json:"trial_results,omitempty"`
}

RunMetadata contains Arena-specific execution metadata

type RunResult

type RunResult struct {
	RunID        string                  `json:"RunID"`
	PromptPack   string                  `json:"PromptPack"`
	Region       string                  `json:"Region"`
	ScenarioID   string                  `json:"ScenarioID"`
	ProviderID   string                  `json:"ProviderID"`
	Params       map[string]interface{}  `json:"Params"`
	Messages     []types.Message         `json:"Messages"`
	Commit       map[string]interface{}  `json:"Commit"`
	Cost         types.CostInfo          `json:"Cost"`
	ToolStats    *types.ToolStats        `json:"ToolStats"`
	Violations   []types.ValidationError `json:"Violations"`
	StartTime    time.Time               `json:"StartTime"`
	EndTime      time.Time               `json:"EndTime"`
	Duration     time.Duration           `json:"Duration"`
	Error        string                  `json:"Error"`
	SelfPlay     bool                    `json:"SelfPlay"`
	PersonaID    string                  `json:"PersonaID"`
	MediaOutputs []MediaOutput           `json:"MediaOutputs"` // Media produced during the run

	UserFeedback  *Feedback   `json:"UserFeedback"`
	SessionTags   []string    `json:"SessionTags"`
	AssistantRole interface{} `json:"AssistantRole"` // Using interface{} to avoid circular import
	UserRole      interface{} `json:"UserRole"`

	// Session recording path (if recording is enabled)
	RecordingPath string `json:"RecordingPath,omitempty"`

	// Conversation-level assertions evaluated after the conversation completes (summary format)
	ConversationAssertions AssertionsSummary `json:"conversation_assertions,omitempty"`

	// A2A agent metadata (populated from config for report rendering)
	A2AAgents []A2AAgentInfo `json:"A2AAgents,omitempty"`

	// TrialResults holds aggregated statistics when a scenario is run with Trials > 1.
	TrialResults interface{} `json:"trial_results,omitempty"`
}

RunResult represents the full result structure for JSON compatibility This type mirrors engine.RunResult to avoid circular dependencies

type SelfPlayRoleInfo

type SelfPlayRoleInfo struct {
	Provider string `json:"provider,omitempty"`
	Model    string `json:"model,omitempty"`
	Region   string `json:"region,omitempty"`
}

SelfPlayRoleInfo contains provider information for self-play roles

type ValidationResult

type ValidationResult struct {
	TurnIndex     int                    `json:"turn_index"`
	Timestamp     time.Time              `json:"timestamp"`
	ValidatorType string                 `json:"validator_type"`
	Passed        bool                   `json:"passed"`
	Details       map[string]interface{} `json:"details,omitempty"`
}

ValidationResult captures validation outcome for a turn

Jump to

Keyboard shortcuts

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