ledger

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: 10 Imported by: 0

Documentation

Overview

Package ledger defines Fort's durable control-plane persistence contracts. It depends on domain records, but not on SQLite, Postgres, or transports.

Index

Constants

View Source
const MaxAgentMessageBytes = 2 << 20

Variables

View Source
var (
	ErrNotFound            = errors.New("ledger resource not found")
	ErrIdempotencyConflict = errors.New("ledger idempotency key conflicts with an earlier command")
	ErrRevisionConflict    = errors.New("ledger current revision does not match the expected revision")
	ErrStateConflict       = errors.New("ledger resource is not in a valid state for the command")
	ErrSourceDrift         = errors.New("ledger execution source no longer matches the accepted binding")
)
View Source
var (
	ErrRoutineNeedsRevalidation = errors.New("Routine needs revalidation")
	ErrRoutineRunTerminal       = errors.New("Routine run is already terminal")
)
View Source
var ErrAlreadyCompleted = errors.New("ledger resource already has an authoritative completion")

Functions

This section is empty.

Types

type AcceptAgentRebindCommand

type AcceptAgentRebindCommand struct {
	IdempotencyKey string             `json:"idempotency_key"`
	Preview        AgentRebindPreview `json:"preview"`
	AcceptedBy     string             `json:"accepted_by"`
	AcceptedAt     time.Time          `json:"accepted_at"`
}

func (AcceptAgentRebindCommand) Digest

func (c AcceptAgentRebindCommand) Digest() (string, error)

func (AcceptAgentRebindCommand) Validate

func (c AcceptAgentRebindCommand) Validate() error

type AcceptHandoffCommand

type AcceptHandoffCommand struct {
	Handoff                   conversation.Handoff `json:"handoff"`
	TargetID                  string               `json:"target_id"`
	ParticipantID             string               `json:"participant_id"`
	ProjectionConversationIDs []string             `json:"projection_conversation_ids"`
	// RequireCurrentRecipient is server-owned acceptance policy. When true,
	// adapters revalidate the recipient pins against the Agent's current
	// Behavior and Binding in the accepting write transaction.
	RequireCurrentRecipient bool `json:"-"`
}

func (AcceptHandoffCommand) Digest

func (c AcceptHandoffCommand) Digest() (string, error)

func (AcceptHandoffCommand) Validate

func (c AcceptHandoffCommand) Validate() error

type AdvanceRoutineRunCommand

type AdvanceRoutineRunCommand struct {
	AccountID        string                       `json:"account_id"`
	RunID            string                       `json:"run_id"`
	IdempotencyKey   string                       `json:"idempotency_key"`
	FromState        conversation.RoutineRunState `json:"from_state"`
	ToState          conversation.RoutineRunState `json:"to_state"`
	AttemptID        string                       `json:"attempt_id,omitempty"`
	LeaseID          string                       `json:"lease_id,omitempty"`
	LeaseExpiresAt   time.Time                    `json:"lease_expires_at,omitempty"`
	Activity         string                       `json:"activity"`
	FailureCode      string                       `json:"failure_code,omitempty"`
	NextAction       string                       `json:"next_action,omitempty"`
	NormalizedResult string                       `json:"normalized_result,omitempty"`
	OccurredAt       time.Time                    `json:"occurred_at"`
}

func (AdvanceRoutineRunCommand) Digest

func (c AdvanceRoutineRunCommand) Digest() (string, error)

func (AdvanceRoutineRunCommand) Validate

func (c AdvanceRoutineRunCommand) Validate() error

type AgentBindingAdvanceResult

type AgentBindingAdvanceResult struct {
	Agent      AgentRecord            `json:"agent"`
	Transition AgentBindingTransition `json:"transition"`
}

type AgentBindingTransition

type AgentBindingTransition struct {
	AccountID                   string                `json:"account_id"`
	AgentID                     string                `json:"agent_id"`
	Kind                        BindingTransitionKind `json:"kind"`
	PreviousBehaviorRevisionID  string                `json:"previous_behavior_revision_id"`
	SuccessorBehaviorRevisionID string                `json:"successor_behavior_revision_id"`
	PreviousBindingRevisionID   string                `json:"previous_binding_revision_id"`
	SuccessorBindingRevisionID  string                `json:"successor_binding_revision_id"`
	PreviewDigest               string                `json:"preview_digest"`
	NonTransferableResources    []RebindResource      `json:"non_transferable_resources"`
	ReadinessEvidence           []string              `json:"readiness_evidence"`
	AuthorityEvidence           []string              `json:"authority_evidence"`
	AcceptedBy                  string                `json:"accepted_by"`
	AcceptedAt                  time.Time             `json:"accepted_at"`
}

AgentBindingTransition is immutable acceptance evidence. The predecessor Binding itself is never updated; retirement is represented by this record, the successor's SupersedesRevisionID, and an append-only ledger event.

type AgentContextManifest

type AgentContextManifest struct {
	ID               string    `json:"id"`
	ConversationID   string    `json:"conversation_id"`
	ThroughMessageID int64     `json:"through_message_id"`
	MessageIDs       []int64   `json:"message_ids"`
	Digest           string    `json:"digest"`
	CreatedAt        time.Time `json:"created_at"`
}

type AgentConversationMessage

