session

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Sep 13, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

Package session owns Peen's durable transport-neutral session transcript.

Index

Constants

View Source
const (
	// DefaultPageLimit is the API default for transcript pagination.
	DefaultPageLimit = 50
	// MaximumPageLimit bounds one transcript page at the storage boundary.
	MaximumPageLimit = 200
)

Variables

View Source
var (
	// ErrSessionBusy reports a concurrent turn attempt for one session.
	ErrSessionBusy = commerr.ErrLockHeld
	// ErrInvalidPage reports invalid transcript pagination arguments.
	ErrInvalidPage = commerr.ErrValidationFailed
)

Functions

This section is empty.

Types

type AgentRunEventInput added in v0.4.0

type AgentRunEventInput struct {
	ID          uuid.UUID
	EventType   string
	PayloadJSON string
	CreatedAt   time.Time
}

AgentRunEventInput is one immutable child-agent event.

type AgentRunEventPage added in v0.4.0

type AgentRunEventPage struct {
	Run        *models.AgentRun
	Items      []*models.AgentRunEvent
	NextCursor int64
	HasMore    bool
}

AgentRunEventPage is one complete ordered child-event window.

type AgentRunPage added in v0.4.0

type AgentRunPage struct {
	Items   []*models.AgentRun
	Limit   int
	Offset  int
	HasMore bool
}

AgentRunPage is one complete child-run page.

type AppendJobOutputInput added in v0.4.0

type AppendJobOutputInput struct {
	ID        uuid.UUID
	Stream    models.JobOutputStream
	Content   string
	CreatedAt time.Time
}

AppendJobOutputInput is one immutable line in the combined process stream.

type CompactionInput

type CompactionInput struct {
	ID                     uuid.UUID
	FromMessageID          uuid.UUID
	ToMessageID            uuid.UUID
	FromSequence           int64
	ToSequence             int64
	DirectFromSequence     int64
	DirectToSequence       int64
	Summary                string
	SourceMessageCount     int64
	InputTokenCount        int64
	SummaryTokenCount      int64
	ModelID                string
	PromptHash             string
	SupersedesCompactionID *uuid.UUID
}

CompactionInput stores one immutable replacement summary.

type CompactionPage added in v0.4.0

type CompactionPage struct {
	Items   []*models.Compaction
	Limit   int
	Offset  int
	HasMore bool
}

CompactionPage is one complete session-local compaction page.

type CreateJobInput added in v0.4.0

type CreateJobInput struct {
	ID         uuid.UUID
	TurnID     uuid.UUID
	ToolCallID string
	PID        int64
	Purpose    string
	Command    string
	Directory  string
	StartedAt  time.Time
}

CreateJobInput records a supervised process before its output is observed.

type CreateModelCallInput added in v0.4.0

type CreateModelCallInput struct {
	ID                  uuid.UUID
	Round               int64
	RequestMessagesJSON string
	RequestToolsJSON    string
	StartedAt           time.Time
}

CreateModelCallInput describes one outbound provider round before bytes leave Peen.

type CreateModelRunInput added in v0.4.0

type CreateModelRunInput struct {
	ID                  uuid.UUID
	TurnID              uuid.UUID
	AgentRunID          *uuid.UUID
	Stage               models.ModelRunStage
	ModelReference      string
	ConnectionName      string
	RequestedModelID    string
	RequestSettingsJSON string
	StartedAt           time.Time
}

CreateModelRunInput describes one logical provider invocation before its first outbound round starts.

type CreateSessionNoticeInput added in v0.4.0

type CreateSessionNoticeInput struct {
	ID        uuid.UUID
	Type      string
	Source    string
	Summary   string
	DataJSON  string
	Delivery  models.NoticeDelivery
	CreatedAt time.Time
}

CreateSessionNoticeInput describes an external or worker report before it is delivered to a model.

type EventInput

type EventInput struct {
	ID               uuid.UUID
	RequestID        uuid.UUID
	EventType        string
	PayloadJSON      string
	ParentToolCallID string
}

EventInput describes one exact internal or protocol event.

type EventPage added in v0.4.0

