sqlstore

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 2, 2026 License: Apache-2.0 Imports: 39 Imported by: 0

Documentation

Overview

Package sqlstore contains shared relational transactions and repositories.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DecodeExperienceStoredValue

func DecodeExperienceStoredValue(content any) (experience.Content, error)

DecodeExperienceStoredValue applies the authoritative Artifact codec to a driver-returned payload value for backend-specific indexes.

func EnsureArtifactHeadSearchableText

func EnsureArtifactHeadSearchableText(ctx context.Context, db DBTX, dialect Dialect) error

EnsureArtifactHeadSearchableText upgrades databases created before the rebuildable Experience projection was added. It is safe to call repeatedly.

func EnsureBuiltinSchema

func EnsureBuiltinSchema(ctx context.Context, db DBTX) error

EnsureBuiltinSchema creates only absent Python-compatible core tables.

func EnsureBuiltinSchemaForDialect

func EnsureBuiltinSchemaForDialect(ctx context.Context, db DBTX, dialect Dialect) error

EnsureBuiltinSchemaForDialect creates the same logical SQLAlchemy schema using the payload/text variants emitted by the frozen Python MySQL dialect.

func EnsureHandoffReportSchema

func EnsureHandoffReportSchema(ctx context.Context, db DBTX) error

EnsureHandoffReportSchema creates the frozen optional schema. Callers must invoke it only after the feature has been enabled.

func EnsureHandoffReportSchemaForDialect

func EnsureHandoffReportSchemaForDialect(ctx context.Context, db DBTX, dialect Dialect) error

func HandoffScopeIDs

func HandoffScopeIDs(ctx context.Context, database *Database) ([]string, error)

HandoffScopeIDs returns only scopes that own a committed Handoff head. It is the authority behind scope-centric Handoff Report discovery.

func MySQLIdentityType

func MySQLIdentityType(length int) string

MySQLIdentityType is the byte-exact string type used for opaque identities by the Python MySQL/OceanBase schema. A database default such as utf8mb4_general_ci would otherwise collapse case- and accent-distinct keys.

func RebuildExperienceProjections

func RebuildExperienceProjections(ctx context.Context, db DBTX) error

RebuildExperienceProjections refreshes the relational searchable_text field from immutable approved Experience heads without touching backend indexes.

func ReplaceExperienceProjection

func ReplaceExperienceProjection(ctx context.Context, db DBTX, scopeID string, value experience.Experience) error

ReplaceExperienceProjection updates the rebuildable relational projection.

func ValidateOceanBaseURL

func ValidateOceanBaseURL(rawURL string) error

ValidateOceanBaseURL validates the frozen Python profile URL without returning credentials or opening a network connection.

Types

type ArtifactCodec

type ArtifactCodec struct {
	// contains filtered or unexported fields
}

ArtifactCodec is an exact family/content route for one persisted Artifact schema. It is immutable after construction.

func ExperienceArtifactCodec

func ExperienceArtifactCodec() ArtifactCodec

ExperienceArtifactCodec returns the Python-compatible Experience route.

func HandoffArtifactCodec

func HandoffArtifactCodec() ArtifactCodec

HandoffArtifactCodec returns the versioned Handoff content route.

func MemoryArtifactCodec

func MemoryArtifactCodec() ArtifactCodec

MemoryArtifactCodec returns the authoritative Memory manifest route.

func NewArtifactCodec

func NewArtifactCodec[T any](
	family string,
	encode func(T) ([]byte, error),
	decode func([]byte) (T, error),
) (ArtifactCodec, error)

NewArtifactCodec constructs an exact concrete content codec.

func SkillArtifactCodec

func SkillArtifactCodec() ArtifactCodec

SkillArtifactCodec returns the Python-compatible managed Skill route.

type ArtifactRepository

type ArtifactRepository struct {
	// contains filtered or unexported fields
}

ArtifactRepository persists immutable revisions and direct ordered lineage.

func NewArtifactRepository

func NewArtifactRepository(dialect Dialect, codecs ...ArtifactCodec) (*ArtifactRepository, error)

func (*ArtifactRepository) Create

func (r *ArtifactRepository) Create(
	ctx context.Context,
	db DBTX,
	scopeID string,
	artifactID string,
	draft artifact.DraftSnapshot,
) (artifact.Snapshot, error)

func (*ArtifactRepository) Get

func (r *ArtifactRepository) Get(
	ctx context.Context,
	db DBTX,
	scopeID string,
	ref artifact.Ref,
) (artifact.Snapshot, error)

func (*ArtifactRepository) Latest

func (r *ArtifactRepository) Latest(
	ctx context.Context,
	db DBTX,
	scopeID, family, artifactID string,
) (artifact.Snapshot, error)

func (*ArtifactRepository) Revise

func (r *ArtifactRepository) Revise(
	ctx context.Context,
	db DBTX,
	scopeID string,
	current artifact.Snapshot,
	draft artifact.DraftSnapshot,
) (artifact.Snapshot, error)

func (*ArtifactRepository) Revisions

func (r *ArtifactRepository) Revisions(
	ctx context.Context,
	db DBTX,
	scopeID, family, artifactID string,
) (result []artifact.Snapshot, returnErr error)

type CandidateRepository

type CandidateRepository struct {
	// contains filtered or unexported fields
}

CandidateRepository stores family-neutral immutable proposal versions and mutable lifecycle heads.

func NewCandidateRepository

func NewCandidateRepository(dialect Dialect, proposalCodecs ...ArtifactCodec) (*CandidateRepository, error)

func (*CandidateRepository) Create