type AgentConversationMessage struct {
	ID             int64                   `json:"id"`
	ConversationID string                  `json:"conversation_id"`
	TurnID         string                  `json:"turn_id,omitempty"`
	TargetID       string                  `json:"target_id,omitempty"`
	AuthorKind     conversation.AuthorKind `json:"author_kind"`
	AuthorID       string                  `json:"author_id"`
	AuthorAgentID  string                  `json:"author_agent_id,omitempty"`
	Body           string                  `json:"body"`
	CreatedAt      time.Time               `json:"created_at"`
}

type AgentConversationProjection

type AgentConversationProjection struct {
	Conversation AgentConversationRecord    `json:"conversation"`
	Messages     []AgentConversationMessage `json:"messages"`
	Turns        []AgentConversationTurn    `json:"turns"`
	Targets      []AgentConversationTarget  `json:"targets"`
}

type AgentConversationRecord

type AgentConversationRecord struct {
	Conversation conversation.Conversation      `json:"conversation"`
	Link         conversation.AgentConversation `json:"link"`
	Pinned       bool                           `json:"pinned"`
	PinnedAt     time.Time                      `json:"pinned_at,omitempty"`
}

type AgentConversationTarget

type AgentConversationTarget struct {
	ID                 string    `json:"id"`
	TurnID             string    `json:"turn_id"`
	ConversationID     string    `json:"conversation_id"`
	AgentID            string    `json:"agent_id"`
	BehaviorRevisionID string    `json:"behavior_revision_id"`
	BindingRevisionID  string    `json:"binding_revision_id"`
	ParticipantID      string    `json:"participant_id"`
	RunID              string    `json:"run_id"`
	State              string    `json:"state"`
	AttemptCount       int       `json:"attempt_count"`
	CreatedAt          time.Time `json:"created_at"`
	UpdatedAt          time.Time `json:"updated_at"`
}

type AgentConversationTurn

type AgentConversationTurn struct {
	ID                   string    `json:"id"`
	ConversationID       string    `json:"conversation_id"`
	ClientTurnID         string    `json:"client_turn_id"`
	PromptMessageID      int64     `json:"prompt_message_id"`
	ThroughMessageID     int64     `json:"through_message_id"`
	MembershipRevisionID string    `json:"membership_revision_id"`
	ContextManifestID    string    `json:"context_manifest_id"`
	State                string    `json:"state"`
	CreatedAt            time.Time `json:"created_at"`
}

type AgentDirectChatRepository

AgentDirectChatRepository is the narrow stable-Agent chat ledger seam. The caller identifies only Fort-owned records; execution identity is resolved from the Agent's accepted revisions inside the write transaction.

type AgentLifecycleRepository

AgentLifecycleRepository adds explicit revision and Conversation lifecycle commands without widening the create/read contract used by migration code.

type AgentRebindPreview

type AgentRebindPreview struct {
	AccountID                string                            `json:"account_id"`
	AgentID                  string                            `json:"agent_id"`
	CurrentBinding           conversation.AgentBindingRevision `json:"current_binding"`
	CurrentExecutionSource   conversation.ExecutionSource      `json:"current_execution_source"`
	CurrentSourceAgent       conversation.SourceAgent          `json:"current_source_agent"`
	ProposedBinding          conversation.AgentBindingRevision `json:"proposed_binding"`
	ProposedExecutionSource  conversation.ExecutionSource      `json:"proposed_execution_source"`
	ProposedSourceAgent      conversation.SourceAgent          `json:"proposed_source_agent"`
	Participant              conversation.Participant          `json:"participant"`
	NonTransferableResources []RebindResource                  `json:"non_transferable_resources"`
	ReadinessEvidence        []string                          `json:"readiness_evidence"`
	AuthorityEvidence        []string                          `json:"authority_evidence"`
	GeneratedAt              time.Time                         `json:"generated_at"`
	Digest                   string                            `json:"digest"`
}

func (AgentRebindPreview) CalculateDigest

func (p AgentRebindPreview) CalculateDigest() (string, error)

func (AgentRebindPreview) Validate

func (p AgentRebindPreview) Validate() error

type AgentRecord

type AgentRecord struct {
	Agent           conversation.Agent                 `json:"agent"`
	Profile         conversation.AgentProfileRevision  `json:"profile"`
	Behavior        conversation.AgentBehaviorRevision `json:"behavior"`
	Binding         conversation.AgentBindingRevision  `json:"binding"`
	ExecutionSource conversation.ExecutionSource       `json:"execution_source"`
	SourceAgent     conversation.SourceAgent           `json:"source_agent"`
	Home            conversation.Conversation          `json:"home"`
	Participant     conversation.Participant           `json:"participant"`
	Link            conversation.AgentConversation     `json:"link"`
}

AgentRecord is the complete immutable evidence created with a stable Agent. Later commands may advance the Agent's current revision links, but never rewrite any revision returned here.

type AgentRepository

type AgentRepository interface {
	CreateAgent(context.Context, CreateAgentCommand) (AgentRecord, error)
	GetAgent(context.Context, string, string) (AgentRecord, error)
	ListAgents(context.Context, string, conversation.AgentState) ([]AgentRecord, error)
	Close() error
}

AgentRepository is implemented by both local SQLite and the cloud ledger. Lists must return an allocated empty slice rather than nil.

type AgentTurnDispatch