type EventPage struct {
	Items   []*models.Event
	Limit   int
	Offset  int
	HasMore bool
}

EventPage is one complete session-local protocol event page.

type FinalizeAgentRunInput added in v0.4.0

type FinalizeAgentRunInput struct {
	State                 models.AgentRunState
	ResponseText          string
	ResponseThinking      string
	ResponseMessagesJSON  string
	FinishReason          string
	PromptTokenCount      int64
	CompletionTokenCount  int64
	FailureClassification string
	FailureDetail         string
}

FinalizeAgentRunInput describes the durable terminal outcome of a child.

type FinalizeJobInput added in v0.4.0

type FinalizeJobInput struct {
	State         models.JobState
	ExitCode      int64
	FailureDetail string
}

FinalizeJobInput stores a job's terminal outcome exactly once.

type FinalizeModelCallInput added in v0.4.0

type FinalizeModelCallInput struct {
	State                   models.ModelCallState
	ResponseMessageJSON     string
	ResponseUsageJSON       string
	RetryAttemptsJSON       string
	RetryAttemptCount       int64
	PromptTokens            int64
	CompletionTokens        int64
	TotalTokens             int64
	ReasoningTokens         int64
	CacheReadTokens         int64
	CacheWriteTokens        int64
	CacheWriteLongTTLTokens int64
	WastedPromptTokens      int64
	WastedCompletionTokens  int64
	WastedTotalTokens       int64
	TotalAttempts           int64
	ResponseModelID         string
	FinishReason            string
	ResponseCostAmount      string
	RetryCostAmount         string
	BilledCostAmount        string
	CostKnown               bool
	FailureClassification   string
	FailureDetail           string
}

FinalizeModelCallInput records the complete result of one provider round.

type FinalizeModelRunInput added in v0.4.0

type FinalizeModelRunInput struct {
	State                  models.ModelRunState
	ResponseModelID        string
	ResponseText           string
	ResponseThinking       string
	ResponseMessagesJSON   string
	ResponseInjectionsJSON string
	ResponseUsageJSON      string
	ResponseCostAmount     string
	RetryCostAmount        string
	BilledCostAmount       string
	CostKnown              bool
	FinishReason           string
	FailureClassification  string
	FailureDetail          string
}

FinalizeModelRunInput stores every non-secret result of one logical model invocation, including aggregate usage across its provider rounds.

type FinalizeTurnInput

type FinalizeTurnInput struct {
	State                 models.TurnState
	FailureClassification string
	ContextSnapshotHash   *string
	PromptSnapshotHash    *string
	Messages              []MessageInput
	Events                []EventInput
}

FinalizeTurnInput describes terminal turn state and durable references.

type History

type History struct {
	Compaction *models.Compaction
	Messages   []*models.Message
}

History is the active compaction followed by its uncovered completed tail.

type JobOutputPage added in v0.4.0

type JobOutputPage struct {
	Job        *models.Job
	Items      []*models.JobOutputLine
	NextCursor int64
	HasMore    bool
}

JobOutputPage is one complete ordered output replay page.

type JobPage added in v0.4.0

type JobPage struct {
	Items   []*models.Job
	Limit   int
	Offset  int
	HasMore bool
}

JobPage is one complete process-job page.

type JobSignalRequestPage added in v0.4.0

type JobSignalRequestPage struct {
	Job     *models.Job
	Items   []*models.JobSignalRequest
	Limit   int
	Offset  int
	HasMore bool
}

JobSignalRequestPage is one complete signal-request history page.

type Lease

type Lease struct {
	SessionID uuid.UUID
	TurnID    uuid.UUID
}

Lease uniquely identifies one active turn in a session.

type ListAgentRunEventsOptions added in v0.4.0

type ListAgentRunEventsOptions struct {
	Cursor int64
	Limit  int
}

ListAgentRunEventsOptions controls one replay window. Cursor is the next sequence number the caller has not seen yet, beginning at zero.

type ListAgentRunsOptions added in v0.4.0

type ListAgentRunsOptions struct {
	Limit  int
	Offset int
	State  *models.AgentRunState
}

