indexer

package
v0.0.0-...-3d6ecf2 Latest Latest
Warning

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

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

Documentation

Overview

Package indexer builds zoekt shards via a same-SHA zoekt-git-index child (Epic 3). The child is compiled from this module's go.mod (`go build github.com/sourcegraph/zoekt/cmd/zoekt-git-index`, pinned by the go.mod tool directive), so reader/writer shard skew is structurally impossible (PLAN §1.1). The child process is the OOM isolation boundary.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FindBinary

func FindBinary() (string, error)

FindBinary locates zoekt-git-index: env override, next to our executable, ./bin beside the executable (the `make build` layout), then PATH.

func ReconcileAnalysisUnits

func ReconcileAnalysisUnits(
	ctx context.Context,
	st store.Store,
	scopes map[string]analysisunit.Scope,
) (int, error)

ReconcileAnalysisUnits queues a rebuild when configuration and the last atomically committed index state disagree. It never clears the old state: the previous complete publication remains authoritative until the index job commits its replacement.

func VerifyBinaryPin

func VerifyBinaryPin(binary string) error

VerifyBinaryPin rejects a child whose embedded module identity differs from the zoekt reader linked into this process. This turns the same-module build convention into a runtime admission fence for overrides and PATH binaries.

Types

type Indexer

type Indexer struct {
	DataDir string // mirrors under DataDir/repos, shards under DataDir/index
	Bin     string // zoekt-git-index path (FindBinary)
	// FocusedBin is the same-module phebs-focused-index child. It is required
	// only for repositories with a configured analysis unit.
	FocusedBin string
	Store      store.Store
	// Verbose forwards the child indexer's line-oriented stdout/stderr and
	// parent phase transitions to Logger. Failure diagnostics retain only a
	// bounded tail regardless of this setting.
	Verbose bool
	// Logger receives verbose indexing output. Nil uses log.Default().
	Logger *log.Logger
	// Revisions is the validated per-repository selector -> full Git ref
	// allowlist. HEAD is always implicit and is never present in this map.
	Revisions map[string]map[string]string
	// AnalysisUnits is the validated repository-keyed semantic scope. Its
	// presence selects the focused child and manifest-bound publication.
	AnalysisUnits map[string]analysisunit.Scope
	// AdmitDerived runs after the exact no-op fence and before any staging
	// directory or child is created. T35.3 uses it for hard-watermark refusal.
	AdmitDerived func(context.Context, int64) error

	// OnIndexed, when set, runs once the indexed state is known current — the
	// index→candidate chain hook, mirroring how sync chains index. It also runs
	// on an unchanged-HEAD short circuit: if persisting the successor job failed
	// after a prior index commit, the retried index job can repair the missing
	// chain without rebuilding the shard.
	OnIndexed func(ctx context.Context, repoName, commit string) error
}

func (*Indexer) Handle

func (ix *Indexer) Handle(ctx context.Context, job store.Job) error

Handle adapts Index to the store.Runner: the job target is the repo name.

func (*Indexer) Index

func (ix *Indexer) Index(ctx context.Context, repo store.Repo, force bool) error

Index runs the child builder over the repo's bare mirror and records the exact revision set on success. Repositories without an allowlist retain the child's HEAD-only default.

Jump to

Keyboard shortcuts

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