func (r *CandidateRepository) Create(
	ctx context.Context,
	db DBTX,
	scopeID, candidateID, family string,
	proposal any,
	sources []source.Ref,
	artifacts []artifact.Ref,
	target *artifact.Ref,
	reason *string,
) (review.Snapshot, error)

func (*CandidateRepository) Get

func (r *CandidateRepository) Get(
	ctx context.Context,
	db DBTX,
	scopeID, candidateID string,
) (review.Snapshot, error)

func (*CandidateRepository) List

func (r *CandidateRepository) List(
	ctx context.Context,
	db DBTX,
	scopeID string,
	status review.Status,
	family, cursor *string,
	limit int,
) (page review.Page, returnErr error)

func (*CandidateRepository) LockPending

func (r *CandidateRepository) LockPending(
	ctx context.Context,
	db DBTX,
	scopeID, candidateID string,
	expectedVersion int64,
) (review.Snapshot, error)

func (*CandidateRepository) MarkApproved

func (r *CandidateRepository) MarkApproved(
	ctx context.Context,
	db DBTX,
	scopeID, candidateID string,
	expectedVersion int64,
	resultRef artifact.Ref,
) (review.Snapshot, error)

func (*CandidateRepository) Reject

func (r *CandidateRepository) Reject(
	ctx context.Context,
	db DBTX,
	scopeID, candidateID string,
	expectedVersion int64,
	reason string,
) (review.Snapshot, error)

func (*CandidateRepository) Revise

func (r *CandidateRepository) Revise(
	ctx context.Context,
	db DBTX,
	scopeID, candidateID string,
	expectedVersion int64,
	proposal any,
	sources []source.Ref,
	artifacts []artifact.Ref,
	target *artifact.Ref,
	reason *string,
) (review.Snapshot, error)

type CodecConflictError

type CodecConflictError struct {
	Route string
	Value any
}

CodecConflictError reports an ambiguous family or concrete-type route.

func (*CodecConflictError) Error

func (e *CodecConflictError) Error() string

type CompositeMemoryIndex

type CompositeMemoryIndex struct {
	// contains filtered or unexported fields
}

CompositeMemoryIndex combines orthogonal FTS/vector projections while preserving each backend's deterministic channel order.

func NewCompositeMemoryIndex

func NewCompositeMemoryIndex(indexes ...MemoryIndex) (*CompositeMemoryIndex, error)

func (*CompositeMemoryIndex) Capabilities

func (i *CompositeMemoryIndex) Capabilities() memory.Capabilities

func (*CompositeMemoryIndex) Hydrate

func (i *CompositeMemoryIndex) Hydrate(
	ctx context.Context,
	db DBTX,
	scopeID string,
	projections []memory.Projection,
) ([]memory.Projection, error)

func (*CompositeMemoryIndex) Initialize

func (i *CompositeMemoryIndex) Initialize(ctx context.Context, db DBTX) error

func (*CompositeMemoryIndex) Replace

func (i *CompositeMemoryIndex) Replace(
	ctx context.Context,
	db DBTX,
	scopeID string,
	ref artifact.Ref,
	projections []memory.Projection,
) error

func (*CompositeMemoryIndex) Search

func (i *CompositeMemoryIndex) Search(
	ctx context.Context,
	db DBTX,
	scopeID string,
	request memory.SearchRequest,
) (memory.SearchChannels, error)

func (*CompositeMemoryIndex) VectorComplete

func (i *CompositeMemoryIndex) VectorComplete(
	ctx context.Context,
	db DBTX,
	scopeID string,
	memories []artifact.Ref,
	profile memory.EmbeddingProfile,
) (bool, error)

type DBTX

type DBTX interface {
	ExecContext(context.Context, string, ...any) (sql.Result, error)
	QueryContext(context.Context, string, ...any) (*sql.Rows, error)
	QueryRowContext(context.Context, string, ...any) *sql.Row
}

DBTX is the smallest query surface shared by sql.DB and sql.Tx.

type Database

type Database struct {
	// contains filtered or unexported fields
}

Database owns a connection pool and drains admitted transactions before it closes. Repositories receive DBTX and never own this lifecycle.

func Attach

func Attach(db *sql.DB) (*Database, error)

Attach uses a caller-owned pool without taking close ownership.

func OpenOceanBase

func OpenOceanBase(ctx context.Context, config OceanBaseConfig) (*Database, error)

OpenOceanBase validates the frozen URL shape, probes the tenant mode, and initializes only the Python-compatible relational schema.

func OpenSQLite

func OpenSQLite(ctx context.Context, config SQLiteConfig) (*Database, error)

OpenSQLite opens, configures, warms, and initializes the relational schema.

func OpenSeekDB

func OpenSeekDB(
	ctx context.Context,
	config SeekDBConfig,
) (*Database, *embeddedseekdb.Instance, error)

func (*Database) Close

func (d *Database) Close(ctx context.Context) error

Close rejects new work, waits for admitted transactions, then closes the owned pool. A canceled close restores admission so callers can retry.

func (*Database) Ping

func (d *Database) Ping(ctx context.Context) error

Ping verifies that the pool admits and executes a transaction.

func (*Database) SQLDB

func (d *Database) SQLDB() *sql.DB

SQLDB exposes the pool for driver-specific read-only capability probes. Use Transaction for application operations.

func (*Database) Transaction

func (d *Database) Transaction(ctx context.Context, fn func(DBTX) error) error

Transaction runs one caller-owned use case transaction. A nil callback is rejected before admission.

type DatabaseClosedError

type DatabaseClosedError struct{}

DatabaseClosedError reports that the database owner no longer admits work.

func (*DatabaseClosedError) Error

func (*DatabaseClosedError) Error() string

type Dialect

