grove

package
v0.19.1 Latest Latest
Warning

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

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

Documentation

Overview

Package grove is Prism's adapter to the in-process Grove engine.

Historically this package was an HTTP client that spoke to a long-running `grove serve` daemon. The embedded-Grove architecture removes the daemon: Prism links against `grove/pkg/grove` directly and opens the on-disk index in the same process. The public surface of Client (NewClient, EnsureRunning, Index, Query…) is preserved so the rest of Prism (ranking, MCP, CLI) is unchanged.

Package grove holds typed mirrors of Grove's result shapes used by the Prism client. They are plain structs sharing Grove's JSON wire tags so the rest of Prism (ranking, MCP, CLI) never touches engine types directly, and records can round-trip back into the engine (see toEngineSymbol).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CallSite

type CallSite struct {
	Callee string `json:"callee"`
	Line   int    `json:"line"`
}

CallSite mirrors grove/internal/core.CallSite.

type ChangeImpactResult added in v0.16.1

type ChangeImpactResult struct {
	Query        string         `json:"query"`
	Declarations []SymbolRecord `json:"declarations"`
	Supers       []SymbolRecord `json:"supers"`
	Family       []SymbolRecord `json:"family"`
	Callers      []SymbolRecord `json:"callers"`

	// ExternalSupers: supertype names declared in the hierarchy that resolve
	// to no indexed type (JDK / dependency types). Informational.
	ExternalSupers []string `json:"externalSupers,omitempty"`
	// OverridesExternal: "Type#method" when the queried method belongs to an
	// external supertype's contract — a signature change breaks a contract
	// the project does not own; the change-set is project-local only.
	OverridesExternal []string `json:"overridesExternal,omitempty"`
	// Completeness: "closed" or "project-local".
	Completeness string `json:"completeness,omitempty"`
}

ChangeImpactResult is the deterministic change-set for a method signature change: the declaration(s), the override/implementation family in the subtype closure, super-declarations up the hierarchy, and every method with a resolved call edge into the set.

type Client

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

Client wraps an embedded Grove engine. baseURL/groveBin are ignored in the embedded model and retained only so existing call sites keep compiling.

func NewClient

func NewClient(_, _ string) *Client

NewClient returns a Client. baseURL and groveBin are accepted for API compatibility but unused — Grove is now embedded in-process.

func (*Client) BaseURL

func (c *Client) BaseURL() string

BaseURL returns an embedded-mode marker so legacy log lines remain readable.

func (*Client) CallNeighbors added in v0.15.0

func (c *Client) CallNeighbors(ctx context.Context, query string) ([]SymbolRecord, error)

CallNeighbors returns a symbol's direct call neighbors — callees (out) and callers (in) — as wire symbols, excluding test doubles. Edge types other than `calls` (e.g. uses-type) are deliberately dropped: this is the precise call-chain neighborhood for prism_query's graph include, not the flat, type-erased Impact blast radius.

func (*Client) ChangeImpact added in v0.16.1

func (c *Client) ChangeImpact(ctx context.Context, query string) (*ChangeImpactResult, error)

ChangeImpact resolves a "Type.method" or "Type.method(ParamType, ...)" query to the exact change-set: declaration(s), override/implementation family in the subtype closure, super-declarations, and callers.

func (*Client) DeadCode added in v0.17.0

func (c *Client) DeadCode(ctx context.Context, extraRoots []string) (*DeadCodeResult, error)

DeadCode reports production functions/methods unreachable from every entry point.

func (*Client) Deps

func (c *Client) Deps(ctx context.Context, file string) ([]Edge, error)

Deps returns dependency edges for file.

func (*Client) DiffFile added in v0.7.0

func (c *Client) DiffFile(ctx context.Context, before []SymbolRecord, relPath string) (*FileGraphDiff, error)

DiffFile diffs the symbols delivered earlier (before) against the file's current indexed symbols using Grove's GraphDiff, so renames are paired and breaking changes classified instead of appearing as remove+add churn.

func (*Client) Edges added in v0.16.1

