cadrumo.application.corpus_search.citation_lookup module

Structured exact-citation lookup over the registry legal catalogue.

Exact citations (“art. 27.2 LGT”, ley-58-2003:art-27.2) do not go through the FTS index: the wheel already ships typed citation data (the registry legal_refs with their corpus_ref and BOE permalinks), so this is a direct structured key lookup, not a parallel citation parser. The registry legal catalogue is the single citation authority; this module reuses it and adds the one thing the product lacked at runtime: resolving a citation id to the verbatim authoritative text its corpus_ref points at.

The verbatim text is read from the published authority artifact’s signed evidence projection rather than the raw HTML, and sliced to the unit the citation’s anchor names when the source file carries multiple units.

See also

CitationResolution

Typed result carrying catalogue metadata and verbatim text.

search_corpus()

Exact citation ids short-circuit through this lookup before ranking.

Notes

External adapters may resolve citation ids and retrieval corpus_ref values through this product-owned service.

class CitationLookup[source]

Bases: ABC

Resolve a registry citation id to metadata plus verbatim text.

The lookup is built over one caller-selected component operation. Its text projection is signed with the authority, so resolving a citation never opens a bundled corpus file or source root.

property citation_ids: tuple[str, ...]

Return every resolvable citation id, sorted.

resolve(citation_id)[source]

Resolve citation_id to a CitationResolution.

Parameters:

citation_id (str) – A registry legal_refs id, e.g. ley-58-2003:art-27.2.

Return type:

CitationResolution

Returns:

The citation’s catalogue metadata plus the verbatim authoritative text its corpus_ref points at.

Raises:

CorpusSearchInputError – If the id is unknown to the catalogue or its backing corpus text cannot be read.

resolve_corpus_text(ref)[source]

Resolve a citation id OR a corpus_ref (path#anchor) to verbatim text.

The cadrumo://corpus/{ref} resource accepts either form: a retrieval hit’s corpus_ref or a bare citation id. A known citation id routes through resolve(); otherwise ref is read as a corpus path and anchor.

Raises:

CorpusSearchInputError – If ref resolves to no readable text or escapes the corpus root.

Return type:

str

Parameters:

ref (str)

classmethod from_operation(reference_ids, *, operation)[source]

Build an evidence lookup from exact ids under one pinned operation.

Legal declarations and their evidence are both addressed pointwise. The caller supplies the ids it has selected; this constructor does not hydrate a legal catalogue or accept a parallel metadata projection.

Return type:

CitationLookup

Parameters:
bundled_citation_lookup(reference_ids, *, operation)[source]

Build the bundled lookup from caller-selected ids and one live operation.

The indexed authority does not expose a global legal catalogue projection here. Its composition root must select the ids and keep operation leased for every lookup call.

Return type:

CitationLookup

Parameters: