memoryindex

package
v0.1.0-alpha.1 Latest Latest
Warning

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

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

Documentation

Overview

Package memoryindex defines the provider-neutral port for Memory Core's optional, disposable semantic candidate projection. The selected relational CoreStore remains authoritative for every fact and eligibility decision.

Index

Constants

This section is empty.

Variables

View Source
var ErrUnavailable = errors.New("MemoryIndex projection is unavailable")

Functions

This section is empty.

Types

type Action

type Action string

Action identifies the only disposable-index mutations carried by the queue.

const (
	ActionUpsert Action = "UPSERT"
	ActionDelete Action = "DELETE"
)

type Candidate

type Candidate struct {
	Kind Kind
	Ref  string
}

Candidate contains no similarity score or write authority.

type CanonicalSource

type CanonicalSource interface {
	MemoryIndexDocument(context.Context, Operation) (Document, bool, error)
	EnumerateMemoryIndexDocuments(context.Context, string, int) ([]Document, string, error)
}

CanonicalSource rehydrates one queued operation and enumerates the complete disposable projection through an opaque stable cursor.

type Document

type Document struct {
	Kind  Kind
	Ref   string
	Scope Scope
	Text  string
}

Document is the complete provider-neutral projection of one canonical item.

type Index

type Index interface {
	Search(context.Context, Query) ([]Candidate, error)
	Upsert(context.Context, []Document) error
	Delete(context.Context, Scope, []Candidate) error
	Reset(context.Context) error
}

Index is implemented by any semantic provider. Search output is untrusted and must be rehydrated from the configured relational CoreStore before it can affect selection or consolidation.

type Kind

type Kind string

Kind identifies the only canonical document kinds accepted by the index.

const (
	KindEpisode      Kind = "EPISODE"
	KindRecollection Kind = "RECOLLECTION"
	KindDisposition  Kind = "DISPOSITION"
)

type Operation

type Operation struct {
	ID         string
	StreamRef  string
	Sequence   int64
	Action     Action
	Kind       Kind
	Ref        string
	Scope      Scope
	LeaseToken string
}

Operation is one frozen, ordered projection mutation. It intentionally has no document text: UPSERT text must be rehydrated from canonical Memory.

type OperationQueue

type OperationQueue interface {
	LeaseMemoryIndexOperation(context.Context, time.Time) (Operation, bool, error)
	AcknowledgeMemoryIndexOperation(context.Context, Operation) error
	RetryMemoryIndexOperation(context.Context, Operation, time.Time, string) error
}

OperationQueue owns durable leasing, retry, and acknowledgement.

type Projector

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

Projector independently reconciles canonical Memory into a disposable semantic index. ProcessOne and Rebuild serialize within this process.

func NewProjector

func NewProjector(queue OperationQueue, source CanonicalSource, index Index, config ProjectorConfig) *Projector

func (*Projector) ProcessOne

func (projector *Projector) ProcessOne(ctx context.Context) (bool, error)

func (*Projector) Rebuild

func (projector *Projector) Rebuild(ctx context.Context) error

Rebuild resets only the disposable provider, then copies stable canonical pages. Durable queued deltas remain untouched and reconcile after this lock.

func (*Projector) Run

func (projector *Projector) Run(ctx context.Context) error

type ProjectorConfig

type ProjectorConfig struct {
	LeaseDuration time.Duration
	RetryDelay    time.Duration
	PollInterval  time.Duration
	PageSize      int
	OnError       func(error)
}

func DefaultProjectorConfig

func DefaultProjectorConfig() ProjectorConfig

type Query

type Query struct {
	Scope Scope
	Text  string
	Limit int
}

Query asks a provider for an ordered, bounded candidate set in one owner lane.

type Scope

type Scope struct {
	TenantRef       string
	AgentRef        string
	RelationshipRef string
}

Scope identifies one long-lived owner lane. An empty RelationshipRef is the Agent baseline; a non-empty RelationshipRef is that exact relationship.

Jump to

Keyboard shortcuts

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