func (c *Client) Edges(ctx context.Context, name, direction string, kinds []string) ([]EdgeRecord, error)

Edges returns a seed symbol's direct typed graph neighbors. direction is "out", "in", or "both"; kinds filters by edge-kind name (empty = calls+tests). This is the primitive the agent drives: "what does X call" is (direction=out, kinds=[calls]); "who calls X" is (in, [calls]); "what tests X" is (in, [tests]).

func (*Client) EnsureRunning

func (c *Client) EnsureRunning(ctx context.Context) error

EnsureRunning opens the embedded Grove engine if it has not been opened yet. Replaces the old HTTP probe + auto-spawn of `grove serve`.

func (*Client) FileSymbols added in v0.7.0

func (c *Client) FileSymbols(ctx context.Context, relPath string) ([]SymbolRecord, error)

FileSymbols returns the symbols currently indexed for one repo-relative file path. Used by file reads and working-set drift checks.

func (*Client) Health

func (c *Client) Health(ctx context.Context) error

Health returns nil once the engine is open.

func (*Client) Impact

func (c *Client) Impact(ctx context.Context, query string, maxDepth int) ([]SymbolRecord, error)

Impact returns the blast radius for a symbol/file query.

func (*Client) Index

func (c *Client) Index(ctx context.Context, dir string) (*IndexResult, error)

Index indexes dir (defaults to the project root) and returns a result summary in the wire-format shape Prism's callers expect.

func (*Client) MissingImplementations added in v0.17.0

func (c *Client) MissingImplementations(ctx context.Context, query string) (*MissingImplementationsResult, error)

MissingImplementations resolves a "Type.method" query to every type in the subtype closure that fails to implement the member.

func (*Client) QueryByIntent

func (c *Client) QueryByIntent(ctx context.Context, intent string, limit int) ([]SymbolRecord, error)

QueryByIntent resolves an intent string into ranked symbols.

func (*Client) References added in v0.13.0

func (c *Client) References(ctx context.Context, name string) (groveeng.ReferenceResult, error)

References returns code occurrences of a symbol name — the reference layer ("where is X used"), near-complete for types/classes the call graph misses.

func (*Client) RenamePlan added in v0.18.0

func (c *Client) RenamePlan(ctx context.Context, query, newName string) (*RenamePlanResult, error)

RenamePlan converts the change-impact set for query into concrete line edits renaming the member to newName.

func (*Client) Resolve added in v0.16.1

func (c *Client) Resolve(ctx context.Context, name string) ([]ResolvedSymbol, error)

Resolve returns the symbols a name could anchor on — exact name or qualified (including Type.Method) matches — each tagged with kind, location, and whether it's a test double, so the agent can pick the right seed before asking Edges.

func (*Client) SearchSymbols

func (c *Client) SearchSymbols(ctx context.Context, query string, limit int) ([]SymbolRecord, error)

SearchSymbols returns symbols matching query (substring).

func (*Client) Semantic

func (c *Client) Semantic(ctx context.Context, query string, limit int) ([]SemanticResult, error)

Semantic returns TF-IDF-ranked symbols with cosine-similarity scores.

func (*Client) Shutdown

func (c *Client) Shutdown()

Shutdown closes the engine.

func (*Client) Status

func (c *Client) Status(ctx context.Context) (*StatusResult, error)

Status returns the persisted index summary.

func (*Client) Tests

func (c *Client) Tests(ctx context.Context, query string) ([]SymbolRecord, error)

Tests returns the tests covering query.

func (*Client) UntestedSurface added in v0.17.0

func (c *Client) UntestedSurface(ctx context.Context, query string) (*UntestedSurfaceResult, error)

UntestedSurface partitions a method's change-set by covering-test evidence.

func (*Client) WithTokenFromDir

func (c *Client) WithTokenFromDir(root string) *Client

WithTokenFromDir records the repository root so EnsureRunning can open the engine at <root>/.grove/grove.db. The name is kept for compatibility; no shared-secret token is read or sent (none exists in the embedded model).

type CoverageSite added in v0.17.0

