Documentation
¶
Overview ¶
Package sessiontree stores durable conversation journals.
Repo implementations own thread metadata, append-only entries, forks, leaf movement, and provider-visible context reconstruction. FileRepo and MemoryRepo are safe for concurrent use. Repos used by agentharness should implement TurnLeaseRepo so active-turn serialization is durable per ThreadID and shared across harness instances that use the same backend. Different ThreadIDs, including forked threads, may run concurrently.
Index ¶
- Constants
- Variables
- func BuildContext(path []Entry, opts ContextOptions) []session.Message
- func BuildContextChecked(path []Entry, opts ContextOptions) ([]session.Message, error)
- func CanonicalEffectAttemptID(inv EffectInvocationIdentity) string
- func EffectResultRequestMatches(committed, requested Entry, effectAttemptID string) bool
- func MatchesForkDestinationMeta(meta ThreadMeta, destination *ForkDestinationMeta) bool
- func RawForEntry(entry Entry) string
- func RetryPathHasRetryEligibleDurableInput(path []Entry) (bool, error)
- func RetrySourceHasRetryEligibleDurableInput(path []Entry, sourceTurnID, sourceEntryID string) (int, bool, error)
- func SameThreadAuthority(left, right ThreadMeta) bool
- func SameThreadTitleState(left, right ThreadMeta) bool
- func SortThreadsByCreatedAtDesc(threads []ThreadMeta)
- func StableHash(value string) string
- func SubAgentUserMessageOrigin(kind SubAgentRequestKind) (string, error)
- func ThreadAuthorityTreeIDs(threads []ThreadMeta, rootThreadID string) ([]string, error)
- func TurnAcceptanceRequestFingerprint(req AcceptTurnRequest) (string, error)
- func ValidTurnFailureCode(code string) bool
- func ValidateAcceptTurnReplayRequest(req AcceptTurnRequest) error
- func ValidateAcceptTurnRequest(req AcceptTurnRequest) error
- func ValidateAcceptTurnRequestEnvelope(req AcceptTurnRequest) error
- func ValidateAgentTodoItems(items []AgentTodoItem) error
- func ValidateBeginAutomaticThreadTitleRequest(req BeginAutomaticThreadTitleRequest) error
- func ValidateCancelTurnRequest(req CancelTurnRequest) error
- func ValidateCanonicalThreadTitle(title string) error
- func ValidateCanonicalTurnEntries(entries []Entry, threadID, turnID, runID string) error
- func ValidateCanonicalTurnReadStructure(turn CanonicalTurn, threadID string) error
- func ValidateCompleteAutomaticThreadTitleRequest(req CompleteAutomaticThreadTitleRequest) error
- func ValidateEntryIntegrity(entry Entry) error
- func ValidateEntryMessageAttachments(entry Entry) error
- func ValidateEntryMessageReferences(entry Entry) error
- func ValidateFailAutomaticThreadTitleRequest(req FailAutomaticThreadTitleRequest) error
- func ValidateFinishTurnRequest(req FinishTurnRequest) error
- func ValidateListCanonicalTurnsOptions(opts ListCanonicalTurnsOptions) error
- func ValidateNewEntryMessageAttachments(entry Entry) error
- func ValidateRetrySourcePath(path []Entry, sourceTurnID, sourceEntryID string) (int, error)
- func ValidateRetryStartedEntry(entry Entry, threadID, turnID, runID, startedEntryID string, ...) error
- func ValidateSetThreadTitleRequest(req SetThreadTitleRequest) error
- func ValidateThreadAuthorityGraph(threads []ThreadMeta) error
- func ValidateThreadMetaAuthority(meta ThreadMeta) error
- func ValidateThreadTitleProjection(projection ThreadTitleProjection) error
- func ValidateThreadTitleState(meta ThreadMeta) error
- type AcceptTurnRequest
- type AcceptTurnResult
- type AgentTodoItem
- type AgentTodoState
- type AgentTodoStateRepo
- type AgentTodoStatus
- type AppendCommittedError
- type AppendOptions
- type ArtifactAuthorityRepo
- type ArtifactClosureRequest
- type ArtifactContent
- type ArtifactReadRequest
- type BackendRepo
- func (repo *BackendRepo) AcceptTurn(ctx context.Context, request AcceptTurnRequest) (result AcceptTurnResult, err error)
- func (repo *BackendRepo) Append(ctx context.Context, entry Entry, opts AppendOptions) (Entry, error)
- func (repo *BackendRepo) AppendRuntimeFacts(ctx context.Context, threadID string, entries []Entry) ([]Entry, error)
- func (repo *BackendRepo) ArtifactClosure(ctx context.Context, req ArtifactClosureRequest) (artifact.Closure, error)
- func (repo *BackendRepo) BeginAutomaticThreadTitle(ctx context.Context, req BeginAutomaticThreadTitleRequest) (ThreadTitleMutationResult, error)
- func (repo *BackendRepo) BeginEffectDispatch(ctx context.Context, req BeginEffectDispatchRequest) (EffectAttempt, error)
- func (repo *BackendRepo) CancelTurn(ctx context.Context, req CancelTurnRequest) (CancelTurnResult, error)
- func (repo *BackendRepo) CanonicalTurnEntries(ctx context.Context, threadID, turnID, runID string) ([]Entry, bool, error)
- func (repo *BackendRepo) Checkpoint(ctx context.Context) error
- func (repo *BackendRepo) CheckpointDomain(ctx context.Context, checkpoint func(spi.WriteTx) error) error
- func (repo *BackendRepo) CheckpointDomainUpdate(ctx context.Context, mutate func(*MemoryRepo, spi.WriteTx) error) error
- func (repo *BackendRepo) ClaimEffectRetry(ctx context.Context, req ClaimEffectRetryRequest) (ClaimEffectRetryResult, error)
- func (repo *BackendRepo) CompareAndSwapAgentTodoState(ctx context.Context, state AgentTodoState, expectedVersion int64) (AgentTodoState, error)
- func (repo *BackendRepo) CompleteAutomaticThreadTitle(ctx context.Context, req CompleteAutomaticThreadTitleRequest) (ThreadTitleMutationResult, error)
- func (repo *BackendRepo) CreateThread(ctx context.Context, meta ThreadMeta) (ThreadMeta, error)
- func (repo *BackendRepo) CreateThreadWithInitialEntry(ctx context.Context, meta ThreadMeta, initial Entry) (ThreadMeta, Entry, error)
- func (repo *BackendRepo) DeleteProviderState(ctx context.Context, threadID string) error
- func (repo *BackendRepo) DeleteRootTree(ctx context.Context, rootThreadID string) (DeleteRootTreeResult, error)
- func (repo *BackendRepo) DeleteRootTreeWithRequest(ctx context.Context, rootThreadID, requestKey, fingerprint string) (DeleteRootTreeResult, error)
- func (repo *BackendRepo) EffectAttempt(ctx context.Context, threadID, attemptID string) (EffectAttempt, error)
- func (repo *BackendRepo) Entries(ctx context.Context, threadID string) ([]Entry, error)
- func (repo *BackendRepo) Entry(ctx context.Context, threadID, entryID string) (Entry, error)
- func (repo *BackendRepo) FailAutomaticThreadTitle(ctx context.Context, req FailAutomaticThreadTitleRequest) (ThreadTitleMutationResult, error)
- func (repo *BackendRepo) FinishEffectDispatch(ctx context.Context, req FinishEffectDispatchRequest) (FinishEffectDispatchResult, error)
- func (repo *BackendRepo) FinishTurn(ctx context.Context, req FinishTurnRequest) (FinishTurnResult, error)
- func (repo *BackendRepo) Fork(ctx context.Context, opts ForkOptions) (ThreadMeta, error)
- func (repo *BackendRepo) ForkWithInitialEntry(ctx context.Context, opts ForkOptions, initial Entry) (ThreadMeta, Entry, error)
- func (repo *BackendRepo) ListCanonicalTurns(ctx context.Context, opts ListCanonicalTurnsOptions) (CanonicalTurnsPage, error)
- func (repo *BackendRepo) ListRootThreadInventory(ctx context.Context, opts ListThreadsOptions) ([]RootThreadInventoryItem, error)
- func (repo *BackendRepo) ListThreads(ctx context.Context, opts ListThreadsOptions) ([]ThreadMeta, error)
- func (repo *BackendRepo) MarkEffectUnknown(ctx context.Context, req MarkEffectUnknownRequest) (EffectAttempt, error)
- func (repo *BackendRepo) MoveLeaf(ctx context.Context, threadID, entryID string) error
- func (repo *BackendRepo) Path(ctx context.Context, threadID, leafID string) ([]Entry, error)
- func (repo *BackendRepo) PathPage(ctx context.Context, threadID, leafID, beforeEntryID string, limit int) (PathPage, error)
- func (repo *BackendRepo) PendingAutomaticThreadTitles(ctx context.Context) ([]ThreadMeta, error)
- func (repo *BackendRepo) PrepareEffectAttempt(ctx context.Context, req PrepareEffectAttemptRequest) (PrepareEffectAttemptResult, error)
- func (repo *BackendRepo) ProviderState(ctx context.Context, threadID string) (ProviderStateRecord, error)
- func (repo *BackendRepo) PutProviderState(ctx context.Context, record ProviderStateRecord) error
- func (repo *BackendRepo) ReadAcceptedTurn(ctx context.Context, threadID, turnID, runID string) (AcceptTurnResult, bool, error)
- func (repo *BackendRepo) ReadAgentTodoState(ctx context.Context, threadID string) (AgentTodoState, error)
- func (repo *BackendRepo) ReadArtifact(ctx context.Context, req ArtifactReadRequest) (ArtifactContent, error)
- func (repo *BackendRepo) ReadCanonicalTurn(ctx context.Context, threadID, turnID string) (CanonicalTurnRead, error)
- func (repo *BackendRepo) RejectEffectAttempt(ctx context.Context, req RejectEffectAttemptRequest) (EffectAttempt, error)
- func (repo *BackendRepo) SetThreadTitle(ctx context.Context, req SetThreadTitleRequest) (ThreadTitleMutationResult, error)
- func (repo *BackendRepo) Thread(ctx context.Context, threadID string) (ThreadMeta, error)
- func (repo *BackendRepo) ThreadOrigin(ctx context.Context, requestKey string) (ThreadOrigin, error)
- func (repo *BackendRepo) ThreadTombstone(ctx context.Context, threadID string) (ThreadTombstone, error)
- func (repo *BackendRepo) UpdateDomain(ctx context.Context, mutate func(*MemoryRepo, spi.WriteTx) error) error
- func (repo *BackendRepo) UpdateThread(ctx context.Context, meta ThreadMeta) error
- func (repo *BackendRepo) ValidateArtifactForkDestination(ctx context.Context, closure artifact.Closure) error
- func (repo *BackendRepo) VerifyCurrentStateInTransaction(ctx context.Context, tx spi.ReadTx) error
- func (repo *BackendRepo) ViewDomain(ctx context.Context, read func(*MemoryRepo, spi.ReadTx) error) error
- func (repo *BackendRepo) ViewDomainWithRecords(ctx context.Context, read func(*MemoryRepo, spi.ReadTx) error) error
- type BeginAutomaticThreadTitleRequest
- type BeginEffectDispatchRequest
- type CancelTurnRequest
- type CancelTurnResult
- type CanonicalTurn
- type CanonicalTurnBeforeCursor
- type CanonicalTurnPageRepo
- type CanonicalTurnPathEntry
- type CanonicalTurnRead
- type CanonicalTurnReadRepo
- type CanonicalTurnRepo
- type CanonicalTurnRetrySource
- type CanonicalTurnSinceCursor
- type CanonicalTurnsPage
- type ClaimEffectRetryRequest
- type ClaimEffectRetryResult
- type CompleteAutomaticThreadTitleRequest
- type ContextOptions
- type ContextProjection
- type ContextProjectionOptions
- type DeleteRootTreeResult
- type EffectAttempt
- type EffectAttemptReader
- type EffectAttemptRepo
- type EffectAttemptState
- type EffectInvocationIdentity
- type EffectRetryRepo
- type Entry
- func AppendActiveTools(ctx context.Context, repo JournalRepo, threadID string, ...) (Entry, error)
- func AppendCompaction(ctx context.Context, repo JournalRepo, threadID, turnID string, ...) (Entry, error)
- func AppendFailure(ctx context.Context, repo JournalRepo, threadID, turnID string, message string) (Entry, error)
- func AppendMessage(ctx context.Context, repo JournalRepo, threadID, turnID string, ...) (Entry, error)
- func AppendMessageAt(ctx context.Context, repo JournalRepo, threadID, turnID string, ...) (Entry, error)
- func AppendRunMessage(ctx context.Context, repo JournalRepo, threadID, turnID, runID string, ...) (Entry, error)
- func AppendRunMessageAt(ctx context.Context, repo JournalRepo, threadID, turnID, runID string, ...) (Entry, error)
- func AppendTurnMarker(ctx context.Context, repo JournalRepo, threadID, turnID string, ...) (Entry, error)
- func AppendTurnMarkerWithID(ctx context.Context, repo JournalRepo, threadID, turnID, entryID string, ...) (Entry, error)
- func CanonicalEffectAttemptEntry(attempt EffectAttempt, parentID string) (Entry, error)
- func CanonicalTurnEntriesForRead(entries []Entry) []Entry
- func CompactionEntry(threadID, turnID string, result compaction.Result) (Entry, error)
- func PrepareBranchBoundaryEntry(path []Entry, threadID, parentEntryID, entryID, reason string, now time.Time) (Entry, error)
- func PrepareEntry(entry Entry) Entry
- type EntryType
- type FailAutomaticThreadTitleRequest
- type FileRepo
- func (r *FileRepo) Append(ctx context.Context, entry Entry, opts AppendOptions) (Entry, error)
- func (r *FileRepo) ArtifactClosure(context.Context, ArtifactClosureRequest) (artifact.Closure, error)
- func (r *FileRepo) BeginAutomaticThreadTitle(ctx context.Context, req BeginAutomaticThreadTitleRequest) (ThreadTitleMutationResult, error)
- func (r *FileRepo) CanonicalTurnEntries(ctx context.Context, threadID, turnID, runID string) ([]Entry, bool, error)
- func (r *FileRepo) CompareAndSwapAgentTodoState(ctx context.Context, state AgentTodoState, expectedVersion int64) (AgentTodoState, error)
- func (r *FileRepo) CompleteAutomaticThreadTitle(ctx context.Context, req CompleteAutomaticThreadTitleRequest) (ThreadTitleMutationResult, error)
- func (r *FileRepo) CreateThread(ctx context.Context, meta ThreadMeta) (ThreadMeta, error)
- func (r *FileRepo) Entries(ctx context.Context, threadID string) ([]Entry, error)
- func (r *FileRepo) Entry(ctx context.Context, threadID, entryID string) (Entry, error)
- func (r *FileRepo) FailAutomaticThreadTitle(ctx context.Context, req FailAutomaticThreadTitleRequest) (ThreadTitleMutationResult, error)
- func (r *FileRepo) Fork(ctx context.Context, opts ForkOptions) (ThreadMeta, error)
- func (r *FileRepo) ListCanonicalTurns(ctx context.Context, opts ListCanonicalTurnsOptions) (CanonicalTurnsPage, error)
- func (r *FileRepo) ListThreads(ctx context.Context, opts ListThreadsOptions) ([]ThreadMeta, error)
- func (r *FileRepo) MoveLeaf(ctx context.Context, threadID, entryID string) error
- func (r *FileRepo) Path(ctx context.Context, threadID, leafID string) ([]Entry, error)
- func (r *FileRepo) PathPage(ctx context.Context, threadID, leafID, beforeEntryID string, limit int) (PathPage, error)
- func (r *FileRepo) PendingAutomaticThreadTitles(ctx context.Context) ([]ThreadMeta, error)
- func (r *FileRepo) ReadAgentTodoState(ctx context.Context, threadID string) (AgentTodoState, error)
- func (r *FileRepo) ReadArtifact(context.Context, ArtifactReadRequest) (ArtifactContent, error)
- func (r *FileRepo) SetThreadTitle(ctx context.Context, req SetThreadTitleRequest) (ThreadTitleMutationResult, error)
- func (r *FileRepo) Thread(ctx context.Context, threadID string) (ThreadMeta, error)
- func (r *FileRepo) UpdateThread(ctx context.Context, meta ThreadMeta) error
- type FinishEffectDispatchRequest
- type FinishEffectDispatchResult
- type FinishTurnRequest
- type FinishTurnResult
- type ForkDestinationMeta
- type ForkEntryIdentity
- type ForkOptions
- type ForkPosition
- type JournalRepo
- type LeasePolicy
- type ListCanonicalTurnsOptions
- type ListThreadsOptions
- type MarkEffectUnknownRequest
- type MemoryRepo
- func (r *MemoryRepo) AcceptTurn(_ context.Context, req AcceptTurnRequest) (AcceptTurnResult, error)
- func (r *MemoryRepo) Append(ctx context.Context, entry Entry, opts AppendOptions) (Entry, error)
- func (r *MemoryRepo) AppendRuntimeFacts(ctx context.Context, threadID string, entries []Entry) ([]Entry, error)
- func (r *MemoryRepo) ArtifactClosure(_ context.Context, req ArtifactClosureRequest) (artifact.Closure, error)
- func (r *MemoryRepo) BeginAutomaticThreadTitle(ctx context.Context, req BeginAutomaticThreadTitleRequest) (ThreadTitleMutationResult, error)
- func (r *MemoryRepo) BeginEffectDispatch(_ context.Context, req BeginEffectDispatchRequest) (EffectAttempt, error)
- func (r *MemoryRepo) CancelTurn(ctx context.Context, req CancelTurnRequest) (CancelTurnResult, error)
- func (r *MemoryRepo) CanonicalTurnEntries(_ context.Context, threadID, turnID, runID string) ([]Entry, bool, error)
- func (r *MemoryRepo) ClaimEffectRetry(_ context.Context, req ClaimEffectRetryRequest) (ClaimEffectRetryResult, error)
- func (r *MemoryRepo) CompareAndSwapAgentTodoState(ctx context.Context, state AgentTodoState, expectedVersion int64) (AgentTodoState, error)
- func (r *MemoryRepo) CompleteAutomaticThreadTitle(ctx context.Context, req CompleteAutomaticThreadTitleRequest) (ThreadTitleMutationResult, error)
- func (r *MemoryRepo) CreateThread(_ context.Context, meta ThreadMeta) (ThreadMeta, error)
- func (r *MemoryRepo) CreateThreadWithInitialEntry(ctx context.Context, meta ThreadMeta, initial Entry) (ThreadMeta, Entry, error)
- func (r *MemoryRepo) DeleteProviderState(_ context.Context, threadID string) error
- func (r *MemoryRepo) DeleteRootTree(_ context.Context, rootThreadID string) (DeleteRootTreeResult, error)
- func (r *MemoryRepo) DeleteRootTreeWithRequest(_ context.Context, rootThreadID, requestKey, fingerprint string) (DeleteRootTreeResult, error)
- func (r *MemoryRepo) EffectAttempt(_ context.Context, threadID, attemptID string) (EffectAttempt, error)
- func (repo *MemoryRepo) EncodeMemoryState() ([]byte, error)
- func (r *MemoryRepo) Entries(_ context.Context, threadID string) ([]Entry, error)
- func (r *MemoryRepo) Entry(_ context.Context, threadID, entryID string) (Entry, error)
- func (r *MemoryRepo) FailAutomaticThreadTitle(ctx context.Context, req FailAutomaticThreadTitleRequest) (ThreadTitleMutationResult, error)
- func (r *MemoryRepo) FinishEffectDispatch(_ context.Context, req FinishEffectDispatchRequest) (FinishEffectDispatchResult, error)
- func (r *MemoryRepo) FinishTurn(_ context.Context, req FinishTurnRequest) (FinishTurnResult, error)
- func (r *MemoryRepo) Fork(ctx context.Context, opts ForkOptions) (ThreadMeta, error)
- func (r *MemoryRepo) ForkWithInitialEntry(ctx context.Context, opts ForkOptions, initial Entry) (ThreadMeta, Entry, error)
- func (r *MemoryRepo) ListCanonicalTurns(_ context.Context, opts ListCanonicalTurnsOptions) (CanonicalTurnsPage, error)
- func (r *MemoryRepo) ListRootThreadInventory(_ context.Context, opts ListThreadsOptions) ([]RootThreadInventoryItem, error)
- func (r *MemoryRepo) ListThreads(_ context.Context, opts ListThreadsOptions) ([]ThreadMeta, error)
- func (r *MemoryRepo) MarkEffectUnknown(_ context.Context, req MarkEffectUnknownRequest) (EffectAttempt, error)
- func (r *MemoryRepo) MoveLeaf(_ context.Context, threadID, entryID string) error
- func (r *MemoryRepo) Path(_ context.Context, threadID, leafID string) ([]Entry, error)
- func (r *MemoryRepo) PathPage(_ context.Context, threadID, leafID, beforeEntryID string, limit int) (PathPage, error)
- func (r *MemoryRepo) PendingAutomaticThreadTitles(_ context.Context) ([]ThreadMeta, error)
- func (r *MemoryRepo) PrepareEffectAttempt(_ context.Context, req PrepareEffectAttemptRequest) (PrepareEffectAttemptResult, error)
- func (r *MemoryRepo) ProviderState(_ context.Context, threadID string) (ProviderStateRecord, error)
- func (r *MemoryRepo) PutProviderState(_ context.Context, record ProviderStateRecord) error
- func (r *MemoryRepo) ReadAcceptedTurn(_ context.Context, threadID, turnID, runID string) (AcceptTurnResult, bool, error)
- func (r *MemoryRepo) ReadAgentTodoState(_ context.Context, threadID string) (AgentTodoState, error)
- func (r *MemoryRepo) ReadArtifact(_ context.Context, req ArtifactReadRequest) (ArtifactContent, error)
- func (r *MemoryRepo) ReadCanonicalTurn(_ context.Context, threadID, turnID string) (CanonicalTurnRead, error)
- func (r *MemoryRepo) RejectEffectAttempt(_ context.Context, req RejectEffectAttemptRequest) (EffectAttempt, error)
- func (r *MemoryRepo) SetThreadTitle(ctx context.Context, req SetThreadTitleRequest) (ThreadTitleMutationResult, error)
- func (r *MemoryRepo) Thread(_ context.Context, threadID string) (ThreadMeta, error)
- func (r *MemoryRepo) ThreadOrigin(_ context.Context, requestKey string) (ThreadOrigin, error)
- func (r *MemoryRepo) ThreadTombstone(_ context.Context, threadID string) (ThreadTombstone, error)
- func (r *MemoryRepo) UpdateThread(ctx context.Context, meta ThreadMeta) error
- func (r *MemoryRepo) ValidateArtifactForkDestination(_ context.Context, closure artifact.Closure) error
- type PathPage
- type PendingToolSettlementTarget
- type PrepareEffectAttemptRequest
- type PrepareEffectAttemptResult
- type ProjectedSegment
- type ProjectionPurpose
- type ProviderStateReader
- type ProviderStateRecord
- type ProviderStateStore
- type RejectEffectAttemptRequest
- type Repo
- type RootThreadInventoryItem
- type RuntimeJournalRepo
- type RuntimeTurnRepo
- type SetThreadTitleRequest
- type SubAgentInputRecord
- type SubAgentInputState
- type SubAgentRequestKind
- type ThreadDeleteRepo
- type ThreadLifecycle
- type ThreadListRepo
- type ThreadMeta
- type ThreadOrigin
- type ThreadOriginRepo
- type ThreadPublishRepo
- type ThreadTitleAuthorityRepo
- type ThreadTitleMutationResult
- type ThreadTitleProjection
- type ThreadTitleSource
- type ThreadTitleStatus
- type ThreadTombstone
- type ThreadTombstoneRepo
- type TurnMarkerStatus
- type TurnTerminalOutcome
Constants ¶
const ( PendingToolSettlementKindKey = "authority_kind" PendingToolSettlementKind = "pending_tool_settlement" PendingToolSettlementFingerprintKey = "authority_fingerprint" PendingToolEffectAttemptIDKey = "effect_attempt_id" )
const ( SubAgentRequestPublication SubAgentRequestKind = "publication" SubAgentRequestInput SubAgentRequestKind = "input" SubAgentRequestPendingToolCompletion SubAgentRequestKind = "pending_tool_completion" SubAgentInputIDMetadataKey = "subagent_input_id" SubAgentUserMessageOriginMetadataKey = "subagent_user_message_origin" SubAgentUserMessageOriginDelegatedMission = "delegated_mission" SubAgentUserMessageOriginInput = "subagent_input" SubAgentUserMessageOriginPendingToolCompletion = "pending_tool_completion" )
const ( LogicalRequestIDMetadataKey = "logical_request_id" RetrySourceTurnIDMetadataKey = "retry_source_turn_id" RetrySourceEntryIDMetadataKey = "retry_source_entry_id" InteractionResolutionKind = "interaction_resolution" InteractionResolutionIDKey = "interaction_id" )
const ( TurnFailureCodeMetadataKey = "failure_code" TurnFailureCancelled = "cancelled" TurnFailureInterrupted = "interrupted" TurnFailureProvider = "provider" TurnFailureToolDispatch = "tool_dispatch" TurnFailureControlError = "control_error" TurnFailureEffectOutcomeUnknown = "effect_outcome_unknown" TurnFailureAuthorizationContract = "authorization_contract" TurnFailureStorage = "storage" TurnFailureEngineContract = "engine_contract" TurnFailureLegacyUnclassified = "legacy_unclassified" )
const MaxAgentTodoItems = 40
MaxAgentTodoItems is the canonical upper bound for one Agent todo state.
const MaxThreadTitleRunes = 200
MaxThreadTitleRunes is the canonical title admission and projection limit.
Variables ¶
var ( ErrArtifactNotFound = errors.New("session tree artifact not found") ErrSubAgentNotFound = errors.New("session tree subagent not found") ErrSubAgentParentRequired = errors.New("session tree subagent requires parent authority") ErrUnsupportedStoreCapability = errors.New("session tree store capability is unsupported") )
var ( ErrThreadNotFound = errors.New("session tree thread not found") ErrEntryNotFound = errors.New("session tree entry not found") ErrInvalidParent = errors.New("session tree invalid parent") ErrActiveTurn = errors.New("session tree thread already has an active turn") ErrThreadExists = errors.New("session tree thread already exists") ErrInvalidThreadAuthority = errors.New("session tree invalid thread authority") ErrThreadAuthorityBusy = errors.New("session tree thread authority is busy") ErrThreadClosed = errors.New("session tree thread is closed") ErrThreadDeleted = errors.New("session tree thread is deleted") ErrSubAgentClosing = errors.New("session tree subagent is closing") ErrStaleAuthority = errors.New("session tree authority proof is stale") ErrRecoveryTargetResolved = errors.New("session tree interrupted recovery target is resolved") ErrAuthorityCorrupt = errors.New("session tree authority state is corrupt") ErrForkDestinationConflict = errors.New("session tree fork destination conflicts with operation marker") ErrAgentTodoVersionConflict = errors.New("session tree agent todo version conflict") ErrStaleCanonicalTurnCursor = errors.New("session tree canonical turn cursor is stale") ErrRequestConflict = errors.New("session tree request conflicts with the canonical request") ErrSubAgentRequestConflict = fmt.Errorf("subagent request identity conflicts with canonical request: %w", ErrRequestConflict) ErrSubAgentInputNotFound = errors.New("session tree subagent input not found") ErrEffectAttemptNotFound = errors.New("session tree effect attempt not found") ErrEffectOutcomeUnknown = errors.New("session tree effect outcome is unknown") )
var DefaultLeasePolicy = LeasePolicy{ TTL: 30 * time.Second, RenewInterval: 10 * time.Second, ClockSkewAllowance: 2 * time.Second, }
var ErrCanonicalTurnNotFound = errors.New("session tree canonical turn not found")
var ErrProviderStateNotFound = errors.New("provider state not found")
Functions ¶
func BuildContext ¶
func BuildContext(path []Entry, opts ContextOptions) []session.Message
func BuildContextChecked ¶
func BuildContextChecked(path []Entry, opts ContextOptions) ([]session.Message, error)
func CanonicalEffectAttemptID ¶
func CanonicalEffectAttemptID(inv EffectInvocationIdentity) string
func MatchesForkDestinationMeta ¶
func MatchesForkDestinationMeta(meta ThreadMeta, destination *ForkDestinationMeta) bool
MatchesForkDestinationMeta reports whether persisted ownership metadata exactly matches the fork plan. It is used for replay idempotency.
func RawForEntry ¶
func SameThreadAuthority ¶
func SameThreadAuthority(left, right ThreadMeta) bool
SameThreadAuthority reports whether an update preserves immutable ownership and lineage identity.
func SameThreadTitleState ¶
func SameThreadTitleState(left, right ThreadMeta) bool
func SortThreadsByCreatedAtDesc ¶
func SortThreadsByCreatedAtDesc(threads []ThreadMeta)
func StableHash ¶
func SubAgentUserMessageOrigin ¶
func SubAgentUserMessageOrigin(kind SubAgentRequestKind) (string, error)
func ThreadAuthorityTreeIDs ¶
func ThreadAuthorityTreeIDs(threads []ThreadMeta, rootThreadID string) ([]string, error)
ThreadAuthorityTreeIDs returns one root and all descendants owned through ParentThreadID after validating the complete authority graph.
func TurnAcceptanceRequestFingerprint ¶
func TurnAcceptanceRequestFingerprint(req AcceptTurnRequest) (string, error)
func ValidTurnFailureCode ¶
func ValidateAcceptTurnReplayRequest ¶
func ValidateAcceptTurnReplayRequest(req AcceptTurnRequest) error
func ValidateAcceptTurnRequest ¶
func ValidateAcceptTurnRequest(req AcceptTurnRequest) error
func ValidateAcceptTurnRequestEnvelope ¶
func ValidateAcceptTurnRequestEnvelope(req AcceptTurnRequest) error
func ValidateAgentTodoItems ¶
func ValidateAgentTodoItems(items []AgentTodoItem) error
ValidateAgentTodoItems checks canonical todo identity, content, status, and state-machine invariants at the storage boundary.
func ValidateBeginAutomaticThreadTitleRequest ¶
func ValidateBeginAutomaticThreadTitleRequest(req BeginAutomaticThreadTitleRequest) error
func ValidateCancelTurnRequest ¶
func ValidateCancelTurnRequest(req CancelTurnRequest) error
func ValidateCanonicalThreadTitle ¶
ValidateCanonicalThreadTitle validates committed title text independently from its authority state.
func ValidateCanonicalTurnReadStructure ¶
func ValidateCanonicalTurnReadStructure(turn CanonicalTurn, threadID string) error
ValidateCanonicalTurnReadStructure validates the canonical journal shape.
func ValidateCompleteAutomaticThreadTitleRequest ¶
func ValidateCompleteAutomaticThreadTitleRequest(req CompleteAutomaticThreadTitleRequest) error
func ValidateEntryIntegrity ¶
func ValidateFailAutomaticThreadTitleRequest ¶
func ValidateFailAutomaticThreadTitleRequest(req FailAutomaticThreadTitleRequest) error
func ValidateFinishTurnRequest ¶
func ValidateFinishTurnRequest(req FinishTurnRequest) error
func ValidateListCanonicalTurnsOptions ¶
func ValidateListCanonicalTurnsOptions(opts ListCanonicalTurnsOptions) error
func ValidateRetrySourcePath ¶
func ValidateRetryStartedEntry ¶
func ValidateRetryStartedEntry(entry Entry, threadID, turnID, runID, startedEntryID string, source CanonicalTurnRetrySource) error
func ValidateSetThreadTitleRequest ¶
func ValidateSetThreadTitleRequest(req SetThreadTitleRequest) error
func ValidateThreadAuthorityGraph ¶
func ValidateThreadAuthorityGraph(threads []ThreadMeta) error
ValidateThreadAuthorityGraph requires every SubAgent parent chain to be acyclic and terminate at an existing root thread.
func ValidateThreadMetaAuthority ¶
func ValidateThreadMetaAuthority(meta ThreadMeta) error
ValidateThreadMetaAuthority enforces the durable distinction between independent root threads and parent-owned SubAgent threads.
func ValidateThreadTitleProjection ¶
func ValidateThreadTitleProjection(projection ThreadTitleProjection) error
ValidateThreadTitleProjection validates the observable canonical title state shared by durable authority and public runtime projections.
func ValidateThreadTitleState ¶
func ValidateThreadTitleState(meta ThreadMeta) error
Types ¶
type AcceptTurnRequest ¶
type AcceptTurnRequest struct {
ThreadID string
TurnID string
RunID string
LogicalRequestID string
Input session.Message
RetrySourceTurnID string
RetrySourceEntryID string
PromotedQueueID string
PromotionRequestKey string
PromotionRequestFingerprint string
InputRequestFingerprint string
RequestFingerprint string
Now time.Time
}
type AcceptTurnResult ¶
type AgentTodoItem ¶
type AgentTodoItem struct {
ID string `json:"id"`
Content string `json:"content"`
Status AgentTodoStatus `json:"status"`
}
type AgentTodoState ¶
type AgentTodoState struct {
ThreadID string `json:"thread_id"`
Version int64 `json:"version"`
Items []AgentTodoItem `json:"items"`
UpdatedAt time.Time `json:"updated_at,omitempty"`
UpdatedByTurnID string `json:"updated_by_turn_id,omitempty"`
UpdatedByRunID string `json:"updated_by_run_id,omitempty"`
UpdatedByToolCall string `json:"updated_by_tool_call_id,omitempty"`
}
type AgentTodoStateRepo ¶
type AgentTodoStateRepo interface {
ReadAgentTodoState(context.Context, string) (AgentTodoState, error)
CompareAndSwapAgentTodoState(context.Context, AgentTodoState, int64) (AgentTodoState, error)
}
type AgentTodoStatus ¶
type AgentTodoStatus string
const ( AgentTodoPending AgentTodoStatus = "pending" AgentTodoInProgress AgentTodoStatus = "in_progress" AgentTodoCompleted AgentTodoStatus = "completed" )
type AppendCommittedError ¶
type AppendCommittedError struct {
Err error
}
func (AppendCommittedError) Error ¶
func (e AppendCommittedError) Error() string
func (AppendCommittedError) Unwrap ¶
func (e AppendCommittedError) Unwrap() error
type ArtifactAuthorityRepo ¶
type ArtifactAuthorityRepo interface {
ReadArtifact(context.Context, ArtifactReadRequest) (ArtifactContent, error)
ArtifactClosure(context.Context, ArtifactClosureRequest) (artifact.Closure, error)
}
type ArtifactClosureRequest ¶
type ArtifactContent ¶
type ArtifactReadRequest ¶
type BackendRepo ¶
type BackendRepo struct {
// contains filtered or unexported fields
}
BackendRepo owns the validated in-memory session tree and commits each affected durable record inside one serializable Backend transaction.
func NewBackendRepo ¶
func NewBackendRepo(ctx context.Context, backend spi.Backend, now func() time.Time) (*BackendRepo, error)
NewBackendRepo initializes or validates the canonical session-tree state.
func NewBackendRepoInTransaction ¶
func NewBackendRepoInTransaction(ctx context.Context, backend spi.Backend, tx spi.WriteTx, now func() time.Time) (*BackendRepo, error)
NewBackendRepoInTransaction initializes and fully validates the canonical session-tree state using the caller's startup transaction. The returned repository retains backend for ordinary operations after that transaction commits.
func (*BackendRepo) AcceptTurn ¶
func (repo *BackendRepo) AcceptTurn(ctx context.Context, request AcceptTurnRequest) (result AcceptTurnResult, err error)
AcceptTurn commits the canonical user/queue boundary before provider dispatch. It is a normal domain transaction, not a memory-only receipt.
func (*BackendRepo) Append ¶
func (repo *BackendRepo) Append(ctx context.Context, entry Entry, opts AppendOptions) (Entry, error)
func (*BackendRepo) AppendRuntimeFacts ¶
func (*BackendRepo) ArtifactClosure ¶
func (repo *BackendRepo) ArtifactClosure(ctx context.Context, req ArtifactClosureRequest) (artifact.Closure, error)
func (*BackendRepo) BeginAutomaticThreadTitle ¶
func (repo *BackendRepo) BeginAutomaticThreadTitle(ctx context.Context, req BeginAutomaticThreadTitleRequest) (ThreadTitleMutationResult, error)
func (*BackendRepo) BeginEffectDispatch ¶
func (repo *BackendRepo) BeginEffectDispatch(ctx context.Context, req BeginEffectDispatchRequest) (EffectAttempt, error)
func (*BackendRepo) CancelTurn ¶
func (repo *BackendRepo) CancelTurn(ctx context.Context, req CancelTurnRequest) (CancelTurnResult, error)
func (*BackendRepo) CanonicalTurnEntries ¶
func (*BackendRepo) Checkpoint ¶
func (repo *BackendRepo) Checkpoint(ctx context.Context) error
Checkpoint joins any ancillary durable records to an explicit transaction. Session-tree mutations are already durable at this boundary.
func (*BackendRepo) CheckpointDomain ¶
func (repo *BackendRepo) CheckpointDomain(ctx context.Context, checkpoint func(spi.WriteTx) error) error
CheckpointDomain commits additional durable records after all preceding session-tree record mutations.
func (*BackendRepo) CheckpointDomainUpdate ¶ added in v5.0.2
func (repo *BackendRepo) CheckpointDomainUpdate(ctx context.Context, mutate func(*MemoryRepo, spi.WriteTx) error) error
CheckpointDomainUpdate applies one mutation at a semantic checkpoint. In v6 it shares the same affected-record transaction as every other domain update.
func (*BackendRepo) ClaimEffectRetry ¶
func (repo *BackendRepo) ClaimEffectRetry(ctx context.Context, req ClaimEffectRetryRequest) (ClaimEffectRetryResult, error)
func (*BackendRepo) CompareAndSwapAgentTodoState ¶
func (repo *BackendRepo) CompareAndSwapAgentTodoState(ctx context.Context, state AgentTodoState, expectedVersion int64) (AgentTodoState, error)
func (*BackendRepo) CompleteAutomaticThreadTitle ¶
func (repo *BackendRepo) CompleteAutomaticThreadTitle(ctx context.Context, req CompleteAutomaticThreadTitleRequest) (ThreadTitleMutationResult, error)
func (*BackendRepo) CreateThread ¶
func (repo *BackendRepo) CreateThread(ctx context.Context, meta ThreadMeta) (ThreadMeta, error)
func (*BackendRepo) CreateThreadWithInitialEntry ¶
func (repo *BackendRepo) CreateThreadWithInitialEntry(ctx context.Context, meta ThreadMeta, initial Entry) (ThreadMeta, Entry, error)
func (*BackendRepo) DeleteProviderState ¶
func (repo *BackendRepo) DeleteProviderState(ctx context.Context, threadID string) error
func (*BackendRepo) DeleteRootTree ¶
func (repo *BackendRepo) DeleteRootTree(ctx context.Context, rootThreadID string) (DeleteRootTreeResult, error)
func (*BackendRepo) DeleteRootTreeWithRequest ¶
func (repo *BackendRepo) DeleteRootTreeWithRequest(ctx context.Context, rootThreadID, requestKey, fingerprint string) (DeleteRootTreeResult, error)
func (*BackendRepo) EffectAttempt ¶
func (repo *BackendRepo) EffectAttempt(ctx context.Context, threadID, attemptID string) (EffectAttempt, error)
func (*BackendRepo) FailAutomaticThreadTitle ¶
func (repo *BackendRepo) FailAutomaticThreadTitle(ctx context.Context, req FailAutomaticThreadTitleRequest) (ThreadTitleMutationResult, error)
func (*BackendRepo) FinishEffectDispatch ¶
func (repo *BackendRepo) FinishEffectDispatch(ctx context.Context, req FinishEffectDispatchRequest) (FinishEffectDispatchResult, error)
func (*BackendRepo) FinishTurn ¶
func (repo *BackendRepo) FinishTurn(ctx context.Context, req FinishTurnRequest) (FinishTurnResult, error)
func (*BackendRepo) Fork ¶
func (repo *BackendRepo) Fork(ctx context.Context, opts ForkOptions) (ThreadMeta, error)
func (*BackendRepo) ForkWithInitialEntry ¶
func (repo *BackendRepo) ForkWithInitialEntry(ctx context.Context, opts ForkOptions, initial Entry) (ThreadMeta, Entry, error)
func (*BackendRepo) ListCanonicalTurns ¶
func (repo *BackendRepo) ListCanonicalTurns(ctx context.Context, opts ListCanonicalTurnsOptions) (CanonicalTurnsPage, error)
func (*BackendRepo) ListRootThreadInventory ¶
func (repo *BackendRepo) ListRootThreadInventory(ctx context.Context, opts ListThreadsOptions) ([]RootThreadInventoryItem, error)
ListRootThreadInventory reads a bounded root-thread page and the lifecycle facts needed to project each item inside one backend snapshot.
func (*BackendRepo) ListThreads ¶
func (repo *BackendRepo) ListThreads(ctx context.Context, opts ListThreadsOptions) ([]ThreadMeta, error)
func (*BackendRepo) MarkEffectUnknown ¶
func (repo *BackendRepo) MarkEffectUnknown(ctx context.Context, req MarkEffectUnknownRequest) (EffectAttempt, error)
func (*BackendRepo) MoveLeaf ¶
func (repo *BackendRepo) MoveLeaf(ctx context.Context, threadID, entryID string) error
func (*BackendRepo) PendingAutomaticThreadTitles ¶
func (repo *BackendRepo) PendingAutomaticThreadTitles(ctx context.Context) ([]ThreadMeta, error)
func (*BackendRepo) PrepareEffectAttempt ¶
func (repo *BackendRepo) PrepareEffectAttempt(ctx context.Context, req PrepareEffectAttemptRequest) (PrepareEffectAttemptResult, error)
func (*BackendRepo) ProviderState ¶
func (repo *BackendRepo) ProviderState(ctx context.Context, threadID string) (ProviderStateRecord, error)
func (*BackendRepo) PutProviderState ¶
func (repo *BackendRepo) PutProviderState(ctx context.Context, record ProviderStateRecord) error
func (*BackendRepo) ReadAcceptedTurn ¶
func (repo *BackendRepo) ReadAcceptedTurn(ctx context.Context, threadID, turnID, runID string) (AcceptTurnResult, bool, error)
func (*BackendRepo) ReadAgentTodoState ¶
func (repo *BackendRepo) ReadAgentTodoState(ctx context.Context, threadID string) (AgentTodoState, error)
func (*BackendRepo) ReadArtifact ¶
func (repo *BackendRepo) ReadArtifact(ctx context.Context, req ArtifactReadRequest) (ArtifactContent, error)
func (*BackendRepo) ReadCanonicalTurn ¶
func (repo *BackendRepo) ReadCanonicalTurn(ctx context.Context, threadID, turnID string) (CanonicalTurnRead, error)
func (*BackendRepo) RejectEffectAttempt ¶
func (repo *BackendRepo) RejectEffectAttempt(ctx context.Context, req RejectEffectAttemptRequest) (EffectAttempt, error)
func (*BackendRepo) SetThreadTitle ¶
func (repo *BackendRepo) SetThreadTitle(ctx context.Context, req SetThreadTitleRequest) (ThreadTitleMutationResult, error)
func (*BackendRepo) Thread ¶
func (repo *BackendRepo) Thread(ctx context.Context, threadID string) (ThreadMeta, error)
func (*BackendRepo) ThreadOrigin ¶
func (repo *BackendRepo) ThreadOrigin(ctx context.Context, requestKey string) (ThreadOrigin, error)
func (*BackendRepo) ThreadTombstone ¶
func (repo *BackendRepo) ThreadTombstone(ctx context.Context, threadID string) (ThreadTombstone, error)
func (*BackendRepo) UpdateDomain ¶
func (repo *BackendRepo) UpdateDomain(ctx context.Context, mutate func(*MemoryRepo, spi.WriteTx) error) error
UpdateDomain executes one session-tree mutation and related domain writes in the same serializable backend transaction.
func (*BackendRepo) UpdateThread ¶
func (repo *BackendRepo) UpdateThread(ctx context.Context, meta ThreadMeta) error
func (*BackendRepo) ValidateArtifactForkDestination ¶
func (*BackendRepo) VerifyCurrentStateInTransaction ¶
VerifyCurrentStateInTransaction verifies the final current-schema domain invariant without rewriting canonical bytes.
func (*BackendRepo) ViewDomain ¶
func (repo *BackendRepo) ViewDomain(ctx context.Context, read func(*MemoryRepo, spi.ReadTx) error) error
ViewDomain executes one read against the current validated in-memory authority. The callback must be observational only; durable mutations belong in UpdateDomain.
func (*BackendRepo) ViewDomainWithRecords ¶
func (repo *BackendRepo) ViewDomainWithRecords(ctx context.Context, read func(*MemoryRepo, spi.ReadTx) error) error
ViewDomainWithRecords joins the live memory authority with ancillary durable records in one read transaction. Hot thread projections should use ViewDomain so they never enter SQL while the process authority is live.
type CancelTurnRequest ¶
type CancelTurnRequest struct {
ThreadID string
TurnID string
RunID string
CancelEntryID string
TerminalEntryID string
RequestKey string
RequestFingerprint string
OutcomeFingerprint string
InteractionResolutionPayload json.RawMessage
Metadata map[string]string
ClearProviderState bool
Now time.Time
}
CancelTurnRequest atomically settles one active turn after an explicit user stop. The cancellation fact, pending interaction resolutions, unfinished tool closures, effect fences, and aborted terminal share one transaction.
type CancelTurnResult ¶
type CanonicalTurn ¶
type CanonicalTurn struct {
TurnID string
RunID string
StartedEntryID string
StartedOrdinal int64
RetrySource *CanonicalTurnRetrySource
Entries []CanonicalTurnPathEntry
}
type CanonicalTurnBeforeCursor ¶
type CanonicalTurnBeforeCursor struct {
EntryID string
}
type CanonicalTurnPageRepo ¶
type CanonicalTurnPageRepo interface {
ListCanonicalTurns(context.Context, ListCanonicalTurnsOptions) (CanonicalTurnsPage, error)
}
type CanonicalTurnPathEntry ¶
type CanonicalTurnRead ¶
type CanonicalTurnRead struct {
Turn CanonicalTurn
LatestTurn CanonicalTurn
ThroughOrdinal int64
HasRetryTarget bool
}
CanonicalTurnRead is one admitted canonical turn on the current active path.
type CanonicalTurnReadRepo ¶
type CanonicalTurnReadRepo interface {
ReadCanonicalTurn(context.Context, string, string) (CanonicalTurnRead, error)
}
CanonicalTurnReadRepo reads one admitted turn without scanning a public page.
type CanonicalTurnRepo ¶
type CanonicalTurnRepo interface {
CanonicalTurnEntries(context.Context, string, string, string) ([]Entry, bool, error)
}
CanonicalTurnRepo reads all journal entries associated with one exact turn. Execution replay authority remains owned by TurnAuthorityRepo.
type CanonicalTurnRetrySource ¶
func CanonicalTurnRetrySourceForStartedEntry ¶
func CanonicalTurnRetrySourceForStartedEntry(entry Entry) (*CanonicalTurnRetrySource, error)
func ValidateCanonicalRetrySourceTurn ¶
func ValidateCanonicalRetrySourceTurn(entries []Entry, threadID string, source CanonicalTurnRetrySource) (bool, *CanonicalTurnRetrySource, string, string, error)
type CanonicalTurnSinceCursor ¶
type CanonicalTurnSinceCursor struct {
EntryID string
}
type CanonicalTurnsPage ¶
type CanonicalTurnsPage struct {
Turns []CanonicalTurn
BeforeCursor *CanonicalTurnBeforeCursor
SinceCursor CanonicalTurnSinceCursor
HasMore bool
ThroughOrdinal int64
LatestTurnID string
HasRetryTarget bool
}
type ClaimEffectRetryRequest ¶
type ClaimEffectRetryResult ¶
type ClaimEffectRetryResult struct {
Attempt EffectAttempt
Replayed bool
}
type ContextOptions ¶
type ContextOptions struct{}
type ContextProjection ¶
type ContextProjection struct {
Messages []session.Message `json:"messages"`
Segments []ProjectedSegment `json:"segments,omitempty"`
}
func BuildContextProjection ¶
func BuildContextProjection(path []Entry, opts ContextProjectionOptions) ContextProjection
func BuildContextProjectionChecked ¶
func BuildContextProjectionChecked(path []Entry, opts ContextProjectionOptions) (ContextProjection, error)
type ContextProjectionOptions ¶
type ContextProjectionOptions struct {
Purpose ProjectionPurpose
}
type DeleteRootTreeResult ¶
type EffectAttempt ¶
type EffectAttempt struct {
EffectAttemptID string `json:"effect_attempt_id"`
Invocation EffectInvocationIdentity `json:"invocation"`
RequestFingerprint string `json:"request_fingerprint"`
State EffectAttemptState `json:"state"`
RejectionCode string `json:"rejection_code,omitempty"`
TerminalFingerprint string `json:"terminal_fingerprint,omitempty"`
ResultEntryID string `json:"result_entry_id,omitempty"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
RetryRequestKey string `json:"retry_request_key,omitempty"`
RetryRequestFingerprint string `json:"retry_request_fingerprint,omitempty"`
OwnerID string `json:"owner_id,omitempty"`
Generation int64 `json:"generation,omitempty"`
}
func DecodeCanonicalEffectAttempt ¶
func DecodeCanonicalEffectAttempt(entry Entry) (EffectAttempt, error)
func LatestCanonicalEffectAttempt ¶
func LatestCanonicalEffectAttempt(entries []Entry, attemptID string) (EffectAttempt, bool, error)
func (*EffectAttempt) UnmarshalJSON ¶
func (attempt *EffectAttempt) UnmarshalJSON(data []byte) error
type EffectAttemptReader ¶
type EffectAttemptRepo ¶
type EffectAttemptRepo interface {
PrepareEffectAttempt(context.Context, PrepareEffectAttemptRequest) (PrepareEffectAttemptResult, error)
RejectEffectAttempt(context.Context, RejectEffectAttemptRequest) (EffectAttempt, error)
BeginEffectDispatch(context.Context, BeginEffectDispatchRequest) (EffectAttempt, error)
FinishEffectDispatch(context.Context, FinishEffectDispatchRequest) (FinishEffectDispatchResult, error)
MarkEffectUnknown(context.Context, MarkEffectUnknownRequest) (EffectAttempt, error)
}
type EffectAttemptState ¶
type EffectAttemptState string
const ( EffectAttemptPrepared EffectAttemptState = "prepared" EffectAttemptDispatching EffectAttemptState = "dispatching" EffectAttemptCompleted EffectAttemptState = "completed" EffectAttemptFailed EffectAttemptState = "failed" EffectAttemptRejected EffectAttemptState = "rejected" EffectAttemptUnknown EffectAttemptState = "unknown" EffectAttemptRetrying EffectAttemptState = "retrying" EffectAttemptCancelled EffectAttemptState = "cancelled" )
type EffectInvocationIdentity ¶
type EffectInvocationIdentity struct {
ThreadID string `json:"thread_id"`
TurnID string `json:"turn_id"`
RunID string `json:"run_id"`
ToolCallID string `json:"tool_call_id"`
ToolName string `json:"tool_name"`
ArgumentHash string `json:"argument_hash"`
RetryKey string `json:"retry_key,omitempty"`
SourceEffectAttemptID string `json:"source_effect_attempt_id,omitempty"`
}
func (*EffectInvocationIdentity) UnmarshalJSON ¶
func (inv *EffectInvocationIdentity) UnmarshalJSON(data []byte) error
type EffectRetryRepo ¶
type EffectRetryRepo interface {
ClaimEffectRetry(context.Context, ClaimEffectRetryRequest) (ClaimEffectRetryResult, error)
}
type Entry ¶
type Entry struct {
ID string `json:"id"`
ThreadID string `json:"thread_id"`
ParentID string `json:"parent_id,omitempty"`
PathDepth int64 `json:"path_depth"`
Type EntryType `json:"type"`
TurnID string `json:"turn_id,omitempty"`
RunID string `json:"run_id,omitempty"`
RequestKey string `json:"request_key,omitempty"`
RequestFingerprint string `json:"request_fingerprint,omitempty"`
Payload json.RawMessage `json:"payload,omitempty"`
CreatedAt time.Time `json:"created_at"`
Message session.Message `json:"message,omitempty"`
Raw string `json:"raw,omitempty"`
RawHash string `json:"raw_hash,omitempty"`
TurnStatus TurnMarkerStatus `json:"turn_status,omitempty"`
Provider string `json:"provider,omitempty"`
Model string `json:"model,omitempty"`
CompactionID string `json:"compaction_id,omitempty"`
PreviousCompactionID string `json:"previous_compaction_id,omitempty"`
CompactedThroughEntryID string `json:"compacted_through_entry_id,omitempty"`
SummarySchemaVersion string `json:"summary_schema_version,omitempty"`
CompactionGeneration int `json:"compaction_generation,omitempty"`
CompactionWindowID string `json:"compaction_window_id,omitempty"`
FirstKeptEntryID string `json:"first_kept_entry_id,omitempty"`
KeptUserEntryIDs []string `json:"kept_user_entry_ids,omitempty"`
Summary string `json:"summary,omitempty"`
CompactionTrigger string `json:"compaction_trigger,omitempty"`
CompactionReason string `json:"compaction_reason,omitempty"`
CompactionPhase string `json:"compaction_phase,omitempty"`
CompactionOperationID string `json:"compaction_operation_id,omitempty"`
CompactionRequestID string `json:"compaction_request_id,omitempty"`
CompactionSource string `json:"compaction_source,omitempty"`
TokensBefore int64 `json:"tokens_before,omitempty"`
TokensAfterEstimate int64 `json:"tokens_after_estimate,omitempty"`
ContextUsageBefore contextpolicy.Usage `json:"context_usage_before,omitempty"`
ContextUsageAfter contextpolicy.Usage `json:"context_usage_after,omitempty"`
Error string `json:"error,omitempty"`
Metadata map[string]string `json:"metadata,omitempty"`
}
func AppendActiveTools ¶
func AppendCompaction ¶
func AppendCompaction(ctx context.Context, repo JournalRepo, threadID, turnID string, result compaction.Result) (Entry, error)
func AppendFailure ¶
func AppendMessage ¶
func AppendMessageAt ¶
func AppendRunMessage ¶ added in v5.0.16
func AppendRunMessageAt ¶ added in v5.0.16
func AppendTurnMarker ¶
func AppendTurnMarker(ctx context.Context, repo JournalRepo, threadID, turnID string, status TurnMarkerStatus, metadata map[string]string) (Entry, error)
func AppendTurnMarkerWithID ¶
func AppendTurnMarkerWithID(ctx context.Context, repo JournalRepo, threadID, turnID, entryID string, status TurnMarkerStatus, metadata map[string]string) (Entry, error)
func CanonicalEffectAttemptEntry ¶
func CanonicalEffectAttemptEntry(attempt EffectAttempt, parentID string) (Entry, error)
func CanonicalTurnEntriesForRead ¶
CanonicalTurnEntriesForRead excludes retry/fork structural closures when the same turn already has its execution terminal. A copied unfinished turn keeps its branch boundary as the only canonical terminal.
func CompactionEntry ¶
func CompactionEntry(threadID, turnID string, result compaction.Result) (Entry, error)
func PrepareBranchBoundaryEntry ¶
func PrepareBranchBoundaryEntry(path []Entry, threadID, parentEntryID, entryID, reason string, now time.Time) (Entry, error)
PrepareBranchBoundaryEntry closes a copied unfinished turn so the fork has one idle canonical boundary before it accepts new work.
func PrepareEntry ¶
type EntryType ¶
type EntryType string
const ( EntryThreadInfo EntryType = "thread_info" EntryTurnMarker EntryType = "turn_marker" EntryUserMessage EntryType = "user_message" EntryAssistantMessage EntryType = "assistant_message" EntryToolCall EntryType = "tool_call" EntryToolResult EntryType = "tool_result" EntryModelChange EntryType = "model_change" EntryActiveTools EntryType = "active_tools_change" EntryCompaction EntryType = "compaction" EntryBranchSummary EntryType = "branch_summary" EntryRunFailure EntryType = "run_failure" EntryQueueAdded EntryType = "queue_added" EntryQueueReordered EntryType = "queue_reordered" EntryQueueDeleted EntryType = "queue_deleted" EntryQueuePromoted EntryType = "queue_promoted" EntryInteractionAsked EntryType = "interaction_requested" EntryInteractionDone EntryType = "interaction_resolved" EntryCancelRequested EntryType = "turn_cancel_requested" EntryRuntimeRestarted EntryType = "runtime_restarted" EntryEffectAttempt EntryType = "effect_attempt" EntryCustom EntryType = "custom" )
type FileRepo ¶
type FileRepo struct {
// contains filtered or unexported fields
}
func NewFileRepo ¶
func (*FileRepo) ArtifactClosure ¶
func (*FileRepo) BeginAutomaticThreadTitle ¶
func (r *FileRepo) BeginAutomaticThreadTitle(ctx context.Context, req BeginAutomaticThreadTitleRequest) (ThreadTitleMutationResult, error)
func (*FileRepo) CanonicalTurnEntries ¶
func (*FileRepo) CompareAndSwapAgentTodoState ¶
func (r *FileRepo) CompareAndSwapAgentTodoState(ctx context.Context, state AgentTodoState, expectedVersion int64) (AgentTodoState, error)
func (*FileRepo) CompleteAutomaticThreadTitle ¶
func (r *FileRepo) CompleteAutomaticThreadTitle(ctx context.Context, req CompleteAutomaticThreadTitleRequest) (ThreadTitleMutationResult, error)
func (*FileRepo) CreateThread ¶
func (r *FileRepo) CreateThread(ctx context.Context, meta ThreadMeta) (ThreadMeta, error)
func (*FileRepo) FailAutomaticThreadTitle ¶
func (r *FileRepo) FailAutomaticThreadTitle(ctx context.Context, req FailAutomaticThreadTitleRequest) (ThreadTitleMutationResult, error)
func (*FileRepo) Fork ¶
func (r *FileRepo) Fork(ctx context.Context, opts ForkOptions) (ThreadMeta, error)
func (*FileRepo) ListCanonicalTurns ¶
func (r *FileRepo) ListCanonicalTurns(ctx context.Context, opts ListCanonicalTurnsOptions) (CanonicalTurnsPage, error)
func (*FileRepo) ListThreads ¶
func (r *FileRepo) ListThreads(ctx context.Context, opts ListThreadsOptions) ([]ThreadMeta, error)
func (*FileRepo) PendingAutomaticThreadTitles ¶
func (r *FileRepo) PendingAutomaticThreadTitles(ctx context.Context) ([]ThreadMeta, error)
func (*FileRepo) ReadAgentTodoState ¶
func (*FileRepo) ReadArtifact ¶
func (r *FileRepo) ReadArtifact(context.Context, ArtifactReadRequest) (ArtifactContent, error)
func (*FileRepo) SetThreadTitle ¶
func (r *FileRepo) SetThreadTitle(ctx context.Context, req SetThreadTitleRequest) (ThreadTitleMutationResult, error)
func (*FileRepo) UpdateThread ¶
func (r *FileRepo) UpdateThread(ctx context.Context, meta ThreadMeta) error
type FinishEffectDispatchResult ¶
type FinishEffectDispatchResult struct {
Attempt EffectAttempt
Result Entry
Artifact *artifact.Ref
Replayed bool
}
type FinishTurnRequest ¶
type FinishTurnResult ¶
type ForkDestinationMeta ¶
type ForkDestinationMeta struct {
ParentThreadID string `json:"parent_thread_id"`
ParentTurnID string `json:"parent_turn_id,omitempty"`
TaskName string `json:"task_name,omitempty"`
TaskDescription string `json:"task_description,omitempty"`
AgentPath string `json:"agent_path,omitempty"`
HostProfileRef string `json:"host_profile_ref,omitempty"`
ForkMode string `json:"fork_mode,omitempty"`
Lifecycle ThreadLifecycle `json:"lifecycle,omitempty"`
}
ForkDestinationMeta is the child ownership metadata written atomically with a fork destination. A nil value creates an independent root fork.
type ForkEntryIdentity ¶
type ForkOptions ¶
type ForkOptions struct {
SourceThreadID string
EntryID string
EntryIDPinned bool
ExpectedSourceLeafID string
Position ForkPosition
NewThreadID string
OriginRequestKey string
OriginFingerprint string
Now time.Time
TurnIDMap map[string]string
RunIDMap map[string]string
DestinationMeta *ForkDestinationMeta
ArtifactClosure artifact.Closure
RewriteEntry func(Entry, ForkEntryIdentity) (Entry, error)
}
type ForkPosition ¶
type ForkPosition string
const ( ForkAt ForkPosition = "at" ForkBefore ForkPosition = "before" )
type JournalRepo ¶
type JournalRepo interface {
Thread(context.Context, string) (ThreadMeta, error)
Append(context.Context, Entry, AppendOptions) (Entry, error)
Entry(context.Context, string, string) (Entry, error)
Entries(context.Context, string) ([]Entry, error)
Path(context.Context, string, string) ([]Entry, error)
PathPage(context.Context, string, string, string, int) (PathPage, error)
}
JournalRepo is the durable journal capability used by normal Agent execution. It intentionally excludes lifecycle creation, deletion, fork, and metadata replacement capabilities.
type LeasePolicy ¶
type LeasePolicy struct {
TTL time.Duration
RenewInterval time.Duration
ClockSkewAllowance time.Duration
}
LeasePolicy is retained only to validate and migrate the released physical store schema. ThreadRuntime does not use leases for active lifecycle state.
func (LeasePolicy) Validate ¶
func (policy LeasePolicy) Validate() error
type ListCanonicalTurnsOptions ¶
type ListCanonicalTurnsOptions struct {
ThreadID string
BeforeCursor *CanonicalTurnBeforeCursor
SinceCursor *CanonicalTurnSinceCursor
Tail int
Limit int
}
type ListThreadsOptions ¶
type MemoryRepo ¶
type MemoryRepo struct {
// contains filtered or unexported fields
}
func DecodeMemoryState ¶
func DecodeMemoryState(data []byte, now func() time.Time) (*MemoryRepo, error)
DecodeMemoryState constructs a repo from one exact legacy checkpoint.
func NewMemoryRepo ¶
func NewMemoryRepo() *MemoryRepo
func (*MemoryRepo) AcceptTurn ¶
func (r *MemoryRepo) AcceptTurn(_ context.Context, req AcceptTurnRequest) (AcceptTurnResult, error)
AcceptTurn records the canonical request boundary before provider dispatch. Stable journal identities provide replay; no receipt, lease, or lifecycle ledger participates in the operation.
func (*MemoryRepo) Append ¶
func (r *MemoryRepo) Append(ctx context.Context, entry Entry, opts AppendOptions) (Entry, error)
func (*MemoryRepo) AppendRuntimeFacts ¶
func (*MemoryRepo) ArtifactClosure ¶
func (r *MemoryRepo) ArtifactClosure(_ context.Context, req ArtifactClosureRequest) (artifact.Closure, error)
func (*MemoryRepo) BeginAutomaticThreadTitle ¶
func (r *MemoryRepo) BeginAutomaticThreadTitle(ctx context.Context, req BeginAutomaticThreadTitleRequest) (ThreadTitleMutationResult, error)
func (*MemoryRepo) BeginEffectDispatch ¶
func (r *MemoryRepo) BeginEffectDispatch(_ context.Context, req BeginEffectDispatchRequest) (EffectAttempt, error)
func (*MemoryRepo) CancelTurn ¶
func (r *MemoryRepo) CancelTurn(ctx context.Context, req CancelTurnRequest) (CancelTurnResult, error)
CancelTurn makes user Stop the canonical winner without waiting for provider or tool goroutines. Any late turn-scoped writes are rejected by the terminal authority installed in this transaction.
func (*MemoryRepo) CanonicalTurnEntries ¶
func (*MemoryRepo) ClaimEffectRetry ¶
func (r *MemoryRepo) ClaimEffectRetry(_ context.Context, req ClaimEffectRetryRequest) (ClaimEffectRetryResult, error)
ClaimEffectRetry atomically consumes the source Unknown authority before a retried handler can be dispatched. A second request can only replay the same request identity; it cannot create another irreversible attempt.
func (*MemoryRepo) CompareAndSwapAgentTodoState ¶
func (r *MemoryRepo) CompareAndSwapAgentTodoState(ctx context.Context, state AgentTodoState, expectedVersion int64) (AgentTodoState, error)
func (*MemoryRepo) CompleteAutomaticThreadTitle ¶
func (r *MemoryRepo) CompleteAutomaticThreadTitle(ctx context.Context, req CompleteAutomaticThreadTitleRequest) (ThreadTitleMutationResult, error)
func (*MemoryRepo) CreateThread ¶
func (r *MemoryRepo) CreateThread(_ context.Context, meta ThreadMeta) (ThreadMeta, error)
func (*MemoryRepo) CreateThreadWithInitialEntry ¶
func (r *MemoryRepo) CreateThreadWithInitialEntry(ctx context.Context, meta ThreadMeta, initial Entry) (ThreadMeta, Entry, error)
func (*MemoryRepo) DeleteProviderState ¶
func (r *MemoryRepo) DeleteProviderState(_ context.Context, threadID string) error
func (*MemoryRepo) DeleteRootTree ¶
func (r *MemoryRepo) DeleteRootTree(_ context.Context, rootThreadID string) (DeleteRootTreeResult, error)
func (*MemoryRepo) DeleteRootTreeWithRequest ¶
func (r *MemoryRepo) DeleteRootTreeWithRequest(_ context.Context, rootThreadID, requestKey, fingerprint string) (DeleteRootTreeResult, error)
func (*MemoryRepo) EffectAttempt ¶
func (r *MemoryRepo) EffectAttempt(_ context.Context, threadID, attemptID string) (EffectAttempt, error)
func (*MemoryRepo) EncodeMemoryState ¶
func (repo *MemoryRepo) EncodeMemoryState() ([]byte, error)
EncodeMemoryState returns the detached strict v5 checkpoint representation. Production schema-v6 mutations persist segmented records instead.
func (*MemoryRepo) FailAutomaticThreadTitle ¶
func (r *MemoryRepo) FailAutomaticThreadTitle(ctx context.Context, req FailAutomaticThreadTitleRequest) (ThreadTitleMutationResult, error)
func (*MemoryRepo) FinishEffectDispatch ¶
func (r *MemoryRepo) FinishEffectDispatch(_ context.Context, req FinishEffectDispatchRequest) (FinishEffectDispatchResult, error)
func (*MemoryRepo) FinishTurn ¶
func (r *MemoryRepo) FinishTurn(_ context.Context, req FinishTurnRequest) (FinishTurnResult, error)
FinishTurn settles one active turn using the stable terminal entry as the replay fact. The journal, not a finish ledger, is authoritative.
func (*MemoryRepo) Fork ¶
func (r *MemoryRepo) Fork(ctx context.Context, opts ForkOptions) (ThreadMeta, error)
func (*MemoryRepo) ForkWithInitialEntry ¶
func (r *MemoryRepo) ForkWithInitialEntry(ctx context.Context, opts ForkOptions, initial Entry) (ThreadMeta, Entry, error)
func (*MemoryRepo) ListCanonicalTurns ¶
func (r *MemoryRepo) ListCanonicalTurns(_ context.Context, opts ListCanonicalTurnsOptions) (CanonicalTurnsPage, error)
func (*MemoryRepo) ListRootThreadInventory ¶
func (r *MemoryRepo) ListRootThreadInventory(_ context.Context, opts ListThreadsOptions) ([]RootThreadInventoryItem, error)
func (*MemoryRepo) ListThreads ¶
func (r *MemoryRepo) ListThreads(_ context.Context, opts ListThreadsOptions) ([]ThreadMeta, error)
func (*MemoryRepo) MarkEffectUnknown ¶
func (r *MemoryRepo) MarkEffectUnknown(_ context.Context, req MarkEffectUnknownRequest) (EffectAttempt, error)
func (*MemoryRepo) MoveLeaf ¶
func (r *MemoryRepo) MoveLeaf(_ context.Context, threadID, entryID string) error
func (*MemoryRepo) PendingAutomaticThreadTitles ¶
func (r *MemoryRepo) PendingAutomaticThreadTitles(_ context.Context) ([]ThreadMeta, error)
func (*MemoryRepo) PrepareEffectAttempt ¶
func (r *MemoryRepo) PrepareEffectAttempt(_ context.Context, req PrepareEffectAttemptRequest) (PrepareEffectAttemptResult, error)
func (*MemoryRepo) ProviderState ¶
func (r *MemoryRepo) ProviderState(_ context.Context, threadID string) (ProviderStateRecord, error)
func (*MemoryRepo) PutProviderState ¶
func (r *MemoryRepo) PutProviderState(_ context.Context, record ProviderStateRecord) error
func (*MemoryRepo) ReadAcceptedTurn ¶
func (r *MemoryRepo) ReadAcceptedTurn(_ context.Context, threadID, turnID, runID string) (AcceptTurnResult, bool, error)
func (*MemoryRepo) ReadAgentTodoState ¶
func (r *MemoryRepo) ReadAgentTodoState(_ context.Context, threadID string) (AgentTodoState, error)
func (*MemoryRepo) ReadArtifact ¶
func (r *MemoryRepo) ReadArtifact(_ context.Context, req ArtifactReadRequest) (ArtifactContent, error)
func (*MemoryRepo) ReadCanonicalTurn ¶
func (r *MemoryRepo) ReadCanonicalTurn(_ context.Context, threadID, turnID string) (CanonicalTurnRead, error)
func (*MemoryRepo) RejectEffectAttempt ¶
func (r *MemoryRepo) RejectEffectAttempt(_ context.Context, req RejectEffectAttemptRequest) (EffectAttempt, error)
func (*MemoryRepo) SetThreadTitle ¶
func (r *MemoryRepo) SetThreadTitle(ctx context.Context, req SetThreadTitleRequest) (ThreadTitleMutationResult, error)
func (*MemoryRepo) Thread ¶
func (r *MemoryRepo) Thread(_ context.Context, threadID string) (ThreadMeta, error)
func (*MemoryRepo) ThreadOrigin ¶
func (r *MemoryRepo) ThreadOrigin(_ context.Context, requestKey string) (ThreadOrigin, error)
func (*MemoryRepo) ThreadTombstone ¶
func (r *MemoryRepo) ThreadTombstone(_ context.Context, threadID string) (ThreadTombstone, error)
func (*MemoryRepo) UpdateThread ¶
func (r *MemoryRepo) UpdateThread(ctx context.Context, meta ThreadMeta) error
func (*MemoryRepo) ValidateArtifactForkDestination ¶
func (r *MemoryRepo) ValidateArtifactForkDestination(_ context.Context, closure artifact.Closure) error
ValidateArtifactForkDestination verifies the complete copied artifact set without relying on the source thread still being live.
type PrepareEffectAttemptRequest ¶
type PrepareEffectAttemptRequest struct {
Invocation EffectInvocationIdentity
RequestFingerprint string
Now time.Time
}
type PrepareEffectAttemptResult ¶
type PrepareEffectAttemptResult struct {
Attempt EffectAttempt
Replayed bool
}
type ProjectedSegment ¶
type ProjectedSegment struct {
EntryID string `json:"entry_id,omitempty"`
EntryType EntryType `json:"entry_type,omitempty"`
MessageIndex int `json:"message_index"`
Role session.Role `json:"role,omitempty"`
ToolCallID string `json:"tool_call_id,omitempty"`
ToolName string `json:"tool_name,omitempty"`
TokenEstimate int64 `json:"token_estimate,omitempty"`
ArtifactRefs []artifact.Ref `json:"artifact_refs,omitempty"`
UIPreview string `json:"ui_preview,omitempty"`
}
type ProjectionPurpose ¶
type ProjectionPurpose string
const ( ProjectionProviderRequest ProjectionPurpose = "provider_request" ProjectionCompaction ProjectionPurpose = "compaction" ProjectionTestUI ProjectionPurpose = "test_ui" )
type ProviderStateReader ¶
type ProviderStateReader interface {
ProviderState(context.Context, string) (ProviderStateRecord, error)
}
type ProviderStateRecord ¶
type ProviderStateRecord struct {
ThreadID string
LeafEntryID string
CompatibilityKey string
State provider.State
CreatedByRunID string
CreatedByTurnID string
UpdatedAt time.Time
}
ProviderStateRecord is an optional provider optimization anchored to one canonical journal boundary. It is never a lifecycle or replay authority.
type ProviderStateStore ¶
type ProviderStateStore interface {
ProviderStateReader
PutProviderState(context.Context, ProviderStateRecord) error
DeleteProviderState(context.Context, string) error
}
type Repo ¶
type Repo interface {
JournalRepo
CreateThread(context.Context, ThreadMeta) (ThreadMeta, error)
UpdateThread(context.Context, ThreadMeta) error
MoveLeaf(context.Context, string, string) error
Fork(context.Context, ForkOptions) (ThreadMeta, error)
}
Repo is the internal storage implementation contract. Production runtime actors receive narrower capabilities such as JournalRepo instead.
type RootThreadInventoryItem ¶
type RootThreadInventoryItem struct {
Meta ThreadMeta
Path []Entry
// ProjectionFingerprint validates the cached inventory payload; it is not a
// lifecycle revision or host replay cursor.
ProjectionFingerprint [32]byte `json:"-"`
}
RootThreadInventoryItem is one canonical root thread and its active path.
type RuntimeJournalRepo ¶
type RuntimeJournalRepo interface {
AppendRuntimeFacts(context.Context, string, []Entry) ([]Entry, error)
}
RuntimeJournalRepo is the single low-frequency canonical writer used by the v4 ThreadRuntime. It does not expose leases or receipts to hosts.
type RuntimeTurnRepo ¶
type RuntimeTurnRepo interface {
AcceptTurn(context.Context, AcceptTurnRequest) (AcceptTurnResult, error)
ReadAcceptedTurn(context.Context, string, string, string) (AcceptTurnResult, bool, error)
CancelTurn(context.Context, CancelTurnRequest) (CancelTurnResult, error)
FinishTurn(context.Context, FinishTurnRequest) (FinishTurnResult, error)
}
RuntimeTurnRepo is the canonical low-frequency writer used by ThreadService. Stable journal facts are the only replay and terminal authority.
type SetThreadTitleRequest ¶
type SubAgentInputRecord ¶
type SubAgentInputRecord struct {
SubAgentInputID string
ParentThreadID string
ChildThreadID string
RequestKind SubAgentRequestKind
RequestID string
RequestFingerprint string
Sequence int64
State SubAgentInputState
Message session.Message
HostLabels map[string]string
CorrelationLabels map[string]string
AdmittedTurnID string
AdmittedRunID string
CreatedAt time.Time
AdmittedAt time.Time
CancelledAt time.Time
}
type SubAgentInputState ¶
type SubAgentInputState string
const ( SubAgentInputPending SubAgentInputState = "pending" SubAgentInputAdmitted SubAgentInputState = "admitted" SubAgentInputCancelled SubAgentInputState = "cancelled" )
type SubAgentRequestKind ¶
type SubAgentRequestKind string
type ThreadDeleteRepo ¶
type ThreadDeleteRepo interface {
DeleteRootTreeWithRequest(context.Context, string, string, string) (DeleteRootTreeResult, error)
}
ThreadDeleteRepo is the v4 canonical tombstone boundary. The request key is stored on the tombstone itself rather than in a separate receipt ledger.
type ThreadLifecycle ¶
type ThreadLifecycle string
ThreadLifecycle is the durable canonical lifecycle of a thread identity. A deleted identity is represented by a tombstone rather than by absence.
const ( ThreadLifecycleOpen ThreadLifecycle = "open" ThreadLifecycleClosing ThreadLifecycle = "closing" ThreadLifecycleClosed ThreadLifecycle = "closed" ThreadLifecycleDeleted ThreadLifecycle = "deleted" )
func (ThreadLifecycle) Valid ¶
func (l ThreadLifecycle) Valid() bool
type ThreadListRepo ¶
type ThreadListRepo interface {
ListThreads(context.Context, ListThreadsOptions) ([]ThreadMeta, error)
}
type ThreadMeta ¶
type ThreadMeta struct {
ID string `json:"id"`
OriginRequestKey string `json:"origin_request_key,omitempty"`
OriginFingerprint string `json:"origin_fingerprint,omitempty"`
LeafID string `json:"leaf_id,omitempty"`
ParentThreadID string `json:"parent_thread_id,omitempty"`
ParentTurnID string `json:"parent_turn_id,omitempty"`
ForkedFromThreadID string `json:"forked_from_thread_id,omitempty"`
ForkedFromEntryID string `json:"forked_from_entry_id,omitempty"`
LegacyForkRequestID string `json:"fork_operation_id,omitempty"`
LegacyForkNodeID string `json:"fork_operation_node_id,omitempty"`
TaskName string `json:"task_name,omitempty"`
TaskDescription string `json:"task_description,omitempty"`
AgentPath string `json:"agent_path,omitempty"`
HostProfileRef string `json:"host_profile_ref,omitempty"`
ForkMode string `json:"fork_mode,omitempty"`
Lifecycle ThreadLifecycle `json:"lifecycle,omitempty"`
Archived bool `json:"archived,omitempty"`
Title string `json:"title,omitempty"`
TitleStatus ThreadTitleStatus `json:"title_status,omitempty"`
TitleSource ThreadTitleSource `json:"title_source,omitempty"`
TitleUpdatedAt time.Time `json:"title_updated_at,omitempty"`
TitleError string `json:"title_error,omitempty"`
TitleGeneration int64 `json:"title_generation,omitempty"`
TitleToken string `json:"title_token,omitempty"`
TitleRequestKey string `json:"title_request_key,omitempty"`
TitleRequestFingerprint string `json:"title_request_fingerprint,omitempty"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
LastViewedAt time.Time `json:"last_viewed_at,omitempty"`
}
func ApplyThreadListOptions ¶
func ApplyThreadListOptions(threads []ThreadMeta, opts ListThreadsOptions) []ThreadMeta
func ListThreads ¶
func ListThreads(ctx context.Context, repo JournalRepo, opts ListThreadsOptions) ([]ThreadMeta, error)
func (ThreadMeta) CanonicalLifecycle ¶
func (m ThreadMeta) CanonicalLifecycle() (ThreadLifecycle, error)
func (ThreadMeta) IsClosed ¶
func (m ThreadMeta) IsClosed() bool
func (ThreadMeta) IsClosing ¶
func (m ThreadMeta) IsClosing() bool
type ThreadOrigin ¶
type ThreadOrigin struct {
Thread *ThreadMeta
Tombstone *ThreadTombstone
}
type ThreadOriginRepo ¶
type ThreadOriginRepo interface {
ThreadOrigin(context.Context, string) (ThreadOrigin, error)
}
ThreadOriginRepo resolves canonical create/fork identity without a receipt ledger. A tombstone match prevents a deleted thread from being recreated.
type ThreadPublishRepo ¶
type ThreadPublishRepo interface {
CreateThreadWithInitialEntry(context.Context, ThreadMeta, Entry) (ThreadMeta, Entry, error)
ForkWithInitialEntry(context.Context, ForkOptions, Entry) (ThreadMeta, Entry, error)
}
type ThreadTitleAuthorityRepo ¶
type ThreadTitleAuthorityRepo interface {
SetThreadTitle(context.Context, SetThreadTitleRequest) (ThreadTitleMutationResult, error)
BeginAutomaticThreadTitle(context.Context, BeginAutomaticThreadTitleRequest) (ThreadTitleMutationResult, error)
CompleteAutomaticThreadTitle(context.Context, CompleteAutomaticThreadTitleRequest) (ThreadTitleMutationResult, error)
FailAutomaticThreadTitle(context.Context, FailAutomaticThreadTitleRequest) (ThreadTitleMutationResult, error)
PendingAutomaticThreadTitles(context.Context) ([]ThreadMeta, error)
}
type ThreadTitleMutationResult ¶
type ThreadTitleMutationResult struct {
Thread ThreadMeta
Changed bool
}
type ThreadTitleProjection ¶
type ThreadTitleProjection struct {
Title string
Status ThreadTitleStatus
Source ThreadTitleSource
UpdatedAt time.Time
Error string
Generation int64
}
ThreadTitleProjection is the observable subset of canonical title authority.
type ThreadTitleSource ¶
type ThreadTitleSource string
const ( ThreadTitleSourceFallback ThreadTitleSource = "fallback" ThreadTitleSourceProvider ThreadTitleSource = "provider" ThreadTitleSourceHost ThreadTitleSource = "host" )
type ThreadTitleStatus ¶
type ThreadTitleStatus string
const ( ThreadTitlePending ThreadTitleStatus = "pending" ThreadTitleReady ThreadTitleStatus = "ready" ThreadTitleFailed ThreadTitleStatus = "failed" )
type ThreadTombstone ¶
type ThreadTombstone struct {
ThreadID string
RootThreadID string
ParentThreadID string
OriginRequestKey string
OriginFingerprint string
DeleteRequestKey string
DeleteFingerprint string
ForkedFromThreadID string
ForkedFromEntryID string
LegacyCreateIntent string `json:"create_intent_id,omitempty"`
LegacyForkRequestID string `json:"fork_operation_id,omitempty"`
LegacyForkNodeID string `json:"fork_operation_node_id,omitempty"`
DeletedAt time.Time
}
ThreadTombstone retains identity provenance after queryable Agent state is deleted. It is intentionally not a ThreadMeta and is never returned as a normal thread read.
func (*ThreadTombstone) UnmarshalJSON ¶
func (tombstone *ThreadTombstone) UnmarshalJSON(data []byte) error
ThreadTombstone was published with a mixed PascalCase/snake_case shape. Keep decoding both names while the v2-v4 lineage is converted into the v5 canonical provenance fields.
type ThreadTombstoneRepo ¶
type ThreadTombstoneRepo interface {
ThreadTombstone(context.Context, string) (ThreadTombstone, error)
}
type TurnMarkerStatus ¶
type TurnMarkerStatus string
const ( TurnStarted TurnMarkerStatus = "started" TurnSavePoint TurnMarkerStatus = "save_point" TurnCompleted TurnMarkerStatus = "completed" TurnWaiting TurnMarkerStatus = "waiting" TurnFailed TurnMarkerStatus = "failed" TurnAborted TurnMarkerStatus = "aborted" BranchBoundaryTurnFailureMessage = "turn interrupted by branch boundary" )
type TurnTerminalOutcome ¶
Source Files
¶
- artifact_authority.go
- backend_repo.go
- backend_repo_generated.go
- backend_repo_journal.go
- backend_repo_v6.go
- canonical_turn_page.go
- canonical_turn_read.go
- doc.go
- effect_authority.go
- fallback_title.go
- legacy_entry_projection_repair.go
- legacy_lease_policy.go
- lifecycle.go
- memory_state.go
- root_thread_inventory.go
- runtime_turn_journal.go
- schema_lineage_migration.go
- sessiontree.go
- thread_runtime_v5_migration.go
- title_authority.go
- turn_authority.go
- turn_failure.go