store

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package store provides SQLite-backed persistence.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DiffRecord

type DiffRecord struct {
	SnapshotID int64
	NodeID     string
	Op         string
	OldHash    string
	NewHash    string
	OldContent string
	NewContent string
}

type Node

type Node struct {
	ID           string
	ParentID     string
	SourceFile   string
	NodeType     string
	Depth        int
	Label        string
	Content      string
	Format       string
	TokenCount   int
	ContentHash  string
	Temperature  float64
	AccessCount  int
	LastAccessed sql.NullInt64
	CreatedAt    int64
	UpdatedAt    int64
	SeedTemp     *float64
}

func BuildTree

func BuildTree(nodes []*Node) (roots []*Node, children map[string][]*Node)

type RankedNode

type RankedNode struct {
	Node *Node
	Rank float64
}

type RowScanner

type RowScanner interface {
	Scan(...any) error
}

type Snapshot

type Snapshot struct {
	ID          int64
	CursorHash  string
	ParentID    sql.NullInt64
	Message     string
	CompileRoot string
	CreatedAt   int64
}

type Stats

type Stats struct {
	NodeCount     int
	SnapshotCount int
	AvgTemp       float64
	HotCount      int
	ColdCount     int
}

type Store

type Store struct {
	OpMu sync.Mutex
	// contains filtered or unexported fields
}

func Open

func Open(path string) (*Store, error)

func (*Store) AdvanceCursorTx

func (s *Store) AdvanceCursorTx(ctx context.Context, tx *sql.Tx, snapshotID int64) error

func (*Store) BoostTemperature

func (s *Store) BoostTemperature(ctx context.Context, id string, boost float64) error

func (*Store) BoostTemperatureBatch

func (s *Store) BoostTemperatureBatch(ctx context.Context, ids []string, boost float64) error

func (*Store) Close

func (s *Store) Close() error

func (*Store) CreateSnapshotTx

func (s *Store) CreateSnapshotTx(ctx context.Context, tx *sql.Tx, cursorHash, message, compileRoot string) (int64, error)

func (*Store) DecayTemperatures

func (s *Store) DecayTemperatures(ctx context.Context, factor float64) (int64, error)

func (*Store) DeleteNode

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

func (*Store) DeleteNodeTx

func (s *Store) DeleteNodeTx(ctx context.Context, tx *sql.Tx, id string) error

func (*Store) DeleteNodesByFiles

func (s *Store) DeleteNodesByFiles(ctx context.Context, paths []string) error

func (*Store) ExecRewriteSourcePaths

func (s *Store) ExecRewriteSourcePaths(ctx context.Context, oldPrefix, newPrefix string) error

Replace every source file prefix matching oldPrefix with newPrefix.

func (*Store) GetAllNodes

func (s *Store) GetAllNodes(ctx context.Context) ([]*Node, error)

func (*Store) GetAncestors

func (s *Store) GetAncestors(ctx context.Context, id string) ([]*Node, error)

func (*Store) GetChildren

func (s *Store) GetChildren(ctx context.Context, parentID string) ([]*Node, error)

func (*Store) GetColdNodes

func (s *Store) GetColdNodes(ctx context.Context, threshold float64) ([]*Node, error)

func (*Store) GetDescendants

func (s *Store) GetDescendants(ctx context.Context, id string, maxDepth int) ([]*Node, error)

func (*Store) GetDiffsBySnapshot

func (s *Store) GetDiffsBySnapshot(ctx context.Context, snapshotID int64) ([]*DiffRecord, error)

func (*Store) GetDiffsForNode

func (s *Store) GetDiffsForNode(ctx context.Context, nodeID string) ([]*DiffRecord, error)

func (*Store) GetDiffsSince

func (s *Store) GetDiffsSince(ctx context.Context, sinceSnapshotID int64) ([]*DiffRecord, error)

func (*Store) GetHeadCursorHash

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

func (*Store) GetLatestCompileRoot

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

Return the compile root of the most recent snapshot created via a directory compile.

func (*Store) GetNode

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

func (*Store) GetNodesByFile

func (s *Store) GetNodesByFile(ctx context.Context, path string) ([]*Node, error)

func (*Store) GetNodesByFiles

func (s *Store) GetNodesByFiles(ctx context.Context, paths []string) ([]*Node, error)

func (*Store) GetRootNodes

func (s *Store) GetRootNodes(ctx context.Context) ([]*Node, error)

func (*Store) GetSiblings

func (s *Store) GetSiblings(ctx context.Context, id string) ([]*Node, error)

func (*Store) GetSnapshot

func (s *Store) GetSnapshot(ctx context.Context, id int) (*Snapshot, error)

func (*Store) GetStats

func (s *Store) GetStats(ctx context.Context) (*Stats, error)

func (*Store) IncrementAccess

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

func (*Store) InsertDiffTx

func (s *Store) InsertDiffTx(ctx context.Context, tx *sql.Tx, d *DiffRecord) error

func (*Store) ListSnapshots

func (s *Store) ListSnapshots(ctx context.Context, limit int) ([]*Snapshot, error)

func (*Store) Migrate

func (s *Store) Migrate(ctx context.Context) error

Apply any embedded migration that hasn't run on the DB yet.

func (*Store) Search

func (s *Store) Search(ctx context.Context, query string, limit int) ([]*Node, error)

func (*Store) SearchRanked

func (s *Store) SearchRanked(ctx context.Context, query string, limit int) ([]*RankedNode, error)

func (*Store) Tx

func (s *Store) Tx(ctx context.Context, fn func(tx *sql.Tx) error) error

Tx runs fn inside a transaction. Commits on nil error, rolls back otherwise.

func (*Store) UpdateTemperature

func (s *Store) UpdateTemperature(ctx context.Context, id string, temp float64) error

func (*Store) UpsertNode

func (s *Store) UpsertNode(ctx context.Context, n *Node) error

func (*Store) UpsertNodeTx

func (s *Store) UpsertNodeTx(ctx context.Context, tx *sql.Tx, n *Node) error

Jump to

Keyboard shortcuts

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