store

package
v1.0.4 Latest Latest
Warning

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

Go to latest
Published: Aug 22, 2026 License: MIT Imports: 19 Imported by: 0

Documentation

Overview

Package store is Fort's SQLite state store (backlog AO-016, spec §6.6): run, node_run, route_decision, and an append-only event log. The event log is the source the fort-ui live feed replays from.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInviteInvalid = errors.New("store: invite invalid or already used")
	ErrInviteExpired = errors.New("store: invite expired")
)

Invite errors distinguish the join responses (spec 024): 401 vs 410.

View Source
var ErrAgentChannelState = errors.New("Agent Channel resource is not open")
View Source
var ErrPlaybookRevisionStale = errors.New("store: stale playbook revision")

ErrPlaybookRevisionStale identifies a failed compare-and-append. Callers can map it to a conflict without depending on SQLite or matching error text.

View Source
var ErrScheduleCatalogLimit = errors.New("schedule_catalog_limit")

Functions

This section is empty.

Types

type AgentChannelMigrationReport added in v1.0.4

type AgentChannelMigrationReport struct {
	Channels      []conversation.AgentChannel             `json:"channels"`
	Conversations []conversation.AgentChannelConversation `json:"conversations"`
	Pins          []conversation.AgentConversationPin     `json:"pins"`
	Skipped       []AgentChannelMigrationSkip             `json:"skipped"`
}

type AgentChannelMigrationSkip added in v1.0.4

type AgentChannelMigrationSkip struct {
	ConversationID string `json:"conversation_id"`
	Reason         string `json:"reason"`
}

type BacklogItem added in v0.7.0

type BacklogItem struct {
	ID        string
	Title     string
	Body      string
	Agent     string // optional forced agent
	Machine   string // optional pinned host
	Labels    []string
	Source    string // "user" | "agent"
	CreatedAt time.Time
}

BacklogItem is a task queued for later dispatch (spec 025). It becomes a run only when dispatched (dragged onto the board / the Run action).

type ConversationDetail added in v0.13.0

type ConversationDetail struct {
	Conversation   conversation.Conversation    `json:"conversation"`
	Participants   []conversation.Participant   `json:"participants"`
	Messages       []conversation.Message       `json:"messages"`
	Turns          []conversation.Turn          `json:"turns"`
	Targets        []conversation.Target        `json:"targets"`
	PrimaryChannel *conversation.PrimaryChannel `json:"primary_identity,omitempty"`
}

type ConversationTargetDispatch added in v0.13.0

type ConversationTargetDispatch struct {
	Target       conversation.Target
	Turn         conversation.Turn
	Conversation conversation.Conversation
	Participant  conversation.Participant
}

type ConversationTurnTarget added in v0.13.0

type ConversationTurnTarget struct {
	ID            string
	ParticipantID string
	RunID         string
	Authority     *conversation.TargetAuthority
}

type CreateAgentChannelConversationTurnParams added in v1.0.4

type CreateAgentChannelConversationTurnParams struct {
	ChannelID     string
	Conversation  conversation.Conversation
	ParticipantID string
	TurnID        string
	ClientTurnID  string
	TargetID      string
	RunID         string
	HumanID       string
	Body          string
	Authority     *conversation.TargetAuthority
	CreatedAt     time.Time
}

type CreateConversationTurnParams added in v0.13.0

type CreateConversationTurnParams struct {
	TurnID         string
	ClientTurnID   string
	ConversationID string
	// AgentChannelID activates the exact parent/child open-state check at the
	// same immediate transaction boundary as a nested Agent Conversation turn.
	// Legacy and non-Agent callers leave it empty.
	AgentChannelID string
	HumanID        string
	Body           string
	Targets        []ConversationTurnTarget
	CreatedAt      time.Time
	// PrimarySingleFlight serializes the idempotency lookup and durable insert
	// before enforcing the one-active-target Primary Channel invariant. Legacy
	// conversation callers leave it false and retain their existing semantics.
	PrimarySingleFlight bool
}