type Dialect string

Dialect selects the small number of locking statements that differ between SQLite and OceanBase/MySQL.

const (
	SQLiteDialect Dialect = "sqlite"
	MySQLDialect  Dialect = "mysql"
)

type ExperienceIncubationStore

type ExperienceIncubationStore struct {
	// contains filtered or unexported fields
}

ExperienceIncubationStore keeps the authoritative window snapshot separate from model inference, then commits all pending Candidates and the cursor CAS in one transaction.

func NewExperienceIncubationStore

func NewExperienceIncubationStore(
	database *Database,
	scopeID string,
	sources *SourceRepository,
	candidates *CandidateRepository,
) (*ExperienceIncubationStore, error)

func (*ExperienceIncubationStore) ApplyWindow

func (s *ExperienceIncubationStore) ApplyWindow(
	ctx context.Context,
	bindingName string,
	candidateIDs []string,
	plans []experience.CandidateInput,
	next source.Cursor,
	expectedGeneration *int64,
) error

func (*ExperienceIncubationStore) ObserveWindow

func (s *ExperienceIncubationStore) ObserveWindow(
	ctx context.Context,
	bindingName string,
	limit int64,
) (
	previous source.Cursor,
	next source.Cursor,
	generation *int64,
	highWatermark int64,
	values []source.Value,
	available []source.Ref,
	err error,
)

type ExperienceIndex

type ExperienceIndex interface {
	Initialize(context.Context, DBTX) error
	Replace(context.Context, DBTX, string, experience.Experience) error
	Search(context.Context, DBTX, string, string, int) ([]experience.SearchHit, error)
}

type ExternalSkillRepository

type ExternalSkillRepository struct{}

ExternalSkillRepository reads and replaces rebuildable host projections. The caller controls the transaction so a failed replacement restores the preceding snapshot.

func (ExternalSkillRepository) Get

func (ExternalSkillRepository) Get(
	ctx context.Context,
	db DBTX,
	scopeID, externalSkillID string,
) (skill.Registration, error)

func (ExternalSkillRepository) List

func (ExternalSkillRepository) List(
	ctx context.Context,
	db DBTX,
	scopeID string,
) (result []skill.Registration, returnErr error)

func (ExternalSkillRepository) Replace

func (ExternalSkillRepository) Replace(
	ctx context.Context,
	db DBTX,
	scopeID string,
	providers []string,
	hostID string,
	registrations []skill.Registration,
) ([]skill.Registration, error)

type ExternalSkillSnapshotStore

type ExternalSkillSnapshotStore struct {
	// contains filtered or unexported fields
}

func NewExternalSkillSnapshotStore

func NewExternalSkillSnapshotStore(
	database *Database,
	repository *SourceRepository,
) (*ExternalSkillSnapshotStore, error)

func (*ExternalSkillSnapshotStore) Store

func (s *ExternalSkillSnapshotStore) Store(
	ctx context.Context,
	scopeID string,
	capture skill.SnapshotCapture,
) (source.Ref, error)

type ExternalSkillStore

type ExternalSkillStore struct {
	// contains filtered or unexported fields
}

ExternalSkillStore owns transaction boundaries for the domain Registry.

func NewExternalSkillStore

func NewExternalSkillStore(database *Database, scopeID string) (*ExternalSkillStore, error)

func (*ExternalSkillStore) Get

func (s *ExternalSkillStore) Get(ctx context.Context, externalSkillID string) (skill.Registration, error)

func (*ExternalSkillStore) List

func (*ExternalSkillStore) Replace

func (s *ExternalSkillStore) Replace(
	ctx context.Context,
	providers []string,
	hostID string,
	registrations []skill.Registration,
) ([]skill.Registration, error)

type GenerationConflictError

type GenerationConflictError struct {
	BindingName string
	Expected    *int64
	Actual      *int64
}

GenerationConflictError reports a stale Source cursor CAS.

func (*GenerationConflictError) Error

func (e *GenerationConflictError) Error() string

type GenerationEvidenceReader

type GenerationEvidenceReader struct {
	// contains filtered or unexported fields
}

func NewGenerationEvidenceReader

func NewGenerationEvidenceReader(
	database *Database,
	scopeID string,
	sources *SourceRepository,
	artifacts *ArtifactRepository,
) (*GenerationEvidenceReader, error)

func (*GenerationEvidenceReader) Read

func (r *GenerationEvidenceReader) Read(
	ctx context.Context,
	sourceRefs []source.Ref,
	artifactRefs []artifact.Ref,
) ([]artifact.GenerationEvidence, error)

type HandoffActivationStore

type HandoffActivationStore struct {
	// contains filtered or unexported fields
}

HandoffActivationStore owns the two short transactional stages surrounding Handoff generation: observing a durable Source boundary and CAS-advancing the stable trigger cursor after generation succeeds.

func NewHandoffActivationStore

func NewHandoffActivationStore(
	database *Database,
	sources *SourceRepository,
) (*HandoffActivationStore, error)

func (*HandoffActivationStore) LoadBoundary

func (s *HandoffActivationStore) LoadBoundary(
	ctx context.Context,
	scopeID string,
	boundary source.Ref,
	bindingName string,
) (position int64, cursor source.Cursor, generation *int64, err error)

func (*HandoffActivationStore) SaveBoundary

func (s *HandoffActivationStore) SaveBoundary(
	ctx context.Context,
	scopeID, bindingName string,
	cursor source.Cursor,
	expectedGeneration *int64,
) error

type HandoffBackend

type HandoffBackend struct {
	// contains filtered or unexported fields
}

