tools

package
v0.3.2 Latest Latest
Warning

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

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

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	DefaultBlastRadiusDepth     = 3
	MaximumBlastRadiusDepth     = hotsnapshot.MaxTraversalDepth
	DefaultBlastRadiusLimit     = 50
	MaximumBlastRadiusLimit     = hotsnapshot.MaxExactResults
	DefaultBlastRadiusMaxNodes  = 5_000
	MaximumBlastRadiusMaxNodes  = hotsnapshot.MaxTraversalNodes
	SortingVersionBlastRadiusV1 = "blast-radius-v1"
)
View Source
const (
	// VerdictComplete means nothing the index recorded could add to this
	// answer: the list is the whole list.
	VerdictComplete = "COMPLETE"
	// VerdictLowerBound means the answer is a minimum. The index recorded
	// places it could not read that this query reaches, and they are listed.
	VerdictLowerBound = "LOWER_BOUND"
)

Verdicts a caller can branch on without reading anything else.

View Source
const (
	// CursorFormatVersion changes whenever the encoded cursor body changes.
	// Existing cursors then fail closed as CURSOR_INVALID instead of being
	// interpreted under a different layout. Version 2 replaced the
	// base64-wrapped JSON object with the binary body below, which costs about
	// a tenth of the tokens on every truncated page.
	CursorFormatVersion uint8 = 2

	// SortingVersionStableKeyV1 identifies the current deterministic ordering
	// used for exact symbol result pages: ascending stable key.
	SortingVersionStableKeyV1 = "stable-key-v1"
)
View Source
const (
	CodeInvalidArgument       = "INVALID_ARGUMENT"
	CodeSymbolNotFound        = "SYMBOL_NOT_FOUND"
	CodeAmbiguousSymbol       = "AMBIGUOUS_SYMBOL"
	CodeRepositoryNotFound    = "REPOSITORY_NOT_FOUND"
	CodeCursorInvalid         = "CURSOR_INVALID"
	CodeCursorSnapshotExpired = "CURSOR_SNAPSHOT_EXPIRED"
	CodeTraversalLimitReached = "TRAVERSAL_LIMIT_REACHED"
	CodeSnapshotUnavailable   = "SNAPSHOT_UNAVAILABLE"
	CodeIndexNotReady         = "INDEX_NOT_READY"
	CodePermissionRequired    = "PERMISSION_REQUIRED"
	CodePermissionDenied      = "PERMISSION_DENIED"
	CodeIndexingFailed        = "INDEXING_FAILED"
)

Stable tool error codes are part of the public MCP contract. Clients must branch on Code, never on the human-readable message.

View Source
const (
	DefaultOutlineLimit = 200
	MaximumOutlineLimit = hotsnapshot.MaxExactResults
)
View Source
const (
	CrossRepoConsumerExactSymbol = "exact_symbol"
	CrossRepoConsumerPackage     = "package"
	CrossRepoConsumerCandidate   = "candidate"
	CrossRepoConsumerUnresolved  = "unresolved"

	DefaultCrossRepoConsumerLimit      = 50
	MaximumCrossRepoConsumerLimit      = hotsnapshot.MaxExactResults
	SortingVersionCrossRepoConsumersV1 = "consumers-v1"
)
View Source
const (
	FindReferencesDirectionIncoming = "incoming"
	FindReferencesDirectionOutgoing = "outgoing"
	DefaultReferenceLimit           = 50
	MaximumReferenceLimit           = hotsnapshot.MaxExactResults
	SortingVersionReferencesV1      = "references-v1"
)
View Source
const (
	FindSymbolModeExact          = "exact"
	FindSymbolModeQualifiedExact = "qualified_exact"
	FindSymbolModePrefix         = "prefix"
	FindSymbolModeSubstring      = "substring"

	DefaultSymbolLimit = 50
	MaximumSymbolLimit = hotsnapshot.MaxExactResults
)
View Source
const (

	// DefaultSourceContextLines is zero because the graph knows where a
	// declaration begins and ends. Context is for what surrounds it, which the
	// caller asks for when it wants it.
	DefaultSourceContextLines = 0
	// MaximumSourceContextLines bounds the surrounding lines a caller can ask
	// for. Above this a caller wants the file, and the host reads files.
	MaximumSourceContextLines = 100
	// MaximumSourceSymbols bounds how many bodies one call assembles.
	MaximumSourceSymbols = 20
	// MaximumSourceBytes is the ceiling on the bytes one response carries. It is
	// declared when it trims: a response that quietly stops halfway is worse
	// than one that says it stopped.
	MaximumSourceBytes = 262_144
)
View Source
const (
	DefaultRepositoryLimit = 50
	MaximumRepositoryLimit = 500
)
View Source
const (
	ResponseFormatConcise  = "concise"
	ResponseFormatDetailed = "detailed"
)

Response formats. A row carries what an agent can act on -- a name, a path, a line. The identifiers it can only hand back to another tool are opt-in: they are most of the bytes and none of the meaning.

View Source
const (
	// GraphStatusEmpty means no snapshot is published: every query tool
	// answers INDEX_NOT_READY until one is.
	GraphStatusEmpty = "empty"
	// GraphStatusReady means a snapshot is published and queryable.
	GraphStatusReady = "ready"

	// HealthNotConfigured is reported for a component this deployment
	// wired a probe for that answered nothing. It is a statement about the
	// server, not about the component: an unprobed worker is not the same
	// as a healthy one.
	HealthNotConfigured = "not_configured"
	// HealthNotApplicable is reported for a component this process does
	// not use. `serve` answers queries from the published HotSnapshot: it
	// never opens the database and never runs the TypeScript worker, so
	// reporting those two as unconfigured suggested a misconfiguration
	// where there is none. What is or is not being served is `status`,
	// `snapshot_id` and `snapshot_age_ms`.
	HealthNotApplicable = "not_applicable"
)
View Source
const (
	DefaultDependencyDepth       = 3
	MaximumDependencyDepth       = hotsnapshot.MaxTraversalDepth
	DefaultDependencyLimit       = 50
	MaximumDependencyLimit       = hotsnapshot.MaxExactResults
	DefaultDependencyMaxNodes    = 5_000
	MaximumDependencyMaxNodes    = hotsnapshot.MaxTraversalNodes
	SortingVersionDependenciesV1 = "dependencies-v1"
)
View Source
const (
	DefaultUnresolvedLimit     = 50
	MaximumUnresolvedLimit     = hotsnapshot.MaxExactResults
	SortingVersionUnresolvedV1 = "unresolved-v1"
)
View Source
const (
	// ViewCompact hoists whatever every row shares into the header and groups
	// rows by file. It is the default.
	ViewCompact = "compact"
	// ViewFull is the row-per-fact shape: every field on every row.
	ViewFull = "full"
	// ViewFiles answers only which files hold the facts, with a count each.
	ViewFiles = "files"
)

Views. A view is the granularity of an answer, not a different answer: the same edges, with the same confidence and the same provenance, spelled with or without the parts a row shares with every other row.

The measured cost of spelling them out on every row, over `kena` (`benchmarks/codebase-memory-comparison`): `confidence` plus `provenance` were `1.200` of the `4.236` tokens of one `find_references` page, and every one of the fifty rows carried the same pair. See ADR 0046.

View Source
const MaximumBlindSpots = 20

MaximumBlindSpots bounds what one response enumerates. The count is always exact even when the list is cut: a truncated warning must not read as a smaller problem than it is.

View Source
const MaximumTraversalResultChars = 120_000

MaximumTraversalResultChars is wide enough for a full page of either traversal tool and well inside the 500.000 ceiling a client will accept.

Variables

This section is empty.

Functions

func ErrorCode

func ErrorCode(err error) string

ErrorCode returns the stable public code carried by err, or an empty string when err is not a classified MCP tool error.

func HashQuery

func HashQuery(query any) (string, error)

HashQuery computes the lowercase SHA-256 hash of the canonical JSON form of a query identity. The identity must include the tool name and every argument that can affect result membership or ordering.

func RegisterFindCrossRepoConsumers

func RegisterFindCrossRepoConsumers(server *sdkmcp.Server)

RegisterFindCrossRepoConsumers adds the read-only consumer lookup without a graph source. Calls require a snapshot-backed registration to return data.

func RegisterFindCrossRepoConsumersWithObserver

func RegisterFindCrossRepoConsumersWithObserver(server *sdkmcp.Server, observer Observer)

RegisterFindCrossRepoConsumersWithObserver adds the tool and observes its handler latency when observer is non-nil.

func RegisterFindCrossRepoConsumersWithObserverAndSnapshotStore

