Installation
Creating a Membrane instance
Start by loading or constructing aConfig, then pass it to membrane.New.
Starting and stopping
Start launches the background decay and consolidation schedulers. Stop gracefully shuts them down and closes the store.
Always call
m.Stop() (or defer m.Stop()) to flush the store and release database locks before your process exits.Ingestion methods
All ingestion calls return a*schema.MemoryRecord containing the assigned UUID, type, sensitivity, salience, and confidence.
IngestEvent
Captures a raw event (tool calls, errors, observations) as an episodic record.| Field | Type | Required | Description |
|---|---|---|---|
Source | string | Yes | Actor or system that produced the event |
EventKind | string | Yes | Event type, e.g. "tool_call", "error", "user_input" |
Ref | string | Yes | Source event reference ID |
Summary | string | No | Human-readable summary |
Timestamp | time.Time | No | Defaults to time.Now() |
Tags | []string | No | Labels for categorization |
Scope | string | No | Visibility scope |
Sensitivity | schema.Sensitivity | No | Overrides default sensitivity |
IngestToolOutput
Captures a tool invocation with its arguments and result as an episodic record. The payload includes aToolGraph node for dependency tracking.
| Field | Type | Description |
|---|---|---|
Source | string | Actor that invoked the tool |
ToolName | string | Name of the tool invoked |
Args | map[string]any | Arguments passed to the tool |
Result | any | Output produced by the tool |
DependsOn | []string | IDs of tool nodes this output depends on |
Tags | []string | Labels for categorization |
Scope | string | Visibility scope |
IngestObservation
Captures a subject-predicate-object observation as a semantic record.IngestOutcome
Updates an existing episodic record with an outcome status. The target must be an episodic record.IngestWorkingState
Captures the current in-flight task state as a working memory record.| Field | Type | Description |
|---|---|---|
Source | string | Actor that produced the working state |
ThreadID | string | Thread or session identifier |
State | schema.TaskState | Current task state |
NextActions | []string | Planned next actions |
OpenQuestions | []string | Unresolved questions |
ContextSummary | string | Summary of the current context |
ActiveConstraints | []schema.Constraint | Currently active constraints |
Retrieve with trust context
Retrieve performs layered retrieval in canonical order: working → semantic → competence → plan_graph → episodic. The TrustContext gates which records are returned.
Revision operations
Revision operations update the record’s status and append an audit entry. All operations accept anactor and rationale for full provenance.
Supersede
Atomically replaces an old record with a new version.Fork
Creates a conditional variant derived from a source record.Retract
Marks a record as retracted without deleting it. The record remains in the audit trail.Merge
Combines multiple records into one consolidated record.Contest
Marks a record as contested when conflicting evidence exists.Reinforce and Penalize
Reinforce boosts a record’s salience; Penalize reduces it by a specified amount.GetMetrics
Returns a point-in-time*metrics.Snapshot of the substrate.
Config struct reference
Storage backend:
"sqlite" (default) or "postgres".SQLite database file path. Default:
"membrane.db".PostgreSQL connection string. Required when
Backend is "postgres". Falls back to MEMBRANE_POSTGRES_DSN.gRPC listen address. Default:
":9090".How often the decay scheduler runs. Default:
1h.How often the consolidation scheduler runs. Default:
6h.Default sensitivity assigned at ingestion. Default:
"low". Valid values: public, low, medium, high, hyper.Minimum confidence for competence and plan_graph candidates in the selector. Default:
0.7.SQLCipher key for the SQLite database. Falls back to
MEMBRANE_ENCRYPTION_KEY.HTTP endpoint for generating embeddings (Postgres only).
Embedding model name sent to the embedding endpoint.
Output dimension of the embedding model. Default:
1536.API key for the embedding endpoint. Falls back to
MEMBRANE_EMBEDDING_API_KEY.HTTP endpoint for semantic fact extraction during consolidation (Postgres only).
Chat model name for the LLM extraction endpoint.
API key for the LLM endpoint. Falls back to
MEMBRANE_LLM_API_KEY.Path to TLS certificate PEM file. TLS is disabled when empty.
Path to TLS private key PEM file.
Shared secret for authenticating gRPC clients. Falls back to
MEMBRANE_API_KEY. Authentication disabled when empty.Maximum requests per second per client.
0 disables rate limiting. Default: 100.