Documentation
¶
Overview ¶
Package tools implements the MCP tools Kivgraph answers questions with, along with their arguments, cursors, error codes and response shapes.
Index ¶
- Constants
- func ErrorCode(err error) string
- func HashQuery(query any) (string, error)
- func IsRefusal(err error) bool
- func ProfileSetSnapshotID(profiles []ProfileSnapshot) uint64
- func RefusalCodes() []string
- func RegisterFindByIntent(server *sdkmcp.Server)
- func RegisterFindByIntentWithObserver(server *sdkmcp.Server, observer Observer)
- func RegisterFindByIntentWithObserverAndSnapshotStore(server *sdkmcp.Server, observer Observer, ...)
- func RegisterFindByIntentWithSnapshotStore(server *sdkmcp.Server, snapshotStore *hotsnapshot.SnapshotStore)
- func RegisterFindCrossRepoConsumers(server *sdkmcp.Server)
- func RegisterFindCrossRepoConsumersWithObserver(server *sdkmcp.Server, observer Observer)
- func RegisterFindCrossRepoConsumersWithObserverAndSnapshotStore(server *sdkmcp.Server, observer Observer, ...)
- func RegisterFindCrossRepoConsumersWithSnapshotStore(server *sdkmcp.Server, snapshotStore *hotsnapshot.SnapshotStore)
- func RegisterFindReferences(server *sdkmcp.Server)
- func RegisterFindReferencesWithObserver(server *sdkmcp.Server, observer Observer)
- func RegisterFindReferencesWithObserverAndSnapshotStore(server *sdkmcp.Server, observer Observer, ...)
- func RegisterFindReferencesWithSnapshotStore(server *sdkmcp.Server, snapshotStore *hotsnapshot.SnapshotStore)
- func RegisterFindSymbol(server *sdkmcp.Server)
- func RegisterFindSymbolWithObserver(server *sdkmcp.Server, observer Observer)
- func RegisterFindSymbolWithObserverAndSnapshotStore(server *sdkmcp.Server, observer Observer, ...)
- func RegisterFindSymbolWithSnapshotStore(server *sdkmcp.Server, snapshotStore *hotsnapshot.SnapshotStore)
- func RegisterGetBlastRadius(server *sdkmcp.Server)
- func RegisterGetBlastRadiusWithObserver(server *sdkmcp.Server, observer Observer)
- func RegisterGetBlastRadiusWithObserverAndSnapshotStore(server *sdkmcp.Server, observer Observer, ...)
- func RegisterGetBlastRadiusWithSnapshotStore(server *sdkmcp.Server, snapshotStore *hotsnapshot.SnapshotStore)
- func RegisterGetFileOutline(server *sdkmcp.Server)
- func RegisterGetFileOutlineWithObserverAndSnapshotStore(server *sdkmcp.Server, observer Observer, ...)
- func RegisterGetFileOutlineWithSnapshotStore(server *sdkmcp.Server, snapshotStore *hotsnapshot.SnapshotStore)
- func RegisterGetSource(server *sdkmcp.Server)
- func RegisterGetSourceWithObserverAndSnapshotStore(server *sdkmcp.Server, observer Observer, ...)
- func RegisterGetSourceWithSnapshotStore(server *sdkmcp.Server, snapshotStore *hotsnapshot.SnapshotStore)
- func RegisterGetSymbol(server *sdkmcp.Server)
- func RegisterGetSymbolWithObserver(server *sdkmcp.Server, observer Observer)
- func RegisterGetSymbolWithObserverAndSnapshotStore(server *sdkmcp.Server, observer Observer, ...)
- func RegisterGetSymbolWithSnapshotStore(server *sdkmcp.Server, snapshotStore *hotsnapshot.SnapshotStore)
- func RegisterGetUnresolvedReferences(server *sdkmcp.Server)
- func RegisterGetUnresolvedReferencesWithObserver(server *sdkmcp.Server, observer Observer)
- func RegisterGetUnresolvedReferencesWithObserverAndSnapshotStore(server *sdkmcp.Server, observer Observer, ...)
- func RegisterGetUnresolvedReferencesWithSnapshotStore(server *sdkmcp.Server, snapshotStore *hotsnapshot.SnapshotStore)
- func RegisterGraphStatus(server *sdkmcp.Server)
- func RegisterGraphStatusWithObserver(server *sdkmcp.Server, observer Observer)
- func RegisterGraphStatusWithObserverAndSnapshotStore(server *sdkmcp.Server, observer Observer, ...)
- func RegisterGraphStatusWithObserverAndSnapshotStoreAndMetrics(server *sdkmcp.Server, observer Observer, ...)
- func RegisterGraphStatusWithSnapshotStore(server *sdkmcp.Server, snapshotStore *hotsnapshot.SnapshotStore)
- func RegisterIndexProject(server *sdkmcp.Server, indexer indexing.ProjectIndexer, ...)
- func RegisterListRepositories(server *sdkmcp.Server)
- func RegisterListRepositoriesWithObserver(server *sdkmcp.Server, observer Observer)
- func RegisterListRepositoriesWithObserverAndSnapshotStore(server *sdkmcp.Server, observer Observer, ...)
- func RegisterListRepositoriesWithSnapshotStore(server *sdkmcp.Server, snapshotStore *hotsnapshot.SnapshotStore)
- func RegisterTraceDependencies(server *sdkmcp.Server)
- func RegisterTraceDependenciesWithObserver(server *sdkmcp.Server, observer Observer)
- func RegisterTraceDependenciesWithObserverAndSnapshotStore(server *sdkmcp.Server, observer Observer, ...)
- func RegisterTraceDependenciesWithSnapshotStore(server *sdkmcp.Server, snapshotStore *hotsnapshot.SnapshotStore)
- func RequireStableKeyProfile(profileCount int, stableKey string, requested []string) error
- type BlastRadius
- type BlastRadiusDepthGroup
- type BlastRadiusGroup
- type BlastRadiusPackageGroup
- type BlindSpot
- type CallObservation
- type CallObserver
- type CompactCrossRepoConsumer
- type CompactCrossRepoConsumers
- type CompactCrossRepoGroup
- type CompactCrossRepoSubject
- type Completeness
- type ComponentHealth
- type Coverage
- type CrossRepoConsumerSummary
- type CrossRepoConsumers
- type CrossRepoSubject
- type Cursor
- type DependencyTrace
- type Fallback
- type FileOutline
- type FindByIntentInput
- type FindCrossRepoConsumersInput
- type FindReferencesInput
- type FindSymbolInput
- type GetBlastRadiusInput
- type GetFileOutlineInput
- type GetSourceInput
- type GetSymbolInput
- type GetUnresolvedReferencesInput
- type GraphProfileStatus
- type GraphStatus
- type GraphStatusCount
- type GraphStatusDerived
- type GraphStatusInput
- type HostStatus
- type HostStatusProbe
- type IndexProjectEntry
- type IndexProjectInput
- type IntentMatches
- type IntentSymbol
- type IntentTerm
- type ListRepositoriesInput
- type Observer
- type OutlineFile
- type OutlineSymbol
- type ProfileNames
- type ProfileSnapshot
- type ReachedSymbol
- type ReferenceResult
- type ReferenceSubject
- type ReferenceSummary
- type RepositorySummary
- type Response
- type SourceBody
- type SourceRequest
- type SourceResult
- type SymbolDetails
- type SymbolResults
- type SymbolSummary
- type ToolError
- type TraceDependenciesInput
- type UnresolvedReferenceSummary
Constants ¶
const ( DefaultBlastRadiusDepth = 3 MaximumBlastRadiusDepth = hotsnapshot.MaxTraversalDepth DefaultBlastRadiusLimit = 50 MaximumBlastRadiusLimit = hotsnapshot.MaxExactResults DefaultBlastRadiusMaxNodes = 5_000 MaximumBlastRadiusMaxNodes = hotsnapshot.MaxTraversalNodes SortingVersionBlastRadiusV1 = "blast-radius-v1" )
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.
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" )
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" 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.
const ( DefaultOutlineLimit = 200 MaximumOutlineLimit = hotsnapshot.MaxExactResults )
const ( DefaultIntentLimit = 10 MaximumIntentLimit = 50 MaximumIntentKeywords = 16 MaximumIntentChars = 400 SortingVersionIntentV1 = "intent-v1" )
const ( CrossRepoConsumerExactSymbol = "exact_symbol" CrossRepoConsumerPackage = "package" CrossRepoConsumerCandidate = "candidate" CrossRepoConsumerUnresolved = "unresolved" DefaultCrossRepoConsumerLimit = 50 MaximumCrossRepoConsumerLimit = hotsnapshot.MaxExactResults SortingVersionCrossRepoConsumersV1 = "consumers-v1" )
const ( FindReferencesDirectionIncoming = "incoming" FindReferencesDirectionOutgoing = "outgoing" DefaultReferenceLimit = 50 MaximumReferenceLimit = hotsnapshot.MaxExactResults SortingVersionReferencesV1 = "references-v1" )
const ( FindSymbolModeExact = "exact" FindSymbolModeQualifiedExact = "qualified_exact" FindSymbolModePrefix = "prefix" FindSymbolModeSubstring = "substring" DefaultSymbolLimit = 50 MaximumSymbolLimit = hotsnapshot.MaxExactResults )
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 )
const ( DefaultRepositoryLimit = 50 MaximumRepositoryLimit = 500 )
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.
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" )
const ( DefaultDependencyDepth = 3 MaximumDependencyDepth = hotsnapshot.MaxTraversalDepth DefaultDependencyLimit = 50 MaximumDependencyLimit = hotsnapshot.MaxExactResults DefaultDependencyMaxNodes = 5_000 MaximumDependencyMaxNodes = hotsnapshot.MaxTraversalNodes SortingVersionDependenciesV1 = "dependencies-v1" )
const ( DefaultUnresolvedLimit = 50 MaximumUnresolvedLimit = hotsnapshot.MaxExactResults SortingVersionUnresolvedV1 = "unresolved-v1" )
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 `workspace` (`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.
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.
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 ¶
ErrorCode returns the stable public code carried by err, or an empty string when err is not a classified MCP tool error.
func HashQuery ¶
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 IsRefusal ¶ added in v0.9.2
IsRefusal reports whether err is one of those: an answer, not a failure.
func ProfileSetSnapshotID ¶ added in v0.9.4
func ProfileSetSnapshotID(profiles []ProfileSnapshot) uint64
ProfileSetSnapshotID compresses the profile/generation vector into the immutable identity the existing cursor already pins. A global offset over canonical profile order then needs no per-profile positions on the wire.
func RefusalCodes ¶ added in v0.9.2
func RefusalCodes() []string
RefusalCodes are the codes a tool returns when declining *is* the good answer, rather than the report of one that could not be produced.
There is one today and ADR 0077 designed it. An ambiguous name is answered by naming the candidates, which costs `129` tokens where the `find_symbol` it replaced cost `750`, and the caller narrows by copying one of them. It leaves through the error path because it returns no rows -- and that is what needed separating, because every counter that reads the error path was scoring the good answer as a failure. Measured over five days, `29` of `find_references`' `63` "failures" were this.
It is a list and not a constant so a second designed refusal has one place to join, and so the readers that classify -- `tool-stats`, and the bridge into `internal/metrics` -- read the vocabulary from the package that owns it instead of restating it.
func RegisterFindByIntent ¶ added in v0.8.0
RegisterFindByIntent adds the read-only retrieval tool without a graph source.
func RegisterFindByIntentWithObserver ¶ added in v0.8.0
RegisterFindByIntentWithObserver adds the tool and observes handler latency.
func RegisterFindByIntentWithObserverAndSnapshotStore ¶ added in v0.8.0
func RegisterFindByIntentWithObserverAndSnapshotStore( server *sdkmcp.Server, observer Observer, snapshotStore *hotsnapshot.SnapshotStore, callObservers ...CallObserver, )
RegisterFindByIntentWithObserverAndSnapshotStore registers the tool over an immutable snapshot and optionally observes latency.
func RegisterFindByIntentWithSnapshotStore ¶ added in v0.8.0
func RegisterFindByIntentWithSnapshotStore(server *sdkmcp.Server, snapshotStore *hotsnapshot.SnapshotStore)
RegisterFindByIntentWithSnapshotStore registers the tool over the immutable snapshot currently published by snapshotStore.
func RegisterFindCrossRepoConsumers ¶
RegisterFindCrossRepoConsumers adds the read-only consumer lookup without a graph source. Calls require a snapshot-backed registration to return data.
func RegisterFindCrossRepoConsumersWithObserver ¶
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 ¶
RegisterFindReferences adds the read-only reference lookup tool without a graph source. Calls require a snapshot-backed registration to return data.
func RegisterFindReferencesWithObserver ¶
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 ¶
RegisterFindSymbol adds the read-only symbol search tool without a graph source. Calls require a snapshot-backed registration to return data.
func RegisterFindSymbolWithObserver ¶
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 ¶
RegisterGetBlastRadius adds the read-only impact query without a graph source. Calls require a snapshot-backed registration to return data.
func RegisterGetBlastRadiusWithObserver ¶
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 ¶
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 ¶
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 ¶
RegisterGetSymbol adds the read-only symbol lookup tool without a graph source. Calls require a snapshot-backed registration to return data.
func RegisterGetSymbolWithObserver ¶
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 ¶
RegisterGetUnresolvedReferences adds the read-only unresolved lookup without a graph source. Calls require a snapshot-backed registration to return data.
func RegisterGetUnresolvedReferencesWithObserver ¶
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 ¶
RegisterGraphStatus adds the read-only graph status tool with no snapshot and no host probe.
func RegisterGraphStatusWithObserver ¶
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, callObservers ...CallObserver, )
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.
The observers are variadic because every other Register* in this package takes them that way, and because this tool acquired them late: it is the one call that costs minutes, so leaving it untimed made the log quietest exactly where a reader most needs it.
func RegisterListRepositories ¶
RegisterListRepositories adds the read-only repository listing tool.
func RegisterListRepositoriesWithObserver ¶
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 ¶
RegisterTraceDependencies adds the read-only dependency traversal without a graph source. Calls require a snapshot-backed registration to return data.
func RegisterTraceDependenciesWithObserver ¶
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 BlastRadiusGroup ¶
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 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"`
// Occurrences is how many recorded failures share an invisible scope. It
// is absent from a failed reference, which is one occurrence by
// definition.
Occurrences int `json:"occurrences,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 {
Profiles ProfileNames `json:"profile,omitempty"`
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, and
// they are one row per scope: the unit is the package, so a reader learns
// nothing from the same package repeated once per failure inside it.
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 ¶
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 {
Profiles ProfileNames `json:"profile,omitempty"`
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 ¶
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 ¶
Encode returns the URL-safe, unpadded opaque cursor token, 31 characters for a live snapshot id and a reachable offset.
func (Cursor) ValidateAgainst ¶
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"`
// WitnessTo and WitnessHops answer a `to` request and are absent from every
// other one, so a fan-out page costs exactly what it cost before. Hops is the
// length of the route in edges; a named target with no rows is the bounded
// absence, and the guidance says which bound produced it.
WitnessTo string `json:"witness_to,omitempty"`
WitnessHops int `json:"witness_hops,omitempty"`
// 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 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 FindByIntentInput ¶ added in v0.8.0
type FindByIntentInput struct {
Profile []string `json:"profile,omitempty" jsonschema:"Profiles to query; omit for the default, or use * alone for all."`
Intent string `json:"intent" jsonschema:"What the code you are looking for does, in plain language."`
Keywords []string `json:"keywords,omitempty" jsonschema:"Extra terms the code itself uses, when they differ from the words of the question."`
Repo string `json:"repo,omitempty" jsonschema:"Consider only candidates in this repository. It narrows the question, not just the page."`
PathPrefix string `json:"path_prefix,omitempty" jsonschema:"Consider only candidates under this repository-relative path prefix."`
Kind string `json:"kind,omitempty" jsonschema:"Consider only symbols of this kind, such as function, struct or interface."`
Limit int `json:"limit,omitempty" jsonschema:"Candidates in one page. Defaults to 10, maximum 50."`
Cursor string `json:"cursor,omitempty" jsonschema:"The next_cursor of the previous page. Every other argument must stay the same."`
ResponseFormat string `json:"response_format,omitempty" jsonschema:"concise (the default) omits the derived identifiers; detailed returns them."`
View string `` /* 155-byte string literal not displayed */
}
FindByIntentInput asks the one question the rest of this surface cannot: which symbols a description most likely names, when the caller does not know what anything is called.
Keywords extend the question rather than replacing it, and they are where a caller supplies the vocabulary the code uses when it differs from the vocabulary the question used. There is no thesaurus here and no embedding: the model asking already knows more synonyms than a table would hold.
repo, path_prefix and kind narrow which candidates are considered, so they change the answer rather than trimming it -- unlike the traversals of this surface, a retrieval has no reachability to preserve and a narrower corpus is simply a narrower question.
type FindCrossRepoConsumersInput ¶
type FindCrossRepoConsumersInput struct {
Profile []string `json:"profile,omitempty" jsonschema:"Profiles to query; omit for the default, or use * alone for all."`
StableKey string `` /* 130-byte string literal not displayed */
QualifiedName string `json:"qualified_name,omitempty" jsonschema:"The target symbol fully qualified name, as every row of this surface carries it."`
Repository string `json:"repository,omitempty" jsonschema:"The repository that declares the target symbol, the provider side of the question."`
Path string `json:"path,omitempty" jsonschema:"The repository-relative file that declares the target symbol."`
Repo string `json:"repo,omitempty" jsonschema:"Keep only consumers found in this repository."`
Language string `json:"language,omitempty" jsonschema:"Keep only consumers written in this language."`
Limit int `json:"limit,omitempty" jsonschema:"Consumers in one page. Defaults to 50."`
Cursor string `json:"cursor,omitempty" jsonschema:"The next_cursor of the previous page. Every other argument must stay the same."`
ResponseFormat string `json:"response_format,omitempty" jsonschema:"concise (the default) omits the derived identifiers; detailed returns them."`
View string `` /* 189-byte string literal not displayed */
}
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 {
Profile []string `json:"profile,omitempty" jsonschema:"Profiles to query; omit for the default, or use * alone for all."`
StableKey string `` /* 134-byte string literal not displayed */
QualifiedName string `json:"qualified_name,omitempty" jsonschema:"The subject fully qualified name, as every row of this surface carries it."`
Name string `` /* 149-byte string literal not displayed */
Repository string `json:"repository,omitempty" jsonschema:"The repository that declares the subject, to separate an ambiguous name."`
Path string `json:"path,omitempty" jsonschema:"The repository-relative file that declares the subject, to separate an ambiguous name."`
Direction string `json:"direction,omitempty" jsonschema:"incoming (the default) answers who uses the subject; outgoing answers what it uses."`
Repo string `json:"repo,omitempty" jsonschema:"Keep only rows from this repository. Naming the derived provider also opts it in."`
Language string `json:"language,omitempty" jsonschema:"Keep only rows written in this language."`
EdgeKinds []string `` /* 168-byte string literal not displayed */
Confidence string `` /* 127-byte string literal not displayed */
IncludeDerived bool `json:"include_derived,omitempty" jsonschema:"Include rows of the derived provider, which is withheld by default."`
ResponseFormat string `json:"response_format,omitempty" jsonschema:"concise (the default) omits the derived identifiers; detailed returns them."`
View string `` /* 168-byte string literal not displayed */
Limit int `json:"limit,omitempty" jsonschema:"Rows in one page. Defaults to 50."`
Cursor string `json:"cursor,omitempty" jsonschema:"The next_cursor of the previous page. Every other argument must stay the same."`
}
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 {
Profile []string `json:"profile,omitempty" jsonschema:"Profiles to query; omit for the default, or use * alone for all."`
Name string `json:"name" jsonschema:"The name to look for, matched the way mode says."`
Mode string `json:"mode,omitempty" jsonschema:"How name is matched: exact (the default), qualified_exact, prefix or substring."`
Kind string `json:"kind,omitempty" jsonschema:"Keep only symbols of this kind, such as function, struct or interface."`
Repo string `json:"repo,omitempty" jsonschema:"Keep only symbols from this repository. Naming the derived provider also opts it in."`
IncludeDerived bool `json:"include_derived,omitempty" jsonschema:"Include symbols of the derived provider, which is withheld by default."`
PathPrefix string `json:"path_prefix,omitempty" jsonschema:"Keep only symbols under this repository-relative path prefix."`
ResponseFormat string `json:"response_format,omitempty" jsonschema:"concise (the default) omits the derived identifiers; detailed returns them."`
View string `` /* 158-byte string literal not displayed */
Limit int `json:"limit,omitempty" jsonschema:"Declarations in one page. Defaults to 50."`
Cursor string `json:"cursor,omitempty" jsonschema:"The next_cursor of the previous page. Every other argument must stay the same."`
}
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 {
Profile []string `json:"profile,omitempty" jsonschema:"Profiles to query; omit for the default, or use * alone for all."`
StableKey string `` /* 128-byte string literal not displayed */
QualifiedName string `json:"qualified_name,omitempty" jsonschema:"The root symbol fully qualified name, as every row of this surface carries it."`
Repository string `json:"repository,omitempty" jsonschema:"The repository that declares the root symbol."`
Path string `json:"path,omitempty" jsonschema:"The repository-relative file that declares the root symbol."`
Depth int `json:"depth,omitempty" jsonschema:"Hops the walk may follow inward, away from the root. Defaults to 3."`
MaxNodes int `json:"max_nodes,omitempty" jsonschema:"Nodes the walk may visit before it stops and declares that it did. Defaults to 5000."`
EdgeKinds []string `` /* 143-byte string literal not displayed */
Confidence string `json:"confidence,omitempty" jsonschema:"Follow only edges resolved at this confidence, such as EXACT_TYPECHECKED."`
Kinds []string `` /* 158-byte string literal not displayed */
IncludeDerived bool `json:"include_derived,omitempty" jsonschema:"Include affected symbols of the derived provider, which is withheld by default."`
Limit int `json:"limit,omitempty" jsonschema:"Affected symbols in one page. Defaults to 50."`
Cursor string `json:"cursor,omitempty" jsonschema:"The next_cursor of the previous page. Every other argument must stay the same."`
ResponseFormat string `json:"response_format,omitempty" jsonschema:"concise (the default) omits the derived identifiers; detailed returns them."`
View string `` /* 155-byte string literal not displayed */
}
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 `workspace`, 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 {
Profile []string `json:"profile,omitempty" jsonschema:"Profiles to query; omit for the default, or use * alone for all."`
Repository string `json:"repository" jsonschema:"The repository that holds the path, as list_repositories names it."`
Path string `json:"path" jsonschema:"A repository-relative file, or a directory whose files are all wanted."`
Kind string `json:"kind,omitempty" jsonschema:"Keep only declarations of this kind, such as function, struct or interface."`
// 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 `` /* 157-byte string literal not displayed */
ResponseFormat string `json:"response_format,omitempty" jsonschema:"concise (the default) omits the derived identifiers; detailed returns them."`
Limit int `json:"limit,omitempty" jsonschema:"Declarations in one page. Defaults to 200."`
Cursor string `json:"cursor,omitempty" jsonschema:"The next_cursor of the previous page. Every other argument must stay the same."`
View string `` /* 150-byte string literal not displayed */
}
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 {
Profile []string `json:"profile,omitempty" jsonschema:"Profiles to query; omit for the default, or use * alone for all."`
Symbols []SourceRequest `json:"symbols" jsonschema:"The symbols whose code you want, up to 20 in one call, across any files and repositories."`
ContextLines int `json:"context_lines,omitempty" jsonschema:"Source lines to add around each declaration. Defaults to 0, maximum 100."`
ResponseFormat string `json:"response_format,omitempty" jsonschema:"concise (the default) omits the derived identifiers; detailed returns them."`
}
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 {
Profile []string `json:"profile,omitempty" jsonschema:"Profiles to query; omit for the default, or use * alone for all."`
StableKey string `` /* 129-byte string literal not displayed */
QualifiedName string `json:"qualified_name,omitempty" jsonschema:"The symbol fully qualified name, as every row of this surface carries it."`
Repository string `json:"repository,omitempty" jsonschema:"The repository that declares the symbol. Pass it with qualified_name and path."`
Path string `json:"path,omitempty" jsonschema:"The repository-relative file that declares the symbol."`
ResponseFormat string `json:"response_format,omitempty" jsonschema:"concise (the default) omits the derived identifiers; detailed returns them."`
}
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 GraphProfileStatus ¶ added in v0.9.4
type GraphProfileStatus struct {
Name string `json:"name"`
SnapshotID *uint64 `json:"snapshot_id"`
Repositories int `json:"repositories"`
Default bool `json:"default,omitempty"`
}
GraphProfileStatus is the discovery row graph_status owns once an installation contains more than one profile.
type GraphStatus ¶
type GraphStatus struct {
ContentFreshness *freshness.Status `json:"content_freshness,omitempty"`
Status string `json:"status"`
Profiles []GraphProfileStatus `json:"profiles,omitempty"`
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"`
// SchemaVersionExpected is the canonical schema this binary builds, and
// SchemaOutdated is the comparison against the one above, stated rather
// than left for the reader to make.
//
// A generation published by an older binary stays readable: the snapshot
// is a projection with its own row format, so nothing refuses to open it
// and every query answers. What it cannot do is carry facts its resolver
// never emitted -- after ADR 0060, the reach of a Go or Rust type built
// under schema 3 still excludes its methods. That answer looks complete
// and is not, which is the one thing this tool exists to catch.
//
// Reporting is deliberate and refusing is not the same decision: a graph
// one schema behind is stale, not corrupt, and cutting a session off from
// a usable answer needs its own measurement.
SchemaVersionExpected int `json:"schema_version_expected,omitempty"`
SchemaOutdated bool `json:"schema_outdated,omitempty"`
// SnapshotUnreadable is why the generation this server holds could not be
// mapped, when that is what happened.
//
// The snapshot is read by the first query that needs it rather than at
// startup (ADR 0067), so a refusal that used to kill the process now reaches
// a caller instead. `status` is honestly `empty` -- nothing is published --
// but «empty» alone would read as «never indexed», which is a different
// problem with a different fix.
SnapshotUnreadable string `json:"snapshot_unreadable,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 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 GraphStatusInput ¶ added in v0.9.4
type GraphStatusInput struct {
Profile []string `json:"profile,omitempty" jsonschema:"Profiles to report; omit or use * alone for all."`
}
GraphStatusInput optionally narrows profile discovery to named graphs.
type HostStatus ¶
type HostStatus struct {
ContentFreshness *freshness.Status
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" jsonschema:"Name to register the repository under. It is an identifier, compared exactly."`
Path string `json:"path" jsonschema:"Absolute directory of the repository. Nothing is written inside it."`
Languages []string `json:"languages" jsonschema:"Languages to index here, such as go, typescript, rust, python or dart."`
}
IndexProjectEntry is one repository of a batch.
type IndexProjectInput ¶
type IndexProjectInput struct {
Profile string `json:"profile,omitempty" jsonschema:"Profile to index; omit for the default. A missing name creates it."`
Projects []IndexProjectEntry `` /* 153-byte string literal not displayed */
Name string `json:"name,omitempty" jsonschema:"Name for a single project. Use it with path and languages, never together with projects."`
Path string `json:"path,omitempty" jsonschema:"Absolute directory of a single project. Nothing is written inside it."`
Languages []string `` /* 127-byte string literal not displayed */
Confirmed *bool `` /* 146-byte string literal not displayed */
}
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 IntentMatches ¶ added in v0.8.0
type IntentMatches struct {
Terms []IntentTerm `json:"terms,omitempty"`
Unmatched []string `json:"unmatched_terms,omitempty"`
Symbols []IntentSymbol `json:"symbols"`
View string `json:"-"`
}
IntentMatches is a page of ranked candidates and an account of the terms that produced them.
func (IntentMatches) MarshalJSON ¶ added in v0.8.0
func (matches IntentMatches) MarshalJSON() ([]byte, error)
MarshalJSON writes the page at the granularity the caller asked for.
type IntentSymbol ¶ added in v0.8.0
type IntentSymbol struct {
Profiles ProfileNames `json:"profile,omitempty"`
Name string `json:"name,omitempty"`
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"`
Terms int `json:"terms"`
Match string `json:"match"`
StableKey string `json:"stable_key,omitempty"`
// contains filtered or unexported fields
}
IntentSymbol is one candidate, addressable the way every row of this surface is: repository, repository-relative path, qualified name and line range, so the next call is built from the answer without a key ever appearing.
No score travels. It orders candidates inside one answer and means nothing on its own -- scaling every weight leaves the order identical -- so publishing it would invite a reader to treat it as a confidence this layer cannot claim.
Match is `lexical` on every row, and it is not decoration. Every other row this server returns is an edge an analyser resolved; these rows are text that looked alike, and they must not be read with the same authority or counted in the same coverage.
type IntentTerm ¶ added in v0.8.0
type IntentTerm struct {
Term string `json:"term"`
Symbols int `json:"symbols"`
Frequency string `json:"frequency"`
}
IntentTerm is one term of the question and how much of the graph it reached.
Frequency travels because it is the difference between a term that answered the question and a term that merely matched: a term carried by most of the corpus is why an unrelated file appears at all, and a caller that can see that can fix its question instead of doubting the tool. IntentTerm is one word of the question that the answer has to account for.
Only two kinds of term earn a row here, and a roster of every term does not: measured on this repository, the full list was a quarter of a `view=files` payload and most of its lines said `to 70`, `is 178`, `when 1` -- the question's grammar, counted. A term that matched four symbols and produced the answer needs no line, because the rows are the line. What a caller can act on is the term that matched nothing, which is in Unmatched, and the term that matched so much it separated nothing, which is here.
type ListRepositoriesInput ¶
type ListRepositoriesInput struct {
Profile []string `json:"profile,omitempty" jsonschema:"Profiles to list; omit or use * alone for all."`
Cursor string `json:"cursor,omitempty" jsonschema:"The next_cursor of the previous page. Every other argument must stay the same."`
Limit int `json:"limit,omitempty" jsonschema:"Repositories in one page. Defaults to 50, maximum 500."`
}
ListRepositoriesInput contains the optional page controls for list_repositories.
type OutlineFile ¶
type OutlineFile struct {
Profiles ProfileNames `json:"profile,omitempty"`
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 {
Profiles ProfileNames `json:"profile,omitempty"`
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 ProfileNames ¶ added in v0.9.4
type ProfileNames string
ProfileNames is a comparable in-memory list so existing result rows remain comparable in tests while the wire shape is the required JSON array.
func (ProfileNames) MarshalJSON ¶ added in v0.9.4
func (names ProfileNames) MarshalJSON() ([]byte, error)
MarshalJSON emits the public array shape.
func (ProfileNames) ProfileNames ¶ added in v0.9.4
func (names ProfileNames) ProfileNames() []string
ProfileNames returns the client-facing provenance list.
type ProfileSnapshot ¶ added in v0.9.4
type ProfileSnapshot struct {
Name string `json:"name"`
SnapshotID uint64 `json:"snapshot_id"`
Completeness *Completeness `json:"completeness,omitempty"`
}
ProfileSnapshot identifies one independently published graph in a union.
type ReachedSymbol ¶
type ReachedSymbol struct {
Profiles ProfileNames `json:"profile,omitempty"`
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"`
// EdgeKindsExcluded names the kinds a filter the caller never asked for
// left out. Present in every view, because a count that does not say it
// was filtered understates the references to a symbol.
EdgeKindsExcluded []string `json:"edge_kinds_default_excluded,omitempty"`
// DispatchThrough names the interface methods whose references this answer
// also holds, because the subject is their one implementation. Present only
// when a row came that way, and every such row repeats it in `via`.
DispatchThrough []string `json:"dispatch_through,omitempty"`
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 {
Profiles ProfileNames `json:"profile,omitempty"`
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"`
// Via is the interface method this reference reached the subject through,
// set only when the subject is the one implementation of it. Empty means
// the row is a direct reference to the subject itself.
Via string `json:"via,omitempty"`
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 {
Profile string `json:"profile,omitempty"`
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"` // Profile scopes a single-profile answer when the installation contains // several profiles. It is omitted for the compatibility shape. Profile string `json:"profile,omitempty"` // Profiles replaces snapshot_id when several profiles were queried. Profiles []ProfileSnapshot `json:"profiles,omitempty"` // CrossProfileEdges states that a union contains no edges resolved between // its independently indexed graphs. CrossProfileEdges string `json:"cross_profile_edges,omitempty"` 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
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 {
Profiles ProfileNames `json:"profile,omitempty"`
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"`
// 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" jsonschema:"The symbol durable key. The triple below works instead."`
QualifiedName string `json:"qualified_name,omitempty" jsonschema:"The symbol fully qualified name, as every row of this surface carries it."`
Repository string `json:"repository,omitempty" jsonschema:"The repository that declares the symbol."`
Path string `json:"path,omitempty" jsonschema:"The repository-relative file that declares the symbol."`
}
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 {
Profiles ProfileNames `json:"profile,omitempty"`
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"`
Variants []SymbolDetails `json:"-"`
}
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.
func (SymbolDetails) MarshalJSON ¶ added in v0.9.4
func (details SymbolDetails) MarshalJSON() ([]byte, error)
MarshalJSON preserves the historical object for one profile and emits the independently observed variants as rows for a multi-profile union.
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 {
Profiles ProfileNames `json:"profile,omitempty"`
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 ¶
NewToolError creates a classified tool error without an internal cause.
func WrapToolError ¶
WrapToolError classifies a failure and retains its cause for server-side diagnostics. The cause is deliberately omitted when the value is marshaled.
type TraceDependenciesInput ¶
type TraceDependenciesInput struct {
Profile []string `json:"profile,omitempty" jsonschema:"Profiles to query; omit for the default, or use * alone for all."`
StableKey string `` /* 128-byte string literal not displayed */
QualifiedName string `json:"qualified_name,omitempty" jsonschema:"The root symbol fully qualified name, as every row of this surface carries it."`
Repository string `json:"repository,omitempty" jsonschema:"The repository that declares the root symbol."`
Path string `json:"path,omitempty" jsonschema:"The repository-relative file that declares the root symbol."`
To string `` /* 145-byte string literal not displayed */
ToPath string `json:"to_path,omitempty" jsonschema:"The repository-relative file of the to symbol, to separate an ambiguous name."`
Depth int `json:"depth,omitempty" jsonschema:"Hops the walk may follow outward. Defaults to 3."`
MaxNodes int `json:"max_nodes,omitempty" jsonschema:"Nodes the walk may visit before it stops and declares that it did. Defaults to 5000."`
Repo string `` /* 142-byte string literal not displayed */
Language string `json:"language,omitempty" jsonschema:"Keep only reached symbols written in this language. Refused with to."`
EdgeKinds []string `` /* 143-byte string literal not displayed */
Confidence string `` /* 142-byte string literal not displayed */
IncludeDerived bool `` /* 141-byte string literal not displayed */
Limit int `json:"limit,omitempty" jsonschema:"Reached symbols in one page. Defaults to 50."`
Cursor string `json:"cursor,omitempty" jsonschema:"The next_cursor of the previous page. Every other argument must stay the same."`
ResponseFormat string `json:"response_format,omitempty" jsonschema:"concise (the default) omits the derived identifiers; detailed returns them."`
View string `` /* 186-byte string literal not displayed */
}
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.
To asks a different question of the same walk: not what this root reaches, but by which route it reaches one named symbol. The answer is then the route itself, one row per hop in order, and the fields that select rows after reachability -- repo, language, include_derived -- are refused instead of applied, because a route missing a link is not a route. "compact" is refused for the same reason: it groups rows by file, and the order is the answer.
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.
Source Files
¶
- blast_radius.go
- completeness.go
- cursor.go
- derived.go
- errors.go
- file_outline.go
- find_by_intent.go
- find_cross_repo_consumers.go
- find_references.go
- find_symbol.go
- get_source.go
- get_symbol.go
- guidance.go
- index_project.go
- meta.go
- observer.go
- profiles.go
- repositories.go
- response.go
- response_format.go
- root_symbol.go
- status.go
- text_result.go
- trace_dependencies.go
- trace_witness.go
- unresolved.go
- view.go