func RegisterFindCrossRepoConsumersWithObserverAndSnapshotStore(
	server *sdkmcp.Server,
	observer Observer,
	snapshotStore *hotsnapshot.SnapshotStore,
	callObservers ...CallObserver,
)

RegisterFindCrossRepoConsumersWithObserverAndSnapshotStore registers the tool over an immutable snapshot and optionally observes latency.

func RegisterFindCrossRepoConsumersWithSnapshotStore

func RegisterFindCrossRepoConsumersWithSnapshotStore(server *sdkmcp.Server, snapshotStore *hotsnapshot.SnapshotStore)

RegisterFindCrossRepoConsumersWithSnapshotStore registers the tool over the immutable snapshot currently published by snapshotStore.

func RegisterFindReferences

func RegisterFindReferences(server *sdkmcp.Server)

RegisterFindReferences adds the read-only reference lookup tool without a graph source. Calls require a snapshot-backed registration to return data.

func RegisterFindReferencesWithObserver

func RegisterFindReferencesWithObserver(server *sdkmcp.Server, observer Observer)

RegisterFindReferencesWithObserver adds find_references and optionally observes handler latency.

func RegisterFindReferencesWithObserverAndSnapshotStore

func RegisterFindReferencesWithObserverAndSnapshotStore(
	server *sdkmcp.Server,
	observer Observer,
	snapshotStore *hotsnapshot.SnapshotStore,
	callObservers ...CallObserver,
)

RegisterFindReferencesWithObserverAndSnapshotStore registers find_references over a snapshot store and optionally observes latency.

func RegisterFindReferencesWithSnapshotStore

func RegisterFindReferencesWithSnapshotStore(server *sdkmcp.Server, snapshotStore *hotsnapshot.SnapshotStore)

RegisterFindReferencesWithSnapshotStore registers find_references over the immutable snapshot currently published by snapshotStore.

func RegisterFindSymbol

func RegisterFindSymbol(server *sdkmcp.Server)

RegisterFindSymbol adds the read-only symbol search tool without a graph source. Calls require a snapshot-backed registration to return data.

func RegisterFindSymbolWithObserver

func RegisterFindSymbolWithObserver(server *sdkmcp.Server, observer Observer)

RegisterFindSymbolWithObserver adds find_symbol and optionally observes handler latency.

func RegisterFindSymbolWithObserverAndSnapshotStore

func RegisterFindSymbolWithObserverAndSnapshotStore(
	server *sdkmcp.Server,
	observer Observer,
	snapshotStore *hotsnapshot.SnapshotStore,
	callObservers ...CallObserver,
)

RegisterFindSymbolWithObserverAndSnapshotStore registers find_symbol over a snapshot store and optionally observes latency.

func RegisterFindSymbolWithSnapshotStore

func RegisterFindSymbolWithSnapshotStore(server *sdkmcp.Server, snapshotStore *hotsnapshot.SnapshotStore)

RegisterFindSymbolWithSnapshotStore registers find_symbol over the immutable snapshot currently published by snapshotStore.

func RegisterGetBlastRadius

func RegisterGetBlastRadius(server *sdkmcp.Server)

RegisterGetBlastRadius adds the read-only impact query without a graph source. Calls require a snapshot-backed registration to return data.

func RegisterGetBlastRadiusWithObserver

func RegisterGetBlastRadiusWithObserver(server *sdkmcp.Server, observer Observer)

RegisterGetBlastRadiusWithObserver adds the tool and observes its handler latency when observer is non-nil.

func RegisterGetBlastRadiusWithObserverAndSnapshotStore

func RegisterGetBlastRadiusWithObserverAndSnapshotStore(
	server *sdkmcp.Server,
	observer Observer,
	snapshotStore *hotsnapshot.SnapshotStore,
	callObservers ...CallObserver,
)

RegisterGetBlastRadiusWithObserverAndSnapshotStore registers the tool over an immutable snapshot and optionally observes latency.

func RegisterGetBlastRadiusWithSnapshotStore

func RegisterGetBlastRadiusWithSnapshotStore(server *sdkmcp.Server, snapshotStore *hotsnapshot.SnapshotStore)

RegisterGetBlastRadiusWithSnapshotStore registers the tool over the immutable snapshot currently published by snapshotStore.

func RegisterGetFileOutline

func RegisterGetFileOutline(server *sdkmcp.Server)

RegisterGetFileOutline adds the read-only outline tool without a graph source. Calls require a snapshot-backed registration to return data.

func RegisterGetFileOutlineWithObserverAndSnapshotStore

func RegisterGetFileOutlineWithObserverAndSnapshotStore(
	server *sdkmcp.Server,
	observer Observer,
	snapshotStore *hotsnapshot.SnapshotStore,
	callObservers ...CallObserver,
)

RegisterGetFileOutlineWithObserverAndSnapshotStore registers get_file_outline over a snapshot store and optionally observes latency.

func RegisterGetFileOutlineWithSnapshotStore

func RegisterGetFileOutlineWithSnapshotStore(server *sdkmcp.Server, snapshotStore *hotsnapshot.SnapshotStore)

RegisterGetFileOutlineWithSnapshotStore registers get_file_outline over the immutable snapshot currently published by snapshotStore.

func RegisterGetSource

func RegisterGetSource(server *sdkmcp.Server)

RegisterGetSource adds the read-only source tool without a graph source.

func RegisterGetSourceWithObserverAndSnapshotStore

func RegisterGetSourceWithObserverAndSnapshotStore(
	server *sdkmcp.Server,
	observer Observer,
	snapshotStore *hotsnapshot.SnapshotStore,
	callObservers ...CallObserver,
)

RegisterGetSourceWithObserverAndSnapshotStore registers get_source over a snapshot store and optionally observes latency.

func RegisterGetSourceWithSnapshotStore

func RegisterGetSourceWithSnapshotStore(server *sdkmcp.Server, snapshotStore *hotsnapshot.SnapshotStore)

RegisterGetSourceWithSnapshotStore registers get_source over the immutable snapshot currently published by snapshotStore.

func RegisterGetSymbol

func RegisterGetSymbol(server *sdkmcp.Server)

RegisterGetSymbol adds the read-only symbol lookup tool without a graph source. Calls require a snapshot-backed registration to return data.

func RegisterGetSymbolWithObserver

func RegisterGetSymbolWithObserver(server *sdkmcp.Server, observer Observer)

RegisterGetSymbolWithObserver adds get_symbol and optionally observes handler latency.

func RegisterGetSymbolWithObserverAndSnapshotStore

func RegisterGetSymbolWithObserverAndSnapshotStore(
	server *sdkmcp.Server,
	observer Observer,
	snapshotStore *hotsnapshot.SnapshotStore,
	callObservers ...CallObserver,
)

RegisterGetSymbolWithObserverAndSnapshotStore registers get_symbol over a snapshot store and optionally observes latency.

func RegisterGetSymbolWithSnapshotStore

func RegisterGetSymbolWithSnapshotStore(server *sdkmcp.Server, snapshotStore *hotsnapshot.SnapshotStore)

RegisterGetSymbolWithSnapshotStore registers get_symbol over the immutable snapshot currently published by snapshotStore.

func RegisterGetUnresolvedReferences

func RegisterGetUnresolvedReferences(server *sdkmcp.Server)

RegisterGetUnresolvedReferences adds the read-only unresolved lookup without a graph source. Calls require a snapshot-backed registration to return data.

func RegisterGetUnresolvedReferencesWithObserver

func RegisterGetUnresolvedReferencesWithObserver(server *sdkmcp.Server, observer Observer)

RegisterGetUnresolvedReferencesWithObserver adds the tool and observes its handler latency when observer is non-nil.

func RegisterGetUnresolvedReferencesWithObserverAndSnapshotStore

func RegisterGetUnresolvedReferencesWithObserverAndSnapshotStore(
	server *sdkmcp.Server,
	observer Observer,
	snapshotStore *hotsnapshot.SnapshotStore,
	callObservers ...CallObserver,
)

RegisterGetUnresolvedReferencesWithObserverAndSnapshotStore registers the tool over an immutable snapshot and optionally observes latency.

func RegisterGetUnresolvedReferencesWithSnapshotStore

func RegisterGetUnresolvedReferencesWithSnapshotStore(server *sdkmcp.Server, snapshotStore *hotsnapshot.SnapshotStore)

RegisterGetUnresolvedReferencesWithSnapshotStore registers the tool over the immutable snapshot currently published by snapshotStore.

func RegisterGraphStatus

func RegisterGraphStatus(server *sdkmcp.Server)