HandoffBackend binds one scoped Handoff lifecycle to the shared immutable Artifact tables. Generation and evidence validation remain outside this adapter; only the final Artifact CAS is transactional here.

func NewHandoffBackend

func NewHandoffBackend(database *Database, scopeID string, artifacts *ArtifactRepository) (*HandoffBackend, error)

func (*HandoffBackend) Create

func (b *HandoffBackend) Create(
	ctx context.Context,
	artifactID string,
	draft handoff.ArtifactDraft,
) (handoff.Handoff, error)

func (*HandoffBackend) Get

func (*HandoffBackend) Latest

func (b *HandoffBackend) Latest(ctx context.Context, artifactID string) (handoff.Handoff, bool, error)

func (*HandoffBackend) Revise

func (*HandoffBackend) Revisions

func (b *HandoffBackend) Revisions(ctx context.Context, artifactID string) ([]handoff.Handoff, error)

type HandoffEvidenceResolver

type HandoffEvidenceResolver struct {
	// contains filtered or unexported fields
}

HandoffEvidenceResolver resolves exact immutable citations inside one Scope. Each lookup owns a short transaction; model generation is therefore never performed while a database transaction is open.

func NewHandoffEvidenceResolver

func NewHandoffEvidenceResolver(
	database *Database,
	scopeID string,
	sources *SourceRepository,
	artifacts *ArtifactRepository,
	memoryService *memory.Service,
) (*HandoffEvidenceResolver, error)

func (*HandoffEvidenceResolver) Resolve

func (r *HandoffEvidenceResolver) Resolve(
	ctx context.Context,
	citation handoff.Citation,
) (handoff.Evidence, error)

func (*HandoffEvidenceResolver) Validate

func (r *HandoffEvidenceResolver) Validate(ctx context.Context, citation handoff.Citation) error

type HandoffReportStore

type HandoffReportStore struct {
	// contains filtered or unexported fields
}

HandoffReportStore is a use-case shaped adapter for the optional schema. Each exported method owns exactly one transaction; report snapshots freeze catalog and Activity state together.

func NewHandoffReportStore

func NewHandoffReportStore(database *Database, dialect Dialect) (*HandoffReportStore, error)

func (*HandoffReportStore) AttachWorkspaceBinding

func (s *HandoffReportStore) AttachWorkspaceBinding(ctx context.Context, workspaceID, projectID string, repository handoffreport.RepositoryRef, expected *int, confirmedAt time.Time) (handoffreport.WorkspaceBinding, error)

func (*HandoffReportStore) CreateProject

func (*HandoffReportStore) DetachWorkspaceBinding

func (s *HandoffReportStore) DetachWorkspaceBinding(ctx context.Context, workspaceID string, expected int) (handoffreport.WorkspaceBinding, error)

func (*HandoffReportStore) EnsureSchema

func (s *HandoffReportStore) EnsureSchema(ctx context.Context) error

func (*HandoffReportStore) GetProject

func (*HandoffReportStore) GetWorkspaceBinding

func (s *HandoffReportStore) GetWorkspaceBinding(ctx context.Context, workspaceID string) (handoffreport.WorkspaceBinding, error)

func (*HandoffReportStore) ListActivities

func (s *HandoffReportStore) ListActivities(ctx context.Context, projectID string, periodStart, periodEnd *time.Time, sources []handoffreport.ActivitySource, afterCursor int64, throughCursor *int64, limit int) (handoffreport.ActivityPage, error)

func (*HandoffReportStore) ListProjects

func (s *HandoffReportStore) ListProjects(ctx context.Context, cursor *string, limit int, includeArchived bool) (handoffreport.Page[handoffreport.ProjectDescriptor], error)

func (*HandoffReportStore) ListWorkstreams

func (s *HandoffReportStore) ListWorkstreams(ctx context.Context, projectID string, cursor *string, limit int, includeArchived bool) (handoffreport.Page[handoffreport.WorkstreamDescriptor], error)

func (*HandoffReportStore) PurgeActivities

func (s *HandoffReportStore) PurgeActivities(ctx context.Context, projectID string, observedBefore time.Time) (int64, error)

func (*HandoffReportStore) ReadHandoffReportInputs

func (s *HandoffReportStore) ReadHandoffReportInputs(
	ctx context.Context,
	projectID string,
	includeArchived bool,
	periodStart, periodEnd, previousStart, previousEnd *time.Time,
) (
	project handoffreport.ProjectDescriptor,
	workstreams []handoffreport.WorkstreamDescriptor,
	activities []handoffreport.ActivityEvent,
	activityCursor int64,
	previousActivityCount int,
	err error,
)

ReadHandoffReportInputs freezes the mutable catalog and Activity journal in one transaction. Handoff head selection intentionally happens afterwards so no model or cross-scope read is ever performed while this transaction lives.

func (*HandoffReportStore) RecordActivity

func (*HandoffReportStore) RegisterWorkstream

func (*HandoffReportStore) UpdateProject

func (s *HandoffReportStore) UpdateProject(ctx context.Context, value handoffreport.ProjectDescriptor, expected int, effectiveAt time.Time) (handoffreport.ProjectDescriptor, error)

func (*HandoffReportStore) UpdateWorkstream

func (s *HandoffReportStore) UpdateWorkstream(ctx context.Context, value handoffreport.WorkstreamDescriptor, expected int, effectiveAt time.Time) (handoffreport.WorkstreamDescriptor, error)

type IdentityMismatchError

type IdentityMismatchError struct {
	Kind    string
	Indexed any
	Decoded any
}

IdentityMismatchError reports disagreement between indexed columns and a decoded payload.

func (*IdentityMismatchError) Error

func (e *IdentityMismatchError) Error() string