ListAgentRunsOptions controls a bounded child-run page.

type ListCompactionsOptions added in v0.4.0

type ListCompactionsOptions struct {
	Limit  int
	Offset int
}

ListCompactionsOptions controls a bounded page of compaction records.

type ListEventsOptions added in v0.4.0

type ListEventsOptions struct {
	Limit  int
	Offset int
	Order  PageOrder
}

ListEventsOptions controls a bounded page of durable protocol events.

type ListJobOutputOptions added in v0.4.0

type ListJobOutputOptions struct {
	Cursor int64
	Limit  int
	Stream *models.JobOutputStream
}

ListJobOutputOptions controls one ordered process-output replay window.

type ListJobSignalRequestsOptions added in v0.4.0

type ListJobSignalRequestsOptions struct {
	Limit  int
	Offset int
}

ListJobSignalRequestsOptions controls a bounded signal-request history page.

type ListJobsOptions added in v0.4.0

type ListJobsOptions struct {
	Limit  int
	Offset int
	State  *models.JobState
}

ListJobsOptions controls a bounded session-local process-job page.

type ListMessagesOptions

type ListMessagesOptions struct {
	Limit  int
	Offset int
	Order  PageOrder
}

ListMessagesOptions controls a bounded session-local message page.

type ListModelCallsOptions added in v0.4.0

type ListModelCallsOptions struct {
	Limit  int
	Offset int
}

ListModelCallsOptions controls one ordered provider-round page.

type ListModelRunsOptions added in v0.4.0

type ListModelRunsOptions struct {
	Limit  int
	Offset int
	Stage  *models.ModelRunStage
	State  *models.ModelRunState
}

ListModelRunsOptions controls a bounded session-local model-run page.

type ListSessionNoticesOptions added in v0.4.0

type ListSessionNoticesOptions struct {
	Limit  int
	Offset int
}

ListSessionNoticesOptions controls a bounded page of notice history.

type ListTurnsOptions added in v0.4.0

type ListTurnsOptions struct {
	Limit  int
	Offset int
}

ListTurnsOptions controls a bounded page of durable session turns.

type MessageInput

type MessageInput struct {
	ID            uuid.UUID
	Workspace     string
	Role          models.MessageRole
	Content       string
	ModelID       string
	Thinking      string
	ToolCallsJSON string
	ToolCallID    string
	IsError       bool
	Incomplete    bool
}

MessageInput describes a durable transcript record.

type MessagePage

type MessagePage struct {
	Items   []*models.Message
	Limit   int
	Offset  int
	HasMore bool
}

MessagePage is one complete limit-offset transcript page.

type ModelCallPage added in v0.4.0

type ModelCallPage struct {
	Run     *models.ModelRun
	Items   []*models.ModelCall
	Limit   int
	Offset  int
	HasMore bool
}

ModelCallPage is one complete provider-round page for a model run.

type ModelRunPage added in v0.4.0

type ModelRunPage struct {
	Items   []*models.ModelRun
	Limit   int
	Offset  int
	HasMore bool
}

ModelRunPage is one complete model-run page.

type NoticePage added in v0.5.0

type NoticePage struct {
	Items   []*models.SessionNotice
	Limit   int
	Offset  int
	HasMore bool
}

NoticePage is one complete session-local notice page.

type OpenSessionOptions

type OpenSessionOptions struct {
	RootAgent string
	ModelID   string
}

OpenSessionOptions supplies immutable session attribution on creation.

type OpenSessionResult

type OpenSessionResult struct {
	Session *models.Session
	Created bool
}

OpenSessionResult is a resolved session and whether this call created it.

type Options

type Options struct {
	Clock func() time.Time
	NewID func() uuid.UUID

	// MaxStoredMessageBytes bounds one message row of any role. An assistant
	// or tool message has no caller-facing size limit, so without this a
	// single tool result could grow the transcript without bound. Zero takes
	// the package default.
	MaxStoredMessageBytes int
}

Options supplies deterministic seams for the transport-neutral store.

type PageOrder

type PageOrder string

PageOrder controls transcript pagination direction.

