persistence

package
v0.3.1 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func TouchTimestamp

func TouchTimestamp(ts time.Time) time.Time

TouchTimestamp normalizes zero-value timestamps before persistence.

Types

type ActionEventRecord

type ActionEventRecord struct {
	bun.BaseModel      `bun:"table:action_events"`
	ID                 string `bun:",pk"`
	SchemaVersion      int
	CreatedAtUnixMilli int64
	RequestID          string
	SessionID          string
	PrincipalID        string
	Transport          string
	Direction          string
	MessageType        string
	Gateway            string
	ServerName         string
	Endpoint           string
	ToolName           string
	OriginalToolName   string
	Success            bool
	IsError            bool
	PayloadJSON        json.RawMessage
}

ActionEventRecord is the persisted SQL projection of one MCP action log entry.

type SchemaMigrationRequiredError

type SchemaMigrationRequiredError struct {
	StoredVersion   int
	ExpectedVersion int
}

SchemaMigrationRequiredError reports that an existing event store schema cannot be opened safely without an explicit migration path.

func (*SchemaMigrationRequiredError) Error

type Store

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

Store persists task and action events to SQLite using Bun.

func NewSQLiteStore

func NewSQLiteStore(path string) (*Store, error)

NewSQLiteStore creates a Bun-backed SQLite store and bootstraps the schema.

func (*Store) ActionEventRowsByTaskRunID

func (s *Store) ActionEventRowsByTaskRunID(taskRunID string) ([]actionEventTaskContextRow, error)

ActionEventRowsByTaskRunID returns bridge rows for one task run.

func (*Store) ActionEventTaskContexts

func (s *Store) ActionEventTaskContexts() ([]taskverification.ActionEventTaskContext, error)

ActionEventTaskContexts returns all persisted action-to-task bridge rows ordered by timestamp.

func (*Store) ActionEvents

func (s *Store) ActionEvents() ([]ActionEventRecord, error)

ActionEvents returns all persisted action events ordered by timestamp.

func (*Store) ActionEventsByRequestID

func (s *Store) ActionEventsByRequestID(requestID string) ([]ActionEventRecord, error)

ActionEventsByRequestID returns all persisted action events for a request id.

func (*Store) AppendActionEvent

func (s *Store) AppendActionEvent(entry *common.LogEntry) error

AppendActionEvent persists one action event projected from the MCP request log.

func (*Store) AppendActionEventTaskContext

func (s *Store) AppendActionEventTaskContext(ctx taskverification.ActionEventTaskContext) error

AppendActionEventTaskContext persists one action-to-task bridge record.

func (*Store) AppendTaskEvent

func (s *Store) AppendTaskEvent(event *taskverification.TaskEvent) error

AppendTaskEvent persists one task lifecycle event.

func (*Store) Close

func (s *Store) Close() error

Close releases the underlying database handle.

func (*Store) DB

func (s *Store) DB() *bun.DB

DB exposes the Bun DB handle for focused tests.

func (*Store) GetTaskRunEvents

func (s *Store) GetTaskRunEvents(ctx context.Context, runID string) ([]TaskRunEvent, error)

GetTaskRunEvents returns the unified task/action timeline for one run.

func (*Store) ListTaskRuns

func (s *Store) ListTaskRuns(ctx context.Context) ([]TaskRunSummary, error)

ListTaskRuns returns aggregated task run summaries ordered by start time descending.

func (*Store) TaskEventRowsByTaskRunID

func (s *Store) TaskEventRowsByTaskRunID(taskRunID string) ([]taskEventRow, error)

TaskEventRowsByTaskRunID returns lifecycle rows for one task run.

func (*Store) TaskEvents

func (s *Store) TaskEvents() ([]taskverification.TaskEvent, error)

TaskEvents returns all persisted task lifecycle events ordered by timestamp.

type TaskRunEvent

type TaskRunEvent struct {
	Source             TaskRunEventSource `json:"source"`
	ID                 string             `json:"id"`
	CreatedAtUnixMilli int64              `json:"createdAtUnixMilli"`
	PayloadJSON        json.RawMessage    `json:"payloadJson,omitempty"`

	EventType              string `json:"eventType,omitempty"`
	Outcome                string `json:"outcome,omitempty"`
	RelatedActionRequestID string `json:"relatedActionRequestId,omitempty"`
	PhasePath              string `json:"phasePath,omitempty"`
	NodeKind               string `json:"nodeKind,omitempty"`
	ResultingPhasePath     string `json:"resultingPhasePath,omitempty"`
	ResultingNodeKind      string `json:"resultingNodeKind,omitempty"`

	RequestID        string `json:"requestId,omitempty"`
	Direction        string `json:"direction,omitempty"`
	MessageType      string `json:"messageType,omitempty"`
	ToolName         string `json:"toolName,omitempty"`
	OriginalToolName string `json:"originalToolName,omitempty"`
	Success          *bool  `json:"success,omitempty"`
	IsError          *bool  `json:"isError,omitempty"`
	Transport        string `json:"transport,omitempty"`
	Gateway          string `json:"gateway,omitempty"`
	ServerName       string `json:"serverName,omitempty"`
	Endpoint         string `json:"endpoint,omitempty"`
}

TaskRunEvent is the unified task timeline projection used by the UI.

type TaskRunEventSource

type TaskRunEventSource string

TaskRunEventSource identifies where one timeline row originated.

const (
	// TaskRunEventSourceTask marks a task lifecycle event.
	TaskRunEventSourceTask TaskRunEventSource = "task"
	// TaskRunEventSourceAction marks an MCP action event.
	TaskRunEventSourceAction TaskRunEventSource = "action"
)

type TaskRunSummary

type TaskRunSummary struct {
	RunID            string `json:"runId"`
	TemplateID       string `json:"templateId"`
	PrincipalID      string `json:"principalId,omitempty"`
	SessionID        string `json:"sessionId,omitempty"`
	StartedAt        int64  `json:"startedAt"`
	EndedAt          *int64 `json:"endedAt,omitempty"`
	Status           string `json:"status"`
	CurrentPhase     string `json:"currentPhase"`
	CurrentNodeKind  string `json:"currentNodeKind,omitempty"`
	TaskEventCount   int    `json:"taskEventCount"`
	ActionEventCount int    `json:"actionEventCount"`
	EventCount       int    `json:"eventCount"`
}

TaskRunSummary is the aggregated view of one persisted task run.

Jump to

Keyboard shortcuts

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