type AgentTurnDispatch struct {
	Message AgentConversationMessage `json:"message"`
	Turn    AgentConversationTurn    `json:"turn"`
	Context AgentContextManifest     `json:"context"`
	Target  AgentConversationTarget  `json:"target"`
	Created bool                     `json:"created"`
}

type AppendAgentBehaviorCommand

type AppendAgentBehaviorCommand struct {
	IdempotencyKey             string                             `json:"idempotency_key"`
	AccountID                  string                             `json:"account_id"`
	AgentID                    string                             `json:"agent_id"`
	ExpectedBehaviorRevisionID string                             `json:"expected_behavior_revision_id"`
	ExpectedBindingRevisionID  string                             `json:"expected_binding_revision_id"`
	Behavior                   conversation.AgentBehaviorRevision `json:"behavior"`
	Binding                    conversation.AgentBindingRevision  `json:"binding"`
	Participant                conversation.Participant           `json:"participant"`
	ReadinessEvidence          []string                           `json:"readiness_evidence"`
	AuthorityEvidence          []string                           `json:"authority_evidence"`
	AcceptedBy                 string                             `json:"accepted_by"`
	AcceptedAt                 time.Time                          `json:"accepted_at"`
}

AppendAgentBehaviorCommand accepts immutable Fort-owned behavior and an otherwise identical successor Binding. Execution changes require Rebind.

func (AppendAgentBehaviorCommand) Digest

func (c AppendAgentBehaviorCommand) Digest() (string, error)

func (AppendAgentBehaviorCommand) Validate

func (c AppendAgentBehaviorCommand) Validate() error

type AppendAgentProfileCommand

type AppendAgentProfileCommand struct {
	IdempotencyKey            string                            `json:"idempotency_key"`
	AccountID                 string                            `json:"account_id"`
	AgentID                   string                            `json:"agent_id"`
	ExpectedProfileRevisionID string                            `json:"expected_profile_revision_id"`
	Revision                  conversation.AgentProfileRevision `json:"revision"`
	AcceptedBy                string                            `json:"accepted_by"`
}

AppendAgentProfileCommand appends one presentation-only revision and moves the Agent's current profile pointer if and only if the expected revision is still current. It cannot alter execution identity.

func (AppendAgentProfileCommand) Digest

func (c AppendAgentProfileCommand) Digest() (string, error)

func (AppendAgentProfileCommand) Validate

func (c AppendAgentProfileCommand) Validate() error

type BindingTransitionKind

type BindingTransitionKind string
const (
	BindingTransitionBehavior BindingTransitionKind = "behavior"
	BindingTransitionRebind   BindingTransitionKind = "rebind"
)

type CancelAgentTargetCommand

type CancelAgentTargetCommand struct {
	IdempotencyKey string    `json:"idempotency_key"`
	AccountID      string    `json:"account_id"`
	AgentID        string    `json:"agent_id"`
	ConversationID string    `json:"conversation_id"`
	TargetID       string    `json:"target_id"`
	CanceledBy     string    `json:"canceled_by"`
	CanceledAt     time.Time `json:"canceled_at"`
}

func (CancelAgentTargetCommand) Digest

func (command CancelAgentTargetCommand) Digest() (string, error)

func (CancelAgentTargetCommand) Validate

func (command CancelAgentTargetCommand) Validate() error

type CancelHandoffCommand

type CancelHandoffCommand struct {
	IdempotencyKey string    `json:"idempotency_key"`
	AccountID      string    `json:"account_id"`
	HandoffID      string    `json:"handoff_id"`
	CanceledBy     string    `json:"canceled_by"`
	CanceledAt     time.Time `json:"canceled_at"`
}

CancelHandoffCommand records an owner's durable request against the one target already pinned by a Handoff. It never accepts a replacement target.

func (CancelHandoffCommand) Digest

func (c CancelHandoffCommand) Digest() (string, error)

func (CancelHandoffCommand) Validate

func (c CancelHandoffCommand) Validate() error

type CollaborationRepository

CollaborationRepository is the shared persistence seam for the first stable-Agent Group and Handoff slice. SQLite and Postgres implement the same account-scoped operations; list operations return allocated empty slices.

type CompleteHandoffCommand

type CompleteHandoffCommand struct {
	AccountID         string    `json:"account_id"`
	HandoffID         string    `json:"handoff_id"`
	IdempotencyKey    string    `json:"idempotency_key"`
	AuthorAgentID     string    `json:"author_agent_id"`
	AttemptID         string    `json:"attempt_id"`
	LeaseID           string    `json:"lease_id"`
	FenceToken        string    `json:"fence_token"`
	TerminalReceiptID string    `json:"terminal_receipt_id"`
	Body              string    `json:"body"`
	CreatedAt         time.Time `json:"created_at"`
}

func (CompleteHandoffCommand) Digest

func (c CompleteHandoffCommand) Digest() (string, error)

func (CompleteHandoffCommand) Validate

func (c CompleteHandoffCommand) Validate() error

type CreateAgentCommand

