store

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Jun 5, 2026 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BatchItem

type BatchItem struct {
	Index      *FileIndex
	Symbols    []Symbol
	Calls      []Call
	Flows      []Flow
	Violations []Violation
}

type Call

type Call struct {
	ID         int    `json:"id"`
	CallerName string `json:"caller_name"`
	CalleeName string `json:"callee_name"`
	Path       string `json:"path"`
	Line       int    `json:"line"`
	CalleePath string `json:"callee_path"`
	LinkType   string `json:"link_type"`
	Indegree   int    `json:"indegree"`
	Body       string `json:"body"`
}

type CriticalSymbol

type CriticalSymbol struct {
	Symbol
	Centrality int `json:"centrality"`
	Fragility  int `json:"fragility"`
}

type DBTX

type DBTX interface {
	ExecContext(context.Context, string, ...interface{}) (sql.Result, error)
	PrepareContext(context.Context, string) (*sql.Stmt, error)
	QueryContext(context.Context, string, ...interface{}) (*sql.Rows, error)
	QueryRowContext(context.Context, string, ...interface{}) *sql.Row
}

type DiagnosticStore

type DiagnosticStore interface {
	GetAllFailedTests(ctx context.Context) iter.Seq2[types.TestResult, error]
	SaveTestResult(ctx context.Context, res *types.TestResult) error
	GetHealthReport(ctx context.Context, symbol string, failuresOnly bool) iter.Seq2[types.TestResult, error]
	ClearTestResults(ctx context.Context) error
	SaveViolation(ctx context.Context, v *types.ASTRuleMatch) error
	GetViolationsByFile(ctx context.Context, path string) ([]Violation, error)
}

type FileIndex

type FileIndex struct {
	Path      string `json:"path"`
	Mtime     int    `json:"mtime"`
	Hash      string `json:"hash"`
	AstJson   string `json:"ast_json"`
	Project   string `json:"project"`
	Freshness int    `json:"freshness"`
}

type Flow

type Flow struct {
	Source string `json:"source"`
	Sink   string `json:"sink"`
	Type   string `json:"type"` // assignment, parameter, return
	Path   string `json:"path"`
	Line   int    `json:"line"`
}

type GetCallersParams

type GetCallersParams struct {
	CalleeName string `json:"callee_name"`
	Limit      int64  `json:"limit"`
	Offset     int64  `json:"offset"`
}

type Queries

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

func New

func New(db DBTX) *Queries

func (*Queries) ClearSymbols

func (q *Queries) ClearSymbols(ctx context.Context, path string) error

func (*Queries) GetCallees

func (q *Queries) GetCallees(ctx context.Context, callerName string) ([]Call, error)

func (*Queries) GetCallers

func (q *Queries) GetCallers(ctx context.Context, arg GetCallersParams) ([]Call, error)

func (*Queries) SaveCall

func (q *Queries) SaveCall(ctx context.Context, arg SaveCallParams) error

func (*Queries) SaveFileIndex

func (q *Queries) SaveFileIndex(ctx context.Context, arg SaveFileIndexParams) error

func (*Queries) SaveSymbol

func (q *Queries) SaveSymbol(ctx context.Context, arg SaveSymbolParams) error

func (*Queries) SearchSymbols

func (q *Queries) SearchSymbols(ctx context.Context, arg SearchSymbolsParams) ([]Symbol, error)

func (*Queries) WithTx

func (q *Queries) WithTx(tx *sql.Tx) *Queries

type SaveCallParams

type SaveCallParams struct {
	CallerName string `json:"caller_name"`
	CalleeName string `json:"callee_name"`
	Path       string `json:"path"`
	Line       int    `json:"line"`
	CalleePath string `json:"callee_path"`
	LinkType   string `json:"link_type"`
	Indegree   int    `json:"indegree"`
	Body       string `json:"body"`
}

type SaveFileIndexParams

type SaveFileIndexParams struct {
	Path      string `json:"path"`
	Mtime     int    `json:"mtime"`
	Hash      string `json:"hash"`
	AstJson   string `json:"ast_json"`
	Project   string `json:"project"`
	Freshness int    `json:"freshness"`
}

