Skip to main content

schema

Import path: github.com/BennettSchwartz/membrane/pkg/schema

The schema package defines the atomic unit of storage (MemoryRecord), all payload types, lifecycle metadata, provenance, audit, and relation structures, plus the full set of enumerations used throughout the system.

MemoryRecord

type MemoryRecord struct { ... }

The atomic unit of storage. Every stored memory item must conform to this shape (RFC 15A.2).

IDstringrequired

Globally unique identifier (UUID recommended). Immutable once created.

TypeMemoryTyperequired

Memory category. One of episodic, working, semantic, competence, plan_graph.

SensitivitySensitivityrequired

Sensitivity classification. One of public, low, medium, high, hyper.

Confidencefloat64required

Epistemic confidence in this record. Range: [0, 1].

Saliencefloat64required

Decay-weighted importance score. Range: [0, +inf). Starts at 1.0 by default.

Scopestring

Visibility scope. Examples: user, device, project, workspace, global. Records with an empty scope are visible to all trust contexts.

Tags[]string

Free-form labels for categorisation and retrieval.

CreatedAttime.Timerequired

Timestamp when the record was created.

UpdatedAttime.Timerequired

Timestamp when the record was last updated.

LifecycleLifecyclerequired

Decay, reinforcement, and deletion metadata.

ProvenanceProvenancerequired

Links to the source events or artifacts that justify this record.

Relations[]Relation

Graph edges to other MemoryRecord instances.

PayloadPayloadrequired

Type-specific structured content. One of EpisodicPayload, WorkingPayload, SemanticPayload, CompetencePayload, or PlanGraphPayload.

AuditLog[]AuditEntryrequired

Append-only log of every action performed on this record.

Constructor

func NewMemoryRecord(id string, memType MemoryType, sensitivity Sensitivity, payload Payload) *MemoryRecord

Convenience constructor. Sets Confidence and Salience to 1.0, initialises Lifecycle with exponential decay (half-life 86 400 s), and appends a create audit entry.


Lifecycle

type Lifecycle struct { ... }
DecayDecayProfilerequired

Decay curve and half-life configuration.

LastReinforcedAttime.Timerequired

Timestamp of the last reinforcement event. Used by the decay function.

Pinnedbooldefault: false

When true, the record is exempt from automatic decay.

DeletionPolicyDeletionPolicy

Controls how the record may be deleted. See the DeletionPolicy enum below.

DecayProfile

type DecayProfile struct { ... }
CurveDecayCurverequired

Mathematical function for decay. Currently only exponential is supported.

HalfLifeSecondsint64required

Time in seconds for salience to decay by half. Minimum value: 1.

MinSaliencefloat64

Floor value below which salience will not decay. Range: [0, 1].

MaxAgeSecondsint64

Maximum age in seconds before the record is eligible for deletion, regardless of salience.

ReinforcementGainfloat64

Amount by which salience increases on each Reinforce call.


Provenance

type Provenance struct {
Sources []ProvenanceSource `json:"sources"`
CreatedBy string `json:"created_by,omitempty"`
}

ProvenanceSource

KindProvenanceKindrequired

Type of source: event, artifact, tool_call, observation, or outcome.

Refstringrequired

Opaque reference into the host system.

Hashstring

Optional content hash for immutability verification.

CreatedBystring

Actor or system that created this source.

Timestamptime.Time

When this source was created or observed.


Relation

type Relation struct { ... }
Predicatestringrequired

Relationship type. Common values: supports, contradicts, derived_from, supersedes, contested_by.

TargetIDstringrequired

ID of the related MemoryRecord.

Weightfloat64

Strength of the relationship. Range: [0, 1].

CreatedAttime.Time

When this relation was established.


AuditEntry

type AuditEntry struct { ... }
ActionAuditActionrequired

Type of action. See the AuditAction enum.

Actorstringrequired

Who or what performed the action (e.g., a user ID or system component name).

Timestamptime.Timerequired

When the action occurred.

Rationalestringrequired

Explanation of why the action was taken.


Enumerations

MemoryType

ValueConstantDescription
episodicMemoryTypeEpisodicRaw experience: user inputs, tool calls, errors, and observations. Intentionally short-lived.
workingMemoryTypeWorkingCurrent state of an ongoing task. Enables resumption across sessions.
semanticMemoryTypeSemanticStable knowledge: preferences, environment facts, and relationships. Supports revisability.
competenceMemoryTypeCompetenceProcedural knowledge: how to achieve goals reliably under specific conditions.
plan_graphMemoryTypePlanGraphReusable solution structures stored as directed graphs of actions.

Sensitivity

ValueConstantDescription
publicSensitivityPublicFreely shareable content.
lowSensitivityLowMinimal sensitivity (default).
mediumSensitivityMediumModerately sensitive content.
highSensitivityHighHighly sensitive; requires elevated trust.
hyperSensitivityHyperExtremely sensitive; maximum protection.

RevisionStatus

ValueConstantDescription
activeRevisionStatusActiveThe record is currently valid.
contestedRevisionStatusContestedValidity is uncertain pending resolution.
retractedRevisionStatusRetractedThe record has been withdrawn.

DecayCurve

ValueConstantDescription
exponentialDecayCurveExponentialExponential decay controlled by HalfLifeSeconds.

DeletionPolicy

ValueConstantDescription
auto_pruneDeletionPolicyAutoPruneAutomatically deleted when salience reaches the floor.
manual_onlyDeletionPolicyManualOnlyRequires explicit user action to delete.
neverDeletionPolicyNeverDeletion is prevented entirely.

ValidityMode

ValueConstantDescription
globalValidityModeGlobalThe fact is universally valid.
conditionalValidityModeConditionalThe fact is valid under specific conditions.
timeboxedValidityModeTimeboxedThe fact is valid within a time window.

TaskState

ValueConstantDescription
planningTaskStatePlanningTask is in the planning phase.
executingTaskStateExecutingTask is actively being executed.
blockedTaskStateBlockedTask cannot proceed due to a blocker.
waitingTaskStateWaitingTask is waiting for external input.
doneTaskStateDoneTask has completed.

OutcomeStatus

ValueConstantDescription
successOutcomeStatusSuccessExperience completed successfully.
failureOutcomeStatusFailureExperience ended in failure.
partialOutcomeStatusPartialPartial success or incomplete outcome.

AuditAction

ValueConstantDescription
createAuditActionCreateA new record was created.
reviseAuditActionReviseAn existing record was revised.
forkAuditActionForkA record was forked into conditional variants.
mergeAuditActionMergeRecords were merged together.
deleteAuditActionDeleteA record was deleted or retracted.
reinforceAuditActionReinforceA record's salience was reinforced.
decayAuditActionDecayA record's salience was decayed or penalised.

ProvenanceKind

ValueConstantDescription
eventProvenanceKindEventSource is an event.
artifactProvenanceKindArtifactSource is an artifact (log, file, etc.).
tool_callProvenanceKindToolCallSource is a tool invocation.
observationProvenanceKindObservationSource is an observation.
outcomeProvenanceKindOutcomeSource is a task outcome.

EdgeKind

ValueConstantDescription
dataEdgeKindDataData dependency edge in a plan graph.
controlEdgeKindControlControl flow edge in a plan graph.