type CreateAgentCommand struct {
	IdempotencyKey  string                             `json:"idempotency_key"`
	Agent           conversation.Agent                 `json:"agent"`
	Profile         conversation.AgentProfileRevision  `json:"profile"`
	Behavior        conversation.AgentBehaviorRevision `json:"behavior"`
	Binding         conversation.AgentBindingRevision  `json:"binding"`
	ExecutionSource conversation.ExecutionSource       `json:"execution_source"`
	SourceAgent     conversation.SourceAgent           `json:"source_agent"`
	Home            conversation.Conversation          `json:"home"`
	Participant     conversation.Participant           `json:"participant"`
	Link            conversation.AgentConversation     `json:"link"`
}

CreateAgentCommand is the single atomic boundary for a new stable Agent and its permanent Home Conversation. IdempotencyKey is account-scoped.

func (CreateAgentCommand) Digest

func (c CreateAgentCommand) Digest() (string, error)

Digest returns the lowercase SHA-256 digest used for idempotent replay. It excludes the key itself and canonicalizes set-like evidence slices, so two logically identical commands have one digest without mutating caller data.

func (CreateAgentCommand) Validate

func (c CreateAgentCommand) Validate() error

Validate rejects an aggregate that could not be reconstructed without inference. In particular, every execution identity and the canonical Home evidence must agree before any durable row is written.

type CreateGroupCommand

type CreateGroupCommand struct {
	IdempotencyKey string                               `json:"idempotency_key"`
	Group          conversation.GroupConversation       `json:"group"`
	Conversation   conversation.Conversation            `json:"conversation"`
	Membership     conversation.GroupMembershipRevision `json:"membership"`
	MemberBindings []conversation.GroupRecipient        `json:"member_bindings"`
}

func (CreateGroupCommand) Digest

func (c CreateGroupCommand) Digest() (string, error)

func (CreateGroupCommand) Validate

func (c CreateGroupCommand) Validate() error

type CreateHumanHandoffCommand

type CreateHumanHandoffCommand struct {
	IdempotencyKey       string    `json:"idempotency_key"`
	AccountID            string    `json:"account_id"`
	SourceConversationID string    `json:"source_conversation_id"`
	SourceMessageID      string    `json:"source_message_id"`
	RecipientAgentID     string    `json:"recipient_agent_id"`
	ContextMessageIDs    []string  `json:"context_message_ids"`
	RequestedResult      string    `json:"requested_result"`
	ReplyToMessageID     string    `json:"reply_to_message_id,omitempty"`
	HardDeadline         time.Time `json:"hard_deadline"`

	HandoffID             string    `json:"handoff_id"`
	TargetID              string    `json:"target_id"`
	RootDelegationGrantID string    `json:"root_delegation_grant_id"`
	CreatedByID           string    `json:"created_by_id"`
	CreatedAt             time.Time `json:"created_at"`
}

CreateHumanHandoffCommand is the narrow owner-facing Handoff command. The first block is client-visible intent; Fort allocates every identity and receipt field in the second block. Digest deliberately excludes the latter so a network replay returns the originally accepted Handoff.

func (CreateHumanHandoffCommand) Digest

func (c CreateHumanHandoffCommand) Digest() (string, error)

func (CreateHumanHandoffCommand) Validate

func (c CreateHumanHandoffCommand) Validate() error

type CreateRoutineCommand

type CreateRoutineCommand struct {
	IdempotencyKey string                       `json:"idempotency_key"`
	Routine        conversation.Routine         `json:"routine"`
	Revision       conversation.RoutineRevision `json:"revision"`
}

func (CreateRoutineCommand) Digest

func (c CreateRoutineCommand) Digest() (string, error)

func (CreateRoutineCommand) Validate

func (c CreateRoutineCommand) Validate() error

type CreateSecondaryConversationCommand

type CreateSecondaryConversationCommand struct {
	IdempotencyKey string                         `json:"idempotency_key"`
	AccountID      string                         `json:"account_id"`
	AgentID        string                         `json:"agent_id"`
	Conversation   conversation.Conversation      `json:"conversation"`
	Link           conversation.AgentConversation `json:"link"`
	CreatedBy      string                         `json:"created_by"`
}

func (CreateSecondaryConversationCommand) Digest

func (CreateSecondaryConversationCommand) Validate

type EnqueueRoutineOccurrenceCommand

type EnqueueRoutineOccurrenceCommand struct {
	AccountID          string                      `json:"account_id"`
	RoutineID          string                      `json:"routine_id"`
	RoutineRevisionID  string                      `json:"routine_revision_id"`
	OccurrenceID       string                      `json:"occurrence_id"`
	RunID              string                      `json:"run_id"`
	Kind               conversation.RoutineRunKind `json:"kind"`
	ScheduledFor       time.Time                   `json:"scheduled_for"`
	IdempotencyKey     string                      `json:"idempotency_key"`
	ApprovalEvidenceID string                      `json:"approval_evidence_id"`
	CreatedAt          time.Time                   `json:"created_at"`
}

func (EnqueueRoutineOccurrenceCommand) Digest

func (EnqueueRoutineOccurrenceCommand) Validate

type ExecutionSourceConfigObservation

type ExecutionSourceConfigObservation struct {
	ID                 string    `json:"id"`
	Sequence           int64     `json:"sequence"`
	AccountID          string    `json:"account_id"`
	ExecutionSourceID  string    `json:"execution_source_id"`
	SourceConfigDigest string    `json:"source_config_digest"`
	ObservedBy         string    `json:"observed_by"`
	ObservedAt         time.Time `json:"observed_at"`
}