type InvalidRepositoryArgumentError

type InvalidRepositoryArgumentError struct {
	Field  string
	Detail string
}

InvalidRepositoryArgumentError reports an invalid repository control value.

func (*InvalidRepositoryArgumentError) Error

type InvalidStoredColumnError

type InvalidStoredColumnError struct {
	Column   string
	Expected string
}

InvalidStoredColumnError reports a driver value outside the declared schema.

func (*InvalidStoredColumnError) Error

func (e *InvalidStoredColumnError) Error() string

type InvalidStoredPayloadError

type InvalidStoredPayloadError struct {
	Kind  string
	Name  string
	Issue string
}

InvalidStoredPayloadError reports persisted JSON outside its schema.

func (*InvalidStoredPayloadError) Error

func (e *InvalidStoredPayloadError) Error() string

type MemoryFlushStore

type MemoryFlushStore struct {
	// contains filtered or unexported fields
}

MemoryFlushStore implements the two short relational stages around Memory extraction for one Scope. ObserveWindow owns one consistent read snapshot; ApplyWindow atomically commits authoritative Memory state and cursor CAS.

func NewMemoryFlushStore

func NewMemoryFlushStore(
	database *Database,
	scopeID string,
	sources *SourceRepository,
	memoryRepository *MemoryRepository,
) (*MemoryFlushStore, error)

func (*MemoryFlushStore) ApplyWindow

func (s *MemoryFlushStore) ApplyWindow(
	ctx context.Context,
	bindingName string,
	plan memory.WritePlan,
	next source.Cursor,
	expectedGeneration *int64,
) (*memory.Memory, error)

func (*MemoryFlushStore) ObserveWindow

func (s *MemoryFlushStore) ObserveWindow(
	ctx context.Context,
	bindingName string,
	limit int64,
) (
	previous source.Cursor,
	next source.Cursor,
	generation *int64,
	highWatermark int64,
	values []source.Value,
	err error,
)

type MemoryIndex

MemoryIndex is a rebuildable projection updated in the authoritative Memory transaction.

type MemoryRepository

type MemoryRepository struct {
	// contains filtered or unexported fields
}

MemoryRepository composes shared Artifact revisions with Memory-owned entry and rebuildable search projections for one scope.

func NewMemoryRepository

func NewMemoryRepository(
	database *Database,
	scopeID string,
	artifacts *ArtifactRepository,
	index MemoryIndex,
) (*MemoryRepository, error)

func (*MemoryRepository) Capabilities

func (r *MemoryRepository) Capabilities() memory.Capabilities

func (*MemoryRepository) Changes

func (r *MemoryRepository) Changes(
	ctx context.Context,
	ref artifact.Ref,
	sinceRevision *int64,
) ([]memory.RevisionChanges, error)

func (*MemoryRepository) Commit

func (r *MemoryRepository) Commit(ctx context.Context, value memory.Commit) (memory.Memory, error)

func (*MemoryRepository) Entries

func (*MemoryRepository) Expand

func (r *MemoryRepository) Expand(ctx context.Context, hits []memory.Hit) ([]memory.EntryVersion, error)

func (*MemoryRepository) Get

func (*MemoryRepository) Initialize

func (r *MemoryRepository) Initialize(ctx context.Context) error

func (*MemoryRepository) Latest

func (r *MemoryRepository) Latest(ctx context.Context, artifactID string) (memory.Memory, error)

func (*MemoryRepository) Projections

func (r *MemoryRepository) Projections(ctx context.Context, ref artifact.Ref) ([]memory.Projection, error)

func (*MemoryRepository) Search

func (*MemoryRepository) VectorComplete

func (r *MemoryRepository) VectorComplete(
	ctx context.Context,
	refs []artifact.Ref,
	profile memory.EmbeddingProfile,
) (bool, error)

type MemorySourceResolver

type MemorySourceResolver struct {
	// contains filtered or unexported fields
}

MemorySourceResolver exposes the exact Source catalog semantics required by memory.Service for one Scope. Each canonicalization is a short read transaction; callers therefore never retain a SQL transaction across model inference.

func NewMemorySourceResolver

func NewMemorySourceResolver(
	database *Database,
	scopeID string,
	repository *SourceRepository,
) (*MemorySourceResolver, error)

func (*MemorySourceResolver) Get

func (*MemorySourceResolver) Ref

func (r *MemorySourceResolver) Ref(value source.Value) (source.Ref, error)

type NoExperienceIndex

type NoExperienceIndex struct{}

func (NoExperienceIndex) Initialize

func (NoExperienceIndex) Replace

func (NoExperienceIndex) Search

type NoMemoryIndex

type NoMemoryIndex struct{}

NoMemoryIndex exposes an authoritative store without search capabilities.

func (NoMemoryIndex) Capabilities

func (NoMemoryIndex) Capabilities() memory.Capabilities

func (NoMemoryIndex) Hydrate

func (NoMemoryIndex) Hydrate(
	_ context.Context,
	_ DBTX,
	_ string,
	projections []memory.Projection,
) ([]memory.Projection, error)

func (NoMemoryIndex) Initialize

func (NoMemoryIndex) Initialize(context.Context, DBTX) error

func (NoMemoryIndex) Replace

func (NoMemoryIndex) VectorComplete

type OceanBaseConfig

type OceanBaseConfig struct {
	URL             string
	MaxOpenConns    int
	MaxIdleConns    int
	ConnMaxLifetime time.Duration
}

OceanBaseConfig configures the Python-compatible OceanBase MySQL profile. URL must retain the frozen mysql+aoceanbase scheme even though the Go driver speaks the MySQL wire protocol directly.

type RecallTokenProjectionError