type Event

type Event struct {
	ID        int64
	RunID     string
	NodeID    string // DAG step this event came from (spec 027); "" for run-level/single-run events
	Type      string
	Data      string
	Code      int
	CreatedAt time.Time
}

Event is one append-only event row.

type NodeRun

type NodeRun struct {
	ID        string // runID:nodeID
	RunID     string
	NodeID    string
	Type      string
	Status    string
	Input     string
	Output    string
	Attempts  int
	CreatedAt time.Time
	UpdatedAt time.Time
}

NodeRun is a persisted DAG node execution (Phase 2).

type PlaybookRevision added in v0.12.0

type PlaybookRevision struct {
	ID        string
	Revision  int
	Data      string
	CreatedAt time.Time
}

PlaybookRevision stores one opaque, immutable definition revision. The core store owns durability while the bounded control adapter owns validation and JSON interpretation (spec 036).

type RouteDecision

type RouteDecision struct {
	ID          string
	TaskID      string
	Route       string
	MatchedRule string
	IsDefault   bool
	Reason      string
	CreatedAt   time.Time
}

RouteDecision is a persisted routing outcome.

type Run

type Run struct {
	ID          string
	Title       string
	Body        string // markdown body from a multiline compose (spec 031); "" if title-only
	Agent       string
	Profile     string // exact Fort-owned profile requested for a direct run
	Model       string // provider model derived from Profile; empty means configured default
	Status      string
	MatchedRule string
	Machine     string // resolved target host (spec 022); "" = local/single-machine
	FlowID      string
	ExitCode    int
	Error       string
	CreatedAt   time.Time
	UpdatedAt   time.Time
}

Run is a persisted execution (a routed task or a flow run).

type ScheduleChannelLink struct {
	ID   string `json:"id"`
	Name string `json:"name"`
}

type ScheduleReadDetail added in v1.0.4

type ScheduleReadDetail struct {
	Row      ScheduleReadRow
	Upcoming []scheduler.Occurrence
	Recent   []scheduler.Occurrence
}

type ScheduleReadRow added in v1.0.4

type ScheduleReadRow struct {
	Definition       scheduler.Definition
	LatestOccurrence *scheduler.Occurrence
	RelatedChannel   *ScheduleChannelLink
}

type Store

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

Store wraps the SQLite database.

func Open

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

Open opens (creating if needed) the database at path and applies migrations.

func (*Store) AcceptAgentRebind added in v1.0.4

func (*Store) AcceptHandoff added in v1.0.4

func (s *Store) AcceptHandoff(ctx context.Context, command ledger.AcceptHandoffCommand) (ledger.HandoffRecord, error)

func (*Store) AddConversationParticipant added in v0.13.0

func (s *Store) AddConversationParticipant(participant conversation.Participant) error

func (*Store) AdvanceRoutineRun added in v1.0.4

func (s *Store) AdvanceRoutineRun(ctx context.Context, command ledger.AdvanceRoutineRunCommand) (ledger.RoutineRunRecord, error)

func (*Store) AgentConversationOwned added in v1.0.4

func (s *Store) AgentConversationOwned(channelID, conversationID string) (bool, error)

func (*Store) AgentCreatedConversationChannel added in v1.0.4

func (s *Store) AgentCreatedConversationChannel(conversationID string) (conversation.AgentChannel, bool, error)

AgentCreatedConversationChannel identifies Conversations created through the Agent-first product. Migrated legacy Primary Conversations deliberately do not have this provenance, so their legacy mutation contract remains intact.

func (*Store) AllNodeRuns added in v0.11.0

func (s *Store) AllNodeRuns() ([]NodeRun, error)