type ExecutionSourceConfigObservationRepository

type ExecutionSourceConfigObservationRepository interface {
	ObserveExecutionSourceConfig(context.Context, ObserveExecutionSourceConfigCommand) (ExecutionSourceConfigObservation, error)
	LatestExecutionSourceConfigObservation(context.Context, string, string) (ExecutionSourceConfigObservation, error)
}

ExecutionSourceConfigObservationRepository stores source-neutral inventory evidence separately from immutable accepted Bindings. Dispatch compares the latest append to the exact Binding pin and fails closed on drift.

type GroupRecord

type GroupRecord struct {
	Group          conversation.GroupConversation       `json:"group"`
	Conversation   conversation.Conversation            `json:"conversation"`
	Membership     conversation.GroupMembershipRevision `json:"membership"`
	MemberBindings []conversation.GroupRecipient        `json:"member_bindings"`
}

GroupRecord reconstructs a Group's current immutable membership and the exact participant/binding evidence accepted for that revision.

type GroupTurnRecord

type GroupTurnRecord struct {
	Message        conversation.Message           `json:"message"`
	Envelope       conversation.GroupTurnEnvelope `json:"envelope"`
	Recipients     []conversation.GroupRecipient  `json:"recipients"`
	InitialTargets []InitialTargetRecord          `json:"initial_targets"`
}

GroupTurnRecord is the atomic durable result of one human Group Send.

type HandoffAttemptRecord

type HandoffAttemptRecord struct {
	ID                string              `json:"id"`
	HandoffID         string              `json:"handoff_id"`
	LeaseID           string              `json:"lease_id"`
	MachineID         string              `json:"machine_id"`
	FenceToken        string              `json:"fence_token"`
	State             HandoffAttemptState `json:"state"`
	StartedAt         time.Time           `json:"started_at"`
	LeaseExpiresAt    time.Time           `json:"lease_expires_at"`
	TerminalReceiptID string              `json:"terminal_receipt_id,omitempty"`
	CompletedAt       time.Time           `json:"completed_at,omitempty"`
}

HandoffAttemptRecord is the exact leased execution evidence required before a Handoff can commit its one authoritative result.

type HandoffAttemptState

type HandoffAttemptState string
const (
	HandoffAttemptWorking   HandoffAttemptState = "working"
	HandoffAttemptCompleted HandoffAttemptState = "completed"
	HandoffAttemptFailed    HandoffAttemptState = "failed"
	HandoffAttemptCanceled  HandoffAttemptState = "canceled"
)

type HandoffCancellationRecord

type HandoffCancellationRecord struct {
	HandoffID          string                   `json:"handoff_id"`
	TargetID           string                   `json:"target_id"`
	AgentID            string                   `json:"agent_id"`
	BehaviorRevisionID string                   `json:"behavior_revision_id"`
	BindingRevisionID  string                   `json:"binding_revision_id"`
	ParticipantID      string                   `json:"participant_id"`
	State              HandoffCancellationState `json:"state"`
	RequestedBy        string                   `json:"requested_by"`
	RequestedAt        time.Time                `json:"requested_at"`
}

HandoffCancellationRecord is durable evidence that cancellation addressed the original target and exact accepted revision pins.

type HandoffCancellationState

type HandoffCancellationState string
const (
	HandoffCancellationRequested HandoffCancellationState = "requested"
	HandoffCancellationCanceled  HandoffCancellationState = "canceled"
)

type HandoffRecord

type HandoffRecord struct {
	Handoff      conversation.Handoff             `json:"handoff"`
	Target       HandoffTargetRecord              `json:"target"`
	Attempt      *HandoffAttemptRecord            `json:"attempt,omitempty"`
	Cancellation *HandoffCancellationRecord       `json:"cancellation,omitempty"`
	Projections  []conversation.HandoffProjection `json:"projections"`
	Result       *conversation.HandoffResult      `json:"result,omitempty"`
}

type HandoffTargetRecord

type HandoffTargetRecord struct {
	ID                 string                   `json:"id"`
	HandoffID          string                   `json:"handoff_id"`
	ConversationID     string                   `json:"conversation_id"`
	AgentID            string                   `json:"agent_id"`
	BehaviorRevisionID string                   `json:"behavior_revision_id"`
	BindingRevisionID  string                   `json:"binding_revision_id"`
	ParticipantID      string                   `json:"participant_id"`
	State              conversation.TargetState `json:"state"`
	CreatedAt          time.Time                `json:"created_at"`
}

type ImportRoutineCommand

type ImportRoutineCommand struct {
	Create  CreateRoutineCommand `json:"create"`
	Receipt RoutineImportReceipt `json:"receipt"`
}

func (ImportRoutineCommand) Digest

func (c ImportRoutineCommand) Digest() (string, error)

func (ImportRoutineCommand) Validate

func (c ImportRoutineCommand) Validate(projection SourceRoutineProjection) error

type InitialTargetRecord

type InitialTargetRecord struct {
	ID string `json:"id"`
	conversation.GroupInitialTarget
	State     conversation.TargetState `json:"state"`
	CreatedAt time.Time                `json:"created_at"`
}

InitialTargetRecord is one persisted wave-zero target. There is no repository command for creating a later reply wave.

type ObserveExecutionSourceConfigCommand