type RecallTokenProjectionError struct{ SourceType string }

RecallTokenProjectionError identifies a persisted Source type that has no stable primary-text projection. The Source identity and content are omitted deliberately so the error is safe to classify at an operational boundary.

func (*RecallTokenProjectionError) Error

type RelationalRecallTokenEstimator

type RelationalRecallTokenEstimator struct {
	// contains filtered or unexported fields
}

RelationalRecallTokenEstimator resolves the exact Source lineage of the entries that survived Context Pack budgeting. All Artifact, Memory entry, and Source reads share one relational snapshot; token estimation happens after that snapshot has been released.

func NewRelationalRecallTokenEstimator

func NewRelationalRecallTokenEstimator(
	database *Database,
	scopeID string,
	sources *SourceRepository,
	artifacts *ArtifactRepository,
	estimator *inference.TokenEstimator,
) (*RelationalRecallTokenEstimator, error)

func (*RelationalRecallTokenEstimator) Estimate

type RepositoryNotFoundError

type RepositoryNotFoundError struct {
	Kind     string
	Identity any
}

RepositoryNotFoundError reports a missing persisted object or codec route.

func (*RepositoryNotFoundError) Error

func (e *RepositoryNotFoundError) Error() string

type ReviewBackend

type ReviewBackend struct {
	// contains filtered or unexported fields
}

ReviewBackend keeps Candidate CAS, Artifact CAS, projection replacement, and terminal head update inside one database transaction.

func NewReviewBackend

func NewReviewBackend(
	database *Database,
	scopeID string,
	candidates *CandidateRepository,
	artifacts *ArtifactRepository,
	sources *SourceRepository,
	experienceIndex ExperienceIndex,
) (*ReviewBackend, error)

func (*ReviewBackend) Approve

func (r *ReviewBackend) Approve(
	ctx context.Context,
	candidateID string,
	expectedVersion int64,
	idFactory review.IDFactory,
) (review.Snapshot, error)

func (*ReviewBackend) Get

func (r *ReviewBackend) Get(ctx context.Context, candidateID string) (review.Snapshot, error)

func (*ReviewBackend) GetArtifact

func (r *ReviewBackend) GetArtifact(ctx context.Context, ref artifact.Ref) (artifact.Snapshot, error)

func (*ReviewBackend) Initialize

func (r *ReviewBackend) Initialize(ctx context.Context) error

func (*ReviewBackend) List

func (r *ReviewBackend) List(
	ctx context.Context,
	status review.Status,
	family, cursor *string,
	limit int,
) (review.Page, error)

func (*ReviewBackend) Propose

func (r *ReviewBackend) Propose(
	ctx context.Context,
	candidateID, family string,
	proposal any,
	sources []source.Ref,
	artifacts []artifact.Ref,
	target *artifact.Ref,
	reason *string,
) (review.Snapshot, error)

func (*ReviewBackend) Reject

func (r *ReviewBackend) Reject(
	ctx context.Context,
	candidateID string,
	expectedVersion int64,
	reason string,
) (review.Snapshot, error)

func (*ReviewBackend) Revise

func (r *ReviewBackend) Revise(
	ctx context.Context,
	candidateID string,
	expectedVersion int64,
	proposal any,
	sources []source.Ref,
	artifacts []artifact.Ref,
	target *artifact.Ref,
	reason *string,
) (review.Snapshot, error)

func (*ReviewBackend) SearchExperiences

func (r *ReviewBackend) SearchExperiences(
	ctx context.Context,
	query string,
	limit int,
) ([]experience.SearchHit, error)

type RuntimeSourceBackend

type RuntimeSourceBackend struct {
	// contains filtered or unexported fields
}

RuntimeSourceBackend is the use-case-shaped adapter consumed by runtime.SourceApplication. Source resolution remains outside the SQL transaction; journal allocation and idempotent insertion are atomic.

func NewRuntimeSourceBackend

func NewRuntimeSourceBackend(database *Database, repository *SourceRepository) (*RuntimeSourceBackend, error)

func (*RuntimeSourceBackend) Capture

func (b *RuntimeSourceBackend) Capture(
	ctx context.Context,
	scopeID string,
	capture source.ContentCapture,
) (source.Ref, int64, error)

func (*RuntimeSourceBackend) Entries

func (b *RuntimeSourceBackend) Entries(ctx context.Context, scopeID string) ([]source.JournalEntry, error)

Entries returns a stable decoded snapshot of one scoped Source journal.

func (*RuntimeSourceBackend) ScopeIDs

func (b *RuntimeSourceBackend) ScopeIDs(ctx context.Context) ([]string, error)

ScopeIDs returns only partitions that own a Source journal, in deterministic database byte order. It intentionally does not infer Scopes from Artifacts or configuration.

type SQLiteConfig

type SQLiteConfig struct {
	DSN             string
	BusyTimeout     time.Duration
	JournalMode     string
	ForeignKeys     bool
	MaxOpenConns    int
	MaxIdleConns    int
	ConnMaxLifetime time.Duration
}

SQLiteConfig configures the Python-compatible SQLite profile.

func DefaultSQLiteConfig

func DefaultSQLiteConfig(dsn string) SQLiteConfig

DefaultSQLiteConfig returns the current Python-compatible profile defaults.

type SQLiteExperienceFTSIndex

type SQLiteExperienceFTSIndex struct{}

SQLiteExperienceFTSIndex maintains approved Experience heads in FTS5.

func (SQLiteExperienceFTSIndex) Initialize

func (SQLiteExperienceFTSIndex) Initialize(ctx context.Context, db DBTX) error

func (SQLiteExperienceFTSIndex) Replace

