indexer

package
v0.8.1 Latest Latest
Warning

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

Go to latest
Published: Aug 27, 2026 License: MIT Imports: 36 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AssembleGraphObservationBatches added in v0.5.13

func AssembleGraphObservationBatches(req GraphAssemblyRequest) (model.GraphBundle, error)

AssembleGraphObservationBatches validates and deterministically assembles sealed observations.

func BuildSearchText added in v0.2.0

func BuildSearchText(name, signature, docComment, parent, filePath, kind string) string

BuildSearchText constructs enriched search text from symbol metadata for intent-based search.

func EmbeddingIndexTimeout added in v0.5.9

func EmbeddingIndexTimeout(totalChunks int, batchSize int, requestTimeout time.Duration, configured time.Duration) time.Duration

EmbeddingIndexTimeout estimates a full index budget when the workspace has embeddings enabled. The embeddings phase renews the HTTP timeout per batch, so the outer CLI/job budget must scale with the number of expected batches instead of using a fixed short deadline.

func ExtractCatalog

func ExtractCatalog(root string, repo model.WorkspaceRepo, absolutePath string, content []byte) ([]model.SymbolRecord, model.FileRecord)

func ExtractDocComment added in v0.2.0

func ExtractDocComment(lines []string, symbolLineIndex int) string

ExtractDocComment looks backwards from a line index to find doc comments above a symbol.

func ExtractFileSymbols

func ExtractFileSymbols(workspaceRoot string, filePath string, repoID string, repoName string) ([]model.SymbolRecord, string, error)

ExtractFileSymbols reads a file and extracts symbols from it. Used by the file watcher for incremental indexing.

func IndexTimeout added in v0.5.0

func IndexTimeout() time.Duration

IndexTimeout returns the configured index timeout, used to bound a synchronous auto-index so it cannot hang indefinitely (AUD-01). Configurable via MI_LSP_INDEX_TIMEOUT; default 30 minutes.

func IsAuthorityConfigPath added in v0.8.0

func IsAuthorityConfigPath(path string) bool

IsAuthorityConfigPath reports whether a path can change canonical document discovery or another high-fanout authority input. The watcher uses the same predicate as incremental indexing so a config event cannot be mistaken for an ordinary document edit.

func ObserveGoGraph added in v0.5.13

func ObserveGraph added in v0.5.13

ObserveGraph runs local Go observation and the externally supplied Roslyn observer. Unsupported languages are recorded as gated omissions, never as semantic graph claims.

func PublishGraphObservationBatches added in v0.5.13

func PublishGraphObservationBatches(ctx context.Context, db *sql.DB, req GraphAssemblyRequest, expectedPrior *model.GraphDigest) (model.GraphGeneration, error)

PublishGraphObservationBatches assembles exactly once, then stages and activates the generation. An already-active identical generation is validated and activated through the same pointer CAS without re-staging.

func ResolveRepoFromProjectFile

func ResolveRepoFromProjectFile(workspaceRoot string, projectFile model.ProjectFile, filePath string) (string, string)

func SmartSyncTimeout added in v0.5.1

func SmartSyncTimeout() time.Duration

SmartSyncTimeout returns the short window during which workspace.add/init index synchronously before degrading to a background job (hybrid smart-sync, FD1). Configurable via MI_LSP_INDEX_SYNC_TIMEOUT; default 20s. Small/incremental repos finish well within it (preserving init-then-query); very large first indexes exceed it and continue in the background returning a job_id.

func StageGraphObservationBatches added in v0.5.13

func StageGraphObservationBatches(ctx context.Context, db *sql.DB, req GraphAssemblyRequest) (model.GraphGeneration, error)

StageGraphObservationBatches assembles once and persists one staged generation.

func StartBackgroundIndex added in v0.5.0

func StartBackgroundIndex(ctx context.Context, root string, clean bool, mode IndexMode) (string, error)

StartBackgroundIndex starts an async index job and returns its jobID immediately.

The job runs in a background goroutine with per-stage timeouts. The state is tracked in the package-level job registry and can be queried via IndexJobStatus. The mode parameter determines whether to do a full index or incremental (git-aware).

Lock acquisition is handled by the caller (workspace_ops) with timeout and degradation.

func WalkWorkspace