type CoverageSite struct {
	Symbol    SymbolRecord   `json:"symbol"`
	TestCount int            `json:"testCount"`
	Tests     []SymbolRecord `json:"tests"` // capped; testCount carries the truth
}

CoverageSite pairs a change-set site with the tests that reach it within the engine's bounded caller-hop horizon.

type DeadCodeResult added in v0.17.0

type DeadCodeResult struct {
	RootCount            int            `json:"rootCount"`
	ReachableCount       int            `json:"reachableCount"`
	Considered           int            `json:"considered"`
	Dead                 []SymbolRecord `json:"dead"`
	ExportedUnreferenced []SymbolRecord `json:"exportedUnreferenced"`
	Caveats              []string       `json:"caveats"`
}

DeadCodeResult reports production functions/methods nothing reaches. Precision-first; Caveats are part of the answer, not documentation.

type Edge

type Edge struct {
	From       string  `json:"from"`
	To         string  `json:"to"`
	Type       string  `json:"type"`
	Confidence float64 `json:"confidence"`
}

Edge mirrors grove/internal/core.Edge.

type EdgeRecord added in v0.16.1

type EdgeRecord struct {
	Name       string  `json:"name"`     // neighbor's qualified name
	File       string  `json:"file"`     // neighbor's file path
	Line       int     `json:"line"`     // neighbor's start line
	Kind       string  `json:"kind"`     // symbol kind of the neighbor
	EdgeType   string  `json:"edgeType"` // calls, tests, uses-type, implements…
	Direction  string  `json:"direction"`
	Confidence float64 `json:"confidence"`
	TestDouble bool    `json:"testDouble,omitempty"`
}

EdgeRecord is one typed graph edge from a resolved seed to a neighbor symbol.

type FileGraphDiff added in v0.7.0

type FileGraphDiff struct {
	Added    []SymbolRecord `json:"added"`
	Removed  []SymbolRecord `json:"removed"`
	Changed  []SymbolChange `json:"changed"`
	Renamed  []SymbolChange `json:"renamed,omitempty"`
	Breaking []SymbolChange `json:"breakingChanges"`
}

FileGraphDiff mirrors grove's core.GraphDiff scoped to one file: the structural delta between a delivered symbol snapshot and the current index, with renames paired and breaking changes classified.

type ImpactNode

type ImpactNode = SymbolRecord

ImpactNode is one entry returned by Grove's /impact endpoint.

type IndexResult

type IndexResult struct {
	Root         string `json:"root"`
	FilesSeen    int    `json:"filesSeen"`
	FilesUpdated int    `json:"filesUpdated"`
	FilesSkipped int    `json:"filesSkipped"`
	FilesPruned  int    `json:"filesPruned"`
	SymbolCount  int    `json:"symbolCount"`
	EdgeCount    int    `json:"edgeCount"`
}

IndexResult mirrors Grove's /index response.

type MissingImplementationsResult added in v0.17.0

type MissingImplementationsResult struct {
	Query    string         `json:"query"`
	Contract []SymbolRecord `json:"contract"`

	// Missing: concrete closure types with no implementation, own or
	// inherited through the class-extends chain — compile errors once the
	// member is required.
	Missing []SymbolRecord `json:"missing"`
	// AbstractMissing: abstract classes without an implementation.
	// Informational — their concrete subtypes appear in Missing.
	AbstractMissing []SymbolRecord `json:"abstractMissing,omitempty"`
	// Unverifiable: no visible implementation, but the class-extends chain
	// leaves the index — an external base may provide the member.
	Unverifiable []SymbolRecord `json:"unverifiable,omitempty"`

	ImplementedCount int  `json:"implementedCount"`
	DefaultProvided  bool `json:"defaultProvided,omitempty"`

	ExternalSupers    []string `json:"externalSupers,omitempty"`
	OverridesExternal []string `json:"overridesExternal,omitempty"`
	Completeness      string   `json:"completeness,omitempty"`
}

MissingImplementationsResult answers "which types claiming this contract do not implement Type.method" — the interface-evolution companion to ChangeImpactResult: what must change vs. who is broken once the member is required.