type SaveSymbolParams

type SaveSymbolParams struct {
	Name           string  `json:"name"`
	Type           string  `json:"type"`
	PackagePath    string  `json:"package_path"`
	ReceiverType   string  `json:"receiver_type"`
	Signature      string  `json:"signature"`
	Doc            string  `json:"doc"`
	Path           string  `json:"path"`
	StartByte      int     `json:"start_byte"`
	EndByte        int     `json:"end_byte"`
	StartLine      int     `json:"start_line"`
	StartCol       int     `json:"start_col"`
	EndLine        int     `json:"end_line"`
	StructuralHash string  `json:"structural_hash"`
	Indegree       int     `json:"indegree"`
	Relevance      float64 `json:"relevance"`
	Pagerank       float64 `json:"pagerank"`
	ChurnScore     float64 `json:"churn_score"`
	RuntimeHits    int     `json:"runtime_hits"`
	AiSummary      string  `json:"ai_summary"`
}

type SearchSymbolsParams

type SearchSymbolsParams struct {
	Column1 sql.NullString `json:"column_1"`
	Column2 sql.NullString `json:"column_2"`
	Limit   int64          `json:"limit"`
	Offset  int64          `json:"offset"`
}

type ShardManager

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

ShardManager manages multiple SQLite databases (shards) for large codebases.

func NewShardManager

func NewShardManager(basePath string) *ShardManager

func (*ShardManager) Close

func (m *ShardManager) Close() error

func (*ShardManager) GetShard

func (m *ShardManager) GetShard(ctx context.Context, path string) (Store, error)

GetShard returns the store responsible for the given file path.

type SovereignDelta

type SovereignDelta struct {
	Path    string   `json:"path"`
	Hash    string   `json:"hash"`
	Symbols []Symbol `json:"symbols"`
	Calls   []Call   `json:"calls"`
	Flows   []Flow   `json:"flows"`
}

SovereignDelta represents the index data for a single file, stable for Git.

type Store

func NewStore

func NewStore(ctx context.Context, dbPath string) (Store, error)

type StructuralGraph

type StructuralGraph interface {
	GetAllCalls(ctx context.Context) iter.Seq2[Call, error]
	SaveCall(ctx context.Context, call Call) error
	SaveCallsBulk(ctx context.Context, calls []Call) error
	GetCallers(ctx context.Context, calleeName string, limit, offset int) ([]Call, error)
	GetCallees(ctx context.Context, callerName string) ([]Call, error)
	GetCallersRecursive(ctx context.Context, name, path string, maxDepth int) ([]Call, error)
	GetAffectedTestsRecursive(ctx context.Context, name, path string) ([]Symbol, error)
	ClearCalls(ctx context.Context, path string) error

	// Data Flow
	SaveFlow(ctx context.Context, flow Flow) error
	GetFlows(ctx context.Context, sink string) ([]Flow, error)
	ClearFlows(ctx context.Context, path string) error
}

type Symbol

type Symbol struct {
	ID             int                    `json:"id"`
	Name           string                 `json:"name"`
	Type           string                 `json:"type"`
	PackagePath    string                 `json:"package_path"`
	ReceiverType   string                 `json:"receiver_type"`
	Signature      string                 `json:"signature"`
	Doc            string                 `json:"doc"`
	Path           string                 `json:"path"`
	StartByte      int                    `json:"start_byte"`
	EndByte        int                    `json:"end_byte"`
	StartLine      int                    `json:"start_line"`
	StartCol       int                    `json:"start_col"`
	EndLine        int                    `json:"end_line"`
	StructuralHash string                 `json:"structural_hash"`
	Indegree       int                    `json:"indegree"`
	Relevance      float64                `json:"relevance"`
	Pagerank       float64                `json:"pagerank"`
	ChurnScore     float64                `json:"churn_score"`
	RuntimeHits    int                    `json:"runtime_hits"`
	AiSummary      string                 `json:"ai_summary"`
	Metrics        *types.SemanticMetrics `json:"metrics,omitempty"`
}

