Skip to main content

quipu/
lib.rs

1//! Quipu -- AI-native knowledge graph with strict ontology enforcement.
2//!
3//! This crate implements an immutable bitemporal EAVT fact log backed by `SQLite`,
4//! designed as a foundation for agent-enforced knowledge graphs.
5
6pub mod acquisition;
7pub mod align;
8pub mod applier;
9pub mod asof_rdf;
10/// As-of scoped share: a replica bootstrap cut at one transaction.
11#[cfg(not(target_arch = "wasm32"))]
12pub mod asof_share;
13pub mod bindings;
14pub mod changeset;
15/// Change-sets against a live store: `/diff` and the `/patch` state check.
16#[cfg(not(target_arch = "wasm32"))]
17pub mod changeset_store;
18pub mod client_changeset;
19/// Separately signed resolver evidence, without changing the client v1 wire.
20pub mod client_resolver;
21pub mod compact;
22pub mod competency;
23pub mod config;
24mod config_load;
25pub mod context;
26pub mod crew_credentials;
27/// DataBook documents: parse and render (kurtcagle/databook 1.5.0).
28pub mod databook;
29/// Export a graph as a DataBook; import a DataBook's graph data.
30pub mod databook_store;
31pub mod derivation;
32pub mod embedding;
33pub mod embedding_runtime;
34pub mod entity_key;
35mod entity_key_guard;
36pub mod entity_namespaces;
37pub mod entity_reference;
38pub mod episode;
39pub mod error;
40pub mod governance;
41pub mod graph;
42pub mod graph_view;
43pub mod http_auth;
44pub mod impact;
45pub mod import_embedding;
46pub mod lattice;
47pub mod lattice_fold;
48pub mod lattice_kind;
49pub mod lexical;
50mod literal_identity;
51pub mod mcp;
52pub mod memory_budget;
53pub mod memory_files;
54pub mod merge3;
55#[cfg(not(target_arch = "wasm32"))]
56mod merge_adapters;
57/// Opt-in diagnostic projection of the common planner, without writer authority.
58#[cfg(feature = "merge-benchmark")]
59#[doc(hidden)]
60pub mod merge_benchmark;
61/// One merge write core: the merge spec's time, sequencing and report rules (aegis-karb.2).
62mod merge_core;
63#[cfg(not(target_arch = "wasm32"))]
64pub mod merge_ingress;
65#[cfg(not(target_arch = "wasm32"))]
66mod merge_lists;
67#[cfg(not(target_arch = "wasm32"))]
68mod merge_pending;
69#[cfg(not(target_arch = "wasm32"))]
70pub mod merge_plan;
71#[cfg(not(target_arch = "wasm32"))]
72mod merge_plan_gate;
73#[cfg(not(target_arch = "wasm32"))]
74mod merge_profile;
75/// One way to reconcile a failed merge: shared decisions view, resolve and layout (aegis-k7l).
76pub mod merge_reconcile;
77#[cfg(not(target_arch = "wasm32"))]
78mod merge_review;
79#[cfg(not(target_arch = "wasm32"))]
80mod merge_session;
81pub mod metrics;
82#[cfg(feature = "lancedb")]
83pub mod migration;
84#[cfg(not(target_arch = "wasm32"))]
85pub mod model_assets;
86#[cfg(not(target_arch = "wasm32"))]
87pub mod model_backfill;
88pub mod namespace;
89mod namespace_publication;
90mod numeric_value;
91#[cfg(feature = "onnx")]
92pub mod onnx_embedder;
93#[cfg(feature = "onnx")]
94pub mod onnx_runtime;
95/// Portable bootstrap manifest and signature verification, including WASM.
96#[path = "asof_share/manifest.rs"]
97pub mod replica_manifest;
98pub mod replica_provider;
99#[cfg(not(target_arch = "wasm32"))]
100pub mod replicate_source;
101pub mod replicate_wire;
102/// Prospective resolver types and content-bound validation evidence; no admission authority.
103pub mod resolver_contract;
104mod search_graph_scope;
105pub mod search_outcome;
106pub mod search_trace;
107/// Portable logical full-store replication values.
108pub mod store_replica;
109/// Opt-in logical store replication; opening a store never enables its journal.
110#[cfg(not(target_arch = "wasm32"))]
111pub mod store_stream;
112pub mod substring;
113pub mod transaction_auth;
114/// Pure declared write-base binding; no writer integration or admission authority.
115pub mod write_base;
116pub mod write_kind;
117pub mod write_observation;
118pub mod write_provenance;
119#[cfg(not(target_arch = "wasm32"))]
120pub mod writer_lock;
121// `explain` resolves OWL axiom families through the `owl` module, so the two
122// share the feature gate.
123#[cfg(feature = "owl")]
124pub mod explain;
125#[cfg(feature = "owl")]
126pub mod owl;
127// Reactive OWL rides the observer infrastructure, which is gated behind
128// `reactive-reasoner`; it needs both features.
129mod change_risk;
130#[cfg(all(feature = "owl", feature = "reactive-reasoner"))]
131mod owl_reactive;
132pub mod pack;
133#[cfg(not(target_arch = "wasm32"))]
134mod pack_load;
135mod pack_turtle;
136pub mod path;
137pub mod proposal;
138pub mod proposal_migration;
139pub mod proposal_plan;
140pub mod provider;
141pub mod rdf;
142mod rdf_compact;
143mod rdf_export;
144pub mod rdf_triple;
145pub mod term_vocabulary;
146pub use rdf_compact::{COMPACT_RDF_LIMIT, CompactRdf, export_compact_graph};
147/// Oversized-transaction parts shared by the change stream and the as-of share.
148pub mod feed_parts;
149pub mod fluent;
150pub mod follow;
151#[cfg(feature = "remote")]
152pub mod follow_http;
153/// Whether a follower may serve reads in place of its primary (aegis-tnh).
154pub mod follow_ready;
155/// Resolve a fork promotion that stopped on conflicts (aegis-k7l).
156pub mod fork_merge_decisions;
157pub mod grant_scope;
158/// Immutable admission plans for the per-graph writer pilot; not an activation API.
159pub mod graph_catalog;
160/// Inactive SQLite-only HA read profile; no serving adapter is installed.
161#[cfg(all(feature = "ha-read-profile", target_os = "linux"))]
162pub mod ha_read;
163/// Experimental pure ownership-handoff model; no Store or runtime integration.
164pub mod ownership_handoff_model;
165mod rdf_graph_store;
166mod rdf_scope;
167pub mod read_authorization;
168pub mod read_pin;
169pub mod reasoner;
170pub mod reconcile;
171pub mod render;
172pub mod report;
173pub mod request_usage;
174pub mod resolution;
175pub mod rule_answers;
176pub mod schema;
177pub mod semweb;
178#[cfg(not(target_arch = "wasm32"))]
179pub mod session_attestation;
180#[cfg(feature = "shacl")]
181pub mod shacl;
182#[cfg(feature = "shacl")]
183mod shacl_admission;
184#[cfg(feature = "shacl")]
185pub mod shacl_context;
186pub mod shacl_cycles;
187#[cfg(feature = "shacl")]
188mod shacl_debt;
189/// Refuse SHACL-SPARQL shapes, which are not evaluated (aegis-rk4).
190pub mod shacl_unsupported;
191pub mod share;
192#[cfg(not(target_arch = "wasm32"))]
193pub mod verified_write;
194pub mod writer_scope;
195// The delta FORMAT is wasm-safe; only its filesystem entry points are gated,
196// inside the module. The wasm explorer produces the same `share-delta/v1`
197// artifact the CLI does, and it can only do that if the builder compiles there
198// (aegis-8fdp8d).
199pub mod pack_full;
200pub mod pack_full_text;
201// The format gate + `restore`. Filesystem-bound like `pack_load`, so gated the
202// same way.
203#[cfg(not(target_arch = "wasm32"))]
204pub mod git_merge;
205#[cfg(not(target_arch = "wasm32"))]
206mod git_merge_alias;
207#[cfg(not(target_arch = "wasm32"))]
208mod git_merge_repo;
209#[cfg(not(target_arch = "wasm32"))]
210pub mod pack_restore;
211#[cfg(not(target_arch = "wasm32"))]
212pub mod project_graph;
213#[cfg(not(target_arch = "wasm32"))]
214pub mod share_attestation;
215pub mod share_completeness;
216pub mod share_compose;
217#[cfg(not(target_arch = "wasm32"))]
218pub mod share_current;
219pub mod share_delta;
220pub mod share_pointer_load;
221// Entity-grouped, blank-node-stable payload diffs and the `git diff` textconv
222// rendering (aegis-fxpbys.1). Pure apart from `read_payload`, which is gated.
223pub mod share_diff;
224// The PR-review report over two pack versions: facts, introduced SHACL
225// violations, merge decisions, alias caveat (aegis-fxpbys.1, M2).
226pub mod promotion_control;
227pub mod shape_mapping;
228pub mod share_alignments;
229/// Opaque fluent proof transport, separate from native admission authority.
230pub mod share_fluent;
231pub mod share_import;
232pub(crate) mod share_import_resolve;
233#[cfg(not(target_arch = "wasm32"))]
234pub mod share_merge;
235pub mod share_merge_decisions;
236#[cfg(not(target_arch = "wasm32"))]
237pub mod share_merge_decisions_view;
238#[cfg(not(target_arch = "wasm32"))]
239pub mod share_mint;
240#[cfg(not(target_arch = "wasm32"))]
241pub mod share_pack_review;
242mod share_promotion;
243pub mod share_queries;
244pub mod share_review;
245pub mod share_scrub;
246pub mod share_transport;
247pub mod signing;
248pub mod sparql;
249pub mod sparql_structure;
250#[cfg(not(target_arch = "wasm32"))]
251pub mod statement_profile;
252pub mod store;
253pub mod time;
254pub mod types;
255pub mod vector;
256pub mod vector_delegate;
257#[cfg(feature = "lancedb")]
258pub mod vector_lance;
259pub mod verdict_schemes;
260pub mod vocabulary;
261pub mod w3c;
262pub mod write_gate;
263
264/// The crate version this build was compiled from.
265///
266/// Exported because consumers that are not the CLI or the server still need to
267/// say which quipu produced them — the wasm bundle in `wasm/explorer` reports it
268/// beside a pack's own `producer.version`, so a reader can see whether the
269/// engine reading the artifact is the engine that wrote it.
270pub const VERSION: &str = env!("CARGO_PKG_VERSION");
271
272/// The git commit this build was compiled from, as stamped by `build.rs`.
273pub const GIT_SHA: &str = env!("QUIPU_GIT_SHA");
274
275pub use rdf_export::{export_rdf_construct, export_rdf_group};
276
277pub use config::{
278    AttachmentConfig, EmbeddingConfig, FederationConfig, GovernanceConfig, ProjectionColumnConfig,
279    ProjectionConfig, QuipuConfig, RemoteEndpoint, ResolutionConfig, SearchConfig, ServerConfig,
280    ShaclConfig, VectorBackend, VectorConfig, open_with_configured_attachments,
281};
282pub use context::{
283    ContextPipeline, ContextPipelineConfig, KnowledgeContext, KnowledgeEntity, KnowledgeFact,
284    KnowledgeRelevance, tool_context, tool_unified_search,
285};
286pub use derivation::{DerivationMethod, Rederivation};
287pub use embedding::{
288    DeferredEmbed, EmbeddingProvider, NO_PROVIDER_HELP, build_entity_text,
289    build_entity_text_for_graph_backfill,
290};
291pub use episode::{
292    Episode, IngestResolutionOpts, IngestResult, episode_provenance, ingest_batch, ingest_episode,
293    ingest_episode_with_resolution,
294};
295pub use error::{Error, Result};
296// `project` is the only way to BUILD a ProjectedGraph, so exporting page_rank +
297// ProjectedGraph without it left the typed graph API unusable from outside the
298// crate — consumers had to reach through `quipu::graph::` or fall back to the
299// `tool_project` JSON adapter. Bobbin chose the adapter (bobbin-jdlkh), which is
300// how it ended up needing `&mut Store` for a read-only PageRank: tool_project
301// takes `&mut` solely for its community-persist branch. Exporting it closes the
302// gap (aegis-nwuf / bobbin-kue26).
303pub use graph::{
304    Communities, PageRankConfig, ProjectedGraph, louvain, page_rank, persist_communities, project,
305    tool_project,
306};
307pub use graph_view::tool_graph_view;
308pub use impact::{DEFAULT_HOPS, ImpactNode, ImpactOptions, ImpactReport, impact, speculate_remove};
309pub use mcp::align::{tool_align_apply, tool_align_decide, tool_align_propose};
310#[cfg(feature = "owl")]
311pub use mcp::explain::tool_explain;
312pub use mcp::graphiti::tool_episodes_complete;
313pub use mcp::history::tool_entity_history;
314pub use mcp::impact::tool_impact;
315pub use mcp::mapping::{tool_mapping_apply, tool_mapping_decide, tool_mapping_propose};
316#[cfg(not(target_arch = "wasm32"))]
317pub use mcp::merge_decisions::{tool_merge_apply, tool_merge_decisions, tool_merge_resolve};
318pub use mcp::named_query::tool_ask;
319#[cfg(feature = "owl")]
320pub use mcp::owl::tool_load_ontology;
321pub use mcp::path::{tool_path_backtest, tool_path_cone};
322pub use mcp::proposal::{
323    tool_accept_proposal, tool_list_proposals, tool_propose_schema_change, tool_reject_proposal,
324};
325pub use mcp::resolution::tool_resolve_entity;
326pub use mcp::rule_answers::tool_rule_query;
327pub use mcp::search::{tool_search_facts, tool_search_nodes};
328pub use mcp::tools::{
329    PreparedEpisode, SERVER_DERIVED_EMBEDDING, resolve_validation_shapes, tool_cord, tool_datasets,
330    tool_episode, tool_episode_commit, tool_episode_prepare, tool_graph_freeze, tool_graph_list,
331    tool_graph_thaw, tool_hybrid_search, tool_queries, tool_retract, tool_retract_episode,
332    tool_search, tool_set, tool_shapes, tool_subscriptions, tool_unravel, tool_validate,
333};
334#[cfg(not(target_arch = "wasm32"))]
335pub use mcp::tools::{tool_attest_challenge, tool_attest_commit, tool_attest_receipt};
336#[cfg(not(target_arch = "wasm32"))]
337pub use mcp::tools::{tool_deck_attest, tool_deck_present, tool_deck_receipt};
338pub use mcp::{
339    inference_header, labels_json, query_inference, query_result, query_result_with_federation,
340    tool_cooccurrence, tool_definitions, tool_export, tool_graph_create, tool_graph_label,
341    tool_knot, tool_overlay_compose, tool_overlay_create, tool_overlay_write, tool_policy_check,
342    tool_query, tool_query_with_federation, tool_retract_source, tool_verdict_verify,
343    tool_verifier_authorized, value_to_json, value_to_json_compact, value_to_json_with_prefixes,
344};
345#[cfg(feature = "lancedb")]
346pub use migration::{MigrateResult, migrate_sqlite_to_lancedb};
347#[cfg(feature = "onnx")]
348pub use onnx_embedder::OnnxEmbeddingProvider;
349#[cfg(feature = "owl")]
350pub use owl::{MaterializeReport, Ontology, OwlViolation};
351#[cfg(all(feature = "owl", feature = "reactive-reasoner"))]
352pub use owl_reactive::ReactiveOwl;
353pub use proposal::{NewProposal, Proposal, ProposalKind, ProposalStatus};
354pub use provider::{
355    DeclaredLabel, FederatedProvider, FederatedQuery, GraphProvider, LocalProvider,
356    ProviderOutcome, ProviderStatus,
357};
358#[cfg(feature = "remote")]
359pub use provider::{RemoteProvider, federated_from_config};
360pub use rdf::{
361    IngestReport, LoadDeclaration, export_rdf, export_rdf_subset, ingest_rdf, ingest_rdf_chunked,
362    ingest_rdf_declared,
363};
364pub use rdf_graph_store::{delete_rdf_graph, replace_rdf_graph};
365#[cfg(feature = "reactive-reasoner")]
366pub use reasoner::reactive::ReactiveReasoner;
367pub use reconcile::{
368    GoResolver, ImportResolver, PythonResolver, ReconcileReport, RustResolver, default_resolvers,
369    reconcile,
370};
371pub use report::tool_report;
372pub use resolution::{EntityCandidate, ResolutionResult, resolve_entity};
373#[cfg(feature = "shacl")]
374pub use shacl::{ValidationFeedback, Validator, validate_shapes};
375pub use sparql::{
376    GraphScope, QueryResult, TemporalContext, Triple, query as sparql_query,
377    query_temporal as sparql_query_temporal,
378};
379pub use store::forks::{ForkDiff, ForkInfo, ForkPromotion};
380pub use store::{
381    Datum, GroupBy, PROJECTION_ROWS_MAX, ProjectionAggregate, ProjectionCertificate,
382    ProjectionRows, ProjectionStatus, RowsAfter, Store,
383};
384#[cfg(feature = "reactive-reasoner")]
385pub use store::{Delta, TransactObserver};
386pub use types::{Fact, Op, Term, Transaction, Value};
387pub use vector::{KnowledgeVectorStore, VectorMatch};
388pub use vector_delegate::VectorSearchDelegate;
389#[cfg(feature = "lancedb")]
390pub use vector_lance::LanceVectorStore;
391
392/// Native MCP protocol adapters over the governed HTTP application.
393#[cfg(feature = "mcp")]
394pub mod mcp_transport;
395
396/// Bounded search-seeded SPARQL SELECT queries.
397pub mod search_query;
398pub use search_query::tool_search_query;
399
400#[cfg(test)]
401mod share_competency_tests;