type ObserveExecutionSourceConfigCommand struct {
	IdempotencyKey     string    `json:"idempotency_key"`
	ObservationID      string    `json:"observation_id"`
	AccountID          string    `json:"account_id"`
	ExecutionSourceID  string    `json:"execution_source_id"`
	SourceConfigDigest string    `json:"source_config_digest"`
	ObservedBy         string    `json:"observed_by"`
	ObservedAt         time.Time `json:"observed_at"`
}

ObserveExecutionSourceConfigCommand accepts only Fort-owned opaque source identity and a digest. Provider, model, and machine selection are not part of this evidence command.

func (ObserveExecutionSourceConfigCommand) Digest

func (command ObserveExecutionSourceConfigCommand) Digest() (string, error)

func (ObserveExecutionSourceConfigCommand) Validate

func (command ObserveExecutionSourceConfigCommand) Validate() error

type PreviewAgentRebindCommand

type PreviewAgentRebindCommand struct {
	AccountID                 string                            `json:"account_id"`
	AgentID                   string                            `json:"agent_id"`
	ExpectedBindingRevisionID string                            `json:"expected_binding_revision_id"`
	Binding                   conversation.AgentBindingRevision `json:"binding"`
	ExecutionSource           conversation.ExecutionSource      `json:"execution_source"`
	SourceAgent               conversation.SourceAgent          `json:"source_agent"`
	Participant               conversation.Participant          `json:"participant"`
	NonTransferableResources  []RebindResource                  `json:"non_transferable_resources"`
	ReadinessEvidence         []string                          `json:"readiness_evidence"`
	AuthorityEvidence         []string                          `json:"authority_evidence"`
	GeneratedAt               time.Time                         `json:"generated_at"`
}

func (PreviewAgentRebindCommand) Validate

func (c PreviewAgentRebindCommand) Validate() error

type RebindResource

type RebindResource string
const (
	RebindResourceSourceMemory RebindResource = "source_managed_memory"
	RebindResourceSkills       RebindResource = "skills"
	RebindResourceSessions     RebindResource = "sessions"
	RebindResourceFiles        RebindResource = "files"
	RebindResourceToolState    RebindResource = "tool_state"
)

type RenameAgentConversationCommand

type RenameAgentConversationCommand struct {
	IdempotencyKey string    `json:"idempotency_key"`
	AccountID      string    `json:"account_id"`
	AgentID        string    `json:"agent_id"`
	ConversationID string    `json:"conversation_id"`
	ExpectedTitle  string    `json:"expected_title"`
	Title          string    `json:"title"`
	ChangedBy      string    `json:"changed_by"`
	ChangedAt      time.Time `json:"changed_at"`
}

RenameAgentConversationCommand changes only the presentation title of one secondary Conversation. ExpectedTitle provides an optimistic concurrency boundary; the permanent canonical Home is rejected by repositories.

func (RenameAgentConversationCommand) Digest

func (RenameAgentConversationCommand) Validate

type RenameGroupCommand

type RenameGroupCommand struct {
	IdempotencyKey string    `json:"idempotency_key"`
	AccountID      string    `json:"account_id"`
	GroupID        string    `json:"group_id"`
	ExpectedTitle  string    `json:"expected_title"`
	Title          string    `json:"title"`
	ChangedBy      string    `json:"changed_by"`
	ChangedAt      time.Time `json:"changed_at"`
}

RenameGroupCommand changes only the Group Conversation's presentation title. ExpectedTitle is the optimistic concurrency boundary supplied by the owner; every identity and audit field is allocated by Fort.

func (RenameGroupCommand) Digest

func (c RenameGroupCommand) Digest() (string, error)

func (RenameGroupCommand) Validate

func (c RenameGroupCommand) Validate() error

type ReplaceGroupMembersCommand

type ReplaceGroupMembersCommand struct {
	IdempotencyKey               string                               `json:"idempotency_key"`
	AccountID                    string                               `json:"account_id"`
	GroupID                      string                               `json:"group_id"`
	ExpectedMembershipRevisionID string                               `json:"expected_membership_revision_id"`
	Membership                   conversation.GroupMembershipRevision `json:"membership"`
	MemberBindings               []conversation.GroupRecipient        `json:"member_bindings"`
	ChangedBy                    string                               `json:"changed_by"`
	ChangedAt                    time.Time                            `json:"changed_at"`
}

ReplaceGroupMembersCommand appends one complete successor membership. The owner supplies only the expected predecessor and ordered stable Agent IDs; Fort resolves Membership, binding, and participant evidence before calling the repository.

func (ReplaceGroupMembersCommand) Digest

func (c ReplaceGroupMembersCommand) Digest() (string, error)

func (ReplaceGroupMembersCommand) Validate

func (c ReplaceGroupMembersCommand) Validate() error

type RetryAgentTargetCommand

type RetryAgentTargetCommand struct {
	IdempotencyKey string    `json:"idempotency_key"`
	AccountID      string    `json:"account_id"`
	AgentID        string    `json:"agent_id"`
	ConversationID string    `json:"conversation_id"`
	TargetID       string    `json:"target_id"`
	RetriedBy      string    `json:"retried_by"`
	RetriedAt      time.Time `json:"retried_at"`
}

func (RetryAgentTargetCommand) Digest

