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 ¶
- type Store
- func (s *Store) AsOf(commit string) core.Store
- func (s *Store) BeginCommit(ctx context.Context, sourceSha string) (core.CommitWriter, error)
- func (s *Store) Close() error
- func (s *Store) DriftSince(ctx context.Context, sourceSha string) (core.DriftResult, error)
- func (s *Store) GetKnowledgeCommit(ctx context.Context, sourceSha string) (core.KnowledgeCommit, error)
- func (s *Store) GetRecord(ctx context.Context, id core.Hash) (core.Record, error)
- func (s *Store) ListCurrent(ctx context.Context) ([]core.Symbol, []core.Edge, error)
- func (s *Store) ListKnowledgeCommits(ctx context.Context) ([]core.KnowledgeCommit, error)
- func (s *Store) ListLineages(ctx context.Context) ([]core.Lineage, error)
- func (s *Store) PruneKCs(ctx context.Context, sourceShas []string) (int, error)
- func (s *Store) Walk(ctx context.Context, from core.Hash, kind core.EdgeKind, dir core.Direction) iter.Seq2[core.Edge, error]
- func (s *Store) WhyTouches(ctx context.Context, id core.Hash) ([]core.WhyEvent, error)
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 ¶
Open opens or creates a Crowl SQLite store at path. Path must be a regular file path (use ":memory:" for tests).
func (*Store) BeginCommit ¶
BeginCommit creates a CommitWriter (one per source SHA).
func (*Store) DriftSince ¶
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) ListCurrent ¶
ListCurrent returns all symbols and edges active at HEAD.
func (*Store) ListKnowledgeCommits ¶
ListKnowledgeCommits returns all KCs in seq (insertion) order.
func (*Store) ListLineages ¶
ListLineages returns all lineage records.
func (*Store) PruneKCs ¶
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 ¶
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.