← Guides

Smart Search

"Where is the login handler?" and "Why does the login handler bypass the rate limiter?" are different questions that deserve different answers. SourcePrep reads the shape of your query and routes it to the right backend automatically.

Why routing matters

A single search tool is only good at one kind of answer. If everything goes through semantic search, exact symbol lookups get polluted with near-matches. If everything goes through the symbol index, conceptual questions return nothing. SourcePrep classifies your query into one of seven intents and sends it to the backend that actually knows how to answer it.

Classification is rule-based and deterministic — no LLM call, no latency — so the same query always routes the same way.

The seven intents

LOCATE

Triggers on where is, find, show me. Routes to symbol lookup. Returns path, signature, and line number — the kind of answer you'd get from "Go to Definition."

e.g. "where is the login handler"

EXPLAIN

Triggers on how does, what does, or anything without a stronger signal. Runs semantic search with trace expansion so you see both the code and its immediate collaborators. This is the default.

e.g. "how does authentication work"

RATIONALE

Triggers on why. Hits recorded concepts first — the place where business rules and design decisions live — and falls back to semantic search if nothing lands.

e.g. "why does the billing queue retry twice"

TRACE

Triggers on who calls, who imports, dependents of. Routes through prep_impact so you get graph-accurate callers and importers rather than string matches.

e.g. "who imports the rate limiter"

EXAMPLE

Triggers on example of, how to use. Returns real call sites rather than the definition — the thing you actually want when you're trying to use an API.

e.g. "example of using the retry decorator"

COMPARE

Triggers on difference between, X vs Y. Pulls both sides in parallel so they can be read side-by-side.

e.g. "difference between eager and lazy loader"

DISCOVER

Triggers on what's in, overview of. Returns a module-level summary — the right altitude for orientation rather than a specific answer.

e.g. "what's in the auth directory"

Overriding the classifier

The classifier is right most of the time, but it's not magic. If you know what you want and the phrasing is ambiguous, pass intent explicitly:

prep_search(query="session token", intent="locate")

Every returned result includes the intent that was used, so you can see at a glance whether routing matched your mental model.

Query rewriting

Once an intent is detected, SourcePrep strips the signal words ("where is", "why does", "how to") before passing the remainder to the chosen backend. That means "where is the login handler" becomes a clean login handler lookup against the symbol index — without the scaffolding words polluting the score.

How ties are broken

A query can match multiple intent patterns at once. The classifier picks the most specific one using this priority:

  1. TRACE
  2. RATIONALE
  3. COMPARE
  4. EXAMPLE
  5. DISCOVER
  6. LOCATE
  7. EXPLAIN (fallback — always wins if nothing else matched)

So "why does the login handler retry" routes to RATIONALE (concepts) rather than LOCATE (symbol lookup), because the why signal wins over the login handler noun phrase.

Good to know

  • Classification is local and deterministic — no model inference, no telemetry, no surprise latency.
  • Results include a confidence score alongside the chosen intent, so low-confidence routes can be audited.
  • If none of the patterns hit, the query defaults to EXPLAIN and runs as plain semantic search.