func (command RetryAgentTargetCommand) Digest() (string, error)

func (RetryAgentTargetCommand) Validate

func (command RetryAgentTargetCommand) Validate() error

type RevalidateRoutineCommand

type RevalidateRoutineCommand struct {
	AccountID      string                       `json:"account_id"`
	RoutineID      string                       `json:"routine_id"`
	IdempotencyKey string                       `json:"idempotency_key"`
	Revision       conversation.RoutineRevision `json:"revision"`
}

RevalidateRoutineCommand appends one successor Routine Revision after an Agent Behavior or Binding change. It never rewrites the prior revision.

func (RevalidateRoutineCommand) Digest

func (c RevalidateRoutineCommand) Digest() (string, error)

func (RevalidateRoutineCommand) Validate

func (c RevalidateRoutineCommand) Validate(record RoutineRecord) error

type RoutineImportReceipt

type RoutineImportReceipt struct {
	ID                          string    `json:"id"`
	AccountID                   string    `json:"account_id"`
	SourceRoutineProjectionID   string    `json:"source_routine_projection_id"`
	RoutineID                   string    `json:"routine_id"`
	RoutineRevisionID           string    `json:"routine_revision_id"`
	SourceDisabledAt            time.Time `json:"source_disabled_at"`
	ExactLastSourceOccurrenceAt time.Time `json:"exact_last_source_occurrence_at,omitempty"`
	ExactNextSourceOccurrenceAt time.Time `json:"exact_next_source_occurrence_at,omitempty"`
	FencingReceiptCiphertext    []byte    `json:"fencing_receipt_ciphertext"`
	FencingReceiptKeyID         string    `json:"fencing_receipt_key_id"`
	FencingReceiptNonce         []byte    `json:"fencing_receipt_nonce"`
	FencingReceiptDigest        string    `json:"fencing_receipt_digest"`
	ImportedAt                  time.Time `json:"imported_at"`
}

RoutineImportReceipt proves source-native scheduling was disabled before Fort assumed fort_cloud authority.

func (RoutineImportReceipt) Validate

func (r RoutineImportReceipt) Validate() error

type RoutineOccurrence

type RoutineOccurrence struct {
	ID                 string                       `json:"id"`
	AccountID          string                       `json:"account_id"`
	RoutineID          string                       `json:"routine_id"`
	RoutineRevisionID  string                       `json:"routine_revision_id"`
	Kind               conversation.RoutineRunKind  `json:"kind"`
	State              conversation.RoutineRunState `json:"state"`
	ScheduledFor       time.Time                    `json:"scheduled_for"`
	IdempotencyKey     string                       `json:"idempotency_key"`
	ApprovalEvidenceID string                       `json:"approval_evidence_id"`
	CreatedAt          time.Time                    `json:"created_at"`
	UpdatedAt          time.Time                    `json:"updated_at"`
}

RoutineOccurrence is the exact idempotent trigger materialization used by scheduled and Test Routine requests alike.

type RoutinePauseReason

type RoutinePauseReason string
const RoutinePauseNeedsRevalidation RoutinePauseReason = "needs_revalidation"

type RoutineRecord

type RoutineRecord struct {
	Routine         conversation.Routine         `json:"routine"`
	CurrentRevision conversation.RoutineRevision `json:"current_revision"`
	PauseReason     RoutinePauseReason           `json:"pause_reason,omitempty"`
	ImportReceipt   *RoutineImportReceipt        `json:"import_receipt,omitempty"`
}

RoutineRecord is the complete current read model for one Agent-owned Routine. Revisions and import receipts remain append-only.

type RoutineRepository

RoutineRepository is the shared SQLite/Postgres persistence seam for Agent-owned Routines. List operations return allocated empty slices.

type RoutineRunActivity

type RoutineRunActivity struct {
	Sequence       int64                        `json:"sequence"`
	State          conversation.RoutineRunState `json:"state"`
	AttemptID      string                       `json:"attempt_id,omitempty"`
	LeaseID        string                       `json:"lease_id,omitempty"`
	LeaseExpiresAt time.Time                    `json:"lease_expires_at,omitempty"`
	Activity       string                       `json:"activity"`
	FailureCode    string                       `json:"failure_code,omitempty"`
	NextAction     string                       `json:"next_action,omitempty"`
	CreatedAt      time.Time                    `json:"created_at"`
}

RoutineRunActivity is append-only attempt, lease, failure, and next-action evidence for one run transition.

type RoutineRunRecord

type RoutineRunRecord struct {
	Occurrence           RoutineOccurrence       `json:"occurrence"`
	Run                  conversation.RoutineRun `json:"run"`
	ResultConversationID string                  `json:"result_conversation_id"`
	AttemptID            string                  `json:"attempt_id,omitempty"`
	LeaseID              string                  `json:"lease_id,omitempty"`
	LeaseExpiresAt       time.Time               `json:"lease_expires_at,omitempty"`
	FailureCode          string                  `json:"failure_code,omitempty"`
	NextAction           string                  `json:"next_action,omitempty"`
	Activities           []RoutineRunActivity    `json:"activities"`
}

type SendAgentTurnCommand

