Documentation
¶
Index ¶
- Constants
- Variables
- func Backup(ctx context.Context, source, destination string) error
- func CurrentSchemaVersion() int
- func EncodeCursor(c ThreadsCursor) string
- func Inspect(path string) (sqliteutil.Inspection, error)
- type AttachmentClaimPolicy
- type ComputerAccess
- type ExecutionAuthority
- type ExecutionAuthorityCursor
- type PendingInputMigrationHandler
- type PendingInputMigrationRecord
- type PendingInputMigrationSource
- type SQLiteCompactionPlan
- type SQLitePageStats
- type Store
- func (s *Store) AdoptCanonicalRootSettings(ctx context.Context, settings ThreadSettings) error
- func (s *Store) AuthorizeUploadStagingScope(ctx context.Context, ...) (UploadStagingScope, error)
- func (s *Store) ClaimStagedUploadsToThread(ctx context.Context, endpointID string, threadID string, uploadIDs []string, ...) error
- func (s *Store) Close() error
- func (s *Store) CompleteUploadAttemptToStaging(ctx context.Context, attempt UploadAttemptRecord, rec UploadRecord, ...) error
- func (s *Store) CreateThreadSettings(ctx context.Context, t ThreadSettings) error
- func (s *Store) CreateUploadStagingScope(ctx context.Context, scope UploadStagingScope) error
- func (s *Store) DeleteExecutionAuthorities(ctx context.Context, requestKeys []string) (int64, error)
- func (s *Store) DeleteThreadProductData(ctx context.Context, endpointID, threadID string) error
- func (s *Store) EnsureUpload(ctx context.Context, rec UploadRecord) error
- func (s *Store) ExpireStaleUploadAttempts(ctx context.Context, staleBeforeUnixMs int64) (int64, error)
- func (s *Store) FailUploadAttempt(ctx context.Context, attempt UploadAttemptRecord, errorCode string) error
- func (s *Store) FinalizeDeletedUploads(ctx context.Context, uploadIDs []string) (int64, error)
- func (s *Store) GetComputerAccess(ctx context.Context, threadID string) (ComputerAccess, error)
- func (s *Store) GetComputerTarget(ctx context.Context, threadID string) (string, error)
- func (s *Store) GetExecutionAuthority(ctx context.Context, requestKey string) (*ExecutionAuthority, error)
- func (s *Store) GetExecutionAuthorityByTurn(ctx context.Context, threadID, turnID string) (*ExecutionAuthority, error)
- func (s *Store) GetStagingOwnedUpload(ctx context.Context, ...) (*UploadRecord, error)
- func (s *Store) GetThreadOwnedUpload(ctx context.Context, endpointID string, threadID string, uploadID string) (*UploadRecord, error)
- func (s *Store) GetThreadSettings(ctx context.Context, endpointID string, threadID string) (*ThreadSettings, error)
- func (s *Store) GetThreadSettingsByCanonicalThreadID(ctx context.Context, threadID string) (*ThreadSettings, error)
- func (s *Store) GetUpload(ctx context.Context, endpointID string, uploadID string) (*UploadRecord, error)
- func (s *Store) GetUserOwnedUpload(ctx context.Context, endpointID string, ownerUserHash string, uploadID string) (*UploadRecord, error)
- func (s *Store) HasCompletedOwnedUploadAttempt(ctx context.Context, endpointID string, ownerUserHash string, uploadID string) (bool, error)
- func (s *Store) InsertUpload(ctx context.Context, rec UploadRecord) error
- func (s *Store) InterruptReceivingUploadAttempts(ctx context.Context, nowUnixMs int64) ([]UploadAttemptRecord, error)
- func (s *Store) ListExecutionAuthoritiesPage(ctx context.Context, cursor ExecutionAuthorityCursor, limit int) ([]ExecutionAuthority, ExecutionAuthorityCursor, bool, error)
- func (s *Store) ListThreadSettings(ctx context.Context, endpointID string, limit int, cursor ThreadsCursor) ([]ThreadSettings, string, error)
- func (s *Store) ListThreadSettingsForRecoveryPage(ctx context.Context, cursor ThreadSettingsRecoveryCursor, limit int) ([]ThreadSettings, ThreadSettingsRecoveryCursor, bool, error)
- func (s *Store) MaybeCompact(ctx context.Context) (SQLiteCompactionPlan, error)
- func (s *Store) MovePinnedThread(ctx context.Context, endpointID, threadID, anchorID, placement string) ([]ThreadPinMetadata, error)
- func (s *Store) PrepareExpiredUploadsForDeletion(ctx context.Context, nowUnixMs int64, limit int) ([]UploadRecord, error)
- func (s *Store) PrepareUserStagedUploadDeletion(ctx context.Context, endpointID string, ownerUserHash string, uploadID string, ...) (*UploadRecord, error)
- func (s *Store) ProtectedUploadArtifactNames(ctx context.Context) (map[string]struct{}, error)
- func (s *Store) PruneTerminalUploadAttemptsPage(ctx context.Context, cutoffUnixMs int64, cursor UploadAttemptPruneCursor, ...) (UploadAttemptPruneCursor, int64, bool, error)
- func (s *Store) PutExecutionAuthority(ctx context.Context, authority ExecutionAuthority) error
- func (s *Store) ReleaseExpiredUploadStagingScopes(ctx context.Context, nowUnixMs int64, limit int) ([]UploadRecord, int, error)
- func (s *Store) ReleaseUploadStagingScope(ctx context.Context, scope UploadStagingScope, nowUnixMs int64) ([]UploadRecord, error)
- func (s *Store) ReleaseUploadStagingScopeUpload(ctx context.Context, scope UploadStagingScope, uploadID string, ...) ([]UploadRecord, error)
- func (s *Store) RequireThreadSettingsWritable(ctx context.Context, endpointID, threadID string) error
- func (s *Store) RescheduleUploadDeletion(ctx context.Context, uploadIDs []string, retryAtUnixMs int64) error
- func (s *Store) ReserveUploadAttempt(ctx context.Context, attempt UploadAttemptRecord) (UploadAttemptRecord, bool, error)
- func (s *Store) RestartFailedUploadAttempt(ctx context.Context, attempt UploadAttemptRecord) (bool, error)
- func (s *Store) RetainCanonicalUploads(ctx context.Context, endpointID, threadID string, uploadIDs []string) error
- func (s *Store) SQLitePageStats(ctx context.Context) (SQLitePageStats, error)
- func (s *Store) SetComputerAccess(ctx context.Context, threadID string, access ComputerAccess) error
- func (s *Store) SetComputerTarget(ctx context.Context, threadID, targetID string) error
- func (s *Store) SetThreadPinned(ctx context.Context, endpointID, threadID string, pinned bool) (*ThreadPinMetadata, error)
- func (s *Store) UpdateThreadModelAndReasoningSelection(ctx context.Context, endpointID string, threadID string, modelID string, ...) error
- func (s *Store) UpdateThreadModelID(ctx context.Context, endpointID string, threadID string, modelID string) error
- func (s *Store) UpdateThreadPermissionType(ctx context.Context, endpointID string, threadID string, permissionType string) error
- func (s *Store) UpdateThreadReasoningSelection(ctx context.Context, endpointID string, threadID string, ...) error
- type ThreadPinMetadata
- type ThreadSettings
- type ThreadSettingsRecoveryCursor
- type ThreadsCursor
- type UploadAttemptPruneCursor
- type UploadAttemptRecord
- type UploadQuotaError
- type UploadRecord
- type UploadStagingScope
Constants ¶
const ( UploadStateStaged = "staged" UploadStateLive = "live" UploadStateDeleting = "deleting" UploadRefKindThread = "thread" UploadRefKindStaging = "staging" UploadSourceFile = "uploaded_file" UploadSourceLongText = "long_text" UploadAttemptReceiving = "receiving" UploadAttemptComplete = "complete" UploadAttemptFailed = "failed" UploadStagedOwnerItemLimit = 100 UploadStagedOwnerByteLimit = int64(100 << 20) UploadLiveOwnerItemLimit = 1000 UploadLiveOwnerByteLimit = int64(1 << 30) UploadLiveThreadItemLimit = 1000 UploadLiveThreadByteLimit = int64(250 << 20) AttachmentClaimPolicyMaxCount = 10 AttachmentClaimPolicyMaxTurnBytes = int64(25 << 20) )
Variables ¶
var ( ErrUploadIdempotencyConflict = errors.New("upload idempotency conflict") ErrUploadInProgress = errors.New("upload is still in progress") ErrUploadQuotaExceeded = errors.New("upload quota exceeded") ErrLongTextAttachmentRequired = errors.New("long_text_attachment_required") )
var ErrCanonicalThreadSettingsConflict = errors.New("canonical thread settings conflict")
var ErrExecutionAuthorityConflict = errors.New("execution authority conflicts with an existing request")
var ErrPinPositionConflict = errors.New("pinned conversations changed; refresh the list and try again")
Functions ¶
func Backup ¶ added in v0.13.0
Backup snapshots product storage while its service generation is closed.
func CurrentSchemaVersion ¶
func CurrentSchemaVersion() int
CurrentSchemaVersion returns the product-only threadstore schema version.
func EncodeCursor ¶
func EncodeCursor(c ThreadsCursor) string
EncodeCursor encodes a cursor as a URL-safe base64 string.
func Inspect ¶ added in v0.13.0
func Inspect(path string) (sqliteutil.Inspection, error)
Inspect checks a product store before any other owner begins an upgrade.
Types ¶
type AttachmentClaimPolicy ¶ added in v0.11.0
type ComputerAccess ¶ added in v0.13.0
type ComputerAccess struct {
Origins []string `json:"origins"`
Apps []string `json:"apps"`
AllowForeground bool `json:"allow_foreground"`
}
ComputerAccess is product authorization for a thread, not runtime ownership. Forks start with the empty database default; no permission follows history.
func (ComputerAccess) Validate ¶ added in v0.13.0
func (a ComputerAccess) Validate() error
type ExecutionAuthority ¶ added in v0.11.0
type ExecutionAuthority struct {
RequestKey string
ThreadID string
TurnID string
EndpointID string
NamespacePublicID string
ChannelID string
UserPublicID string
UserEmail string
PermissionType string
CreatedAtUnixMs int64
}
ExecutionAuthority is the minimum durable host fact needed to rebuild one provider execution after restart. PermissionType records admission policy for attribution; live tool authorization reads thread settings. It is not a second Agent lifecycle or transcript store; Floret remains authoritative for all execution state.
type ExecutionAuthorityCursor ¶ added in v0.13.0
type PendingInputMigrationHandler ¶ added in v0.13.0
type PendingInputMigrationHandler func(context.Context, PendingInputMigrationSource, []PendingInputMigrationRecord) ([]ExecutionAuthority, error)
PendingInputMigrationHandler converts every supplied retired queue item into canonical Floret state. Returned authorities must correspond one-to-one with the records. The product migration commits those authorities and removes the retired source in the same transaction after the handler succeeds.
type PendingInputMigrationRecord ¶ added in v0.13.0
type PendingInputMigrationRecord struct {
RequestID string
EndpointID string
ThreadID string
ModelID string
TextContent string
AttachmentsJSON string
ContextActionJSON string
OptionsJSON string
SessionMetaJSON string
CreatedAtUnixMs int64
}
PendingInputMigrationRecord is one retired product queue item presented only while an older threadstore is being upgraded. It is never current-schema state and cannot be created by production handlers.
type PendingInputMigrationSource ¶ added in v0.13.0
type PendingInputMigrationSource interface {
GetThreadSettings(context.Context, string, string) (*ThreadSettings, error)
LegacyPrimaryTargetID(context.Context, string, string) (string, error)
GetThreadOwnedUpload(context.Context, string, string, string) (*UploadRecord, error)
}
PendingInputMigrationSource exposes only the current product facts needed to convert a retired queue item into Floret's canonical input contract.
type SQLiteCompactionPlan ¶
type SQLiteCompactionPlan struct {
ShouldCompact bool
UseIncremental bool
PageSize int64
PageCount int64
FreelistCount int64
FreeBytes int64
PagesToRelease int64
}
func BuildSQLiteCompactionPlan ¶
func BuildSQLiteCompactionPlan(stats SQLitePageStats) SQLiteCompactionPlan
type SQLitePageStats ¶
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store is a local SQLite-backed persistence layer for Redeven product data.
Notes: - Data is scoped by endpoint_id (env public id). It is intentionally shared within the same env for collaboration. - WAL is enabled to support concurrent reads while writing (multiple browser sessions).
func OpenWithPendingInputMigration ¶ added in v0.13.0
func OpenWithPendingInputMigration(ctx context.Context, path string, migrate PendingInputMigrationHandler) (*Store, error)
OpenWithPendingInputMigration opens the current product store and gives the startup owner one atomic opportunity to convert retired queue inputs into canonical Floret state before their old table is removed.
func (*Store) AdoptCanonicalRootSettings ¶ added in v0.11.0
func (s *Store) AdoptCanonicalRootSettings(ctx context.Context, settings ThreadSettings) error
func (*Store) AuthorizeUploadStagingScope ¶ added in v0.11.0
func (*Store) ClaimStagedUploadsToThread ¶ added in v0.11.0
func (s *Store) ClaimStagedUploadsToThread( ctx context.Context, endpointID string, threadID string, uploadIDs []string, admission AttachmentClaimPolicy, scope UploadStagingScope, ) error
ClaimStagedUploadsToThread moves product-owned upload references from a transport staging scope to their canonical thread. It does not create a turn, queue item, admission receipt, or any other agent lifecycle state.
func (*Store) CompleteUploadAttemptToStaging ¶ added in v0.11.0
func (s *Store) CompleteUploadAttemptToStaging(ctx context.Context, attempt UploadAttemptRecord, rec UploadRecord, scope UploadStagingScope) error
func (*Store) CreateThreadSettings ¶ added in v0.10.0
func (s *Store) CreateThreadSettings(ctx context.Context, t ThreadSettings) error
func (*Store) CreateUploadStagingScope ¶ added in v0.11.0
func (s *Store) CreateUploadStagingScope(ctx context.Context, scope UploadStagingScope) error
func (*Store) DeleteExecutionAuthorities ¶ added in v0.13.0
func (*Store) DeleteThreadProductData ¶ added in v0.11.0
DeleteThreadProductData removes only Redeven-owned catalog and attachment rows. The caller deletes the canonical Floret thread first.
func (*Store) EnsureUpload ¶
func (s *Store) EnsureUpload(ctx context.Context, rec UploadRecord) error
func (*Store) ExpireStaleUploadAttempts ¶ added in v0.11.0
func (*Store) FailUploadAttempt ¶ added in v0.11.0
func (*Store) FinalizeDeletedUploads ¶
func (*Store) GetComputerAccess ¶ added in v0.13.0
func (*Store) GetComputerTarget ¶ added in v0.13.0
GetComputerTarget reads selection for an already authorized canonical thread. Selection is not an authorization grant and does not imply target readiness.
func (*Store) GetExecutionAuthority ¶ added in v0.11.0
func (*Store) GetExecutionAuthorityByTurn ¶ added in v0.11.0
func (*Store) GetStagingOwnedUpload ¶ added in v0.11.0
func (*Store) GetThreadOwnedUpload ¶ added in v0.10.0
func (*Store) GetThreadSettings ¶ added in v0.10.0
func (*Store) GetThreadSettingsByCanonicalThreadID ¶ added in v0.11.0
func (*Store) GetUserOwnedUpload ¶ added in v0.11.0
func (*Store) HasCompletedOwnedUploadAttempt ¶ added in v0.11.0
func (*Store) InsertUpload ¶
func (s *Store) InsertUpload(ctx context.Context, rec UploadRecord) error
func (*Store) InterruptReceivingUploadAttempts ¶ added in v0.11.0
func (*Store) ListExecutionAuthoritiesPage ¶ added in v0.13.0
func (s *Store) ListExecutionAuthoritiesPage(ctx context.Context, cursor ExecutionAuthorityCursor, limit int) ([]ExecutionAuthority, ExecutionAuthorityCursor, bool, error)
func (*Store) ListThreadSettings ¶ added in v0.10.0
func (s *Store) ListThreadSettings(ctx context.Context, endpointID string, limit int, cursor ThreadsCursor) ([]ThreadSettings, string, error)
func (*Store) ListThreadSettingsForRecoveryPage ¶ added in v0.11.0
func (s *Store) ListThreadSettingsForRecoveryPage(ctx context.Context, cursor ThreadSettingsRecoveryCursor, limit int) ([]ThreadSettings, ThreadSettingsRecoveryCursor, bool, error)
ListThreadSettingsForRecoveryPage returns a stable page of host-owned root identities for startup reconciliation. It does not project Agent state.
func (*Store) MaybeCompact ¶
func (s *Store) MaybeCompact(ctx context.Context) (SQLiteCompactionPlan, error)
func (*Store) MovePinnedThread ¶ added in v0.13.0
func (s *Store) MovePinnedThread(ctx context.Context, endpointID, threadID, anchorID, placement string) ([]ThreadPinMetadata, error)
MovePinnedThread applies one relative move to the complete current endpoint order. Immediate SQLite transactions serialize it with pin, unpin and deletion.
func (*Store) PrepareExpiredUploadsForDeletion ¶
func (*Store) PrepareUserStagedUploadDeletion ¶ added in v0.11.0
func (*Store) ProtectedUploadArtifactNames ¶ added in v0.11.0
func (*Store) PruneTerminalUploadAttemptsPage ¶ added in v0.13.0
func (s *Store) PruneTerminalUploadAttemptsPage(ctx context.Context, cutoffUnixMs int64, cursor UploadAttemptPruneCursor, limit int) (UploadAttemptPruneCursor, int64, bool, error)
PruneTerminalUploadAttemptsPage removes one bounded page whose idempotency window has elapsed. Receiving attempts are handled by recovery first.
func (*Store) PutExecutionAuthority ¶ added in v0.11.0
func (s *Store) PutExecutionAuthority(ctx context.Context, authority ExecutionAuthority) error
func (*Store) ReleaseExpiredUploadStagingScopes ¶ added in v0.11.0
func (*Store) ReleaseUploadStagingScope ¶ added in v0.11.0
func (s *Store) ReleaseUploadStagingScope(ctx context.Context, scope UploadStagingScope, nowUnixMs int64) ([]UploadRecord, error)
func (*Store) ReleaseUploadStagingScopeUpload ¶ added in v0.11.0
func (s *Store) ReleaseUploadStagingScopeUpload(ctx context.Context, scope UploadStagingScope, uploadID string, nowUnixMs int64) ([]UploadRecord, error)
func (*Store) RequireThreadSettingsWritable ¶ added in v0.10.0
func (s *Store) RequireThreadSettingsWritable(ctx context.Context, endpointID, threadID string) error
RequireThreadSettingsWritable verifies product catalog ownership only. Floret owns thread lifecycle and deletion tombstones.
func (*Store) RescheduleUploadDeletion ¶
func (*Store) ReserveUploadAttempt ¶ added in v0.11.0
func (s *Store) ReserveUploadAttempt(ctx context.Context, attempt UploadAttemptRecord) (UploadAttemptRecord, bool, error)
func (*Store) RestartFailedUploadAttempt ¶ added in v0.11.0
func (*Store) RetainCanonicalUploads ¶ added in v0.13.0
func (s *Store) RetainCanonicalUploads(ctx context.Context, endpointID, threadID string, uploadIDs []string) error
RetainCanonicalUploads records product resource retention after the caller has verified membership in Floret's canonical history, including fork paths. It does not admit a message or grant access to an attachment.
func (*Store) SQLitePageStats ¶
func (s *Store) SQLitePageStats(ctx context.Context) (SQLitePageStats, error)
func (*Store) SetComputerAccess ¶ added in v0.13.0
func (*Store) SetComputerTarget ¶ added in v0.13.0
SetComputerTarget changes only the selected target. It never creates thread settings, changes permissions or copies a parent's control session on fork.
func (*Store) SetThreadPinned ¶ added in v0.7.1
func (*Store) UpdateThreadModelAndReasoningSelection ¶ added in v0.7.2
func (*Store) UpdateThreadModelID ¶
func (*Store) UpdateThreadPermissionType ¶ added in v0.7.2
type ThreadPinMetadata ¶ added in v0.13.0
type ThreadPinMetadata struct {
ThreadID string `json:"thread_id"`
PinnedAtUnixMs int64 `json:"pinned_at_unix_ms"`
PinRank int64 `json:"pin_rank"`
SettingsRevision int64 `json:"settings_revision"`
}
ThreadPinMetadata is a product mutation result, never a canonical thread view.
type ThreadSettings ¶ added in v0.10.0
type ThreadSettings struct {
ThreadID string `json:"thread_id"`
ParentThreadID string `json:"parent_thread_id,omitempty"`
EndpointID string `json:"endpoint_id"`
NamespacePublicID string `json:"namespace_public_id"`
ModelID string `json:"model_id"`
ReasoningSelectionJSON string `json:"reasoning_selection_json"`
PermissionType string `json:"permission_type"`
WorkingDir string `json:"working_dir"`
PinnedAtUnixMs int64 `json:"pinned_at_unix_ms"`
PinRank int64 `json:"pin_rank"`
SettingsCreatedAtUnixMs int64 `json:"settings_created_at_unix_ms"`
SettingsUpdatedAtUnixMs int64 `json:"settings_updated_at_unix_ms"`
}
type ThreadSettingsRecoveryCursor ¶ added in v0.11.0
type ThreadsCursor ¶
func DecodeCursor ¶
func DecodeCursor(raw string) (ThreadsCursor, bool)
type UploadAttemptPruneCursor ¶ added in v0.13.0
type UploadAttemptRecord ¶ added in v0.11.0
type UploadQuotaError ¶ added in v0.11.0
func (*UploadQuotaError) Error ¶ added in v0.11.0
func (e *UploadQuotaError) Error() string
func (*UploadQuotaError) Unwrap ¶ added in v0.11.0
func (e *UploadQuotaError) Unwrap() error
type UploadRecord ¶
type UploadRecord struct {
UploadID string `json:"upload_id"`
EndpointID string `json:"endpoint_id"`
OwnerUserHash string `json:"owner_user_hash,omitempty"`
StorageRelPath string `json:"storage_relpath"`
Name string `json:"name"`
DetectedMediaType string `json:"detected_media_type"`
MimeType string `json:"mime_type"`
SizeBytes int64 `json:"size_bytes"`
ContentSHA256 string `json:"content_sha256,omitempty"`
UnicodeCodePoints *int64 `json:"unicode_code_points,omitempty"`
LogicalLineCount *int64 `json:"logical_line_count,omitempty"`
Source string `json:"source"`
State string `json:"state"`
CreatedAtUnixMs int64 `json:"created_at_unix_ms"`
DeleteAfterUnixMs int64 `json:"delete_after_unix_ms"`
}