func WalkWorkspace(ctx context.Context, root string, matcher *workspace.IgnoreMatcher) ([]string, error)

Types

type GoGraphObservationRequest added in v0.5.13

type GoGraphObservationRequest struct {
	Root               string
	RepositoryIdentity string
	ProjectOrModule    string
	BuildTags          []string
	GOOS               string
	GOARCH             string
}

GoGraphObservationRequest describes one exact, repository-relative Go module selection.

type GraphAssemblyRequest added in v0.5.13

type GraphAssemblyRequest struct {
	Batches            []model.GraphObservationBatch
	Docs               []model.DocRecord
	DocEdges           []model.DocEdge
	DocMentions        []model.DocMention
	WorkspaceIdentity  string
	RepositoryIdentity string
	CreatedAt          time.Time
}

GraphAssemblyRequest is the deterministic input to graph assembly.

type GraphIndexOptions added in v0.5.13

type GraphIndexOptions struct {
	RoslynObserver GraphObserver
}

type GraphObservationRequest added in v0.5.13

type GraphObservationRequest struct {
	WorkspaceRoot      string
	WorkspaceIdentity  string
	RepositoryIdentity string
	RepoID             string
	RepoName           string
	RepoRoot           string
	EntrypointID       string
	EntrypointPath     string
	ProjectOrModule    string
	EntrypointKind     string
	Backend            string
}

GraphObservationRequest identifies one exact repository and topology entrypoint.

type GraphObserver added in v0.5.13

GraphObserver is the adapter boundary for external semantic compilers.

type IndexJobPublication added in v0.6.0

type IndexJobPublication struct {
	JobID string
	Fence store.IndexJobFence
}

type IndexJobState added in v0.5.0

type IndexJobState struct {
	JobID string `json:"job_id"`
	Phase string `json:"phase"`
	Done  bool   `json:"done"`
	Err   string `json:"err,omitempty"`
}

IndexJobState is the observable state of a background index job.

func IndexJobStatus added in v0.5.0

func IndexJobStatus(jobID string) (IndexJobState, bool)

IndexJobStatus returns the state of a background index job.

The returned bool indicates whether the job was found in the registry.

type IndexMode added in v0.5.0

type IndexMode int

IndexMode selects the indexing strategy for a background job.

const (
	// IndexModeFull rebuilds the whole index.
	IndexModeFull IndexMode = iota
	// IndexModeIncremental indexes only git-changed files when a prior index exists.
	IndexModeIncremental
)

type Progress added in v0.3.0

type Progress struct {
	Stage      string
	Path       string
	Files      int
	Symbols    int
	Docs       int
	FilesTotal int
	Force      bool
}

type ProgressFunc added in v0.3.0

type ProgressFunc func(context.Context, Progress) error

type ReconcileDocsResult added in v0.8.0

type ReconcileDocsResult struct {
	AuthorityConfigHash string
	Warnings            []string
	StoredStates        map[string]model.DocArtifactState
	New                 []string
	Changed             []string
	Unchanged           []string
	Deleted             []string
	ExcludedAlive       []string
	Concurrent          []string
}

ReconcileDocsResult holds the classification outcomes for all scanned docs.

func ReconcileDocs added in v0.8.0

func ReconcileDocs(ctx context.Context, root string) (*ReconcileDocsResult, error)

ReconcileDocs compares the canonical document profile against stored artifact states. A file missing from a scan is deletion only when disk absence is positively proven; an alive excluded file is retained and warned.

type Result

type Result struct {
	Files                []model.FileRecord
	Symbols              []model.SymbolRecord
	Docs                 int
	Stats                model.Stats
	Warnings             []string
	GraphGenerationID    string
	GraphBackendManifest string
	GraphOmissions       []model.GraphObservationOmission
	GraphNotApplicable   bool
}

func IncrementalIndex

func IncrementalIndex(ctx context.Context, workspaceRoot string) (Result, error)

func IncrementalIndexWithGraphProgress added in v0.5.13

func IncrementalIndexWithGraphProgress(ctx context.Context, workspaceRoot, generationID string, progress ProgressFunc, graphOptions GraphIndexOptions) (Result, error)

IncrementalIndexWithGraphProgress updates the catalog and, when needed, republishes a complete graph generation before returning success. Observation happens before catalog writes so observer failures preserve the prior graph; graph staging and activation retain their own transactional CAS guarantees.

