cadrumo.application.corpus_search._retrieval module

Corpus retrieval: exact citation short-circuit over an FTS5 lexical ranking.

The grounding search runs two cooperating retrievers, neither of which needs a model:

  • an exact-citation short-circuit — when the query IS a citation id (ley-58-2003:art-27.2), it resolves directly through the structured lookup, no ranking needed;

  • the FTS5 lexical index (lexical_index) for exact and stemmed in-prose recall, ranked by BM25 over the diacritic-folded and Spanish-stemmed columns.

The shipped product carries no semantic runtime: nothing here loads an embedding model, computes or consumes vectors, or reaches the network. Semantic recall re-enters the product, if ever, only as laundered precompiled data produced by the dev-side oracle.

run_retrieval(query, *, database_path, citation_lookup=None, limit=10)[source]

Run grounding retrieval for query and return a typed response.

Parameters:
  • query (str) – The free-text query, or an exact citation id.

  • database_path (Path) – A lexical index built by build_lexical_index.

  • citation_lookup (CitationLookup | None) – Optional catalogue lookup enabling the exact-citation short-circuit.

  • limit (int) – Maximum number of ranked hits to return.

Return type:

RetrievalResponse

Returns:

A RetrievalResponse — a citation resolution, or the ranked lexical hits.

Raises:

CorpusSearchInputError – If query is blank or limit is not positive.