RegisterGraphStatus adds the read-only graph status tool with no snapshot and no host probe.

func RegisterGraphStatusWithObserver

func RegisterGraphStatusWithObserver(server *sdkmcp.Server, observer Observer)

RegisterGraphStatusWithObserver adds graph_status and optionally observes handler latency.

func RegisterGraphStatusWithObserverAndSnapshotStore

func RegisterGraphStatusWithObserverAndSnapshotStore(
	server *sdkmcp.Server,
	observer Observer,
	snapshotStore *hotsnapshot.SnapshotStore,
	probe HostStatusProbe,
	callObservers ...CallObserver,
)

RegisterGraphStatusWithObserverAndSnapshotStore registers graph_status over a snapshot store, optionally observing latency and probing host state.

func RegisterGraphStatusWithObserverAndSnapshotStoreAndMetrics

func RegisterGraphStatusWithObserverAndSnapshotStoreAndMetrics(
	server *sdkmcp.Server,
	observer Observer,
	snapshotStore *hotsnapshot.SnapshotStore,
	probe HostStatusProbe,
	registry *metrics.Registry,
	callObservers ...CallObserver,
)

RegisterGraphStatusWithObserverAndSnapshotStoreAndMetrics registers graph_status with the process-local metrics report when registry is set.

func RegisterGraphStatusWithSnapshotStore

func RegisterGraphStatusWithSnapshotStore(server *sdkmcp.Server, snapshotStore *hotsnapshot.SnapshotStore)

RegisterGraphStatusWithSnapshotStore registers graph_status over the immutable snapshot currently published by snapshotStore.

func RegisterIndexProject

func RegisterIndexProject(server *sdkmcp.Server, indexer indexing.ProjectIndexer)

RegisterIndexProject adds the mutating project-indexing tool. The tool is absent when no configured indexer is supplied, so the empty/read-only MCP server cannot accidentally gain filesystem or storage access.

func RegisterListRepositories

func RegisterListRepositories(server *sdkmcp.Server)

RegisterListRepositories adds the read-only repository listing tool.

func RegisterListRepositoriesWithObserver

func RegisterListRepositoriesWithObserver(server *sdkmcp.Server, observer Observer)

RegisterListRepositoriesWithObserver adds list_repositories and optionally observes handler latency.

func RegisterListRepositoriesWithObserverAndSnapshotStore

func RegisterListRepositoriesWithObserverAndSnapshotStore(
	server *sdkmcp.Server,
	observer Observer,
	snapshotStore *hotsnapshot.SnapshotStore,
	callObservers ...CallObserver,
)

RegisterListRepositoriesWithObserverAndSnapshotStore registers list_repositories over a snapshot store and optionally observes latency.

func RegisterListRepositoriesWithSnapshotStore

func RegisterListRepositoriesWithSnapshotStore(server *sdkmcp.Server, snapshotStore *hotsnapshot.SnapshotStore)

RegisterListRepositoriesWithSnapshotStore registers list_repositories over the immutable snapshot currently published by snapshotStore.

func RegisterTraceDependencies

func RegisterTraceDependencies(server *sdkmcp.Server)

RegisterTraceDependencies adds the read-only dependency traversal without a graph source. Calls require a snapshot-backed registration to return data.

func RegisterTraceDependenciesWithObserver

func RegisterTraceDependenciesWithObserver(server *sdkmcp.Server, observer Observer)

RegisterTraceDependenciesWithObserver adds the tool and observes its handler latency when observer is non-nil.

func RegisterTraceDependenciesWithObserverAndSnapshotStore

func RegisterTraceDependenciesWithObserverAndSnapshotStore(
	server *sdkmcp.Server,
	observer Observer,
	snapshotStore *hotsnapshot.SnapshotStore,
	callObservers ...CallObserver,
)

RegisterTraceDependenciesWithObserverAndSnapshotStore registers the tool over an immutable snapshot and optionally observes latency.

func RegisterTraceDependenciesWithSnapshotStore

func RegisterTraceDependenciesWithSnapshotStore(server *sdkmcp.Server, snapshotStore *hotsnapshot.SnapshotStore)

RegisterTraceDependenciesWithSnapshotStore registers the tool over the immutable snapshot currently published by snapshotStore.

Types

type BlastRadius

type BlastRadius struct {
	RootKey            string                    `json:"root_key"`
	RootRepository     string                    `json:"root_repository"`
	Depth              int                       `json:"depth"`
	MaxNodes           int                       `json:"max_nodes"`
	Kinds              []string                  `json:"kinds,omitempty"`
	KindsExcluded      []string                  `json:"kinds_default_excluded,omitempty"`
	Affected           int                       `json:"affected"`
	DeepestDepth       int                       `json:"deepest_depth"`
	TraversalTruncated bool                      `json:"traversal_truncated"`
	Symbols            []ReachedSymbol           `json:"symbols"`
	ByRepository       []BlastRadiusGroup        `json:"by_repository"`
	ByDepth            []BlastRadiusDepthGroup   `json:"by_depth"`
	ByKind             []BlastRadiusGroup        `json:"by_kind"`
	ByPackage          []BlastRadiusPackageGroup `json:"by_package"`

	// View and the root location are marshaling inputs, never payload: the
	// compact header names the root as `repository:path:line` instead of the
	// stable key, and the view says which spelling to write.
	View     string `json:"-"`
	RootPath string `json:"-"`
	RootLine uint32 `json:"-"`
}

BlastRadius is the impact of changing one symbol: the affected symbols themselves plus the four axes a reviewer acts on. The root is excluded everywhere, because a symbol is not affected by its own change.

The envelope pages over Symbols. Every axis is computed over the whole traversal, not over the page, so aggregates stay stable while paging.

func (BlastRadius) MarshalJSON added in v0.3.0

func (radius BlastRadius) MarshalJSON() ([]byte, error)

MarshalJSON writes the impact at the granularity the caller asked for.

The compact answer leads with the filter and the four axes, because "how far does this reach" is the question and the page behind them only names what the axes counted. The root is `repository:path:line`, the triple every tool accepts as a selector, instead of the stable key the full view carries.

type BlastRadiusDepthGroup

type BlastRadiusDepthGroup struct {
	Depth int `json:"depth"`
	Count int `json:"count"`
}

type BlastRadiusGroup

type BlastRadiusGroup struct {
	Key   string `json:"key"`
	Count int    `json:"count"`
}

BlastRadiusGroup counts affected symbols under one repository key or one relation kind. A symbol reaching the traversed subgraph through several relation kinds is counted once per kind, so by_kind can exceed affected; by_repository and by_package always partition it.

type BlastRadiusPackageGroup

type BlastRadiusPackageGroup struct {
	PackageKey  string `json:"package_key"`
	PackageName string `json:"package_name"`
	Repository  string `json:"repository"`
	Count       int    `json:"count"`
}

type BlindSpot

type BlindSpot struct {
	Reason           string `json:"reason"`
	Repository       string `json:"repository"`
	FilePath         string `json:"file_path,omitempty"`
	StartLine        uint32 `json:"start_line,omitempty"`
	RequestedSymbol  string `json:"requested_symbol,omitempty"`
	RequestedPackage string `json:"requested_package,omitempty"`
	Detail           string `json:"detail,omitempty"`
}

BlindSpot is one place the index knows it could not resolve. It is evidence about a failed request and never an inferred relationship: the requested names are the strings the resolver used, not graph keys.

type CallObservation

type CallObservation struct {
	ToolName          string
	Elapsed           time.Duration
	Total             int
	Returned          int
	Truncated         bool
	UnresolvedRelated int
	SnapshotID        *uint64
	SnapshotAgeMS     *int64
	Err               error
}

CallObservation describes the common metadata available after a typed MCP tool handler returns. It deliberately excludes the response payload itself: result counts and truncation are enough for metrics and avoid retaining potentially large graph results.

type CallObserver

type CallObserver func(CallObservation)

CallObserver receives the metadata of one completed MCP tool handler.

type CompactCrossRepoConsumer added in v0.3.0

