runtimegraph

package
v0.0.4-rc.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 12, 2026 License: MIT Imports: 18 Imported by: 0

Documentation

Overview

Package runtimegraph provides concrete graph lifecycle management for MALT. A graph represents a scoped collection of arcs authenticated by structure commitments. This file contains the sentinel errors and GraphState type.

Package runtimegraph provides ArcTable-backed graph runtime wiring for MALT. Runtime graph values do not own authoritative heads or freshness policy.

Package runtimegraph provides graph lifecycle management for MALT. A graph is runtime metadata for reopening a namespace with a compatible backend profile. It does not own an authoritative result root or freshness policy. The current daemon path creates an ad hoc default Graph instead of exposing this lifecycle manager as a public API. This file contains the Store and Manager types.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotFound      = errors.New("graph not found")
	ErrAlreadyExists = errors.New("graph already exists")
	ErrDeleted       = errors.New("graph is deleted")
	ErrFrozen        = errors.New("graph is frozen")
	ErrInvalidState  = errors.New("invalid graph state")
)

Sentinel errors.

Functions

This section is empty.

Types

type GraphMeta

type GraphMeta struct {
	ID           string     `json:"id"`
	CreatedAt    time.Time  `json:"created_at"`
	UpdatedAt    time.Time  `json:"updated_at"`
	Backend      string     `json:"backend"`       // per-graph commitment scheme used when reopening the graph
	ArcTableType string     `json:"arctable_type"` // node-scoped ArcTable compatibility requirement for this graph
	State        GraphState `json:"state"`
}

GraphMeta represents a MALT graph with metadata.

func (*GraphMeta) IsActive

func (g *GraphMeta) IsActive() bool

IsActive returns true if the graph is in active state.

func (*GraphMeta) IsDeleted

func (g *GraphMeta) IsDeleted() bool

IsDeleted returns true if the graph is deleted.

func (*GraphMeta) IsFrozen

func (g *GraphMeta) IsFrozen() bool

IsFrozen returns true if the graph is frozen.

type GraphState

type GraphState string

GraphState represents the lifecycle state of a graph.

const (
	StateActive  GraphState = "active"
	StateFrozen  GraphState = "frozen"
	StateDeleted GraphState = "deleted"
)

Graph state constants.

type Manager

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

Manager manages graph lifecycle: creation, access, and state transitions. It coordinates graph metadata with ArcTable namespaces and commitment backend selection, but it intentionally does not track an authoritative head root.

func NewManager

func NewManager(store *Store) *Manager

NewManager creates a new graph manager.

func (*Manager) CreateGraph

func (m *Manager) CreateGraph(ctx context.Context, id string, backend string, arcTableType string) (*GraphMeta, error)

CreateGraph creates a new graph metadata entry with the given runtime profile. The graph starts in the "active" state without publishing any root.

func (*Manager) DeleteGraph

func (m *Manager) DeleteGraph(ctx context.Context, id string) error

DeleteGraph soft-deletes a graph (sets state to "deleted").

func (*Manager) FreezeGraph

func (m *Manager) FreezeGraph(ctx context.Context, id string) error

FreezeGraph transitions a graph to the "frozen" state. Frozen graphs cannot be updated but can still be read.

func (*Manager) GetGraph

func (m *Manager) GetGraph(ctx context.Context, id string) (*GraphMeta, error)

GetGraph retrieves a graph by ID. Returns ErrNotFound if the graph doesn't exist, ErrDeleted if it's deleted.

func (*Manager) ListGraphs

func (m *Manager) ListGraphs(ctx context.Context) ([]*GraphMeta, error)

ListGraphs returns all active and frozen graphs.

func (*Manager) RequireActive

func (m *Manager) RequireActive(ctx context.Context, id string) (*GraphMeta, error)

RequireActive returns ErrFrozen or ErrDeleted if the graph is not active. This is a convenience helper for write-side validation.

type Option

type Option func(*Options)

Option configures a Graph instance.

func WithCommitmentScheme

func WithCommitmentScheme(scheme commitment.IndexCommitment) Option

WithCommitmentScheme sets the commitment scheme for this Graph. Default: KZG.

func WithNamespace

func WithNamespace(id string) Option

WithNamespace sets the ArcTable namespace for this Graph. Default: the graph's ID.

type Options

type Options struct {
	Scheme    commitment.IndexCommitment
	Namespace string
}

Options holds configuration for Graph creation.

type RuntimeGraph

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

RuntimeGraph is a per-graph runtime composition of semantic implementations, resolver, and writer. It does not own authoritative heads or freshness policy. The root CID is always supplied by callers.

func NewGraph

func NewGraph(id string, arctable arctable.ArcTable, opts ...Option) (*RuntimeGraph, error)

NewGraph creates a new per-graph instance with its own semantic layer, resolver, and writer.

Parameters:

  • id: unique graph identifier
  • arctable: shared ArcTable (namespace by namespace) — from Node
  • opts: functional options (WithCommitmentScheme, WithNamespace, etc.)

func (*RuntimeGraph) ID

func (g *RuntimeGraph) ID() string

ID returns the graph identifier.

func (*RuntimeGraph) ListSemantic

func (g *RuntimeGraph) ListSemantic() list.Semantics

ListSemantic returns the per-graph list semantic.

func (*RuntimeGraph) Namespace

func (g *RuntimeGraph) Namespace() string

Namespace returns the ArcTable namespace for this graph.

func (*RuntimeGraph) Resolver

func (g *RuntimeGraph) Resolver() graph.Resolver

Resolver returns the per-graph resolver.

func (*RuntimeGraph) Semantic

func (g *RuntimeGraph) Semantic() mapping.Semantics

Semantic returns the per-graph keyed-map semantic.

func (*RuntimeGraph) Writer

func (g *RuntimeGraph) Writer() graph.Writer

Writer returns the per-graph writer.

type Store

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

Store persists and retrieves graph metadata.

func NewStore

func NewStore(kv kvstore.KVStore) *Store

NewStore creates a new graph metadata store backed by a KVStore.

func (*Store) Create

func (s *Store) Create(ctx context.Context, g *GraphMeta) error

Create persists a new graph entry.

func (*Store) Delete

func (s *Store) Delete(ctx context.Context, id string) error

Delete removes a graph entry (soft delete: sets state to deleted).

func (*Store) Get

func (s *Store) Get(ctx context.Context, id string) (*GraphMeta, error)

Get retrieves a graph by ID.

func (*Store) List

func (s *Store) List(ctx context.Context) ([]*GraphMeta, error)

List returns all non-deleted graphs.

func (*Store) Update

func (s *Store) Update(ctx context.Context, g *GraphMeta) error

Update persists updated graph metadata.

Jump to

Keyboard shortcuts

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