func (SQLiteExperienceFTSIndex) Replace(
	ctx context.Context,
	db DBTX,
	scopeID string,
	value experience.Experience,
) error

func (SQLiteExperienceFTSIndex) Search

func (SQLiteExperienceFTSIndex) Search(
	ctx context.Context,
	db DBTX,
	scopeID, query string,
	limit int,
) (hits []experience.SearchHit, returnErr error)

type SQLiteMemoryFTSIndex

type SQLiteMemoryFTSIndex struct{}

SQLiteMemoryFTSIndex implements the Python FTS5 active-head projection. Binaries using it must be built with mattn/go-sqlite3's sqlite_fts5 tag.

func (SQLiteMemoryFTSIndex) Capabilities

func (SQLiteMemoryFTSIndex) Capabilities() memory.Capabilities

func (SQLiteMemoryFTSIndex) Hydrate

func (SQLiteMemoryFTSIndex) Hydrate(
	_ context.Context,
	_ DBTX,
	_ string,
	projections []memory.Projection,
) ([]memory.Projection, error)

func (SQLiteMemoryFTSIndex) Initialize

func (SQLiteMemoryFTSIndex) Initialize(ctx context.Context, db DBTX) error

func (SQLiteMemoryFTSIndex) Replace

func (SQLiteMemoryFTSIndex) Replace(
	ctx context.Context,
	db DBTX,
	scopeID string,
	memoryRef artifact.Ref,
	projections []memory.Projection,
) error

func (SQLiteMemoryFTSIndex) Search

func (SQLiteMemoryFTSIndex) Search(
	ctx context.Context,
	db DBTX,
	scopeID string,
	request memory.SearchRequest,
) (channels memory.SearchChannels, returnErr error)

func (SQLiteMemoryFTSIndex) VectorComplete

type SQLiteMemoryVectorIndex

type SQLiteMemoryVectorIndex struct {
	// contains filtered or unexported fields
}

SQLiteMemoryVectorIndex maintains the Python-compatible sqlite-vec vec0 active-head projection for one exact embedding profile. OpenSQLite embeds and initializes the extension on every connection.

func NewSQLiteMemoryVectorIndex

func NewSQLiteMemoryVectorIndex(profile memory.EmbeddingProfile) (*SQLiteMemoryVectorIndex, error)

func (*SQLiteMemoryVectorIndex) Capabilities

func (i *SQLiteMemoryVectorIndex) Capabilities() memory.Capabilities

func (*SQLiteMemoryVectorIndex) Hydrate

func (i *SQLiteMemoryVectorIndex) Hydrate(
	ctx context.Context,
	db DBTX,
	scopeID string,
	projections []memory.Projection,
) ([]memory.Projection, error)

func (*SQLiteMemoryVectorIndex) Initialize

func (i *SQLiteMemoryVectorIndex) Initialize(ctx context.Context, db DBTX) error

func (*SQLiteMemoryVectorIndex) Replace

func (i *SQLiteMemoryVectorIndex) Replace(
	ctx context.Context,
	db DBTX,
	scopeID string,
	memoryRef artifact.Ref,
	projections []memory.Projection,
) error

func (*SQLiteMemoryVectorIndex) Search

func (i *SQLiteMemoryVectorIndex) Search(
	ctx context.Context,
	db DBTX,
	scopeID string,
	request memory.SearchRequest,
) (channels memory.SearchChannels, returnErr error)

func (*SQLiteMemoryVectorIndex) VectorComplete

func (i *SQLiteMemoryVectorIndex) VectorComplete(
	ctx context.Context,
	db DBTX,
	scopeID string,
	memories []artifact.Ref,
	profile memory.EmbeddingProfile,
) (bool, error)

type ScopedStatistics

type ScopedStatistics struct {
	// contains filtered or unexported fields
}

ScopedStatistics assembles one scope's inventory and bounded daily usage in a single relational snapshot.

func NewScopedStatistics

func NewScopedStatistics(
	database *Database,
	scopeID, memoryArtifactID string,
	artifacts *ArtifactRepository,
	repository StatisticsRepository,
	estimator *inference.TokenEstimatorProfile,
) (*ScopedStatistics, error)

func (*ScopedStatistics) Overview

func (s *ScopedStatistics) Overview(ctx context.Context, period stats.Period, asOf time.Time) (stats.Statistics, error)

func (*ScopedStatistics) Record

func (s *ScopedStatistics) Record(
	ctx context.Context,
	purpose stats.ModelPurpose,
	operation stats.ModelOperation,
	usage inference.Usage,
	usageDate time.Time,
) error

func (*ScopedStatistics) RecordRecall

func (s *ScopedStatistics) RecordRecall(
	ctx context.Context,
	measurement stats.RecallTokenMeasurement,
	usageDate time.Time,
) error

type SeekDBConfig

type SeekDBConfig struct {
	Path            string
	Database        string
	LibraryPath     string
	MaxOpenConns    int
	MaxIdleConns    int
	ConnMaxLifetime time.Duration
}

SeekDBConfig configures one optional embedded seekDB process. libseekdb and its sibling seekdb executable are loaded only when this profile is selected.

type SourceCodec

type SourceCodec struct {
	// contains filtered or unexported fields
}

SourceCodec is an exact concrete Source type route for the Python storage payload. It is immutable after construction.

func ContentSourceCodec

func ContentSourceCodec() SourceCodec

ContentSourceCodec returns the built-in content payload route.

func ExternalSkillSnapshotSourceCodec

func ExternalSkillSnapshotSourceCodec() SourceCodec

ExternalSkillSnapshotSourceCodec preserves the frozen Pydantic Source JSON used by explicit external Skill import/fork evidence.

