Documentation
¶
Index ¶
- Constants
- type AccessLevel
- type Attachment
- type Channel
- type Conversation
- type ConversationAncestry
- type ConversationAncestryFilter
- type ConversationAncestrySegment
- type ConversationGroup
- type ConversationListMode
- type ConversationMembership
- type Entry
- type Memory
- type MemoryKindMigration
- type MemoryKindVersion
- type MemoryVector
- type OwnershipTransfer
- type Task
Constants ¶
const ( MigrationStateQueued = "queued" MigrationStateRunning = "running" MigrationStateCanceling = "canceling" MigrationStateSucceeded = "succeeded" MigrationStateFailed = "failed" MigrationStateCanceled = "canceled" )
Migration state constants.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AccessLevel ¶
type AccessLevel string
AccessLevel represents the level of access a user has to a conversation group.
const ( AccessLevelOwner AccessLevel = "owner" AccessLevelManager AccessLevel = "manager" AccessLevelWriter AccessLevel = "writer" AccessLevelReader AccessLevel = "reader" )
func (AccessLevel) IsAtLeast ¶
func (a AccessLevel) IsAtLeast(level AccessLevel) bool
IsAtLeast returns true if the access level is at least the given level.
type Attachment ¶
type Attachment struct {
ID uuid.UUID `json:"id" gorm:"primaryKey;type:uuid"`
StorageKey *string `json:"storageKey,omitempty"`
Filename *string `json:"filename,omitempty"`
ContentType string `json:"contentType" gorm:"not null"`
Size *int64 `json:"size,omitempty"`
SHA256 *string `json:"sha256,omitempty"`
UserID string `json:"userId" gorm:"not null"`
EntryID *uuid.UUID `json:"entryId,omitempty" gorm:"type:uuid"`
Status string `json:"status" gorm:"not null;default:'ready'"`
SourceURL *string `json:"sourceUrl,omitempty"`
ExpiresAt *time.Time `json:"expiresAt,omitempty"`
CreatedAt time.Time `json:"createdAt" gorm:"not null;default:now()"`
ArchivedAt *time.Time `json:"archivedAt,omitempty"`
}
Attachment represents file attachment metadata.
func (Attachment) TableName ¶
func (Attachment) TableName() string
type Conversation ¶
type Conversation struct {
ID string `json:"id" gorm:"primaryKey;type:text"`
Title []byte `json:"-" gorm:"type:bytea"` // encrypted
OwnerUserID string `json:"ownerUserId" gorm:"not null"`
ClientID string `json:"-" gorm:"not null"`
AgentID *string `json:"agentId,omitempty"`
Metadata map[string]interface{} `json:"metadata" gorm:"type:jsonb;serializer:json;not null;default:'{}'"` // JSONB
ConversationGroupID uuid.UUID `json:"-" gorm:"not null;type:uuid"`
ConversationGroup *ConversationGroup `json:"-" gorm:"foreignKey:ConversationGroupID"`
ForkedAtEntryID *uuid.UUID `json:"forkedAtEntryId,omitempty" gorm:"-"`
ForkedAtConversationID *string `json:"forkedAtConversationId,omitempty" gorm:"-"`
// Started-by lineage is stored on the original conversation in the fork group
// and projected onto every branch in API and store response models.
StartedByConversationID *string `json:"startedByConversationId,omitempty" gorm:"type:text"`
StartedByEntryID *uuid.UUID `json:"startedByEntryId,omitempty" gorm:"type:uuid"`
CreatedAt time.Time `json:"createdAt" gorm:"not null;default:now()"`
UpdatedAt time.Time `json:"updatedAt" gorm:"not null;default:now()"`
VectorizedAt *time.Time `json:"vectorizedAt,omitempty"`
ArchivedAt *time.Time `json:"archivedAt,omitempty"`
}
Conversation represents a single conversation within a group. ClientID is the authenticated app/system identity, not the logical agent (that is AgentID); it is internal metadata kept out of user-facing REST payloads.
func (Conversation) TableName ¶
func (Conversation) TableName() string
type ConversationAncestry ¶ added in v0.0.4
type ConversationAncestry struct {
ConversationGroupID uuid.UUID `json:"-" gorm:"primaryKey;type:uuid"`
DescendantConversationID string `json:"descendantConversationId" gorm:"primaryKey;type:text"`
AncestorConversationID string `json:"ancestorConversationId" gorm:"primaryKey;type:text"`
Depth int `json:"depth" gorm:"not null"`
BeforeEntryID *uuid.UUID `json:"beforeEntryId,omitempty" gorm:"type:uuid"`
ForkedAtEntryID *uuid.UUID `json:"forkedAtEntryId,omitempty" gorm:"type:uuid"`
}
ConversationAncestry materializes the visible fork path for a conversation.
func (ConversationAncestry) TableName ¶ added in v0.0.4
func (ConversationAncestry) TableName() string
type ConversationAncestryFilter ¶
type ConversationAncestryFilter string
ConversationAncestryFilter controls whether list operations return top-level or child conversations.
const ( ConversationAncestryRoots ConversationAncestryFilter = "roots" ConversationAncestryChildren ConversationAncestryFilter = "children" ConversationAncestryAll ConversationAncestryFilter = "all" )
type ConversationAncestrySegment ¶ added in v0.0.4
type ConversationAncestrySegment struct {
ConversationID string
Depth int
BeforeEntryID *uuid.UUID
ForkedAtEntryID *uuid.UUID
}
ConversationAncestrySegment is the datastore-neutral ancestry row shape used to construct a descendant's materialized fork path before mapping it back to a store-specific representation.
func BuildConversationAncestrySegments ¶ added in v0.0.4
func BuildConversationAncestrySegments(convID string, parentRows []ConversationAncestrySegment, forkedAtEntryID *uuid.UUID, anchorOwnerDepth *int) ([]ConversationAncestrySegment, error)
BuildConversationAncestrySegments returns the complete ancestry path for a new conversation. It always includes the depth-0 self segment. When parentRows is non-empty, it copies the parent's already-materialized closure, increments depths, records the direct fork anchor on the copied parent self row, and applies the exclusive boundary to the ancestor segment that owns the anchor. SQL and Mongo stores must both build ancestry through this helper so the inherited-anchor and blank-segment rules stay identical across datastores.
type ConversationGroup ¶
type ConversationGroup struct {
ID uuid.UUID `json:"id" gorm:"primaryKey;type:uuid"`
CreatedAt time.Time `json:"createdAt" gorm:"not null;default:now()"`
ArchivedAt *time.Time `json:"archivedAt,omitempty"`
}
ConversationGroup is the root of a fork tree.
func (ConversationGroup) TableName ¶
func (ConversationGroup) TableName() string
type ConversationListMode ¶
type ConversationListMode string
ConversationListMode controls which conversations from each fork tree are returned.
const ( ListModeAll ConversationListMode = "all" ListModeRoots ConversationListMode = "roots" ListModeLatestFork ConversationListMode = "latest-fork" )
type ConversationMembership ¶
type ConversationMembership struct {
ConversationGroupID uuid.UUID `json:"-" gorm:"primaryKey;type:uuid"`
UserID string `json:"userId" gorm:"primaryKey"`
AccessLevel AccessLevel `json:"accessLevel" gorm:"not null"`
CreatedAt time.Time `json:"createdAt" gorm:"not null;default:now()"`
}
ConversationMembership tracks per-user access to a conversation group.
func (ConversationMembership) TableName ¶
func (ConversationMembership) TableName() string
type Entry ¶
type Entry struct {
ID uuid.UUID `json:"id" gorm:"primaryKey;type:uuid"`
ConversationID string `json:"conversationId" gorm:"not null;type:text"`
ConversationGroupID uuid.UUID `json:"-" gorm:"primaryKey;type:uuid"`
UserID *string `json:"userId,omitempty"`
ClientID *string `json:"clientId,omitempty"`
AgentID *string `json:"agentId,omitempty"`
Channel Channel `json:"channel" gorm:"not null"`
Epoch *int64 `json:"epoch,omitempty"`
Seq *uint32 `json:"seq,omitempty"`
ContentType string `json:"contentType" gorm:"not null"`
Content []byte `json:"-" gorm:"type:bytea;not null"` // encrypted
IndexedContent *string `json:"indexedContent,omitempty"`
IndexedAt *time.Time `json:"indexedAt,omitempty"`
CreatedAt time.Time `json:"createdAt" gorm:"not null;default:now()"`
}
Entry represents a message or context entry in a conversation.
func (Entry) MarshalJSON ¶
MarshalJSON serializes Entry to JSON, including the decrypted content as a raw JSON value. Content is stored as []byte with json:"-" to prevent GORM from leaking encrypted bytes, but API responses need to include the decrypted content.
func (*Entry) UnmarshalJSON ¶
UnmarshalJSON restores Entry from JSON including the decrypted content field. This keeps cache round-trips lossless for model.Entry values.
type Memory ¶
type Memory struct {
// ID is the primary key (UUID).
ID uuid.UUID `json:"id" gorm:"primaryKey;type:uuid;default:gen_random_uuid()"`
// Namespace is the RS-encoded namespace string (percent-encoded segments joined with \x1e).
// Clients always work with []string; this field is for storage only.
Namespace string `json:"-" gorm:"not null"`
// Key is the memory key, unique within a namespace (active rows only).
Key string `json:"key" gorm:"not null"`
// ValueEncrypted is the AES-256-GCM encrypted JSON value. Decrypted on read.
// NULL for tombstones (deleted/expired rows after eviction).
ValueEncrypted []byte `json:"-" gorm:"column:value_encrypted"`
// PolicyAttributes contains plaintext OPA-extracted attributes for server-side filtering.
// Never returned to clients.
PolicyAttributes map[string]interface{} `json:"-" gorm:"type:jsonb;serializer:json;column:policy_attributes"`
// IndexedContent contains caller-provided redacted text keyed by field path.
IndexedContent map[string]string `json:"-" gorm:"type:jsonb;serializer:json;column:indexed_content"`
// Kind records whether this row was a first write (0=add) or a subsequent write (1=update).
// Set at write time; never changed.
Kind int16 `json:"-" gorm:"not null;default:0;column:kind"`
// CreatedAt is when this row was written.
CreatedAt time.Time `json:"createdAt" gorm:"not null;default:now()"`
// ExpiresAt is the optional TTL expiry time. NULL means no expiry.
ExpiresAt *time.Time `json:"expiresAt" gorm:"column:expires_at"`
// ArchivedAt is set when the row is archived (superseded or key deleted).
ArchivedAt *time.Time `json:"-" gorm:"column:archived_at"`
// DeletedReason records why the row was deleted. NULL=active, 0=updated, 1=deleted, 2=expired.
DeletedReason *int16 `json:"-" gorm:"column:deleted_reason"`
// IndexedAt tracks vector index sync state. NULL means pending indexing.
IndexedAt *time.Time `json:"-" gorm:"column:indexed_at"`
}
Memory is a single namespaced episodic memory item. Each row in the memories table represents one write event. The active value of a (namespace, key) pair is the row where ArchivedAt IS NULL.
type MemoryKindMigration ¶ added in v0.2.0
type MemoryKindMigration struct {
ID uuid.UUID `json:"id" gorm:"primaryKey;type:uuid;column:id"`
Source string `json:"source" gorm:"not null;column:source"`
Target string `json:"target" gorm:"not null;column:target"`
NamespacePrefix []string `json:"namespacePrefix" gorm:"type:jsonb;serializer:json;column:namespace_prefix"`
State string `json:"state" gorm:"not null;column:state"`
CancelRequested bool `json:"cancelRequested" gorm:"not null;default:false;column:cancel_requested"`
MigratedCount int64 `json:"migratedCount" gorm:"not null;default:0;column:migrated_count"`
SkippedTombstoneCount int64 `json:"skippedTombstoneCount" gorm:"not null;default:0;column:skipped_tombstone_count"`
VectorPendingCount int64 `json:"vectorPendingCount" gorm:"not null;default:0;column:vector_pending_count"`
RetryCount int `json:"retryCount" gorm:"not null;default:0;column:retry_count"`
LastErrorCode *string `json:"lastErrorCode" gorm:"column:last_error_code"`
CreatedAt time.Time `json:"createdAt" gorm:"not null;default:now();column:created_at"`
StartedAt *time.Time `json:"startedAt" gorm:"column:started_at"`
CompletedAt *time.Time `json:"completedAt" gorm:"column:completed_at"`
}
MemoryKindMigration tracks a background migration job.
func (MemoryKindMigration) TableName ¶ added in v0.2.0
func (MemoryKindMigration) TableName() string
type MemoryKindVersion ¶ added in v0.2.0
type MemoryKindVersion struct {
Name string `json:"name" gorm:"primaryKey;column:name"`
AttributeTypes map[string]string `json:"attributes" gorm:"type:jsonb;serializer:json;column:attribute_types"`
AttributesRego *string `json:"projectionRego" gorm:"column:attributes_rego"`
Writable bool `json:"writable" gorm:"not null;default:true;column:writable"`
CreatedAt time.Time `json:"createdAt" gorm:"not null;default:now();column:created_at"`
}
MemoryKindVersion is an immutable schema resource stored in the datastore.
func (MemoryKindVersion) TableName ¶ added in v0.2.0
func (MemoryKindVersion) TableName() string
type MemoryVector ¶
type MemoryVector struct {
// MemoryID references the memories.id.
MemoryID uuid.UUID `gorm:"not null;primaryKey;column:memory_id"`
// FieldName is the JSON field name within the memory value that was embedded.
FieldName string `gorm:"not null;primaryKey;column:field_name"`
// Namespace is a redundant copy of the memory's encoded namespace for prefix filtering.
Namespace string `gorm:"not null;column:namespace"`
// PolicyAttributes is a redundant copy of the memory's policy_attributes for filtering.
PolicyAttributes map[string]interface{} `gorm:"type:jsonb;serializer:json;column:policy_attributes"`
}
MemoryVector stores the embedding for a single (memory_id, field_name) pair. One Memory can produce multiple MemoryVector rows (one per indexed field).
func (MemoryVector) TableName ¶
func (MemoryVector) TableName() string
TableName implements gorm.Tabler.
type OwnershipTransfer ¶
type OwnershipTransfer struct {
ID uuid.UUID `json:"id" gorm:"primaryKey;type:uuid"`
ConversationGroupID uuid.UUID `json:"-" gorm:"not null;type:uuid"`
FromUserID string `json:"fromUserId" gorm:"not null"`
ToUserID string `json:"toUserId" gorm:"not null"`
CreatedAt time.Time `json:"createdAt" gorm:"not null;default:now()"`
}
OwnershipTransfer represents a pending conversation ownership transfer.
func (OwnershipTransfer) TableName ¶
func (OwnershipTransfer) TableName() string
type Task ¶
type Task struct {
ID uuid.UUID `json:"id" gorm:"primaryKey;type:uuid"`
TaskName *string `json:"taskName,omitempty" gorm:"unique"`
TaskType string `json:"taskType" gorm:"not null"`
TaskBody map[string]interface{} `json:"taskBody" gorm:"type:jsonb;serializer:json;not null"`
CreatedAt time.Time `json:"createdAt" gorm:"not null;default:now()"`
RetryAt time.Time `json:"retryAt" gorm:"not null;default:now()"`
LastError *string `json:"lastError,omitempty"`
RetryCount int `json:"retryCount" gorm:"not null;default:0"`
}
Task represents a background task in the task queue.