storage

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DecodeVector

func DecodeVector(b []byte) []float32

DecodeVector decodes a byte slice from SQLite BLOB to a float32 slice.

func EncodeVector

func EncodeVector(v []float32) []byte

EncodeVector encodes a float32 slice to a byte slice for SQLite BLOB storage.

Types

type Edge

type Edge struct {
	ID, FromID, ToID, Type, Metadata string
	Acyclic                          bool
	Weight                           float64
	CreatedAt                        time.Time
}

Edge represents a relationship between two nodes in the graph.

type Node

type Node struct {
	ID, Type, Content, ContentHash, Summary, Scope, Project, Tags string
	Tier                                                          int
	Confidence                                                    float64
	AccessCount                                                   int
	CreatedAt, UpdatedAt, AccessedAt                              time.Time
	SourceSession, SourceAgent                                    string
	Version                                                       int
}

Node represents a memory node in the Yaad graph.

type NodeFilter

type NodeFilter struct {
	Type, Scope, Project string
	Tier                 int
	MinConfidence        float64
}

NodeFilter specifies criteria for listing nodes.

type NodeVersion

type NodeVersion struct {
	NodeID, Content, ChangedBy, Reason string
	Version                            int
	ChangedAt                          time.Time
}

NodeVersion stores a historical version of a node for audit/rollback.

type ReplayEvent

type ReplayEvent struct {
	ID        int64
	SessionID string
	Data      string // JSON
	CreatedAt time.Time
}

ReplayEvent is a raw tool event stored for session replay.

type Session

type Session struct {
	ID, Project, Summary, Agent string
	StartedAt, EndedAt          time.Time
}

Session tracks a coding agent session.

type Store

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

Store is the SQLite-backed storage layer for Yaad.

func NewStore

func NewStore(dbPath string) (*Store, error)

func (*Store) AddFileWatch

func (s *Store) AddFileWatch(filePath, nodeID, gitHash string) error

func (*Store) AddReplayEvent

func (s *Store) AddReplayEvent(sessionID, data string) error

AddReplayEvent stores a tool event for replay.

func (*Store) AllEmbeddings

func (s *Store) AllEmbeddings() (map[string][]float32, error)

AllEmbeddings returns all stored embeddings as (nodeID, vector) pairs.

func (*Store) Close

func (s *Store) Close() error

func (*Store) CreateEdge

func (s *Store) CreateEdge(e *Edge) error

func (*Store) CreateNode

func (s *Store) CreateNode(n *Node) error

func (*Store) CreateSession

func (s *Store) CreateSession(sess *Session) error

func (*Store) DB

func (s *Store) DB() *sql.DB

DB returns the underlying database connection for direct queries.

func (*Store) DeleteEdge

func (s *Store) DeleteEdge(id string) error

func (*Store) DeleteNode

func (s *Store) DeleteNode(id string) error

func (*Store) EndSession

func (s *Store) EndSession(id string, summary string) error

func (*Store) GetEdge

func (s *Store) GetEdge(id string) (*Edge, error)

func (*Store) GetEdgesFrom

func (s *Store) GetEdgesFrom(nodeID string) ([]*Edge, error)

func (*Store) GetEdgesTo

func (s *Store) GetEdgesTo(nodeID string) ([]*Edge, error)

func (*Store) GetEmbedding

func (s *Store) GetEmbedding(nodeID string) ([]float32, string, error)

GetEmbedding retrieves the embedding for a node.

func (*Store) GetNeighbors

func (s *Store) GetNeighbors(nodeID string) ([]*Node, error)

func (*Store) GetNode

func (s *Store) GetNode(id string) (*Node, error)

func (*Store) GetNodesByFile

func (s *Store) GetNodesByFile(filePath string) ([]*Node, error)

func (*Store) GetReplayEvents

func (s *Store) GetReplayEvents(sessionID string) ([]*ReplayEvent, error)

GetReplayEvents returns all events for a session in order.

func (*Store) GetVersions

func (s *Store) GetVersions(nodeID string) ([]*NodeVersion, error)

func (*Store) ListNodes

func (s *Store) ListNodes(f NodeFilter) ([]*Node, error)

func (*Store) ListSessions

func (s *Store) ListSessions(project string, limit int) ([]*Session, error)

func (*Store) SaveEmbedding

func (s *Store) SaveEmbedding(nodeID, model string, vector []float32) error

SaveEmbedding stores a vector embedding for a node.

func (*Store) SaveVersion

func (s *Store) SaveVersion(nodeID string, content, changedBy, reason string) error

func (*Store) SearchNodeByHash

func (s *Store) SearchNodeByHash(hash, scope, project string) (*Node, error)

SearchNodeByHash finds a node by content hash + scope + project (dedup check).

func (*Store) SearchNodes

func (s *Store) SearchNodes(query string, limit int) ([]*Node, error)

func (*Store) UpdateNode

func (s *Store) UpdateNode(n *Node) error

func (*Store) UpsertByTopic

func (s *Store) UpsertByTopic(n *Node, topicKey string) (*Node, bool, error)

UpsertByTopic updates an existing node if one with the same project+scope+topic_key exists, otherwise creates a new one. Based on Engram's topic dedup approach. topic_key is stored in the Tags field as "topic:<key>".

Jump to

Keyboard shortcuts

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