revision

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: 7 Imported by: 0

Documentation

Overview

Package revision implements the revision layer for the Membrane memory substrate. All revision operations are atomic: partial revisions are never externally visible (RFC 15.7).

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrEpisodicImmutable is returned when attempting to revise an episodic record.
	// RFC Section 5: Episodic memory is append-only and MUST NOT be revised.
	ErrEpisodicImmutable = errors.New("episodic memory is immutable and cannot be revised")

	// ErrRecordNotFound is returned when a referenced record does not exist.
	ErrRecordNotFound = storage.ErrNotFound
)

Common errors returned by revision operations.

Functions

This section is empty.

Types

type Embedder added in v0.2.0

type Embedder interface {
	EmbedRecord(ctx context.Context, rec *schema.MemoryRecord) error
}

Embedder stores embeddings for durable records when available.

type Service

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

Service provides revision operations for memory records. All operations are atomic — partial revisions are never externally visible (RFC 15.7).

func NewService

func NewService(store storage.Store) *Service

NewService creates a new revision Service backed by the given Store.

func NewServiceWithEmbedder added in v0.2.0

func NewServiceWithEmbedder(store storage.Store, embedder Embedder) *Service

NewServiceWithEmbedder creates a new revision Service with best-effort embedding support.

func (*Service) Contest

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

Contest marks a record as contested, indicating conflicting evidence exists. The contestingRef identifies the conflicting record or evidence.

func (*Service) Fork

func (s *Service) Fork(ctx context.Context, sourceID string, forkedRecord *schema.MemoryRecord, actor, rationale string) (*schema.MemoryRecord, error)

Fork creates a new record derived from an existing source record. Unlike Supersede, both the source and the forked record remain active — this is intended for conditional variants, not replacement.

Episodic records cannot be forked (RFC Section 5). The entire operation is performed within a single transaction so that partial revisions are never externally visible (RFC 15.7).

func (*Service) Merge

func (s *Service) Merge(ctx context.Context, recordIDs []string, mergedRecord *schema.MemoryRecord, actor, rationale string) (*schema.MemoryRecord, error)

Merge atomically combines multiple source records into a single merged record. All source records are retracted (salience set to 0, semantic status set to "retracted"), and the merged record is linked to each source via "derived_from" relations.

Episodic records cannot be merged (RFC Section 5). The entire operation is performed within a single transaction so that partial revisions are never externally visible (RFC 15.7).

func (*Service) Retract

func (s *Service) Retract(ctx context.Context, id, actor, rationale string) error

Retract marks a record as retracted without deleting it, preserving auditability. For semantic records, the revision status is set to "retracted". Salience is set to 0 for all record types.

Episodic records cannot be retracted (RFC Section 5). The entire operation is performed within a single transaction so that partial revisions are never externally visible (RFC 15.7).

func (*Service) Supersede

func (s *Service) Supersede(ctx context.Context, oldID string, newRecord *schema.MemoryRecord, actor, rationale string) (*schema.MemoryRecord, error)

Supersede atomically replaces an old record with a new one. The old record is retracted (salience set to 0, semantic status set to "retracted"), and the new record is linked to the old via provenance and a "supersedes" relation.

Episodic records cannot be superseded (RFC Section 5). The entire operation is performed within a single transaction so that partial revisions are never externally visible (RFC 15.7).

Jump to

Keyboard shortcuts

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