indexer

package
v0.0.0-...-d0c2d87 Latest Latest
Warning

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

Go to latest
Published: Jul 12, 2026 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Overview

Package indexer is the indexing pipeline that walks repositories, parses sources, and produces fingerprints for the store.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildSubsystems

func BuildSubsystems(ctx context.Context, s *store.Store) (int, error)

BuildSubsystems aggregates per-directory statistics from the functions and fingerprints tables and populates the subsystems table.

func FinalizeVocabulary

func FinalizeVocabulary(ctx context.Context, s *store.Store) (int, error)

FinalizeVocabulary adds function-derived vocabulary from the functions table and updates usage counts for all entries. The vocabulary table must be cleared before the parse pipeline runs; this function only appends function entries and updates counts.

func FingerprintField

func FingerprintField(fp *types.Fingerprint, field string) (string, bool)

FingerprintField returns the string form of a categorical or boolean fingerprint field by name, and whether that field carries a comparable value. It is the read side that check_conventions matches against mined claims, reusing the same accessors the miner uses to produce them.

func MinePatterns

func MinePatterns(ctx context.Context, s *store.Store) (int, error)

MinePatterns analyzes indexed data and populates the patterns table with statistical claims about coding style in the repository.

func Parse

func Parse(ctx context.Context, in <-chan string, workers int) (<-chan types.FunctionRecord, <-chan types.VocabEntry)

Parse consumes file paths from in, parses each file, extracts named function definitions and vocabulary entries (types, constants, macros), and emits them to the returned channels. Both output channels close when in closes or ctx is cancelled. workers sets the parser pool size (each worker owns its tree-sitter parser); values below 1 are raised to 1.

func PropagateIO

func PropagateIO(ctx context.Context, s *store.Store) (int, error)

PropagateIO walks the call graph and updates does_io for functions that transitively call I/O functions. Returns the number of functions flipped.

func Walk

func Walk(ctx context.Context, repoRoot string) (<-chan string, error)

Walk traverses repoRoot and emits paths to source files in supported languages. The returned channel closes when the walk completes or the context is cancelled. Files that cannot be read or stat'd are skipped silently. Hard-coded ignores (dot-directories, node_modules, vendor, target, dist, build, __pycache__, venv, coverage) take precedence over .gitignore matching; .gitignore files at any depth in the repo add project-specific exclusions on top. The function returns an error only if the walk cannot begin (e.g., root does not exist or is not a directory). The channel is only valid when the returned error is nil.

func Write

func Write(ctx context.Context, s *store.Store, functions <-chan types.FunctionRecord, vocab <-chan types.VocabEntry) (int, error)

Write consumes function records and vocabulary entries from their respective channels and persists them to the store in batched transactions. Returns the total number of function records written and any error that aborted either write loop.

Types

type FunctionFingerprint

type FunctionFingerprint struct {
	Name        string
	StartLine   int
	Fingerprint types.Fingerprint
}

FunctionFingerprint pairs a parsed function's name and start line with its behavioral fingerprint, for on-demand convention checking of proposed code.

func FingerprintSource

func FingerprintSource(ctx context.Context, filePath string, source []byte) ([]FunctionFingerprint, error)

FingerprintSource parses source as the language implied by filePath and returns the fingerprint of every named function it contains. It mirrors the per-file extraction in parseFile but operates on in-memory content, so a proposed edit can be fingerprinted without writing it to disk. Returns nil when filePath's extension maps to no supported language.

Jump to

Keyboard shortcuts

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