type RenameEdit added in v0.18.0

type RenameEdit struct {
	FilePath string `json:"filePath"`
	Line     int    `json:"line"`
	Before   string `json:"before"`
	After    string `json:"after"`
	Site     string `json:"site"`
}

RenameEdit is one suggested line edit in a rename plan.

type RenamePlanResult added in v0.18.0

type RenamePlanResult struct {
	Query   string `json:"query"`
	NewName string `json:"newName"`

	Edits     []RenameEdit `json:"edits"`
	Ambiguous []RenameEdit `json:"ambiguous,omitempty"`

	SitesTotal        int      `json:"sitesTotal"`
	ExternalSupers    []string `json:"externalSupers,omitempty"`
	OverridesExternal []string `json:"overridesExternal,omitempty"`
	Completeness      string   `json:"completeness,omitempty"`
}

RenamePlanResult converts a change-impact set into concrete line edits.

type ResolvedSymbol added in v0.16.1

type ResolvedSymbol struct {
	Name       string `json:"name"` // qualified name
	Kind       string `json:"kind"`
	File       string `json:"file"`
	Line       int    `json:"line"`
	TestDouble bool   `json:"testDouble,omitempty"`
}

ResolvedSymbol is a candidate the agent can anchor a graph query on.

type SemanticResult

type SemanticResult struct {
	Score  float64      `json:"score"`
	Symbol SymbolRecord `json:"symbol"`
}

SemanticResult mirrors Grove's /semantic response entry.

type SpanInfo

type SpanInfo struct {
	Start int `json:"start"`
	End   int `json:"end"`
}

SpanInfo is the start/end line range.

type StatusResult

type StatusResult struct {
	FilesIndexed int `json:"filesIndexed"`
	SymbolCount  int `json:"symbolCount"`
	EdgeCount    int `json:"edgeCount"`
}

StatusResult mirrors Grove's /status response.

type SymbolChange added in v0.7.0

type SymbolChange struct {
	Before           *SymbolRecord `json:"before,omitempty"`
	After            *SymbolRecord `json:"after,omitempty"`
	SignatureChanged bool          `json:"signatureChanged"`
	BodyChanged      bool          `json:"bodyChanged"`
}

SymbolChange mirrors grove's core.SymbolChange: one symbol's before/after pair in a structural diff.

type SymbolRecord

type SymbolRecord struct {
	ID             string     `json:"id"`
	FilePath       string     `json:"filePath"`
	BlobSha        string     `json:"blobSha"`
	Language       string     `json:"language"`
	Kind           string     `json:"kind"`
	Name           string     `json:"name"`
	QualifiedName  string     `json:"qualifiedName"`
	Signature      string     `json:"signature"`
	Docstring      string     `json:"docstring,omitempty"`
	Span           SpanInfo   `json:"span"`
	ParentSymbol   string     `json:"parentSymbol,omitempty"`
	Imports        []string   `json:"imports,omitempty"`
	Exports        bool       `json:"exports"`
	RawText        string     `json:"rawText,omitempty"`
	Modifiers      []string   `json:"modifiers,omitempty"`
	TypeParameters []string   `json:"typeParameters,omitempty"`
	Annotations    []string   `json:"annotations,omitempty"`
	CallSites      []CallSite `json:"callSites,omitempty"`
}

SymbolRecord mirrors grove/internal/core.SymbolRecord.

type UntestedSurfaceResult added in v0.17.0

type UntestedSurfaceResult struct {
	Query      string         `json:"query"`
	Untested   []SymbolRecord `json:"untested"`
	Covered    []CoverageSite `json:"covered"`
	TotalSites int            `json:"totalSites"`

	ExternalSupers    []string `json:"externalSupers,omitempty"`
	OverridesExternal []string `json:"overridesExternal,omitempty"`
	Completeness      string   `json:"completeness,omitempty"`
}

UntestedSurfaceResult partitions a method's change-set by covering-test evidence: "before I change Type.method, what in its blast radius has no test pinning it?"

Jump to

Keyboard shortcuts

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