Skip to main content
Import path: github.com/GustyCube/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).
ID
string
required
Globally unique identifier (UUID recommended). Immutable once created.
Type
MemoryType
required
Memory category. One of episodic, working, semantic, competence, plan_graph.
Sensitivity
Sensitivity
required
Sensitivity classification. One of public, low, medium, high, hyper.
Confidence
float64
required
Epistemic confidence in this record. Range: [0, 1].
Salience
float64
required
Decay-weighted importance score. Range: [0, +inf). Starts at 1.0 by default.
Scope
string
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.
CreatedAt
time.Time
required
Timestamp when the record was created.
UpdatedAt
time.Time
required
Timestamp when the record was last updated.
Lifecycle
Lifecycle
required
Decay, reinforcement, and deletion metadata.
Provenance
Provenance
required
Links to the source events or artifacts that justify this record.
Relations
[]Relation
Graph edges to other MemoryRecord instances.
Payload
Payload
required
Type-specific structured content. One of EpisodicPayload, WorkingPayload, SemanticPayload, CompetencePayload, or PlanGraphPayload.
AuditLog
[]AuditEntry
required
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 { ... }
Decay
DecayProfile
required
Decay curve and half-life configuration.
LastReinforcedAt
time.Time
required
Timestamp of the last reinforcement event. Used by the decay function.
Pinned
bool
default:"false"
When true, the record is exempt from automatic decay.
DeletionPolicy
DeletionPolicy
Controls how the record may be deleted. See the DeletionPolicy enum below.

DecayProfile

type DecayProfile struct { ... }
Curve
DecayCurve
required
Mathematical function for decay. Currently only exponential is supported.
HalfLifeSeconds
int64
required
Time in seconds for salience to decay by half. Minimum value: 1.
MinSalience
float64
Floor value below which salience will not decay. Range: [0, 1].
MaxAgeSeconds
int64
Maximum age in seconds before the record is eligible for deletion, regardless of salience.
ReinforcementGain
float64
Amount by which salience increases on each Reinforce call.

Provenance

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

ProvenanceSource

Kind
ProvenanceKind
required
Type of source: event, artifact, tool_call, observation, or outcome.
Ref
string
required
Opaque reference into the host system.
Hash
string
Optional content hash for immutability verification.
CreatedBy
string
Actor or system that created this source.
Timestamp
time.Time
When this source was created or observed.

Relation

type Relation struct { ... }
Predicate
string
required
Relationship type. Common values: supports, contradicts, derived_from, supersedes, contested_by.
TargetID
string
required
ID of the related MemoryRecord.
Weight
float64
Strength of the relationship. Range: [0, 1].
CreatedAt
time.Time
When this relation was established.

AuditEntry

type AuditEntry struct { ... }
Action
AuditAction
required
Type of action. See the AuditAction enum.
Actor
string
required
Who or what performed the action (e.g., a user ID or system component name).
Timestamp
time.Time
required
When the action occurred.
Rationale
string
required
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.

Build docs developers (and LLMs) love