func NewSourceCodec

func NewSourceCodec[S source.Value](
	name string,
	encode func(S) ([]byte, error),
	decode func([]byte) (S, error),
) (SourceCodec, error)

NewSourceCodec constructs a schema-specific exact-type Source codec.

type SourceCursorRepository

type SourceCursorRepository struct{}

func (SourceCursorRepository) Load

func (SourceCursorRepository) Load(
	ctx context.Context,
	db DBTX,
	scopeID, bindingName string,
) (StoredSourceCursor, bool, error)

func (SourceCursorRepository) Save

func (repository SourceCursorRepository) Save(
	ctx context.Context,
	db DBTX,
	scopeID, bindingName string,
	cursor source.Cursor,
	expectedGeneration *int64,
) (StoredSourceCursor, error)

type SourceRepository

type SourceRepository struct {
	// contains filtered or unexported fields
}

SourceRepository persists stable Sources through exact concrete codecs.

func NewSourceRepository

func NewSourceRepository(dialect Dialect, codecs ...SourceCodec) (*SourceRepository, error)

func (*SourceRepository) Add

func (r *SourceRepository) Add(
	ctx context.Context,
	db DBTX,
	scopeID string,
	value source.Value,
) (StoredSource, error)

func (*SourceRepository) Get

func (r *SourceRepository) Get(
	ctx context.Context,
	db DBTX,
	scopeID string,
	ref source.Ref,
) (StoredSource, error)

func (*SourceRepository) JournalPosition

func (r *SourceRepository) JournalPosition(
	ctx context.Context,
	db DBTX,
	scopeID string,
) (int64, error)

func (*SourceRepository) List

func (r *SourceRepository) List(
	ctx context.Context,
	db DBTX,
	scopeID string,
	after int64,
	limit *int,
) (result []StoredSource, returnErr error)

func (*SourceRepository) Ref

func (r *SourceRepository) Ref(value source.Value) (source.Ref, error)

Ref maps one exact concrete Source value to its stable persisted identity. Routing is deliberately exact, matching source.Catalog and the frozen Python adapter registry; assignable/interface-based fallbacks are rejected.

type StatisticsRepository

type StatisticsRepository struct {
	// contains filtered or unexported fields
}

StatisticsRepository maintains bounded additive aggregates and reads current authoritative inventory. It deliberately does not cache derived totals.

func NewStatisticsRepository

func NewStatisticsRepository(dialect Dialect) (StatisticsRepository, error)

func (StatisticsRepository) Inventory

func (r StatisticsRepository) Inventory(
	ctx context.Context,
	db DBTX,
	scopeID string,
) (stats.InventoryCounts, error)

func (StatisticsRepository) MemoryEntryStates

func (StatisticsRepository) MemoryEntryStates(
	ctx context.Context,
	db DBTX,
	scopeID, memoryArtifactID string,
	artifacts *ArtifactRepository,
) ([]stats.MemoryEntryStateRow, error)

MemoryEntryStates joins the latest authoritative manifest to immutable entry versions. It never derives inventory from the rebuildable head/search tables.

func (StatisticsRepository) RecallUsage

func (r StatisticsRepository) RecallUsage(
	ctx context.Context,
	db DBTX,
	scopeID string,
	startDate, endDate time.Time,
	profile inference.TokenEstimatorProfile,
) (result []stats.StoredRecallTokenUsage, returnErr error)

func (StatisticsRepository) Record

func (r StatisticsRepository) Record(
	ctx context.Context,
	db DBTX,
	scopeID string,
	usageDate time.Time,
	purpose stats.ModelPurpose,
	operation stats.ModelOperation,
	usage inference.Usage,
) error

func (StatisticsRepository) RecordRecall

func (r StatisticsRepository) RecordRecall(
	ctx context.Context,
	db DBTX,
	scopeID string,
	usageDate time.Time,
	measurement stats.RecallTokenMeasurement,
) error

func (StatisticsRepository) Usage

func (r StatisticsRepository) Usage(
	ctx context.Context,
	db DBTX,
	scopeID string,
	startDate, endDate time.Time,
) (result []stats.StoredModelUsage, returnErr error)

type StoredPayloadConflictError

type StoredPayloadConflictError struct {
	Kind     string
	Identity any
}

StoredPayloadConflictError reports reuse of a stable identity for different canonical bytes.

func (*StoredPayloadConflictError) Error

type StoredSource

type StoredSource struct {
	Ref             source.Ref
	Value           source.Value
	JournalPosition int64
}

StoredSource is a decoded Source and its per-scope journal position.

type StoredSourceCursor

type StoredSourceCursor struct {
	ScopeID     string
	BindingName string
	Cursor      source.Cursor
	Generation  int64
}

type UnsupportedOceanBaseTenantError

type UnsupportedOceanBaseTenantError struct{ CompatibilityMode *string }

UnsupportedOceanBaseTenantError reports an OceanBase tenant whose authoritative compatibility marker is absent or not MYSQL.

func (*UnsupportedOceanBaseTenantError) Error

Directories

Path Synopsis
Package oceanbase implements the OceanBase relational profile and indexes.
Package oceanbase implements the OceanBase relational profile and indexes.
Package seekdb loads and owns the embedded seekDB runtime used by the SQL store.
Package seekdb loads and owns the embedded seekDB runtime used by the SQL store.
Package sqlitevec statically embeds the sqlite-vec v0.1.9 amalgamation used by the Python v0.0.2 runtime.
Package sqlitevec statically embeds the sqlite-vec v0.1.9 amalgamation used by the Python v0.0.2 runtime.

Jump to

Keyboard shortcuts

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