const (
	PageOrderAscending  PageOrder = "asc"
	PageOrderDescending PageOrder = "desc"
)

type RecordJobSignalInput added in v0.4.0

type RecordJobSignalInput struct {
	ID          uuid.UUID
	Signal      models.JobSignal
	Accepted    bool
	RequestedAt time.Time
}

RecordJobSignalInput records one accepted or no-op request to stop a job.

type RecordModelCallRetriesInput added in v0.4.0

type RecordModelCallRetriesInput struct {
	RetryAttemptsJSON string
	RetryAttemptCount int64
}

RecordModelCallRetriesInput persists every retry that Elelem reports while a provider round remains active.

type StartAgentRunInput added in v0.4.0

type StartAgentRunInput struct {
	ID               uuid.UUID
	ParentTurnID     uuid.UUID
	ParentAgentRunID *uuid.UUID
	ParentToolCallID string
	RequestID        uuid.UUID
	Name             string
	Definition       models.AgentRunDefinition
	Depth            int64
	Workspace        string
	ModelReference   string
	ModelID          string
	Task             string
	Instructions     string
	AllowedToolsJSON string
	SystemPrompt     string
	StartedAt        time.Time
}

StartAgentRunInput describes the immutable child-agent launch record.

type StartTurnInput

type StartTurnInput struct {
	RequestID uuid.UUID
	Workspace string
	Messages  []MessageInput
	Events    []EventInput
}

StartTurnInput describes the durable beginning of an agent turn.

type Store

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

Store persists sessions and protects each active session turn in-process.

func NewStore

func NewStore(handle *db.Handle, options Options) (*Store, error)

NewStore builds a store over an already-open migrated database handle.

func (*Store) AcquireTurn

func (s *Store) AcquireTurn(
	ctx context.Context,
	sessionID uuid.UUID,
	input StartTurnInput,
) (Lease, error)

AcquireTurn starts one durable turn and records its initial transcript data.

func (*Store) AppendAgentRunEvent added in v0.4.0

func (s *Store) AppendAgentRunEvent(
	ctx context.Context,
	sessionID uuid.UUID,
	agentRunID uuid.UUID,
	input AgentRunEventInput,
) (*models.AgentRunEvent, error)

AppendAgentRunEvent records a child event before it reaches a live client.

func (*Store) AppendCheckpoint

func (s *Store) AppendCheckpoint(
	ctx context.Context,
	lease Lease,
	messages []MessageInput,
	events []EventInput,
) error

AppendCheckpoint records visible messages and events without ending a turn.

func (*Store) AppendJobOutput added in v0.4.0

func (s *Store) AppendJobOutput(
	ctx context.Context,
	sessionID uuid.UUID,
	jobID uuid.UUID,
	input AppendJobOutputInput,
) (*models.JobOutputLine, error)

AppendJobOutput stores one process line in sequence before any live reader can see it. stdout and stderr share the same sequence so replay preserves observed ordering across both streams.

func (*Store) Cancel

func (s *Store) Cancel(ctx context.Context, sessionID uuid.UUID) (bool, error)

Cancel requests cancellation for the active turn without waiting for it.

func (*Store) CompletedHistory

func (s *Store) CompletedHistory(
	ctx context.Context,
	sessionID uuid.UUID,
) (*History, error)

CompletedHistory returns the current summary and the raw completed tail.

func (*Store) CreateAgentRun added in v0.4.0

func (s *Store) CreateAgentRun(
	ctx context.Context,
	sessionID uuid.UUID,
	input StartAgentRunInput,
) (*models.AgentRun, error)

CreateAgentRun records a child before any provider work or visible stream event can begin.

func (*Store) CreateCompaction

func (s *Store) CreateCompaction(
	ctx context.Context,
	sessionID uuid.UUID,
	input CompactionInput,
) (*models.Compaction, error)

CreateCompaction stores an immutable completed-history replacement summary.

func (*Store) CreateJob added in v0.4.0

func (s *Store) CreateJob(
	ctx context.Context,
	sessionID uuid.UUID,
	input CreateJobInput,
) (*models.Job, error)

