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 ¶
- type Config
- type Membrane
- func (m *Membrane) Contest(ctx context.Context, id, contestingRef, actor, rationale string) error
- func (m *Membrane) Fork(ctx context.Context, sourceID string, forkedRec *schema.MemoryRecord, ...) (*schema.MemoryRecord, error)
- func (m *Membrane) GetMetrics(ctx context.Context) (*metrics.Snapshot, error)
- func (m *Membrane) IngestEvent(ctx context.Context, req ingestion.IngestEventRequest) (*schema.MemoryRecord, error)
- func (m *Membrane) IngestObservation(ctx context.Context, req ingestion.IngestObservationRequest) (*schema.MemoryRecord, error)
- func (m *Membrane) IngestOutcome(ctx context.Context, req ingestion.IngestOutcomeRequest) (*schema.MemoryRecord, error)
- func (m *Membrane) IngestToolOutput(ctx context.Context, req ingestion.IngestToolOutputRequest) (*schema.MemoryRecord, error)
- func (m *Membrane) IngestWorkingState(ctx context.Context, req ingestion.IngestWorkingStateRequest) (*schema.MemoryRecord, error)
- func (m *Membrane) Merge(ctx context.Context, ids []string, mergedRec *schema.MemoryRecord, ...) (*schema.MemoryRecord, error)
- func (m *Membrane) Penalize(ctx context.Context, id string, amount float64, actor, rationale string) error
- func (m *Membrane) Reinforce(ctx context.Context, id, actor, rationale string) error
- func (m *Membrane) Retract(ctx context.Context, id, actor, rationale string) error
- func (m *Membrane) Retrieve(ctx context.Context, req *retrieval.RetrieveRequest) (*retrieval.RetrieveResponse, error)
- func (m *Membrane) RetrieveByID(ctx context.Context, id string, trust *retrieval.TrustContext) (*schema.MemoryRecord, error)
- func (m *Membrane) Start(ctx context.Context) error
- func (m *Membrane) Stop() error
- func (m *Membrane) Supersede(ctx context.Context, oldID string, newRec *schema.MemoryRecord, ...) (*schema.MemoryRecord, error)
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 ¶
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 ¶
New initialises all subsystems from the provided Config and returns a ready-to-start Membrane instance.
func (*Membrane) Contest ¶
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 ¶
GetMetrics collects a point-in-time snapshot of substrate metrics.
func (*Membrane) IngestEvent ¶
func (m *Membrane) IngestEvent(ctx context.Context, req ingestion.IngestEventRequest) (*schema.MemoryRecord, error)
IngestEvent creates an episodic memory record from an event.
func (*Membrane) IngestObservation ¶
func (m *Membrane) IngestObservation(ctx context.Context, req ingestion.IngestObservationRequest) (*schema.MemoryRecord, error)
IngestObservation creates a semantic memory record from an observation.
func (*Membrane) IngestOutcome ¶
func (m *Membrane) IngestOutcome(ctx context.Context, req ingestion.IngestOutcomeRequest) (*schema.MemoryRecord, error)
IngestOutcome updates an existing episodic record with outcome data.
func (*Membrane) IngestToolOutput ¶
func (m *Membrane) IngestToolOutput(ctx context.Context, req ingestion.IngestToolOutputRequest) (*schema.MemoryRecord, error)
IngestToolOutput creates an episodic memory record from a tool invocation.
func (*Membrane) IngestWorkingState ¶
func (m *Membrane) IngestWorkingState(ctx context.Context, req ingestion.IngestWorkingStateRequest) (*schema.MemoryRecord, error)
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) Retrieve ¶
func (m *Membrane) Retrieve(ctx context.Context, req *retrieval.RetrieveRequest) (*retrieval.RetrieveResponse, error)
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.