index

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Sep 13, 2026 License: Apache-2.0 Imports: 25 Imported by: 0

Documentation

Overview

Package index orchestrates a full indexing pass: walk the workspace, parse supported files, resolve call references into edges, mine git history, and write everything into the store atomically.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RefreshFixes added in v0.5.0

func RefreshFixes(root, dbPath string, logf func(string, ...any)) (int, error)

RefreshFixes mines and persists only fix commits reachable from the repository's current HEAD. It performs no network access, which makes it the deterministic lesson-source mode for a pinned historical checkout.

func RefreshReviews

func RefreshReviews(root, dbPath string, logf func(string, ...any)) (res reviews.Result, fixCount int, err error)

RefreshReviews mines the lesson sources for the repo at root: PR review comments (network, via gh) and fix commits (local git) — each degrading independently, so a repo without GitHub still gains fix findings and an offline run still keeps its stored reviews. It is deliberately separate from Run: lesson sources change on the review/push cadence, not on every local edit. fixCount reports the fix findings stored this pass.

func ResolveRoot

func ResolveRoot(root string) (string, error)

ResolveRoot widens to the git toplevel when inside a repository.

func WorkspaceState

func WorkspaceState(root string) string

WorkspaceState fingerprints the workspace content the index depends on: HEAD, the status listing, the CONTENT of tracked changes (`git diff HEAD` — an already-dirty file edited again keeps its status line but not its patch), and a size+mtime proxy for untracked files (their status line never changes either). Two equal fingerprints mean the index is current. "" when git is unavailable — there is no cheap fingerprint without it.

Types

type Config

type Config struct {
	Index struct {
		// Generated indexes files carrying a "Code generated … DO NOT
		// EDIT." header. Default false: such files (protoc, stringer,
		// mockgen output) are boilerplate that inflates the graph and
		// pollutes most-called, and are not meant to be hand-navigated.
		Generated bool `yaml:"generated"`
		// Exclude is a list of gitignore-ish globs skipped on top of
		// .gitignore and the built-in skip dirs. Forms: a bare glob
		// (`*.pb.go`, `*_test.go`) matches any basename; a `**/`-prefixed
		// glob matches the basename in any directory; a trailing-slash
		// entry (`internal/gen/`) matches a directory prefix.
		Exclude []string `yaml:"exclude"`
	} `yaml:"index"`

	Reviews struct {
		// WindowDays bounds how old a mined review comment may be:
		// absent means the 730-day default, 0 means unlimited. The
		// newest 200 comments always survive the window, so a slow
		// repository keeps a working corpus with no tuning.
		WindowDays *int `yaml:"window_days"`
	} `yaml:"reviews"`
}

Config tunes what the indexer walks (`.seamark/config.yaml`). An absent file yields the defaults: generated files are skipped, nothing else is excluded. Kept separate from the gate/lessons overlays — this is about which files enter the graph at all.

func LoadConfig

func LoadConfig(root string) (*Config, error)

LoadConfig reads <root>/.seamark/config.yaml. A missing file is not an error (defaults apply); a malformed one is, so a typo'd exclude is not silently ignored.

func (*Config) ReviewWindowDays added in v0.2.0

func (c *Config) ReviewWindowDays() int

ReviewWindowDays maps the config field onto reviews.Options semantics: 0 = default, negative = unlimited.

type Options

type Options struct {
	// Root is the workspace directory. When inside a git repository it is
	// widened to the repository toplevel so paths are repo-relative.
	Root string
	// DBPath overrides the index location (default: <root>/.seamark/index.db).
	DBPath string
	// History tunes the git mining pass.
	History history.Options
	// Force rebuilds even when the workspace fingerprint says the index
	// is already current.
	Force bool
	// Logf receives progress and warnings; nil discards them.
	Logf func(format string, args ...any)
	// Progress receives phase events for interactive surfaces: a phase
	// name with units done/total (0 total = indeterminate, reported
	// again as 1/1 when the phase ends). Nil discards — piped and agent
	// surfaces stay on Logf's plain lines.
	Progress func(phase string, done, total int)
}

Options configures one indexing run.

type Summary

type Summary struct {
	Root   string
	DBPath string
	// Skipped is true when the workspace fingerprint matched the index
	// and nothing was rebuilt.
	Skipped     bool
	FilesSeen   int // files listed in the workspace
	FilesParsed int // files a language extractor handled
	// FilesReparsed counts files actually run through tree-sitter this
	// pass; the rest were served from the parse cache. Equals FilesParsed
	// on a --force or first index.
	FilesReparsed int
	// FilesSkipped counts supported files dropped by config — generated
	// (default) or an exclude glob.
	FilesSkipped int
	ParseErrors  int
	HistoryMined bool
	// HistorySkipNote says why the history layer is absent when
	// HistoryMined is false: "not a git repository" and "mining failed"
	// are different situations and must not be conflated in output.
	HistorySkipNote string
	Stats           store.Stats
	Duration        time.Duration
}

Summary reports what a run produced.

func Run

func Run(opts Options) (*Summary, error)

Run executes a full indexing pass.

Jump to

Keyboard shortcuts

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