CreateJob records a supervised process before its output reaches memory or any connected client.

func (*Store) CreateModelCall added in v0.4.0

func (s *Store) CreateModelCall(
	ctx context.Context,
	sessionID uuid.UUID,
	modelRunID uuid.UUID,
	input CreateModelCallInput,
) (*models.ModelCall, error)

CreateModelCall writes one exact outbound provider request before Elelem gives its driver permission to execute it.

func (*Store) CreateModelRun added in v0.4.0

func (s *Store) CreateModelRun(
	ctx context.Context,
	sessionID uuid.UUID,
	input CreateModelRunInput,
) (*models.ModelRun, error)

CreateModelRun records a logical model invocation before any provider work begins. No live event is permitted to outrun this row.

func (*Store) CreateOrResume

func (s *Store) CreateOrResume(
	ctx context.Context,
	requestedSessionID *uuid.UUID,
	options OpenSessionOptions,
) (*OpenSessionResult, error)

CreateOrResume creates a session or resumes its requested durable ID.

func (*Store) CreateSessionNotice added in v0.4.0

func (s *Store) CreateSessionNotice(
	ctx context.Context,
	sessionID uuid.UUID,
	input CreateSessionNoticeInput,
) (*models.SessionNotice, error)

CreateSessionNotice writes a notice before it reaches an in-process bus or a model. It is the durable source of the session's outside event history.

func (*Store) DrainSessionNotices added in v0.4.0

func (s *Store) DrainSessionNotices(
	ctx context.Context,
	sessionID uuid.UUID,
) ([]*models.SessionNotice, error)

DrainSessionNotices marks every pending notice delivered and returns the exact immutable records for the next model context.

func (*Store) FinalizeAgentRun added in v0.4.0

func (s *Store) FinalizeAgentRun(
	ctx context.Context,
	sessionID uuid.UUID,
	agentRunID uuid.UUID,
	input FinalizeAgentRunInput,
) (*models.AgentRun, error)

FinalizeAgentRun writes the terminal response or failure exactly once.

func (*Store) FinalizeJob added in v0.4.0

func (s *Store) FinalizeJob(
	ctx context.Context,
	sessionID uuid.UUID,
	jobID uuid.UUID,
	input FinalizeJobInput,
) (*models.Job, error)

FinalizeJob records a terminal process result exactly once.

func (*Store) FinalizeModelCall added in v0.4.0

func (s *Store) FinalizeModelCall(
	ctx context.Context,
	sessionID uuid.UUID,
	modelRunID uuid.UUID,
	modelCallID uuid.UUID,
	input FinalizeModelCallInput,
) (*models.ModelCall, error)

FinalizeModelCall writes one provider round's output and accounting exactly once. The request snapshot is immutable from CreateModelCall.

func (*Store) FinalizeModelRun added in v0.4.0

func (s *Store) FinalizeModelRun(
	ctx context.Context,
	sessionID uuid.UUID,
	modelRunID uuid.UUID,
	input FinalizeModelRunInput,
) (*models.ModelRun, error)

FinalizeModelRun writes the logical invocation outcome after every round has either finished or been marked terminal.

func (*Store) FinalizeTurn

func (s *Store) FinalizeTurn(
	ctx context.Context,
	lease Lease,
	input FinalizeTurnInput,
) error

FinalizeTurn atomically writes terminal transcript data and state.

func (*Store) Get

func (s *Store) Get(
	ctx context.Context,
	sessionID uuid.UUID,
) (*models.Session, error)

Get returns durable metadata for one existing session.

func (*Store) GetAgentRun added in v0.4.0

func (s *Store) GetAgentRun(
	ctx context.Context,
	sessionID uuid.UUID,
	agentRunID uuid.UUID,
) (*models.AgentRun, error)

GetAgentRun returns one session-scoped durable child run.

func (*Store) GetCompaction added in v0.4.0

func (s *Store) GetCompaction(
	ctx context.Context,
	sessionID uuid.UUID,
	compactionID uuid.UUID,
) (*models.Compaction, error)

GetCompaction returns one immutable compaction record owned by a session.

func (*Store) GetContextSnapshot added in v0.4.0

