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 ¶
- Variables
- type Event
- type NodeRun
- type RouteDecision
- type Run
- type Store
- func (s *Store) AppendEvent(e Event) (int64, error)
- func (s *Store) CheckInvite(codeHash string, now time.Time) error
- func (s *Store) Close() error
- func (s *Store) CreateInvite(codeHash string, expires time.Time) error
- func (s *Store) CreateRun(r Run) error
- func (s *Store) Events(runID string) ([]Event, error)
- func (s *Store) EventsSince(cursor int64) ([]Event, error)
- func (s *Store) GetRun(id string) (Run, error)
- func (s *Store) ListRuns() ([]Run, error)
- func (s *Store) MarkInviteUsed(codeHash string, now time.Time) error
- func (s *Store) NodeRuns(runID string) ([]NodeRun, error)
- func (s *Store) RouteDecisions(taskID string) ([]RouteDecision, error)
- func (s *Store) SaveRouteDecision(d RouteDecision) error
- func (s *Store) UpdateRunStatus(id, status string, exitCode int, errMsg string) error
- func (s *Store) UpsertNodeRun(n NodeRun) error
- func (s *Store) WaitingGates() ([]NodeRun, error)
Constants ¶
This section is empty.
Variables ¶
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.
Functions ¶
This section is empty.
Types ¶
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 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
Agent string
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 Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store wraps the SQLite database.
func (*Store) AppendEvent ¶
AppendEvent appends an event (append-only) and returns its id.
func (*Store) CheckInvite ¶ added in v0.6.0
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) CreateInvite ¶ added in v0.6.0
CreateInvite records a hashed single-use invite code.
func (*Store) EventsSince ¶
EventsSince returns events with id greater than the cursor (the UI feed tail).
func (*Store) MarkInviteUsed ¶ added in v0.6.0
MarkInviteUsed consumes the invite. The WHERE used_at IS NULL guard makes consumption single-use even under concurrent joins.
func (*Store) RouteDecisions ¶
func (s *Store) RouteDecisions(taskID string) ([]RouteDecision, error)
RouteDecisions returns the decisions recorded for a task, oldest first.
func (*Store) SaveRouteDecision ¶
func (s *Store) SaveRouteDecision(d RouteDecision) error
SaveRouteDecision persists a routing decision.
func (*Store) UpdateRunStatus ¶
UpdateRunStatus updates a run's terminal fields.
func (*Store) UpsertNodeRun ¶
UpsertNodeRun inserts or updates a node run (keyed by id = runID:nodeID).
func (*Store) WaitingGates ¶
WaitingGates returns every gate node currently awaiting a human decision, across all runs (the gate-inbox source).