AllNodeRuns returns every node_run row grouped by run (the board's checkpoint-summary source, spec 033).

func (*Store) AnswerConversationTarget added in v0.13.0

func (s *Store) AnswerConversationTarget(id string, message conversation.Message) (bool, error)

func (*Store) AnswerConversationTargetWithReceipt added in v1.0.4

func (s *Store) AnswerConversationTargetWithReceipt(id string, message conversation.Message, receipt conversation.TargetReceipt) (bool, error)

func (*Store) AppendAgentBehavior added in v1.0.4

func (*Store) AppendAgentProfile added in v1.0.4

func (s *Store) AppendAgentProfile(ctx context.Context, command ledger.AppendAgentProfileCommand) (ledger.AgentRecord, error)

func (*Store) AppendConversationMessage added in v0.13.0

func (s *Store) AppendConversationMessage(message conversation.Message) (conversation.Message, error)

func (*Store) AppendEvent

func (s *Store) AppendEvent(e Event) (int64, error)

AppendEvent appends an event (append-only) and returns its id.

func (*Store) CancelAgentTarget added in v1.0.4

func (*Store) CancelHandoff added in v1.0.4

func (s *Store) CancelHandoff(ctx context.Context, command ledger.CancelHandoffCommand) (ledger.HandoffRecord, error)

func (*Store) CheckInvite added in v0.6.0

func (s *Store) CheckInvite(codeHash string, now time.Time) error

CheckInvite verifies codeHash names an unused, unexpired invite. It does not consume it — the join flow persists the registry first and only then calls MarkInviteUsed (spec 024 ordering).

func (*Store) ClearPrimaryAgentSetting added in v1.0.4

func (s *Store) ClearPrimaryAgentSetting() error

func (*Store) Close

func (s *Store) Close() error

Close closes the database.

func (*Store) CompleteHandoff added in v1.0.4

func (s *Store) CompleteHandoff(ctx context.Context, command ledger.CompleteHandoffCommand) (ledger.HandoffRecord, error)

func (*Store) ConversationContext added in v0.13.0

func (s *Store) ConversationContext(conversationID string, throughMessageID int64) (string, error)

func (*Store) CreateAgent added in v1.0.4

func (s *Store) CreateAgent(ctx context.Context, command ledger.CreateAgentCommand) (ledger.AgentRecord, error)

func (*Store) CreateAgentChannel added in v1.0.4

func (s *Store) CreateAgentChannel(channel conversation.AgentChannel) error

func (*Store) CreateAgentChannelConversation added in v1.0.4

func (s *Store) CreateAgentChannelConversation(channelID string, item conversation.Conversation, participantID string) error

CreateAgentChannelConversation copies the parent's immutable seat into one new conversation and records its ownership atomically. A compatible current Codex binding also receives the existing Primary marker so its execution and rollback contracts remain unchanged.

func (*Store) CreateAgentChannelConversationTurn added in v1.0.4

func (s *Store) CreateAgentChannelConversationTurn(params CreateAgentChannelConversationTurnParams) (conversation.Turn, []conversation.Target, string, error)

CreateAgentChannelConversationTurn is the first-Send durable boundary. It creates the child conversation, copied participant, ownership, compatibility marker, prompt, turn, and queued target in one immediate transaction.

func (*Store) CreateBacklogItem added in v0.7.0

func (s *Store) CreateBacklogItem(b BacklogItem) error

CreateBacklogItem inserts a pending item.

func (*Store) CreateConversation added in v0.13.0

func (s *Store) CreateConversation(item conversation.Conversation, participants []conversation.Participant) error

func (*Store) CreateConversationTurn added in v0.13.0

func (s *Store) CreateConversationTurn(params CreateConversationTurnParams) (conversation.Turn, []conversation.Target, string, error)

func (*Store) CreateGroup added in v1.0.4

func (s *Store) CreateGroup(ctx context.Context, command ledger.CreateGroupCommand) (ledger.GroupRecord, error)

func (*Store) CreateHumanHandoff added in v1.0.4

func (s *Store) CreateHumanHandoff(ctx context.Context, command ledger.CreateHumanHandoffCommand) (ledger.HandoffRecord, error)

func (*Store) CreateInvite added in v0.6.0

func (s *Store) CreateInvite(codeHash string, expires time.Time) error

CreateInvite records a hashed single-use invite code.

func (*Store) CreatePrimaryChannel added in v1.0.4

func (s *Store) CreatePrimaryChannel(item conversation.Conversation, participantID string) error

CreatePrimaryChannel snapshots the current singleton setting and creates the conversation, its sole participant, and the immutable marker in one SQLite transaction.

func (*Store) CreateProject added in v0.13.0

func (s *Store) CreateProject(project conversation.Project) error

func (*Store) CreateRoutine added in v1.0.4

func (s *Store) CreateRoutine(ctx context.Context, command ledger.CreateRoutineCommand) (ledger.RoutineRecord, error)

func (*Store) CreateRun

func (s *Store) CreateRun(r Run) error

CreateRun inserts a new run.

func (*Store) CreateSchedule added in v0.13.0

func (s *Store) CreateSchedule(definition scheduler.Definition) error
func (s *Store) CreateScheduleChannelLink(link conversation.ScheduleChannelLink) error

func (*Store) CreateSecondaryConversation added in v1.0.4

func (s *Store) CreateSecondaryConversation(ctx context.Context, command ledger.CreateSecondaryConversationCommand) (ledger.AgentConversationRecord, error)

func (*Store) DecideWaitingGate added in v0.13.0

func (s *Store) DecideWaitingGate(id, status, output string) (bool, error)

DecideWaitingGate atomically changes one waiting gate to a terminal decision. The false result means another caller already decided or reset that gate.

func (*Store) DeleteBacklogItem added in v0.7.0

func (s *Store) DeleteBacklogItem(id string) error

DeleteBacklogItem removes an item (called after it is dispatched or discarded).

func (*Store) DeleteConversation added in v0.13.0

func (s *Store) DeleteConversation(id string) error

func (*Store) DeleteProject added in v0.13.0

func (s *Store) DeleteProject(id string) error

func (*Store) EnqueueRoutineOccurrence added in v1.0.4

func (s *Store) EnqueueRoutineOccurrence(ctx context.Context, command ledger.EnqueueRoutineOccurrenceCommand) (ledger.RoutineRunRecord, error)

func (*Store) Events

func (s *Store) Events(runID string) ([]Event, error)

Events returns all events for a run, in insertion order.

func (*Store) EventsSince

func (s *Store) EventsSince(cursor int64) ([]Event, error)

EventsSince returns events with id greater than the cursor (the UI feed tail).

func (*Store) FailInterruptedConversationTargets added in v0.13.0

func (s *Store) FailInterruptedConversationTargets(reason string) (int, error)

func (*Store) FailInterruptedDirectRuns added in v0.13.0

func (s *Store) FailInterruptedDirectRuns(reason string) (int, error)

FailInterruptedDirectRuns reconciles direct tasks left running by an earlier daemon lifetime. Flow runs are intentionally excluded: their durable node_run state is the input to graph.Resume after a restart.

func (*Store) FindConversationTurnByClientID added in v1.0.4

func (s *Store) FindConversationTurnByClientID(conversationID, clientTurnID string) (conversation.Turn, []conversation.Target, bool, error)

func (*Store) GetAgent added in v1.0.4

func (s *Store) GetAgent(ctx context.Context, accountID, agentID string) (ledger.AgentRecord, error)

func (*Store) GetAgentChannel added in v1.0.4

func (s *Store) GetAgentChannel(id string) (conversation.AgentChannelDetail, error)

func (*Store) GetBacklogItem added in v0.7.0

func (s *Store) GetBacklogItem(id string) (BacklogItem, error)

GetBacklogItem returns one item by id.

func (*Store) GetConversation added in v0.13.0

func (s *Store) GetConversation(id string) (ConversationDetail, error)

func (*Store) GetConversationTargetDispatch added in v0.13.0

func (s *Store) GetConversationTargetDispatch(id string) (ConversationTargetDispatch, error)

func (*Store) GetGroup added in v1.0.4

func (s *Store) GetGroup(ctx context.Context, accountID, groupID string) (ledger.GroupRecord, error)

func (*Store) GetHandoff added in v1.0.4

func (s *Store) GetHandoff(ctx context.Context, accountID, handoffID string) (ledger.HandoffRecord, error)

func (*Store) GetPrimaryAgentSetting added in v1.0.4

func (s *Store) GetPrimaryAgentSetting() (conversation.PrimaryAgentSetting, error)

func (*Store) GetRoutine added in v1.0.4

func (s *Store) GetRoutine(ctx context.Context, accountID, routineID string) (ledger.RoutineRecord, error)

func (*Store) GetRoutineRun added in v1.0.4

func (s *Store) GetRoutineRun(ctx context.Context, accountID, runID string) (ledger.RoutineRunRecord, error)

func (*Store) GetRun

func (s *Store) GetRun(id string) (Run, error)

GetRun returns a run by id.

func (s *Store) GetScheduleChannelLink(scheduleID string) (conversation.ScheduleChannelLink, error)

func (*Store) ImportSourceRoutine added in v1.0.4

func (s *Store) ImportSourceRoutine(ctx context.Context, command ledger.ImportRoutineCommand) (ledger.RoutineRecord, error)

func (*Store) LatestExecutionSourceConfigObservation added in v1.0.4

func (s *Store) LatestExecutionSourceConfigObservation(ctx context.Context, accountID, executionSourceID string) (ledger.ExecutionSourceConfigObservation, error)

func (*Store) LatestPlaybookRevisions added in v0.12.0

func (s *Store) LatestPlaybookRevisions() ([]PlaybookRevision, error)

LatestPlaybookRevisions returns the newest immutable revision for every id, ordered deterministically by id.

func (*Store) ListAgentChannels added in v1.0.4

func (s *Store) ListAgentChannels(state string) ([]conversation.AgentChannelDetail, error)

func (*Store) ListAgentConversations added in v1.0.4

func (s *Store) ListAgentConversations(ctx context.Context, accountID, agentID string) ([]ledger.AgentConversationRecord, error)

func (*Store) ListAgents added in v1.0.4

func (s *Store) ListAgents(ctx context.Context, accountID string, state conversation.AgentState) ([]ledger.AgentRecord, error)

func (*Store) ListBacklog added in v0.7.0

func (s *Store) ListBacklog() ([]BacklogItem, error)

ListBacklog returns pending items, newest first.

func (*Store) ListConversationTargetDispatches added in v0.13.0

func (s *Store) ListConversationTargetDispatches(states ...conversation.TargetState) ([]ConversationTargetDispatch, error)

func (*Store) ListConversations added in v0.13.0

func (s *Store) ListConversations(scope string) ([]conversation.Conversation, error)

func (*Store) ListGroupTurns added in v1.0.4

func (s *Store) ListGroupTurns(ctx context.Context, accountID, groupID string) ([]ledger.GroupTurnRecord, error)

func (*Store) ListGroups added in v1.0.4

func (s *Store) ListGroups(ctx context.Context, accountID string, state conversation.ConversationState) ([]ledger.GroupRecord, error)

func (*Store) ListHandoffs added in v1.0.4

func (s *Store) ListHandoffs(ctx context.Context, accountID string) ([]ledger.HandoffRecord, error)

func (*Store) ListPrimaryChannels added in v1.0.4

func (s *Store) ListPrimaryChannels(state string) ([]conversation.PrimaryChannelSummary, error)

func (*Store) ListProjects added in v0.13.0

func (s *Store) ListProjects() ([]conversation.Project, error)

func (*Store) ListRoutineRuns added in v1.0.4

func (s *Store) ListRoutineRuns(ctx context.Context, accountID, routineID string) ([]ledger.RoutineRunRecord, error)

func (*Store) ListRoutines added in v1.0.4

func (s *Store) ListRoutines(ctx context.Context, accountID, agentID string) ([]ledger.RoutineRecord, error)

func (*Store) ListRuns

func (s *Store) ListRuns() ([]Run, error)

ListRuns returns all runs, newest first.

func (*Store) ListSchedules added in v0.13.0

func (s *Store) ListSchedules() ([]scheduler.Definition, error)

func (*Store) ListSourceRoutineProjections added in v1.0.4

func (s *Store) ListSourceRoutineProjections(ctx context.Context, accountID, executionSourceID string) ([]ledger.SourceRoutineProjection, error)

func (*Store) MarkInviteUsed added in v0.6.0

func (s *Store) MarkInviteUsed(codeHash string, now time.Time) error

MarkInviteUsed consumes the invite. The WHERE used_at IS NULL guard makes consumption single-use even under concurrent joins.

func (*Store) MigratePrimaryAgentChannels added in v1.0.4

func (s *Store) MigratePrimaryAgentChannels() (AgentChannelMigrationReport, error)

func (*Store) MoveConversation added in v0.13.0

func (s *Store) MoveConversation(id, projectID string) error

func (*Store) NodeRuns

func (s *Store) NodeRuns(runID string) ([]NodeRun, error)

NodeRuns returns the node runs for a run, in creation order.

func (*Store) ObserveExecutionSourceConfig added in v1.0.4

func (*Store) PlaybookRevision added in v0.12.0

func (s *Store) PlaybookRevision(id string, revision int) (PlaybookRevision, error)

PlaybookRevision returns exactly revision; edits never rewrite old rows.

func (*Store) PreviewAgentRebind added in v1.0.4

func (s *Store) PreviewAgentRebind(ctx context.Context, command ledger.PreviewAgentRebindCommand) (ledger.AgentRebindPreview, error)

func (*Store) PreviewPrimaryAgentChannelMigration added in v1.0.4

func (s *Store) PreviewPrimaryAgentChannelMigration() (AgentChannelMigrationReport, error)

func (*Store) ReadAgentConversation added in v1.0.4

func (s *Store) ReadAgentConversation(ctx context.Context, accountID, agentID, conversationID string) (ledger.AgentConversationProjection, error)

func (*Store) ReadScheduleCatalog added in v1.0.4

func (s *Store) ReadScheduleCatalog(ctx context.Context, enabled *bool, limit int) ([]ScheduleReadRow, error)

ReadScheduleCatalog returns one bounded SQLite read snapshot. enabled=nil includes active and paused definitions; a non-nil value filters on the durable enabled bit. The correlated occurrence is evidence only: this read never materializes, registers, or otherwise mutates scheduler state.

func (*Store) ReadScheduleDetail added in v1.0.4

func (s *Store) ReadScheduleDetail(ctx context.Context, id string, observedAt time.Time, occurrenceLimit int) (ScheduleReadDetail, error)

ReadScheduleDetail returns the definition and both bounded occurrence projections from one read transaction at the caller's observed instant.

func (*Store) ReadScheduleOccurrences added in v1.0.4

func (s *Store) ReadScheduleOccurrences(ctx context.Context, id string, limit int, before time.Time, beforeID string) ([]scheduler.Occurrence, error)

ReadScheduleOccurrences returns newest-first persisted occurrences. A cursor is absent only when both before and beforeID are empty; otherwise it is the exclusive (scheduled_for,id) tuple.

func (*Store) RecordSourceRoutineProjection added in v1.0.4

func (s *Store) RecordSourceRoutineProjection(ctx context.Context, projection ledger.SourceRoutineProjection) (ledger.SourceRoutineProjection, error)

func (*Store) RemoveConversationParticipant added in v0.13.0

func (s *Store) RemoveConversationParticipant(conversationID, participantID string, removedAt time.Time) error

func (*Store) RenameAgentChannel added in v1.0.4

func (s *Store) RenameAgentChannel(id, name string) error

func (*Store) RenameAgentConversation added in v1.0.4

func (s *Store) RenameAgentConversation(ctx context.Context, command ledger.RenameAgentConversationCommand) (ledger.AgentConversationRecord, error)

func (*Store) RenameConversation added in v0.13.0

func (s *Store) RenameConversation(id, title string) error

func (*Store) RenameGroup added in v1.0.4

func (s *Store) RenameGroup(ctx context.Context, command ledger.RenameGroupCommand) (ledger.GroupRecord, error)

func (*Store) RenameProject added in v0.13.0

func (s *Store) RenameProject(id, name string) error

func (*Store) ReplaceGroupMembers added in v1.0.4

func (s *Store) ReplaceGroupMembers(ctx context.Context, command ledger.ReplaceGroupMembersCommand) (ledger.GroupRecord, error)

func (*Store) RetryAgentConversationTargetWithAdapterRevision added in v1.0.4

func (s *Store) RetryAgentConversationTargetWithAdapterRevision(
	agentChannelID, originalID, newID, newRunID, selectedAdapterRevision string,
	createdAt time.Time,
) (ConversationTargetDispatch, error)

func (*Store) RetryAgentTarget added in v1.0.4

func (*Store) RetryConversationTarget added in v0.13.0

func (s *Store) RetryConversationTarget(originalID, newID, newRunID string, createdAt time.Time) (ConversationTargetDispatch, error)

func (*Store) RetryConversationTargetWithAdapterRevision added in v1.0.4

func (s *Store) RetryConversationTargetWithAdapterRevision(originalID, newID, newRunID, selectedAdapterRevision string, createdAt time.Time) (ConversationTargetDispatch, error)

func (*Store) RevalidateRoutine added in v1.0.4

func (s *Store) RevalidateRoutine(ctx context.Context, command ledger.RevalidateRoutineCommand) (ledger.RoutineRecord, error)

func (*Store) RouteDecisions

func (s *Store) RouteDecisions(taskID string) ([]RouteDecision, error)

RouteDecisions returns the decisions recorded for a task, oldest first.

func (*Store) SavePlaybookRevision added in v0.12.0

func (s *Store) SavePlaybookRevision(id, data string) (PlaybookRevision, error)

SavePlaybookRevision appends the next immutable revision for id.

func (*Store) SavePlaybookRevisionIfLatest added in v0.12.0

func (s *Store) SavePlaybookRevisionIfLatest(id string, expected int, data string) (PlaybookRevision, error)

SavePlaybookRevisionIfLatest appends only when expected is still the latest revision (zero means the id does not exist). The compare and insert share one transaction, preventing stale whole-document edits from becoming revisions.

func (*Store) SaveRouteDecision

func (s *Store) SaveRouteDecision(d RouteDecision) error

SaveRouteDecision persists a routing decision.

func (*Store) ScheduleOccurrencesBetween added in v0.13.0

func (s *Store) ScheduleOccurrencesBetween(start, end time.Time) ([]scheduler.Occurrence, error)

func (*Store) SeedPlaybookRevisions added in v0.12.0

func (s *Store) SeedPlaybookRevisions(revisions []PlaybookRevision) error

SeedPlaybookRevisions atomically installs an initial catalog when the table is empty. Existing catalogs are left untouched, so startup is idempotent and a crash can never expose a partially seeded set.

func (*Store) SendAgentTurn added in v1.0.4

func (s *Store) SendAgentTurn(ctx context.Context, command ledger.SendAgentTurnCommand) (ledger.AgentTurnDispatch, error)

func (*Store) SendGroupTurn added in v1.0.4

func (s *Store) SendGroupTurn(ctx context.Context, command ledger.SendGroupTurnCommand) (ledger.GroupTurnRecord, error)

func (*Store) SetAgentChannelState added in v1.0.4

func (s *Store) SetAgentChannelState(id string, state conversation.AgentChannelState) error

func (*Store) SetAgentConversationPin added in v1.0.4

func (s *Store) SetAgentConversationPin(ctx context.Context, command ledger.SetAgentConversationPinCommand) (ledger.AgentConversationRecord, error)

func (*Store) SetAgentConversationPinned added in v1.0.4

func (s *Store) SetAgentConversationPinned(channelID, conversationID string, pinned bool, pinnedAt time.Time) error

func (*Store) SetAgentConversationState added in v1.0.4

func (s *Store) SetAgentConversationState(ctx context.Context, command ledger.SetAgentConversationStateCommand) (ledger.AgentConversationRecord, error)

func (*Store) SetConversationState added in v0.13.0

func (s *Store) SetConversationState(id string, state conversation.ConversationState) error

func (*Store) SetGroupState added in v1.0.4

func (s *Store) SetGroupState(ctx context.Context, command ledger.SetGroupStateCommand) (ledger.GroupRecord, error)

func (*Store) SetPrimaryChannelPinned added in v1.0.4

func (s *Store) SetPrimaryChannelPinned(id string, pinned bool, pinnedAt time.Time) error

func (*Store) StartHandoff added in v1.0.4

func (s *Store) StartHandoff(ctx context.Context, command ledger.StartHandoffCommand) (ledger.HandoffRecord, error)

func (*Store) TouchConversationTargetActivity added in v0.13.0

func (s *Store) TouchConversationTargetActivity(id string, observedAt time.Time) error

func (*Store) TransitionConversationTarget added in v0.13.0

func (s *Store) TransitionConversationTarget(id string, from, to conversation.TargetState, errorMessage string) (bool, error)

func (*Store) TransitionConversationTargetWithCode added in v0.13.0

func (s *Store) TransitionConversationTargetWithCode(id string, from, to conversation.TargetState, errorCode, errorMessage string) (bool, error)

func (*Store) TransitionConversationTargetWithReceipt added in v1.0.4

func (s *Store) TransitionConversationTargetWithReceipt(id string, from, to conversation.TargetState, errorCode, errorMessage string, receipt conversation.TargetReceipt) (bool, error)

func (*Store) TransitionRunStatus added in v1.0.4

func (s *Store) TransitionRunStatus(id, flowID, from, to string, exitCode int, errMsg string) (bool, error)

TransitionRunStatus atomically changes one flow run from an expected state. A waiting human gate is never a resumable claim, and linked schedule state is updated in the same transaction only for the caller that wins the transition.

func (*Store) TransitionScheduleOccurrence added in v0.13.0

func (s *Store) TransitionScheduleOccurrence(id string, from, to scheduler.OccurrenceState, runID, errorMessage string) (bool, error)

func (*Store) UpdateBacklogAgent added in v0.11.0

func (s *Store) UpdateBacklogAgent(id, agent string) error

UpdateBacklogAgent reassigns an item to an agent ("" clears the pin, spec 033).

func (*Store) UpdateRunStatus

func (s *Store) UpdateRunStatus(id, status string, exitCode int, errMsg string) error

UpdateRunStatus updates a run and keeps any linked schedule occurrence truthful.

func (*Store) UpdateScheduleFire added in v0.13.0

func (s *Store) UpdateScheduleFire(id string, lastFireAt, nextFireAt time.Time) error

func (*Store) UpsertNodeRun

func (s *Store) UpsertNodeRun(n NodeRun) error

UpsertNodeRun inserts or updates a node run (keyed by id = runID:nodeID).

func (*Store) UpsertPrimaryAgentSetting added in v1.0.4

func (s *Store) UpsertPrimaryAgentSetting(setting conversation.PrimaryAgentSetting) error

func (*Store) UpsertScheduleOccurrence added in v0.13.0

func (s *Store) UpsertScheduleOccurrence(occurrence scheduler.Occurrence) error

func (*Store) WaitingGates

func (s *Store) WaitingGates() ([]NodeRun, error)

WaitingGates returns every gate node currently awaiting a human decision, across all runs (the gate-inbox source).

Jump to

Keyboard shortcuts

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