func IncrementalIndexWithGraphProgressForJob added in v0.6.0

func IncrementalIndexWithGraphProgressForJob(ctx context.Context, workspaceRoot, generationID, jobID string, fence store.IndexJobFence, progress ProgressFunc, graphOptions GraphIndexOptions) (Result, error)

IncrementalIndexWithGraphProgressForJob keeps file-row mutation separate from the final owner-bound metadata/graph publication transaction. The final transaction validates owner, fence, status, and cancellation again.

func IncrementalIndexWithPaths added in v0.8.0

func IncrementalIndexWithPaths(ctx context.Context, workspaceRoot string, changedFiles, deletedFiles []string) (Result, error)

IncrementalIndexWithPaths applies an explicit watcher change set. Unlike IncrementalIndex, it does not consult Git status: fsnotify events are the authoritative input for this background pass, while query-time overlay and reconciliation remain responsible for events that were lost before delivery.

func IndexWorkspace

func IndexWorkspace(ctx context.Context, root string, clean bool) (Result, error)

func IndexWorkspaceCatalogOnly added in v0.3.0

func IndexWorkspaceCatalogOnly(ctx context.Context, root string, clean bool) (Result, error)

func IndexWorkspaceCatalogOnlyWithGeneration added in v0.3.0

func IndexWorkspaceCatalogOnlyWithGeneration(ctx context.Context, root string, clean bool, generationID string) (Result, error)

func IndexWorkspaceCatalogOnlyWithProgress added in v0.3.0

func IndexWorkspaceCatalogOnlyWithProgress(ctx context.Context, root string, clean bool, generationID string, progress ProgressFunc) (Result, error)

func IndexWorkspaceCatalogOnlyWithProgressForJob added in v0.6.0

func IndexWorkspaceCatalogOnlyWithProgressForJob(ctx context.Context, root string, clean bool, generationID, jobID string, fence store.IndexJobFence, progress ProgressFunc) (Result, error)

IndexWorkspaceCatalogOnlyWithProgressForJob is the owner-bound catalog path.

func IndexWorkspaceDocsOnly added in v0.3.0

func IndexWorkspaceDocsOnly(ctx context.Context, root string) (Result, error)

func IndexWorkspaceDocsOnlyWithGeneration added in v0.3.0

func IndexWorkspaceDocsOnlyWithGeneration(ctx context.Context, root string, generationID string) (Result, error)

func IndexWorkspaceDocsOnlyWithProgress added in v0.3.0

func IndexWorkspaceDocsOnlyWithProgress(ctx context.Context, root string, generationID string, progress ProgressFunc) (Result, error)

func IndexWorkspaceDocsOnlyWithProgressForJob added in v0.6.0

func IndexWorkspaceDocsOnlyWithProgressForJob(ctx context.Context, root string, generationID, jobID string, fence store.IndexJobFence, progress ProgressFunc) (Result, error)

IndexWorkspaceDocsOnlyWithProgressForJob is the owner-bound docs publisher.

func IndexWorkspaceWithGeneration added in v0.3.0

func IndexWorkspaceWithGeneration(ctx context.Context, root string, clean bool, generationID string) (Result, error)

func IndexWorkspaceWithGraphProgress added in v0.5.13

func IndexWorkspaceWithGraphProgress(ctx context.Context, root string, clean bool, generationID string, progress ProgressFunc, graphOptions GraphIndexOptions) (Result, error)

func IndexWorkspaceWithGraphProgressForJob added in v0.6.0

func IndexWorkspaceWithGraphProgressForJob(ctx context.Context, root string, clean bool, generationID, jobID string, fence store.IndexJobFence, progress ProgressFunc, graphOptions GraphIndexOptions) (Result, error)

IndexWorkspaceWithGraphProgressForJob is the explicit owner-bound full index path. Its final catalog/docs/generation/graph publication uses one fenced store transaction; it never falls through to the foreground publisher.

func IndexWorkspaceWithProgress added in v0.3.0

func IndexWorkspaceWithProgress(ctx context.Context, root string, clean bool, generationID string, progress ProgressFunc) (Result, error)

Jump to

Keyboard shortcuts

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