type CompactCrossRepoConsumer struct {
	Category string `json:"category,omitempty"`
	Repo     string `json:"repo"`
	// PackageName is the bare name while one package of the repository holds
	// the fact, and the list of names when several do.
	PackageName any    `json:"pkg,omitempty"`
	At          string `json:"at,omitempty"`
	EndLine     uint32 `json:"end_line,omitempty"`

	QualifiedName string `json:"qualified_name,omitempty"`
	Name          string `json:"name,omitempty"`
	Kind          string `json:"kind,omitempty"`
	EdgeKind      string `json:"edge_kind,omitempty"`
	Confidence    string `json:"confidence,omitempty"`
	Provenance    string `json:"provenance,omitempty"`
	EvidenceKind  string `json:"evidence_kind,omitempty"`

	RequestedPackage string `json:"requested_package,omitempty"`
	RequestedSymbol  string `json:"requested_symbol,omitempty"`
	Reason           string `json:"reason,omitempty"`
	Detail           string `json:"detail,omitempty"`
	Column           uint32 `json:"col,omitempty"`
	Offset           uint32 `json:"offset,omitempty"`

	ConsumerSymbolKey     string `json:"consumer_symbol_key,omitempty"`
	ConsumerRepositoryKey string `json:"consumer_repository_key,omitempty"`
	ConsumerPackageKey    string `json:"consumer_package_key,omitempty"`
	ConsumerFileKey       string `json:"consumer_file_key,omitempty"`
	EvidenceKey           string `json:"evidence_key,omitempty"`
	UnresolvedKey         string `json:"unresolved_key,omitempty"`
}

CompactCrossRepoConsumer is one consumer, or one repository's package-level dependency on the provider. `at` is `path:line` inside `repo` and is absent for a package dependency, which proves the repository depends on the provider and never that a file uses the symbol. A field the header or the row's own group already states is absent here, `reason` and `detail` included: a shared reason is common enough to hoist to a group, and a shared `detail` inside that group is a template, not per-row prose.

type CompactCrossRepoConsumers added in v0.3.0

type CompactCrossRepoConsumers struct {
	Subject          CompactCrossRepoSubject    `json:"subject"`
	Category         string                     `json:"category,omitempty"`
	EdgeKind         string                     `json:"edge_kind,omitempty"`
	Confidence       string                     `json:"confidence,omitempty"`
	Provenance       string                     `json:"provenance,omitempty"`
	EvidenceKind     string                     `json:"evidence_kind,omitempty"`
	Reason           string                     `json:"reason,omitempty"`
	RequestedPackage string                     `json:"requested_package,omitempty"`
	RequestedSymbol  string                     `json:"requested_symbol,omitempty"`
	Consumers        []CompactCrossRepoConsumer `json:"consumers,omitempty"`
	Groups           []CompactCrossRepoGroup    `json:"groups,omitempty"`
}

CompactCrossRepoConsumers is one page with the columns every consumer shares lifted into the header, and the rest grouped by whatever tuple they still share instead of repeating it per row; see compact. Consumers and Groups are mutually exclusive: Groups appears only when the page itself could not agree on category, edge_kind, confidence, provenance, evidence_kind or reason.

type CompactCrossRepoGroup added in v0.3.0

type CompactCrossRepoGroup struct {
	Category     string `json:"category,omitempty"`
	EdgeKind     string `json:"edge_kind,omitempty"`
	Confidence   string `json:"confidence,omitempty"`
	Provenance   string `json:"provenance,omitempty"`
	EvidenceKind string `json:"evidence_kind,omitempty"`
	Reason       string `json:"reason,omitempty"`
	Detail       string `json:"detail,omitempty"`

	Consumers []CompactCrossRepoConsumer `json:"consumers"`
}

CompactCrossRepoGroup is every consumer that shares one exact tuple of category, edge_kind, confidence, provenance, evidence_kind and reason the page could not hoist. Absent means this group's rows hold the page's hoisted value too.

Detail is not part of that tuple: it is prose, sometimes a template shared by every unresolved row of one reason and sometimes not, so it is worth a second hoist attempt once the bucket is fixed rather than a grouping key of its own -- the same way ReachedFrom works for get_blast_radius.

type CompactCrossRepoSubject added in v0.3.0

type CompactCrossRepoSubject struct {
	QualifiedName string `json:"qualified_name"`
	At            string `json:"at"`
	PackageName   string `json:"pkg"`
	ModulePath    string `json:"module_path,omitempty"`
	EndLine       uint32 `json:"end_line,omitempty"`

	StableKey     string `json:"stable_key,omitempty"`
	RepositoryKey string `json:"repository_key,omitempty"`
	PackageKey    string `json:"package_key,omitempty"`
}

CompactCrossRepoSubject is the queried symbol with its location written as the `repository:path:line` triple every tool accepts, and `end_line` only when the declaration spans more than the line already stated.

type Completeness

type Completeness struct {
	Verdict string `json:"verdict"`
	// BlindSpots are recorded references the resolver could not follow that
	// could belong to this answer.
	BlindSpots     []BlindSpot `json:"blind_spots,omitempty"`
	MoreBlindSpots int         `json:"more_blind_spots,omitempty"`
	// InvisibleScopes are whole packages or modules the index could not read.
	// They bound every answer about their repository, whatever was asked.
	InvisibleScopes     []BlindSpot `json:"invisible_scopes,omitempty"`
	MoreInvisibleScopes int         `json:"more_invisible_scopes,omitempty"`
	// Fallback closes the gap. A warning without the recovery action forces a
	// whole-repository sweep, which costs more than not warning at all.
	Fallback *Fallback `json:"fallback,omitempty"`
}

Completeness states how far an answer reaches.

Every other index in this space answers with a list and lets the reader assume it is the whole one. This one refuses to guess, so it knows where it failed -- with a file, a line and a reason -- and can say so. An answer that cannot be vouched for is a lower bound, and it says which places it could not read.

type ComponentHealth

type ComponentHealth struct {
	State  string `json:"state"`
	Detail string `json:"detail,omitempty"`
}

ComponentHealth is one probed dependency. State is HealthNotConfigured when the host wired no probe for it.

type Coverage

type Coverage struct {
	Exact             int `json:"exact"`
	Candidate         int `json:"candidate"`
	UnresolvedRelated int `json:"unresolved_related"`
	PackageLevel      int `json:"package_level"`
}

Coverage counts how confidently the response can account for related graph facts. Exact and candidate facts are disjoint; unresolved_related records related references that could not be classified.

PackageLevel is disjoint from all three: it counts facts about a package rather than about the symbol asked for. A package dependency proves the consumer depends on the provider package, never that it uses the queried symbol, so counting one as exact would report a use nobody observed.

type CrossRepoConsumerSummary

type CrossRepoConsumerSummary struct {
	Category string `json:"category"`

	// The consumer, named and located the way every other row of this surface
	// names one: enough to open it, and enough to address it in the next call.
	Name          string `json:"name,omitempty"`
	QualifiedName string `json:"qualified_name,omitempty"`
	Kind          string `json:"kind,omitempty"`
	EdgeKind      string `json:"edge_kind,omitempty"`
	Repository    string `json:"repository"`
	PackageName   string `json:"package_name,omitempty"`
	FilePath      string `json:"file_path,omitempty"`
	StartLine     uint32 `json:"start_line,omitempty"`
	EndLine       uint32 `json:"end_line,omitempty"`

	Confidence   string `json:"confidence"`
	Provenance   string `json:"provenance,omitempty"`
	EvidenceKind string `json:"evidence_kind,omitempty"`

	// Derived identifiers, returned only for the detailed format. Measured on a
	// four-row answer they were 81 % of it.
	ConsumerSymbolKey     string `json:"consumer_symbol_key,omitempty"`
	ConsumerRepositoryKey string `json:"consumer_repository_key,omitempty"`
	ConsumerPackageKey    string `json:"consumer_package_key,omitempty"`
	ConsumerFileKey       string `json:"consumer_file_key,omitempty"`
	EvidenceKey           string `json:"evidence_key,omitempty"`

	UnresolvedKey    string `json:"unresolved_key,omitempty"`
	RequestedPackage string `json:"requested_package,omitempty"`
	RequestedSymbol  string `json:"requested_symbol,omitempty"`
	Reason           string `json:"reason,omitempty"`
	Detail           string `json:"detail,omitempty"`
	StartColumn      uint32 `json:"start_column,omitempty"`
	StartOffset      uint32 `json:"start_offset,omitempty"`
}

CrossRepoConsumerSummary is the common wire shape for exact symbol, package-level, candidate, and unresolved consumer records. Empty fields are intentional when the source fact has no symbol or file identity.

type CrossRepoConsumers

type CrossRepoConsumers struct {
	Subject   CrossRepoSubject           `json:"subject"`
	Consumers []CrossRepoConsumerSummary `json:"consumers"`
	// View selects how the page is written. It is the argument that produced
	// the shape and never travels in it.
	View string `json:"-"`
}

CrossRepoConsumers is one page of consumers around a subject.

func (CrossRepoConsumers) MarshalJSON added in v0.3.0

func (page CrossRepoConsumers) MarshalJSON() ([]byte, error)

