Documentation
¶
Overview ¶
Package search assembles the one pipeline every search surface shares: fetch full-text and recorded-reason candidates in parallel, filter them by path, rerank the full-text pool structurally, absorb the intent hits as evidence, and cut the answer down to the hits that can justify themselves. MCP and the CLI both call this service, so the two cannot drift into answering the same query differently.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Params ¶
type Params struct {
Query string
// Limit bounds how many files the answer shows, not how many candidates
// are fetched: the service over-fetches so reranking can promote matches
// the backend ranked below it.
Limit int
Offset int
PathPrefix string
IncludeWeak bool
}
Params is one search request as every surface phrases it. @intent give MCP and the CLI the same request shape so their answers stay comparable.
type Searcher ¶
type Searcher interface {
Query(ctx context.Context, query string, limit int) ([]graph.Node, error)
QueryIntent(ctx context.Context, query string, limit int) (intentapp.Result, error)
}
Searcher answers one query from both indexes a search runs over: the full-text index of names and content, and the recorded-reason index of @intent/@domainRule text. One port because the two answers are two halves of the same question — a caller wired for only one would answer it worse without any way to see that from the types. @intent keep the service on fetch-only ports so no backend or scoring package leaks in.
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service runs the shared search pipeline over one candidate searcher. @intent hold the fetch→filter→rerank→evidence chain in one place instead of one copy per inbound adapter.
func New ¶
New constructs the shared search service. @intent keep construction trivial so composition roots stay declarative.
func (*Service) Search ¶
Search answers one query within the namespace already on the context.
The whole pool is reranked rather than just Limit of it: the evidence cut decides membership, so bounding the rerank would spend slots on candidates that are about to be dropped anyway. @intent answer a search with the files that can justify their place, not the backend's raw order. @ensures returns at most Limit files, each carrying every hit it answered with.
func (*Service) SearchFederated ¶
func (s *Service) SearchFederated(ctx context.Context, namespaces []string, p Params) (evidence.List, error)
SearchFederated answers one query across an explicit namespace set.
Each namespace stays its own ranked list so fusion charges a hit the rank it held in its own namespace, not its offset in a concatenated slice. The evidence cut runs before the quota, so a namespace's slots go to hits it can justify rather than to whatever it retrieved first. @intent answer one search across several repositories with per-item namespace labels. @domainRule each namespace is queried in isolation, and every namespace with hits keeps at least one file on the page.
Directories
¶
| Path | Synopsis |
|---|---|
|
@index Pure search-document content construction from graph nodes and annotations.
|
@index Pure search-document content construction from graph nodes and annotations. |
|
@index Turns ranked search candidates into a list a reader can judge.
|
@index Turns ranked search candidates into a list a reader can judge. |
|
Package identtoken is the one place search text turns into tokens: Fields cuts free text into identifier-like terms, and Split cuts one identifier into its sub-tokens.
|
Package identtoken is the one place search text turns into tokens: Fields cuts free text into identifier-like terms, and Split cuts one identifier into its sub-tokens. |
|
@index Recorded-reason retrieval: the intent index port and its answer types.
|
@index Recorded-reason retrieval: the intent index port and its answer types. |
|
@index BM25 scoring of recorded reasons against a plain-language question, shared by every search backend.
|
@index BM25 scoring of recorded reasons against a plain-language question, shared by every search backend. |
|
Package queryterm holds the query-side vocabulary rules that both ways of searching this graph have to agree on: the full-text query built for the database, and the term list the fallback scan matches nodes against.
|
Package queryterm holds the query-side vocabulary rules that both ways of searching this graph have to agree on: the full-text query built for the database, and the term list the fallback scan matches nodes against. |
|
Package rank reranks FTS-ranked code-search candidates using dependency-free structural signals (name subsequence similarity, path proximity), so both the CLI `search` command and the MCP `search` tool share one ranking.
|
Package rank reranks FTS-ranked code-search candidates using dependency-free structural signals (name subsequence similarity, path proximity), so both the CLI `search` command and the MCP `search` tool share one ranking. |
|
Package wire is the serialized form of a search answer — the JSON contract MCP's search tool and the CLI's --json output both speak.
|
Package wire is the serialized form of a search answer — the JSON contract MCP's search tool and the CLI's --json output both speak. |