type SymbolRegistry

type SymbolRegistry interface {
	GetFileIndex(ctx context.Context, path string) (*FileIndex, error)
	SaveFileIndex(ctx context.Context, idx *FileIndex) error
	SaveFileIndexBatch(ctx context.Context, items []BatchItem) error
	GetDirectoryHash(ctx context.Context, path string) (string, int64, error)
	SaveDirectoryHash(ctx context.Context, path string, hash string, mtime int64) error
	ClearSymbols(ctx context.Context, path string) error
	SaveSymbol(ctx context.Context, sym *Symbol) error
	SaveSymbolsBulk(ctx context.Context, symbols []*Symbol) error
	SearchSymbols(ctx context.Context, query string, symType string, limit, offset int) ([]Symbol, error)
	GetSymbolsByNameInFile(ctx context.Context, name, path string) ([]Symbol, error)
	GetSymbolsByStructuralHash(ctx context.Context, hash string) ([]Symbol, error)
	SearchSymbolsWeighted(ctx context.Context, query string, symType string) iter.Seq2[Symbol, error]
	GetSymbolsByRange(ctx context.Context, path string, startLine, endLine int) ([]Symbol, error)
	GetSymbolsByPathPrefix(ctx context.Context, pathPrefix string) ([]Symbol, error)
	GetSymbolsByType(ctx context.Context, symType string) ([]Symbol, error)
	GetInterfaces(ctx context.Context) ([]Symbol, error)
	GetAllSymbols(ctx context.Context) iter.Seq2[Symbol, error]
	UpdateSymbolCentrality(ctx context.Context, name, path string, centrality int) error
	UpdateSymbolCentralitiesBulk(ctx context.Context, updates map[string]int) error
	RecomputeIndegrees(ctx context.Context) error
	UpdateSymbolChurn(ctx context.Context, path string, score float64) error
	UpdateSymbolPagerank(ctx context.Context, name, path string, score float64) error
	UpdateSymbolPageranksBulk(ctx context.Context, updates map[string]float64) error
	UpdateSymbolRuntimeHits(ctx context.Context, name, path string, hits int) error
	RecordSymbolUsage(ctx context.Context, env string, usages []UsageRecord) error
	GetStats(ctx context.Context) (int, int, error)
	GetAllFilePaths(ctx context.Context) ([]string, error)
	DeleteFileIndex(ctx context.Context, path string) error
	InsertSemanticVector(ctx context.Context, symbolID int64, embedding []float32) error
	SearchSemantic(ctx context.Context, queryEmbedding []float32, limit int) ([]Symbol, error)
	SearchHybrid(ctx context.Context, textQuery string, queryEmbedding []float32, limit int) ([]Symbol, error)
	SaveDependency(ctx context.Context, dep *types.Dependency) error
	GetDependencies(ctx context.Context) ([]types.Dependency, error)
	ClearDependencies(ctx context.Context) error
	GetUnusedSymbols(ctx context.Context, includeExported bool) ([]Symbol, error)
}

type SyncEngine

type SyncEngine interface {
	ExportDelta(ctx context.Context, syncDir string) error
	ImportDelta(ctx context.Context, syncDir string) error
}

type TransactionManager

type TransactionManager interface {
	WithTransaction(ctx context.Context, fn func(context.Context, Store) error) error
	Close() error
}

type UsageRecord

type UsageRecord struct {
	SymbolName string `json:"symbol_name"`
	SymbolPath string `json:"symbol_path"`
	HitCount   int    `json:"hit_count"`
	LastUsed   int64  `json:"last_used"`
}

type Violation

type Violation struct {
	ID        int    `json:"id"`
	RuleID    string `json:"rule_id"`
	FilePath  string `json:"file_path"`
	Message   string `json:"message"`
	Severity  string `json:"severity"`
	StartLine int    `json:"start_line"`
	StartCol  int    `json:"start_col"`
	Text      string `json:"text"`
}

Jump to

Keyboard shortcuts

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