klieo-memory-graph-rag 3.4.0

Graph-first RAG composer over KnowledgeGraph + LongTermMemory. Stable at 1.x per ADR-039.
Documentation
#![deny(missing_docs)]
#![deny(rust_2018_idioms)]
#![deny(rustdoc::broken_intra_doc_links)]

//! `klieo-memory-graph-rag` — graph-first RAG composer.
//!
//! Stable at `1.x`. Trait freeze contract recorded in ADR-039
//! (`docs/adr/adr-039-graphrag-1-0-promotion.md`).
//!
//! Public surface:
//! - `BuiltinExtractor`, `FallbackExtractor`, `LlmEntityExtractor`
//! - `ProvenanceKnowledgeGraph` — wraps any `KnowledgeGraph` with a
//!   `ProvenanceRepository` so every `index()` mints a v2 chain
//!   entry and every `recall_paths()` attaches the entry per hop
//!   (ADR-038).
//! - `VerbalizationPipeline` — LLM-driven prose summary of a
//!   `RetrievalPath` under a `klieo-spec` `QualityLoop`.
//! - `RegulationIngestTool` — `ImportSource` for structured
//!   regulatory texts (DORA, AI-Act) — pre-seeds typed
//!   `Article` / `Obligation` / `Deadline` entity hints.
//! - `GraphAwareLongTerm` — drop-in `LongTermMemory` that issues
//!   graph-first recall with vector fallback; `recall_traced` exposes
//!   the same authoritative facts plus a `RecallTrace` of extracted
//!   entities and graph paths for "why did retrieval return this?"
//! - `KnowledgeIngestionPipeline` + `ImportSource` extension point
//! - `InMemoryFilterableLongTerm` — zero-infra `FilterableLongTermMemory`
//!   with real cosine similarity over an injected `Embedder`
//!
//! # Quickstart
//!
//! ```no_run
//! # use std::sync::Arc;
//! # use klieo_memory_graph::{FilterableLongTermMemory, KnowledgeGraph};
//! # use klieo_memory_graph_rag::GraphAwareLongTerm;
//! # fn run(vector: Arc<dyn FilterableLongTermMemory>, graph: Arc<dyn KnowledgeGraph>) {
//! let long_term = GraphAwareLongTerm::builder().build(vector, graph);
//! # let _ = long_term; }
//! ```
//!
//! [`GraphAwareLongTerm::builder`] defaults the extractor
//! ([`BuiltinExtractor`]) and the [`klieo_memory_graph::RecallMetrics`]
//! counter so callers only supply the two mandatory backends. Override
//! either via [`GraphAwareLongTermBuilder::extractor`] /
//! [`GraphAwareLongTermBuilder::metrics`] /
//! [`GraphAwareLongTermBuilder::min_graph_hits`].

/// Regex-driven entity recogniser and (future) extractor combinators.
pub mod extractor;
/// Two-stage extractor combinator: secondary runs only when primary is empty.
pub mod fallback_extractor;
/// `GraphAwareLongTerm` — graph-first RAG composer over vector + graph.
pub mod graph_aware;
/// `KnowledgeIngestionPipeline` + `ImportSource` — bulk-ingest extension point.
pub mod import;
/// In-memory [`klieo_memory_graph::FilterableLongTermMemory`] with real cosine similarity.
pub mod in_memory_vector;
/// LLM-backed entity extractor — JSON-array prompt with hint-fallback.
pub mod llm_extractor;
/// Shared reserved metadata-key constants for the ingest/recall contract.
pub mod metadata;
/// `VerbalizationPipeline` — LLM-driven verbalisation of a
/// `RetrievalPath` under a `klieo-spec` `QualityLoop`.
pub mod path_rag;
/// `ProvenanceKnowledgeGraph` — wraps a `KnowledgeGraph` with a
/// `klieo-provenance` chain bridge (see ADR-038).
pub mod provenance;
/// Regulatory-text ingest source — DORA / AI-Act and friends.
pub mod regulation;

pub use extractor::BuiltinExtractor;
pub use fallback_extractor::FallbackExtractor;
pub use graph_aware::{GraphAwareLongTerm, GraphAwareLongTermBuilder, RecallTrace};
pub use import::{ImportDocument, ImportError, ImportSource, KnowledgeIngestionPipeline};
pub use in_memory_vector::InMemoryFilterableLongTerm;
pub use llm_extractor::LlmEntityExtractor;
pub use metadata::{
    KEY_ENTITIES, KEY_IMPORT_SOURCE_ID, KEY_TITLE, KEY_VALID_FROM, RESERVED_METADATA_KEYS,
};
pub use path_rag::{
    LlmRefiner, VerbalizationCritic, VerbalizationPipeline, DEFAULT_MAX_ITERATIONS,
};
pub use provenance::{ProvenanceKnowledgeGraph, DEFAULT_FACT_INDEX_CAPACITY, FORGET_EVENT_LABEL};
pub use regulation::{RegulationDocument, RegulationIngestTool};