MarshalJSON writes the compact page unless the call asked for the full one. Both views report the same consumers with the same confidence and the same provenance: `coverage` keeps `exact` and `package_level` apart in either, so a package dependency is never read as a use of the symbol.

type CrossRepoSubject

type CrossRepoSubject struct {
	QualifiedName string `json:"qualified_name"`
	Repository    string `json:"repository"`
	PackageName   string `json:"package_name"`
	ModulePath    string `json:"module_path,omitempty"`
	FilePath      string `json:"file_path"`
	StartLine     uint32 `json:"start_line"`
	EndLine       uint32 `json:"end_line"`

	StableKey     string `json:"stable_key,omitempty"`
	RepositoryKey string `json:"repository_key,omitempty"`
	PackageKey    string `json:"package_key,omitempty"`
}

CrossRepoSubject is the symbol the query asked about, stated once. It is the argument, not a result, and it was repeated on every row as five target_* fields.

type Cursor

type Cursor struct {
	SnapshotID     uint64
	QueryHash      string
	Offset         int
	SortingVersion string
	Checksum       string
	// contains filtered or unexported fields
}

Cursor is the validated state needed to resume one immutable query page. The wire representation is deliberately opaque; callers should construct it with NewCursor and exchange the value returned by Encode.

QueryHash and SortingVersion are the identity a caller passes in. They are not on the wire, so a cursor returned by DecodeCursor leaves them empty and carries only the digests that ValidateAgainst compares.

func DecodeCursor

func DecodeCursor(token string) (Cursor, error)

DecodeCursor validates and decodes one opaque cursor token. Every malformed input answers CURSOR_INVALID and never panics: bad base64, an unsupported version, a truncated or overlong buffer, a broken varint, trailing bytes, a wrong checksum.

func NewCursor

func NewCursor(snapshotID uint64, queryHash string, offset int, sortingVersion string) (Cursor, error)

NewCursor validates the query and pagination identity and computes its checksum.

func (Cursor) Encode

func (cursor Cursor) Encode() (string, error)

Encode returns the URL-safe, unpadded opaque cursor token, 31 characters for a live snapshot id and a reachable offset.

func (Cursor) ValidateAgainst

func (cursor Cursor) ValidateAgainst(snapshotID uint64, queryHash, sortingVersion string) error

ValidateAgainst checks that a decoded cursor belongs to the active snapshot, query and sorting contract. A snapshot mismatch is distinct from a malformed or cross-query cursor so callers can report expiration and ask the client to restart pagination.

type DependencyTrace

type DependencyTrace struct {
	RootKey            string          `json:"root_key"`
	RootRepository     string          `json:"root_repository"`
	Depth              int             `json:"depth"`
	MaxNodes           int             `json:"max_nodes"`
	Reached            int             `json:"reached"`
	DeepestDepth       int             `json:"deepest_depth"`
	TraversalTruncated bool            `json:"traversal_truncated"`
	Nodes              []ReachedSymbol `json:"nodes"`

	// View decides how MarshalJSON spells the page. It never travels in it:
	// the caller already knows what it asked for.
	View string `json:"-"`
}

DependencyTrace is the traversal itself: the root, what the bounds did to it, and one page of reached symbols. The envelope's total, returned and next_cursor page over Nodes.

func (DependencyTrace) MarshalJSON added in v0.3.0

func (trace DependencyTrace) MarshalJSON() ([]byte, error)

MarshalJSON writes the traversal at the granularity the caller asked for. The compact page states the root, the bounds and what every reached symbol shares once, and then one entry per symbol grouped by file.

type Fallback

type Fallback struct {
	Pattern string   `json:"pattern"`
	Paths   []string `json:"paths,omitempty"`
}

Fallback is the bounded search that covers what the graph could not.

type FileOutline

type FileOutline struct {
	Repository string        `json:"repository"`
	Path       string        `json:"path"`
	Packages   []string      `json:"packages,omitempty"`
	Languages  []string      `json:"languages,omitempty"`
	Files      []OutlineFile `json:"files"`

	// View decides how MarshalJSON spells the outline. It never travels in
	// it: the caller already knows what it asked for.
	View string `json:"-"`
}

FileOutline is the skeleton of everything declared under a path: what is there, of what kind, with what signature and on which lines. It is what a reader needs before deciding which body to open.

Symbols are grouped by file rather than carrying a path each. On a directory outline the path was the second largest field on every row, and it is the one piece of a row that a whole group of rows shares.

func (FileOutline) MarshalJSON added in v0.3.0

func (outline FileOutline) MarshalJSON() ([]byte, error)

MarshalJSON writes the outline at the granularity the caller asked for.

The compact page states the repository, the package when the whole page shares one and the kind when every declaration shares one, and then one entry per declaration grouped by file. A signature is not there: it is the largest field of a row and the reader who wants it asks for `response_format: "detailed"`.

type FindCrossRepoConsumersInput

type FindCrossRepoConsumersInput struct {
	StableKey      string `json:"stable_key,omitempty"`
	QualifiedName  string `json:"qualified_name,omitempty"`
	Repository     string `json:"repository,omitempty"`
	Path           string `json:"path,omitempty"`
	Repo           string `json:"repo,omitempty"`
	Language       string `json:"language,omitempty"`
	Limit          int    `json:"limit,omitempty"`
	Cursor         string `json:"cursor,omitempty"`
	ResponseFormat string `json:"response_format,omitempty"`
	View           string `json:"view,omitempty"`
}

FindCrossRepoConsumersInput identifies one target symbol and asks for all known consumers in other repositories. Unresolved results are deliberately returned as a separate category: they describe a request and evidence, not an exact symbol identity.

`view` is the granularity of the answer, never a different answer: `compact` -the default- states once what every consumer shares and groups the package dependencies of a repository into one entry, and `full` repeats every field on every row. `files` is rejected: this answer is a set of repositories.

type FindReferencesInput

type FindReferencesInput struct {
	StableKey      string   `json:"stable_key,omitempty"`
	QualifiedName  string   `json:"qualified_name,omitempty"`
	Name           string   `json:"name,omitempty"`
	Repository     string   `json:"repository,omitempty"`
	Path           string   `json:"path,omitempty"`
	Direction      string   `json:"direction,omitempty"`
	Repo           string   `json:"repo,omitempty"`
	Language       string   `json:"language,omitempty"`
	EdgeKinds      []string `json:"edge_kinds,omitempty"`
	Confidence     string   `json:"confidence,omitempty"`
	IncludeDerived bool     `json:"include_derived,omitempty"`
	ResponseFormat string   `json:"response_format,omitempty"`
	View           string   `json:"view,omitempty"`
	Limit          int      `json:"limit,omitempty"`
	Cursor         string   `json:"cursor,omitempty"`
}

FindReferencesInput identifies one symbol and the direct relationship page to inspect around it.

Name is the unqualified name, and it exists so the common question costs one call: with a single declaration of that name the tool answers about it, and with several it returns the candidates as `repository:path:line` instead of answering about one nobody chose. Repository and Path narrow it.

View is the granularity of the answer: `compact` groups the rows by file and hoists whatever every row shares, `full` keeps the field-per-row shape, and `files` answers only which files hold references and how many each holds.

type FindSymbolInput

type FindSymbolInput struct {
	Name           string `json:"name"`
	Mode           string `json:"mode,omitempty"`
	Kind           string `json:"kind,omitempty"`
	Repo           string `json:"repo,omitempty"`
	IncludeDerived bool   `json:"include_derived,omitempty"`
	PathPrefix     string `json:"path_prefix,omitempty"`
	ResponseFormat string `json:"response_format,omitempty"`
	View           string `json:"view,omitempty"`
	Limit          int    `json:"limit,omitempty"`
	Cursor         string `json:"cursor,omitempty"`
}

FindSymbolInput contains the search mode, the filters and the page controls for find_symbol. An empty mode is the exact unqualified-name search.

Kind, Repo and PathPrefix narrow the page without changing its cost class: prefix and substring already walk every symbol name in the snapshot, so filtering while walking is free.

View is the granularity of the answer. The default, `compact`, hoists what every row shares into a header and leaves `stable_key` out; `full` is the field-per-row shape of SymbolSummary. `files` is rejected here: find_symbol answers declarations, not files.

type GetBlastRadiusInput