type SendAgentTurnCommand struct {
	IdempotencyKey    string    `json:"idempotency_key"`
	AccountID         string    `json:"account_id"`
	AgentID           string    `json:"agent_id"`
	ConversationID    string    `json:"conversation_id"`
	TurnID            string    `json:"turn_id"`
	ClientTurnID      string    `json:"client_turn_id"`
	ContextManifestID string    `json:"context_manifest_id"`
	DelegationGrantID string    `json:"delegation_grant_id"`
	TargetID          string    `json:"target_id"`
	RunID             string    `json:"run_id"`
	HumanID           string    `json:"human_id"`
	Body              string    `json:"body"`
	CreatedBy         string    `json:"created_by"`
	CreatedAt         time.Time `json:"created_at"`
	HardDeadline      time.Time `json:"hard_deadline"`
}

SendAgentTurnCommand contains no provider, model, machine, participant, or revision choice. Those are deliberately not client-selectable on ordinary Send and are pinned from the current Agent aggregate by the repository.

func (SendAgentTurnCommand) Digest

func (command SendAgentTurnCommand) Digest() (string, error)

func (SendAgentTurnCommand) Validate

func (command SendAgentTurnCommand) Validate() error

type SendGroupTurnCommand

type SendGroupTurnCommand struct {
	AccountID string                         `json:"account_id"`
	HumanID   string                         `json:"human_id"`
	Body      string                         `json:"body"`
	Envelope  conversation.GroupTurnEnvelope `json:"envelope"`
	TargetIDs []string                       `json:"target_ids"`
}

func (SendGroupTurnCommand) Digest

func (c SendGroupTurnCommand) Digest() (string, error)

func (SendGroupTurnCommand) Validate

type SetAgentConversationPinCommand

type SetAgentConversationPinCommand struct {
	IdempotencyKey string    `json:"idempotency_key"`
	AccountID      string    `json:"account_id"`
	AgentID        string    `json:"agent_id"`
	ConversationID string    `json:"conversation_id"`
	ExpectedPinned bool      `json:"expected_pinned"`
	Pinned         bool      `json:"pinned"`
	ChangedBy      string    `json:"changed_by"`
	ChangedAt      time.Time `json:"changed_at"`
}

func (SetAgentConversationPinCommand) Digest

func (SetAgentConversationPinCommand) Validate

type SetAgentConversationStateCommand

type SetAgentConversationStateCommand struct {
	IdempotencyKey string                         `json:"idempotency_key"`
	AccountID      string                         `json:"account_id"`
	AgentID        string                         `json:"agent_id"`
	ConversationID string                         `json:"conversation_id"`
	ExpectedState  conversation.ConversationState `json:"expected_state"`
	State          conversation.ConversationState `json:"state"`
	ChangedBy      string                         `json:"changed_by"`
	ChangedAt      time.Time                      `json:"changed_at"`
}

func (SetAgentConversationStateCommand) Digest

func (SetAgentConversationStateCommand) Validate

type SetGroupStateCommand

type SetGroupStateCommand struct {
	IdempotencyKey string                         `json:"idempotency_key"`
	AccountID      string                         `json:"account_id"`
	GroupID        string                         `json:"group_id"`
	ExpectedState  conversation.ConversationState `json:"expected_state"`
	State          conversation.ConversationState `json:"state"`
	ChangedBy      string                         `json:"changed_by"`
	ChangedAt      time.Time                      `json:"changed_at"`
}

SetGroupStateCommand archives or reopens one Group without changing its stable identity, Conversation, or current membership revision.

func (SetGroupStateCommand) Digest

func (c SetGroupStateCommand) Digest() (string, error)

func (SetGroupStateCommand) Validate

func (c SetGroupStateCommand) Validate() error

type SourceRoutineProjection

type SourceRoutineProjection struct {
	ID                    string          `json:"id"`
	AccountID             string          `json:"account_id"`
	ExecutionSourceID     string          `json:"execution_source_id"`
	OpaqueSourceRoutineID string          `json:"opaque_source_routine_id"`
	ProjectionRevision    int             `json:"projection_revision"`
	ScheduleSnapshot      json.RawMessage `json:"schedule_snapshot"`
	ProjectionDigest      string          `json:"projection_digest"`
	LastOccurrenceAt      time.Time       `json:"last_occurrence_at,omitempty"`
	NextOccurrenceAt      time.Time       `json:"next_occurrence_at,omitempty"`
	ObservedAt            time.Time       `json:"observed_at"`
}

SourceRoutineProjection is immutable read-only evidence of one framework- native schedule observation. It is not an executable Fort Routine.

func (SourceRoutineProjection) Validate

func (p SourceRoutineProjection) Validate() error

type StartHandoffCommand

type StartHandoffCommand struct {
	AccountID      string    `json:"account_id"`
	HandoffID      string    `json:"handoff_id"`
	IdempotencyKey string    `json:"idempotency_key"`
	AttemptID      string    `json:"attempt_id"`
	LeaseID        string    `json:"lease_id"`
	MachineID      string    `json:"machine_id"`
	FenceToken     string    `json:"fence_token"`
	StartedAt      time.Time `json:"started_at"`
	LeaseExpiresAt time.Time `json:"lease_expires_at"`
}

func (StartHandoffCommand) Digest

func (c StartHandoffCommand) Digest() (string, error)

func (StartHandoffCommand) Validate

func (c StartHandoffCommand) Validate() error

Jump to

Keyboard shortcuts

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