refactor: unify tags and edges into single rels table

This commit is contained in:
2026-04-01 12:50:45 +02:00
parent 27c72db042
commit 6288879468
9 changed files with 296 additions and 249 deletions

View File

@@ -3,26 +3,25 @@ package store
import "axolotl/models"
// Store is a primitive graph persistence interface. It provides basic
// operations for nodes, tags, and directed edges. No business logic lives here.
// operations for nodes and directed rels. No business logic lives here.
// "Tag" rels are rels with an empty toID (e.g. "_type::issue" or "backend").
type Store interface {
// Nodes
AddNode(id, title, content, dueDate, createdAt, updatedAt string) error
GetNode(id string) (*models.Node, error) // returns node with tags and edges populated
GetNode(id string) (*models.Node, error) // returns node with tags and rels populated
UpdateNode(id, title, content, dueDate, updatedAt string) error // empty dueDate stores NULL
DeleteNode(id string) error
NodeExists(id string) (bool, error)
GenerateID() (string, error) // returns a random 5-char ID guaranteed unique in the store
// Tags
AddTag(nodeID, tag string) error
RemoveTag(nodeID, tag string) error
// Rels: relName is the relation name; toID is empty for "tag" rels (properties/labels).
AddRel(nodeID, relName, toID string) error
RemoveRel(nodeID, relName, toID string) error
// Edges (directed, typed)
AddEdge(fromID, toID string, relType models.RelType) error
RemoveEdge(fromID, toID string, relType models.RelType) error
// Query returns fully-populated nodes matching all given tag prefixes and edge filters.
FindNodes(tagPrefixes []string, edgeFilters []*models.Rel) ([]*models.Node, error)
// FindNodes returns fully-populated nodes matching all given filters.
// Filters with empty Target match nodes by rel_name prefix with empty toID (tag/property).
// Filters with non-empty Target match nodes by exact rel_name and toID (edge).
FindNodes(filters []*models.Rel) ([]*models.Node, error)
// Transaction runs fn inside an atomic transaction. If fn returns an error
// the transaction is rolled back; otherwise it is committed.