type GetBlastRadiusInput struct {
	StableKey      string   `json:"stable_key,omitempty"`
	QualifiedName  string   `json:"qualified_name,omitempty"`
	Repository     string   `json:"repository,omitempty"`
	Path           string   `json:"path,omitempty"`
	Depth          int      `json:"depth,omitempty"`
	MaxNodes       int      `json:"max_nodes,omitempty"`
	EdgeKinds      []string `json:"edge_kinds,omitempty"`
	Confidence     string   `json:"confidence,omitempty"`
	Kinds          []string `json:"kinds,omitempty"`
	IncludeDerived bool     `json:"include_derived,omitempty"`
	Limit          int      `json:"limit,omitempty"`
	Cursor         string   `json:"cursor,omitempty"`
	ResponseFormat string   `json:"response_format,omitempty"`
	View           string   `json:"view,omitempty"`
}

GetBlastRadiusInput bounds the impact traversal. edge_kinds and confidence gate which incoming edges may be followed, so they change what counts as affected.

Kinds selects which symbol kinds the answer reports. Left empty it excludes `variable` and `field`, the local bindings a traversal walks through on its way to real consumers: measured on `getRequiredField` of `kena`, 48 of the 50 rows of the first page were bindings like `handleBan.userId`, and the callers a reviewer came for fell to page two. `["*"]` reports every kind and an explicit list reports exactly those. The filter is part of the query, not a display option: total, affected and every aggregate count the same set it keeps, and it therefore also changes the cursor's query identity.

View is the granularity of the answer, never a different answer: `compact` (the default) spells the columns every row shares once in the header, `full` repeats them on every row.

type GetFileOutlineInput

type GetFileOutlineInput struct {
	Repository string `json:"repository"`
	Path       string `json:"path"`
	Kind       string `json:"kind,omitempty"`
	// IncludeMembers adds struct fields, properties and enum members. They
	// are off by default because they are not declarations a reader chooses
	// between: they are the shape of the type above them, and on a real file
	// they are half the payload.
	IncludeMembers bool   `json:"include_members,omitempty"`
	ResponseFormat string `json:"response_format,omitempty"`
	Limit          int    `json:"limit,omitempty"`
	Cursor         string `json:"cursor,omitempty"`
	View           string `json:"view,omitempty"`
}

GetFileOutlineInput asks for the declarations under one path.

Path is a repository-relative file, or a directory whose files are all wanted. It is the only entry point into the graph that starts from something an agent already holds: everything else needs a stable key, and the only way to get one is to guess a symbol name.

View is the granularity of the answer: "compact", the default, hoists what every declaration shares and leaves the signatures out; "full" is the row-per-declaration shape; "files" answers only which files hold the page's declarations and how many each holds.

type GetSourceInput

type GetSourceInput struct {
	Symbols        []SourceRequest `json:"symbols"`
	ContextLines   int             `json:"context_lines,omitempty"`
	ResponseFormat string          `json:"response_format,omitempty"`
}

GetSourceInput asks for the bodies of one or more symbols.

Every symbol is named the way the rest of this surface returns them: a stable key, or the repository, path and qualified name of a row the caller already read.

type GetSymbolInput

type GetSymbolInput struct {
	StableKey      string `json:"stable_key,omitempty"`
	QualifiedName  string `json:"qualified_name,omitempty"`
	Repository     string `json:"repository,omitempty"`
	Path           string `json:"path,omitempty"`
	ResponseFormat string `json:"response_format,omitempty"`
}

GetSymbolInput identifies one symbol, either by its durable stable key or by the repository, path and qualified name every row of this surface carries.

type GetUnresolvedReferencesInput

type GetUnresolvedReferencesInput struct {
	Repo             string `json:"repo,omitempty"`
	Package          string `json:"package,omitempty"`
	RequestedPackage string `json:"requested_package,omitempty"`
	RequestedSymbol  string `json:"requested_symbol,omitempty"`
	Reason           string `json:"reason,omitempty"`
	Language         string `json:"language,omitempty"`
	Limit            int    `json:"limit,omitempty"`
	Cursor           string `json:"cursor,omitempty"`
}

GetUnresolvedReferencesInput filters the references that could not be resolved to an exact symbol.

Package is deliberately split in two. Repo, Package, Language and the position describe where the failure was observed; RequestedPackage and RequestedSymbol describe what the resolver asked for and did not find. Collapsing both sides into one "package" filter would make the answer ambiguous the moment a repository consumes a package with its own name.

type GraphStatus

type GraphStatus struct {
	Status string `json:"status"`

	SnapshotID        *uint64 `json:"snapshot_id"`
	SnapshotBuiltAt   string  `json:"snapshot_built_at,omitempty"`
	SnapshotAgeMS     *int64  `json:"snapshot_age_ms"`
	SnapshotRowFormat uint32  `json:"snapshot_row_format_version,omitempty"`
	SchemaVersion     int     `json:"schema_version,omitempty"`
	ResolverVersion   string  `json:"resolver_version,omitempty"`

	Repositories int `json:"repositories"`
	Packages     int `json:"packages"`
	Files        int `json:"files"`
	Symbols      int `json:"symbols"`
	Evidence     int `json:"evidence"`
	Edges        int `json:"edges"`
	PackageEdges int `json:"package_edges"`
	Unresolved   int `json:"unresolved"`
	// Derived breaks out what the providers Kivgraph built from the machine
	// contribute, so the totals above can be read. The standard library of one
	// toolchain is around twenty thousand symbols: a count that folded it in
	// silently would answer «how big is my code» with a number about Rust.
	Derived *GraphStatusDerived `json:"derived,omitempty"`

	EdgesByKind        []GraphStatusCount `json:"edges_by_kind"`
	UnresolvedByReason []GraphStatusCount `json:"unresolved_by_reason"`

	// RepositoryFreshness carries, per repository, the commit the graph was
	// built from and the commit its working tree holds now. It answers, in
	// the one call an agent makes before trusting anything else, whether
	// what it is about to be told is stale.
	//
	// The array is not named "repositories": that key is the repository
	// count of the snapshot and belongs to the block of counts above.
	RepositoryFreshness []RepositorySummary `json:"repository_freshness"`
	// RepositoriesMoved counts the entries of RepositoryFreshness whose
	// working tree left the indexed commit. A repository whose HEAD could
	// not be read is not one of them and is not silently counted as fresh
	// either; its entry says why.
	RepositoriesMoved int `json:"repositories_moved"`

	LastRebuildAt string          `json:"last_rebuild_at,omitempty"`
	LastUpdateAt  string          `json:"last_update_at,omitempty"`
	Worker        ComponentHealth `json:"worker"`
	Storage       ComponentHealth `json:"storage"`

	// Metrics is present only when the hosting process wires a metrics
	// registry; an absent registry must not be reported as healthy or empty
	// metrics.
	Metrics *metrics.Report `json:"metrics,omitempty"`
}

GraphStatus reports what the server is currently serving from. Snapshot and host fields are never inferred; metrics are included only when the process supplies the optional registry.

type GraphStatusCount

type GraphStatusCount struct {
	Key   string `json:"key"`
	Count int    `json:"count"`
}

type GraphStatusDerived

type GraphStatusDerived struct {
	// Repositories names every derived provider in the snapshot.
	Repositories []string `json:"repositories"`
	Packages     int      `json:"packages"`
	Files        int      `json:"files"`
	Symbols      int      `json:"symbols"`
	// EdgesWithin counts the edges whose source is a symbol of a derived
	// provider: the standard library referring to itself.
	EdgesWithin int `json:"edges_within"`
	// EdgesInbound counts the edges that leave a registered repository and
	// land in a derived provider. This is the number the feature exists for.
	EdgesInbound int `json:"edges_inbound"`
	// Unresolved counts the gaps the derived provider declares about its own
	// code. The standard library declares thousands -- most of its arithmetic is
	// generated by macros -- and they are true and none of them the caller's, so
	// the total above only reads as «what my code is missing» with this beside it.
	Unresolved int `json:"unresolved"`
}

GraphStatusDerived is what the providers Kivgraph derived from the machine contribute to the totals of the graph.

Only the counts that can be attributed to a repository are here. An edge is attributed to the repository of its source symbol, which is the side that made the observation: the whole point of indexing the standard library is that code in a registered repository now reaches it, and counting those edges as the standard library's own would hide exactly that.

type HostStatus

type HostStatus struct {
	LastRebuildAt time.Time
	LastUpdateAt  time.Time
	Worker        ComponentHealth
	Storage       ComponentHealth
}

HostStatus is what only the process hosting the server can know: when the graph was last rebuilt or updated, and whether its dependencies answer.

type HostStatusProbe

type HostStatusProbe func(context.Context) (HostStatus, error)

HostStatusProbe supplies HostStatus. It runs on the graph_status fast path, so an implementation must answer from cached state, never by rebuilding or by opening a database.

type IndexProjectEntry