func (s *Store) GetContextSnapshot(
	ctx context.Context,
	sessionID uuid.UUID,
	hash string,
) (*models.ContextSnapshot, error)

GetContextSnapshot returns a snapshot only when this session references it.

func (*Store) GetJob added in v0.4.0

func (s *Store) GetJob(
	ctx context.Context,
	sessionID uuid.UUID,
	jobID uuid.UUID,
) (*models.Job, error)

GetJob reads a single durable process job scoped to its session.

func (*Store) GetModelRun added in v0.4.0

func (s *Store) GetModelRun(
	ctx context.Context,
	sessionID uuid.UUID,
	modelRunID uuid.UUID,
) (*models.ModelRun, error)

GetModelRun returns one session-scoped logical model invocation.

func (*Store) GetPromptSnapshot added in v0.4.0

func (s *Store) GetPromptSnapshot(
	ctx context.Context,
	sessionID uuid.UUID,
	hash string,
) (*models.PromptSnapshot, error)

GetPromptSnapshot returns a snapshot only when this session references it.

func (*Store) IsActive

func (s *Store) IsActive(sessionID uuid.UUID) bool

IsActive reports whether the process currently owns a running turn.

func (*Store) LatestCompaction

func (s *Store) LatestCompaction(
	ctx context.Context,
	sessionID uuid.UUID,
) (*models.Compaction, error)

LatestCompaction returns the current chain head, not a superseded row.

func (*Store) ListAgentRunEvents added in v0.4.0

func (s *Store) ListAgentRunEvents(
	ctx context.Context,
	sessionID uuid.UUID,
	agentRunID uuid.UUID,
	options ListAgentRunEventsOptions,
) (*AgentRunEventPage, error)

ListAgentRunEvents returns ordered durable replay data for one child run.

func (*Store) ListAgentRuns added in v0.4.0

func (s *Store) ListAgentRuns(
	ctx context.Context,
	sessionID uuid.UUID,
	options ListAgentRunsOptions,
) (*AgentRunPage, error)

ListAgentRuns returns a stable newest-first session-scoped child-run page.

func (*Store) ListCompactions added in v0.4.0

func (s *Store) ListCompactions(
	ctx context.Context,
	sessionID uuid.UUID,
	options ListCompactionsOptions,
) (*CompactionPage, error)

ListCompactions returns a stable newest-first page of durable summaries.

func (*Store) ListEvents added in v0.4.0

func (s *Store) ListEvents(
	ctx context.Context,
	sessionID uuid.UUID,
	options ListEventsOptions,
) (*EventPage, error)

ListEvents returns a stable bounded page of durable protocol events.

func (*Store) ListJobOutput added in v0.4.0

func (s *Store) ListJobOutput(
	ctx context.Context,
	sessionID uuid.UUID,
	jobID uuid.UUID,
	options ListJobOutputOptions,
) (*JobOutputPage, error)

ListJobOutput replays the one persisted combined process stream.

func (*Store) ListJobSignalRequests added in v0.4.0

func (s *Store) ListJobSignalRequests(
	ctx context.Context,
	sessionID uuid.UUID,
	jobID uuid.UUID,
	options ListJobSignalRequestsOptions,
) (*JobSignalRequestPage, error)

ListJobSignalRequests returns every durable request to signal one job.

func (*Store) ListJobs added in v0.4.0

func (s *Store) ListJobs(
	ctx context.Context,
	sessionID uuid.UUID,
	options ListJobsOptions,
) (*JobPage, error)

ListJobs returns a stable newest-first session-local process-job page.

func (*Store) ListMessages

func (s *Store) ListMessages(
	ctx context.Context,
	sessionID uuid.UUID,
	options ListMessagesOptions,
) (*MessagePage, error)

ListMessages returns a stable bounded page of one session's transcript.

func (*Store) ListModelCalls added in v0.4.0

func (s *Store) ListModelCalls(
	ctx context.Context,
	sessionID uuid.UUID,
	modelRunID uuid.UUID,
	options ListModelCallsOptions,
) (*ModelCallPage, error)

