Skip to content

Legal Core implements specialized judgment-summary and hierarchical act/article discovery, with separate pinned source reads. Product-worker turns discovered resources into evidence by reading original text; a derived summary is not an original passage.

flowchart TD
  Query["Query and configuration"] --> Branch{"Document type"}
  Branch --> Judgment["Summary candidates and reranking"]
  Branch --> Norm["Act candidates, article branches and reranking"]
  Judgment --> Hit["Resource and source-version identities"]
  Norm --> Hit
  Hit --> Original["Pinned original-text read"]
  Original --> Evidence["Product evidence validation"]

services/legal-core-api/internal/search/domain_search.go owns branch ranking. The server wires internal/vectorindex through search/qdrant.go for semantic/hybrid candidates; PostgreSQL supplies authorized source hydration and exact/lexical reads. Explicit authority, jurisdiction, grade, year and date filters are applied before limits. TestRetrievalPostgres, with its local Qdrant configuration enabled, exercises both backends, legal-time selection, configuration rollback, global-only resources and unavailable-index behavior.

Semantic retrieval queries the selected Qdrant dense vector. Hybrid retrieval queries that same collection’s dense and Italian BM25 sparse vectors separately and applies the existing reciprocal-rank fusion before domain reranking. It no longer requires pg_search in the running API. Missing or stale projections and transport failures fail explicitly: no implicit pgvector or dense-only fallback. Explicit lexical mode remains PostgreSQL full-text search. The SQL candidate backend remains available for differential tests, not as a runtime failover.

Ranking budgets and thresholds are defined in the implementation and checked by domain_search_test.go and reference_parity_test.go. The reference comparison requires its reference source; a skipped comparison is not parity evidence. No tuning values are duplicated here.

Qdrant owns candidate generation, not canonical content. The storage contract specifies collection/profile isolation, minimal payloads, filters, hydration and the incremental projection/erasure lifecycle. The local Compose stack starts a continuous projector after fixture seeding. No reference deployment or existing production collection is modified by this integration.

The separate judgment and normative algorithms are retained: retrieve IDs and scores, batch-load summaries/act profiles/article inputs from PostgreSQL, then run branch-specific reranking. Parent-act scoping is a pre-limit Qdrant filter. Normative validity is evaluated at query time, then rechecked in SQL; unknown validity does not pass current-law retrieval. Before returning, the corpus revision is checked again to reject withdrawals that occurred during reranking. The generic public/private search contract has no duplicate Qdrant-specific endpoints. Semantic classification filters and pool-restricted argument retrieval still belong to the unimplemented specialist scope.

The product adapter in services/product-worker/internal/capabilities/legal.go preserves discovery metadata while fetching a pinned original when a hit has no chunk ID. legal_test.go checks that summary text is not used as an original quote. evidence.go checks quotations against supplied sources.

These checks establish identity and text fidelity. They do not prove that a passage supports the legal conclusion, that all contrary authority was retrieved, or that a dated provision applies to the facts. Those remain evaluation and product-interpretation responsibilities.

Automatic filter inference, full reference parity, general exact-reference resolution and specialist cross-domain, forms, citation analytics, LEX, FORUM and valuation operations remain incomplete or absent. Their inventory is a local backlog, not an API reference. The generated private contract is the source for callable operation shapes.