Documentation
¶
Overview ¶
Package store wraps the per-repo SQLite index database.
The DB lives at ~/.cogni/<repo-hash>/index.db. v0.1 schema is embedded as schema.sql and applied on Open. Writers must serialize themselves; readers are concurrent-safe via SQLite's WAL mode.
Index ¶
- Constants
- type FileRow
- type RefRow
- type Store
- func (s *Store) AllFilePaths() ([]string, error)
- func (s *Store) Close() error
- func (s *Store) DB() *sql.DB
- func (s *Store) DeleteFile(path string) error
- func (s *Store) FileSHA(path string) (string, error)
- func (s *Store) RefsByName(name string, kinds []string, limit int) ([]RefRow, error)
- func (s *Store) ReplaceRefs(fileID int64, refs []parse.Reference) error
- func (s *Store) ReplaceSymbols(fileID int64, syms []parse.Symbol) error
- func (s *Store) SchemaVersionFromDB() (string, error)
- func (s *Store) SymbolsByFile(path string) ([]SymbolRow, error)
- func (s *Store) SymbolsByName(q string, limit int) ([]SymbolRow, error)
- func (s *Store) SymbolsByQualified(q string, limit int) ([]SymbolRow, error)
- func (s *Store) SymbolsFTS(q, kind string, limit int) ([]SymbolRow, error)
- func (s *Store) TopExportedSymbolsByPrefix(prefix string, limit int) ([]SymbolRow, error)
- func (s *Store) UpsertFile(f FileRow) (int64, error)
- type SymbolRow
Constants ¶
const SchemaVersion = "1"
SchemaVersion is the current store schema. Bumped on incompatible changes.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type FileRow ¶
type FileRow struct {
ID int64
Path string
SHA256 string
MtimeNs int64
SizeBytes int64
LineCount int
Language string
LastIndexed int64
}
FileRow describes a row in the files table.
type RefRow ¶
type RefRow struct {
ID int64
FileID int64
FilePath string
SymbolName string
Line int
Col int
ContextKind string
}
RefRow is a persisted reference joined with its file path.
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store owns a sql.DB handle to the index database.
func Open ¶
Open opens (or creates) the SQLite index at path and applies the schema. The caller must Close() when done.
func (*Store) AllFilePaths ¶
AllFilePaths returns every indexed file's repo-relative path. Used by repo_overview to build the package tree in Go.
func (*Store) DeleteFile ¶
DeleteFile removes the row for path; symbols cascade.
func (*Store) RefsByName ¶
RefsByName returns reference sites for the bare symbol name. When kinds is non-empty, results are restricted to those context kinds.
func (*Store) ReplaceRefs ¶
ReplaceRefs deletes all refs for fileID and inserts the given references in a single transaction. Use from the indexer after each (re)parse.
func (*Store) ReplaceSymbols ¶
ReplaceSymbols deletes the existing symbols for fileID and inserts the given symbols in a single transaction. The FTS5 mirror updates via triggers. Use this from the indexer after each (re)parse.
func (*Store) SchemaVersionFromDB ¶
SchemaVersionFromDB returns the schema version recorded in the meta table.
func (*Store) SymbolsByFile ¶
SymbolsByFile returns all symbols for the given repo-relative file path, ordered by start_line. Used by file_outline.
func (*Store) SymbolsByName ¶
SymbolsByName returns symbols whose bare name exactly matches q.
func (*Store) SymbolsByQualified ¶
SymbolsByQualified returns symbols whose fully-qualified name matches q exactly. Used by symbol_source for unambiguous lookup.
func (*Store) SymbolsFTS ¶
SymbolsFTS runs a trigram FTS5 query over name/qualified/docstring and returns the matching symbol rows, ordered by relevance. When kind is non-empty and not "any", results are restricted to that symbol kind.
func (*Store) TopExportedSymbolsByPrefix ¶
TopExportedSymbolsByPrefix returns up to limit non-underscore symbols whose file path begins with prefix. Used by repo_overview to surface the most visible names per package.