sqlite

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package sqlite implements core.Store backed by SQLite (modernc.org/sqlite, pure Go, no CGo).

In v0.1 SQLite is the SOLE backing store: Crowl treats it as both canonical persistence and derived index. The git canonical tier promised by FOUNDATION §6.1 is deferred to a v0.1 patch release; the data model and revisions semantics already match what the git tier will need to preserve.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Store

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

Store implements core.Store.

func Open

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

Open opens or creates a Crowl SQLite store at path. Path must be a regular file path (use ":memory:" for tests).

func (*Store) AsOf

func (s *Store) AsOf(commit string) core.Store

AsOf returns a scoped Store. asOfCommit "" means HEAD.

func (*Store) BeginCommit

func (s *Store) BeginCommit(ctx context.Context, sourceSha string) (core.CommitWriter, error)

BeginCommit creates a CommitWriter (one per source SHA).

func (*Store) Close

func (s *Store) Close() error

Close closes the underlying database.

func (*Store) DriftSince

func (s *Store) DriftSince(ctx context.Context, sourceSha string) (core.DriftResult, error)

DriftSince computes the symbol-level diff between the indexed state at sourceSha and HEAD. Returns ErrUnknownCommit if sourceSha isn't in the index (e.g., the user analyzed HEAD-only).

"Active at seq Y" = there exists a revision r where added_commit_seq(r) ≤ Y AND (removed_commit IS NULL OR removed_commit_seq(r) > Y).

Categories:

  • Added: active at HEAD, not active at Y
  • Removed: active at Y, not active at HEAD
  • Updated: active at both AND a revision exists with added_commit_seq > Y (body changed in the interval)

The returned Symbols are HEAD-active for Added/Updated and Y-active for Removed.

func (*Store) GetKnowledgeCommit

func (s *Store) GetKnowledgeCommit(ctx context.Context, sourceSha string) (core.KnowledgeCommit, error)

GetKnowledgeCommit returns the KC for sourceSha.

func (*Store) GetRecord

func (s *Store) GetRecord(ctx context.Context, id core.Hash) (core.Record, error)

GetRecord returns the record at the current scope.

func (*Store) ListCurrent

func (s *Store) ListCurrent(ctx context.Context) ([]core.Symbol, []core.Edge, error)

ListCurrent returns all symbols and edges active at HEAD.

func (*Store) ListKnowledgeCommits

func (s *Store) ListKnowledgeCommits(ctx context.Context) ([]core.KnowledgeCommit, error)

ListKnowledgeCommits returns all KCs in seq (insertion) order.

func (*Store) ListLineages

func (s *Store) ListLineages(ctx context.Context) ([]core.Lineage, error)

ListLineages returns all lineage records.

func (*Store) PruneKCs

func (s *Store) PruneKCs(ctx context.Context, sourceShas []string) (int, error)

PruneKCs deletes the given KCs and all revisions whose added_commit OR removed_commit references them. After deletion:

  • active HEAD revisions of records modified at non-pruned commits remain
  • records whose only active revision was added at a pruned commit are removed entirely (no historical residue)
  • lineage records added at pruned commits are removed

Returns the number of KCs actually deleted. Skips KCs that don't exist.

This is the storage primitive used by `crowl prune --orphans` and `crowl prune --before`.

func (*Store) Walk

func (s *Store) Walk(ctx context.Context, from core.Hash, kind core.EdgeKind, dir core.Direction) iter.Seq2[core.Edge, error]

Walk iterates active edges from id of the given kind in the given direction.

func (*Store) WhyTouches

func (s *Store) WhyTouches(ctx context.Context, id core.Hash) ([]core.WhyEvent, error)

WhyTouches returns the chronological list of KCs that touched a symbol (added/updated/removed it), with commit metadata where available. This is `blame` enriched with commit_message + author; older KCs (created before the schema migration ran) return empty strings for those fields.

The `Effect` field is one of "added", "updated", "removed", determined by which kc_* table contains the record-id.

Jump to

Keyboard shortcuts

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