type IndexProjectEntry struct {
	Name      string   `json:"name"`
	Path      string   `json:"path"`
	Languages []string `json:"languages"`
}

IndexProjectEntry is one repository of a batch.

type IndexProjectInput

type IndexProjectInput struct {
	Projects  []IndexProjectEntry `json:"projects,omitempty"`
	Name      string              `json:"name,omitempty"`
	Path      string              `json:"path,omitempty"`
	Languages []string            `json:"languages,omitempty"`
	Confirmed *bool               `json:"confirmed,omitempty"`
}

IndexProjectInput is the explicit request accepted by index_project.

Projects is the form to prefer: every project in one call is registered together and the graph is rebuilt once. A rebuild resolves cross-repository edges over the complete fact set, so it costs the whole corpus however many projects were added -- calling the tool once per project pays that cost once per project and keeps only the last result.

The single-project fields remain for one repository and for clients that already send them.

The confirmed flag is used by clients that do not implement MCP elicitation; those clients must obtain user approval before sending true.

type ListRepositoriesInput

type ListRepositoriesInput struct {
	Cursor string `json:"cursor,omitempty"`
	Limit  int    `json:"limit,omitempty"`
}

ListRepositoriesInput contains the optional page controls for list_repositories.

type Observer

type Observer func(toolName string, elapsed time.Duration)

Observer receives the elapsed time spent in an MCP tool handler.

type OutlineFile

type OutlineFile struct {
	Path    string          `json:"path"`
	Symbols []OutlineSymbol `json:"symbols"`
}

OutlineFile is one file and the declarations this page carries for it.

type OutlineSymbol

type OutlineSymbol struct {
	Name      string `json:"name"`
	Kind      string `json:"kind"`
	Signature string `json:"signature"`
	Exported  bool   `json:"exported"`
	StartLine uint32 `json:"start_line"`
	EndLine   uint32 `json:"end_line"`

	QualifiedName     string `json:"qualified_name,omitempty"`
	StableKey         string `json:"stable_key,omitempty"`
	CanonicalIdentity string `json:"canonical_identity,omitempty"`
}

OutlineSymbol is one declaration.

QualifiedName is set only when it differs from Name, which for a top-level declaration in most languages it does not.

The stable key is not here. An outline of a 155-declaration file spent half its tokens on base32 keys, and every row already names the symbol well enough to address it: the repository, the file of its group and its qualified name are what `get_symbol` and `find_references` now accept. The key returns under `response_format: "detailed"`, together with the fully qualified signature.

type ReachedSymbol

type ReachedSymbol struct {
	Name          string `json:"name"`
	QualifiedName string `json:"qualified_name"`
	Kind          string `json:"kind"`
	Depth         int    `json:"depth"`
	Repository    string `json:"repository"`
	Language      string `json:"language"`
	FilePath      string `json:"file_path"`
	StartLine     uint32 `json:"start_line"`
	EndLine       uint32 `json:"end_line"`

	// ReachedFrom names the already-reached symbol this one was discovered
	// from, which is the edge's target when the traversal runs incoming. The
	// edge's own orientation is therefore not implied by this field. It is the
	// qualified name rather than the stable key because a key costs 35 tokens
	// on a row that costs 20, and the symbol it names is another row of the
	// same page.
	ReachedFrom   string `json:"reached_from"`
	ViaKind       string `json:"via_kind"`
	ViaConfidence string `json:"via_confidence"`
	ViaProvenance string `json:"via_provenance"`

	// The identifiers below are derived: the path beside them already spells out
	// the file, and the reached-from key is the stable key of a symbol this same
	// page names.
	StableKey      string `json:"stable_key,omitempty"`
	FileKey        string `json:"file_key,omitempty"`
	ReachedFromKey string `json:"reached_from_key,omitempty"`
}

ReachedSymbol is one symbol a bounded traversal reached, together with the edge it first arrived by. That edge is a fact of this traversal, not the only route: a breadth-first frontier records the shortest one it found. Both trace_dependencies and get_blast_radius return this shape.

StartLine and EndLine are the declaration's own range, so a row can be opened without a second call. A traversal answers with one row per reached symbol, and asking for each range separately turned a page into a page of round trips.

type ReferenceResult

type ReferenceResult struct {
	Subject    ReferenceSubject   `json:"subject"`
	Direction  string             `json:"direction"`
	References []ReferenceSummary `json:"references"`
	View       string             `json:"-"`
}

ReferenceResult is one page of relationships around a subject. View decides how it is written, never which facts it holds: see MarshalJSON below.

func (ReferenceResult) MarshalJSON added in v0.3.0

func (result ReferenceResult) MarshalJSON() ([]byte, error)

MarshalJSON writes the page under the view the caller asked for. The compact and files shapes carry the same edges as full: a column leaves a row only when the header states it for every row, and `confidence` and `provenance` are always readable in one of the two places.

type ReferenceSubject

type ReferenceSubject struct {
	StableKey     string `json:"stable_key"`
	Name          string `json:"name"`
	QualifiedName string `json:"qualified_name"`
	Kind          string `json:"kind"`
	Repository    string `json:"repository"`
	FilePath      string `json:"file_path"`
	StartLine     uint32 `json:"start_line"`
}

ReferenceSubject is the symbol the query asked about. It is stated once per response instead of on every row: it is the argument, not a result, and repeating it on each row was most of the payload.

type ReferenceSummary

type ReferenceSummary struct {
	Name          string `json:"name"`
	QualifiedName string `json:"qualified_name"`
	Kind          string `json:"kind"`
	Repository    string `json:"repository"`
	FilePath      string `json:"file_path"`
	StartLine     uint32 `json:"start_line"`
	EndLine       uint32 `json:"end_line"`
	Language      string `json:"language"`
	EdgeKind      string `json:"edge_kind"`
	Confidence    string `json:"confidence"`
	Provenance    string `json:"provenance"`

	EvidenceKind  string `json:"evidence_kind,omitempty"`
	StableKey     string `json:"stable_key,omitempty"`
	FileKey       string `json:"file_key,omitempty"`
	RepositoryKey string `json:"repository_key,omitempty"`
}

ReferenceSummary is the other end of one exact relationship: the symbol holding the reference for an incoming query, the one being reached for an outgoing one. It is named and located, because a caller identified only by an opaque key costs one more call per row before it means anything.

StartLine and EndLine bound the declaration of that symbol, not the position of the token. The snapshot records which symbol contains a reference and never where inside it: publishing a line nobody observed would be inventing evidence. The range is what makes the row openable without a second call -- without EndLine every row cost one `get_symbol` first, which measured 15 extra calls across the six questions of `benchmarks/mcp-token-cost`.

type RepositorySummary

type RepositorySummary struct {
	Name      string   `json:"name"`
	Path      string   `json:"path"`
	Languages []string `json:"languages"`

	IndexedCommit string `json:"indexed_commit,omitempty"`
	IndexedBranch string `json:"indexed_branch,omitempty"`
	IndexedDirty  bool   `json:"indexed_dirty,omitempty"`
	CurrentCommit string `json:"current_commit,omitempty"`
	CurrentBranch string `json:"current_branch,omitempty"`
	Moved         bool   `json:"moved"`
	MovedDetail   string `json:"moved_detail,omitempty"`
	// Derived marks a provider Kivgraph built from the machine rather than
	// from the registry: the standard library of the toolchain that indexed
	// this graph, whose release is in its name. Nothing checks it out and
	// nothing can move it.
	Derived bool `json:"derived,omitempty"`
}

RepositorySummary is the stable public shape for a registered repository.

The Indexed* fields describe the working tree the graph was built from and the Current* fields the tree on disk right now. Moved reports that the two disagree, which is the only warning a caller gets that a path or a line this server returns may no longer exist.

type Response

type Response[T any] struct {
	SnapshotID    *uint64  `json:"snapshot_id"`
	SnapshotAgeMS *int64   `json:"snapshot_age_ms"`
	Total         int      `json:"total"`
	Returned      int      `json:"returned"`
	Truncated     bool     `json:"truncated"`
	NextCursor    *string  `json:"next_cursor"`
	Coverage      Coverage `json:"coverage"`
	// Completeness is present when the tool checked how far its answer
	// reaches. Absent means it did not check, which is not the same as
	// checking and finding nothing.
	Completeness *Completeness `json:"completeness,omitempty"`
	// Guidance is what the count means and what to call next. It is present only
	// when the answer alone would mislead: zero rows read as "no such thing"
	// unless something says otherwise, and a truncated page does not say whether
	// the rows that mattered are in it.
	Guidance string `json:"guidance,omitempty"`
	Results  T      `json:"results"`
	// View is the granularity the caller asked for. It shapes the envelope and
	// never travels in it.
	View string `json:"-"`
}

