Help us shape the future of Go! Take the 2026 Go Developer Survey

membrane

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Mar 22, 2026 License: MIT Imports: 16 Imported by: 0

Documentation

Overview

Package membrane provides the top-level API surface that wires together all subsystems of the memory substrate: ingestion, retrieval, decay, revision, consolidation, and metrics.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	// Backend selects the storage backend: "sqlite" (default) or "postgres".
	Backend string `yaml:"backend"`

	// DBPath is the SQLite database path.
	DBPath string `yaml:"db_path"`

	// PostgresDSN is the PostgreSQL connection string used when Backend == "postgres".
	PostgresDSN string `yaml:"postgres_dsn"`

	// ListenAddr is the gRPC listen address (default: ":9090").
	ListenAddr string `yaml:"listen_addr"`

	// DecayInterval is how often the decay scheduler runs (default: 1h).
	DecayInterval time.Duration `yaml:"decay_interval"`

	// ConsolidationInterval is how often the consolidation scheduler runs (default: 6h).
	ConsolidationInterval time.Duration `yaml:"consolidation_interval"`

	// DefaultSensitivity is the ingestion default sensitivity level (default: "low").
	DefaultSensitivity string `yaml:"default_sensitivity"`

	// SelectionConfidenceThreshold is the minimum confidence for the retrieval
	// selector to consider a competence or plan_graph candidate (default: 0.7).
	SelectionConfidenceThreshold float64 `yaml:"selection_confidence_threshold"`

	// EncryptionKey is the SQLCipher encryption key for the SQLite database.
	// If empty, the database is not encrypted. Read from MEMBRANE_ENCRYPTION_KEY
	// environment variable if not set in config.
	EncryptionKey string `yaml:"encryption_key"`

	// EmbeddingEndpoint is the HTTP endpoint used to generate embeddings.
	EmbeddingEndpoint string `yaml:"embedding_endpoint"`

	// EmbeddingModel is the embedding model name sent to the embedding endpoint.
	EmbeddingModel string `yaml:"embedding_model"`

	// EmbeddingDimensions is the output dimension of the embedding model.
	EmbeddingDimensions int `yaml:"embedding_dimensions"`

	// EmbeddingAPIKey authenticates requests to the embedding endpoint.
	EmbeddingAPIKey string `yaml:"embedding_api_key"`

	// LLMEndpoint is the HTTP endpoint used for semantic fact extraction.
	LLMEndpoint string `yaml:"llm_endpoint"`

	// LLMModel is the chat model name sent to the LLM endpoint.
	LLMModel string `yaml:"llm_model"`

	// LLMAPIKey authenticates requests to the LLM endpoint.
	LLMAPIKey string `yaml:"llm_api_key"`

	// TLSCertFile is the path to the TLS certificate PEM file.
	// If empty, the server runs without TLS.
	TLSCertFile string `yaml:"tls_cert_file"`

	// TLSKeyFile is the path to the TLS private key PEM file.
	TLSKeyFile string `yaml:"tls_key_file"`

	// APIKey is a shared secret for authenticating gRPC clients.
	// If empty, authentication is disabled. Read from MEMBRANE_API_KEY
	// environment variable if not set in config.
	APIKey string `yaml:"api_key"`

	// RateLimitPerSecond is the maximum requests per second per client.
	// 0 means no rate limiting. Default: 100.
	RateLimitPerSecond int `yaml:"rate_limit_per_second"`
}

Config holds all configurable parameters for a Membrane instance.

func DefaultConfig

func DefaultConfig() *Config

DefaultConfig returns a Config populated with sensible defaults.

func LoadConfig

func LoadConfig(path string) (*Config, error)

LoadConfig reads a YAML configuration file from path and returns a Config. Fields not present in the file retain their default values.

type Membrane

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

Membrane wires all subsystems together and exposes the unified API surface.

func New

func New(cfg *Config) (*Membrane, error)

New initialises all subsystems from the provided Config and returns a ready-to-start Membrane instance.

func (*Membrane) Contest

func (m *Membrane) Contest(ctx context.Context, id, contestingRef, actor, rationale string) error

Contest marks a record as contested, indicating conflicting evidence exists.

func (*Membrane) Fork

func (m *Membrane) Fork(ctx context.Context, sourceID string, forkedRec *schema.MemoryRecord, actor, rationale string) (*schema.MemoryRecord, error)

Fork creates a new record derived from an existing source record.

func (*Membrane) GetMetrics

func (m *Membrane) GetMetrics(ctx context.Context) (*metrics.Snapshot, error)

GetMetrics collects a point-in-time snapshot of substrate metrics.

func (*Membrane) IngestEvent

IngestEvent creates an episodic memory record from an event.

func (*Membrane) IngestObservation

IngestObservation creates a semantic memory record from an observation.

func (*Membrane) IngestOutcome

IngestOutcome updates an existing episodic record with outcome data.

func (*Membrane) IngestToolOutput

IngestToolOutput creates an episodic memory record from a tool invocation.

func (*Membrane) IngestWorkingState

IngestWorkingState creates a working memory record from a working state snapshot.

func (*Membrane) Merge

func (m *Membrane) Merge(ctx context.Context, ids []string, mergedRec *schema.MemoryRecord, actor, rationale string) (*schema.MemoryRecord, error)

Merge atomically combines multiple source records into a single merged record.

func (*Membrane) Penalize

func (m *Membrane) Penalize(ctx context.Context, id string, amount float64, actor, rationale string) error

Penalize reduces a record's salience by the given amount.

func (*Membrane) Reinforce

func (m *Membrane) Reinforce(ctx context.Context, id, actor, rationale string) error

Reinforce boosts a record's salience.

func (*Membrane) Retract

func (m *Membrane) Retract(ctx context.Context, id, actor, rationale string) error

Retract marks a record as retracted without deleting it.

func (*Membrane) Retrieve

Retrieve performs layered retrieval as specified in RFC 15.8.

func (*Membrane) RetrieveByID

func (m *Membrane) RetrieveByID(ctx context.Context, id string, trust *retrieval.TrustContext) (*schema.MemoryRecord, error)

RetrieveByID fetches a single record by ID with trust context gating.

func (*Membrane) Start

func (m *Membrane) Start(ctx context.Context) error

Start begins the background schedulers (decay, consolidation).

func (*Membrane) Stop

func (m *Membrane) Stop() error

Stop gracefully shuts down schedulers and closes the store.

func (*Membrane) Supersede

func (m *Membrane) Supersede(ctx context.Context, oldID string, newRec *schema.MemoryRecord, actor, rationale string) (*schema.MemoryRecord, error)

Supersede atomically replaces an old record with a new one.

Jump to

Keyboard shortcuts

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