ListModelCalls returns the ordered provider rounds for one durable model invocation, including each exact request and retry trail.

func (*Store) ListModelRuns added in v0.4.0

func (s *Store) ListModelRuns(
	ctx context.Context,
	sessionID uuid.UUID,
	options ListModelRunsOptions,
) (*ModelRunPage, error)

ListModelRuns returns a stable newest-first session-local model run page.

func (*Store) ListSessionNotices added in v0.4.0

func (s *Store) ListSessionNotices(
	ctx context.Context,
	sessionID uuid.UUID,
	options ListSessionNoticesOptions,
) (*NoticePage, error)

ListSessionNotices returns all notice history, pending and delivered, in durable sequence order.

func (*Store) ListTurns added in v0.4.0

func (s *Store) ListTurns(
	ctx context.Context,
	sessionID uuid.UUID,
	options ListTurnsOptions,
) (*TurnPage, error)

ListTurns returns a stable newest-first page of durable session turns.

func (*Store) RecordJobSignal added in v0.4.0

func (s *Store) RecordJobSignal(
	ctx context.Context,
	sessionID uuid.UUID,
	jobID uuid.UUID,
	input RecordJobSignalInput,
) (*models.JobSignalRequest, error)

RecordJobSignal stores every accepted and no-op signal request.

func (*Store) RecordModelCallRetries added in v0.4.0

func (s *Store) RecordModelCallRetries(
	ctx context.Context,
	sessionID uuid.UUID,
	modelRunID uuid.UUID,
	modelCallID uuid.UUID,
	input RecordModelCallRetriesInput,
) error

RecordModelCallRetries checkpoints failed attempts while the provider round remains in progress, preserving them even if the process exits mid-backoff.

func (*Store) RecoverInterrupted

func (s *Store) RecoverInterrupted(ctx context.Context) (int, error)

RecoverInterrupted marks active turns and their messages incomplete.

func (*Store) RecoverInterruptedAgentRuns added in v0.4.0

func (s *Store) RecoverInterruptedAgentRuns(ctx context.Context) (int, error)

RecoverInterruptedAgentRuns marks stale child runs terminal during startup.

func (*Store) RecoverInterruptedJobs added in v0.4.0

func (s *Store) RecoverInterruptedJobs(ctx context.Context) (int, error)

RecoverInterruptedJobs marks process rows left running by a prior process terminal. The original child process cannot be safely reattached.

func (*Store) RecoverInterruptedModelRuns added in v0.4.0

func (s *Store) RecoverInterruptedModelRuns(ctx context.Context) (int, error)

RecoverInterruptedModelRuns marks durable work left running by a prior Peen process terminal. No provider connection can be safely resumed in place.

func (*Store) RegisterCancellation

func (s *Store) RegisterCancellation(lease Lease, cancel context.CancelFunc)

RegisterCancellation associates cancellation with one exact active lease.

func (*Store) ReleaseTurn

func (s *Store) ReleaseTurn(lease Lease)

ReleaseTurn removes a lease only when it is still the registered turn.

func (*Store) RequestAgentRunCancellation added in v0.4.0

func (s *Store) RequestAgentRunCancellation(
	ctx context.Context,
	sessionID uuid.UUID,
	agentRunID uuid.UUID,
) (*models.AgentRun, bool, error)

RequestAgentRunCancellation records cancellation before signalling an active in-process child. It is idempotent for terminal and already-requested rows.

func (*Store) SaveContextSnapshot

func (s *Store) SaveContextSnapshot(
	ctx context.Context,
	snapshot *models.ContextSnapshot,
) error

SaveContextSnapshot stores an immutable resolved harness context.

func (*Store) SavePromptSnapshot

func (s *Store) SavePromptSnapshot(
	ctx context.Context,
	snapshot *models.PromptSnapshot,
) error

SavePromptSnapshot stores an immutable effective prompt.

type TurnPage added in v0.4.0

type TurnPage struct {
	Items   []*models.Turn
	Limit   int
	Offset  int
	HasMore bool
}

TurnPage is one complete session-local turn page.

Jump to

Keyboard shortcuts

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