Response is the common envelope returned by every query tool.

A nil snapshot identifier and age mean that no immutable snapshot has been published yet. Under `view: "full"` optional metadata is still encoded as JSON null, so a client can rely on every envelope field being present without confusing an empty graph with a missing response field. Under the compact views the fields that carried nothing are absent instead; see ADR 0046 and `MarshalJSON` in `view.go`.

func (Response[T]) MarshalJSON added in v0.3.0

func (response Response[T]) MarshalJSON() ([]byte, error)

MarshalJSON writes the full envelope unless the response was built for a compact view. View is not serialized: it is the argument that produced the shape, and a client that has to read it back has already paid for it.

type SourceBody

type SourceBody struct {
	Repository    string `json:"repository"`
	Path          string `json:"path"`
	QualifiedName string `json:"qualified_name"`
	Kind          string `json:"kind"`
	StartLine     uint32 `json:"start_line"`
	EndLine       uint32 `json:"end_line"`
	Fresh         bool   `json:"fresh"`
	Code          string `json:"code,omitempty"`

	// Shifted is the signed line offset between the range the generation
	// recorded and the range served. It is absent when nothing moved.
	Shifted int `json:"shifted,omitempty"`
	// Unavailable says why this row carries no code. One stale file does not
	// invalidate the other rows of the same answer.
	Unavailable string `json:"unavailable,omitempty"`

	StableKey string `json:"stable_key,omitempty"`
}

SourceBody is the code of one symbol, or the reason there is none.

Freshness travels with the bytes. When the file still hashes to what the generation recorded, Fresh is true and the range is the graph's. When it does not, the file is the authority -- it is what the agent will edit -- so the declaration is re-anchored by name, Shifted says by how many lines, and the caller can see that the graph's own numbers moved. See ADR 0040.

type SourceRequest

type SourceRequest struct {
	StableKey     string `json:"stable_key,omitempty"`
	QualifiedName string `json:"qualified_name,omitempty"`
	Repository    string `json:"repository,omitempty"`
	Path          string `json:"path,omitempty"`
}

SourceRequest names one symbol.

type SourceResult

type SourceResult struct {
	ContextLines int          `json:"context_lines"`
	Bodies       []SourceBody `json:"bodies"`
	// Trimmed is set when the byte ceiling stopped the response short, naming
	// how many bodies were dropped.
	Trimmed int `json:"trimmed,omitempty"`
}

SourceResult is the assembled answer.

type SymbolDetails

type SymbolDetails struct {
	StableKey      string `json:"stable_key"`
	Repository     string `json:"repository"`
	RepositoryPath string `json:"repository_path"`
	PackageName    string `json:"package_name"`
	ModulePath     string `json:"module_path"`
	FilePath       string `json:"file_path"`
	Name           string `json:"name"`
	QualifiedName  string `json:"qualified_name"`
	Kind           string `json:"kind"`
	Signature      string `json:"signature"`
	Exported       bool   `json:"exported"`
	StartLine      uint32 `json:"start_line"`
	EndLine        uint32 `json:"end_line"`

	CanonicalIdentity string `json:"canonical_identity,omitempty"`
	RepositoryKey     string `json:"repository_key,omitempty"`
}

SymbolDetails is the public detail shape returned for one symbol. The derived identifiers -- the canonical identity and the repository key, whose value is already spelled out by the name and the path beside it -- are returned only for the detailed format.

type SymbolResults added in v0.3.0

type SymbolResults struct {
	Symbols []SymbolSummary
	// View is the granularity the caller asked for and never travels in the
	// payload.
	View string `json:"-"`
	// Format is the response format asked for. Only the detailed one restores
	// the keys a compact row drops.
	Format string `json:"-"`
}

SymbolResults is one page of declarations together with the granularity to spell it with. The rows are always the full shape in memory: MarshalJSON is the single place that decides whether the payload repeats what every row shares.

func (SymbolResults) MarshalJSON added in v0.3.0

func (results SymbolResults) MarshalJSON() ([]byte, error)

MarshalJSON writes the rows as they are under the full view, and the compact page otherwise. An absent page is an empty page, never a null: `results` is documented as always present.

type SymbolSummary

type SymbolSummary struct {
	StableKey         string `json:"stable_key"`
	Name              string `json:"name"`
	QualifiedName     string `json:"qualified_name"`
	Kind              string `json:"kind"`
	Signature         string `json:"signature"`
	Exported          bool   `json:"exported"`
	Repository        string `json:"repository"`
	FilePath          string `json:"file_path"`
	StartLine         uint32 `json:"start_line"`
	EndLine           uint32 `json:"end_line"`
	CanonicalIdentity string `json:"canonical_identity,omitempty"`
}

SymbolSummary is the stable public result shape for symbol discovery. It carries where the symbol is, because a search result the agent cannot open costs a second call to become useful.

CanonicalIdentity is omitted unless the caller asks for the detailed format: it is the concatenation of language, repository, package, qualified name, kind and discriminator, every one of which is already a field here or is the signature itself.

type ToolError

type ToolError struct {
	Code    string `json:"code"`
	Message string `json:"message"`
	Details any    `json:"details,omitempty"`
	// contains filtered or unexported fields
}

ToolError is both an error for Go callers and the JSON-serializable error payload used by MCP tool failures.

func ErrIndexNotReady

func ErrIndexNotReady() *ToolError

ErrIndexNotReady reports that no graph is published yet.

It is the first answer a freshly installed client gets, so it names the two ways out instead of only the state. The code stays stable; only the message carries the guidance.

func NewToolError

func NewToolError(code, message string) *ToolError

NewToolError creates a classified tool error without an internal cause.

func WrapToolError

func WrapToolError(code, message string, cause error) *ToolError

WrapToolError classifies a failure and retains its cause for server-side diagnostics. The cause is deliberately omitted when the value is marshaled.

func (*ToolError) Error

func (err *ToolError) Error() string

func (*ToolError) Unwrap

func (err *ToolError) Unwrap() error

Unwrap preserves the underlying cause for errors.Is/errors.As while keeping internal details out of the wire representation.

type TraceDependenciesInput

type TraceDependenciesInput struct {
	StableKey      string   `json:"stable_key,omitempty"`
	QualifiedName  string   `json:"qualified_name,omitempty"`
	Repository     string   `json:"repository,omitempty"`
	Path           string   `json:"path,omitempty"`
	Depth          int      `json:"depth,omitempty"`
	MaxNodes       int      `json:"max_nodes,omitempty"`
	Repo           string   `json:"repo,omitempty"`
	Language       string   `json:"language,omitempty"`
	EdgeKinds      []string `json:"edge_kinds,omitempty"`
	Confidence     string   `json:"confidence,omitempty"`
	IncludeDerived bool     `json:"include_derived,omitempty"`
	Limit          int      `json:"limit,omitempty"`
	Cursor         string   `json:"cursor,omitempty"`
	ResponseFormat string   `json:"response_format,omitempty"`
	View           string   `json:"view,omitempty"`
}

TraceDependenciesInput bounds one dependency traversal. edge_kinds and confidence gate which edges the traversal may follow, so they change what is reachable; repo and language only select which reached symbols are returned.

View is the granularity of the answer, never a different answer: "compact", the default, hoists what every reached symbol shares into the header and groups the rest by file, and "full" keeps the row-per-fact shape. A traversal is not a set of files, so "files" is rejected rather than reinterpreted.

type UnresolvedReferenceSummary

type UnresolvedReferenceSummary struct {
	UnresolvedKey string `json:"unresolved_key"`

	RepositoryKey   string `json:"repository_key"`
	PackageKey      string `json:"package_key,omitempty"`
	PackageName     string `json:"package_name,omitempty"`
	FileKey         string `json:"file_key,omitempty"`
	FilePath        string `json:"file_path,omitempty"`
	SourceSymbolKey string `json:"source_symbol_key,omitempty"`
	Language        string `json:"language,omitempty"`

	RequestedPackage string `json:"requested_package"`
	RequestedSymbol  string `json:"requested_symbol,omitempty"`
	Reason           string `json:"reason"`
	Detail           string `json:"detail,omitempty"`

	StartLine   uint32 `json:"start_line,omitempty"`
	StartColumn uint32 `json:"start_column,omitempty"`
	StartOffset uint32 `json:"start_offset,omitempty"`
}

UnresolvedReferenceSummary is one recorded resolution failure. It is evidence about a request, never an inferred symbol identity: the requested package and symbol are the strings the resolver used, not graph keys.

Jump to

Keyboard shortcuts

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