refactor: consolidate packages - move output to cmd, config/session to store, rename Store to GraphStore

This commit is contained in:
2026-04-02 00:18:33 +02:00
parent 2bcc310c6d
commit 03a896d23f
25 changed files with 190 additions and 239 deletions

30
src/store/graph_store.go Normal file
View File

@@ -0,0 +1,30 @@
package store
import "axolotl/models"
// GraphStore is a primitive graph persistence interface. It provides basic
// 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 GraphStore interface {
// Nodes
AddNode(id, title, content, dueDate, createdAt, updatedAt string) error
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
// 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
// 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.
// Calls to Transaction inside fn reuse the same transaction (no nesting).
Transaction(fn func(GraphStore) error) error
}