inference_engine/lib.rs
1#![doc = include_str!("../README.md")]
2
3use datalog_structural_model::Program;
4use rdf_reasoning::{Exclusion, Preset, PresetParseError};
5use serde::Serialize;
6
7pub mod reasoning;
8
9/// An exact shared RDF profile, compiled into portable checked Datalog rules.
10///
11/// This is a program description, not an evaluated closure or engine capability claim.
12#[derive(Debug, Serialize)]
13pub struct CompiledProfile {
14 /// The selected semantic contract.
15 pub preset: Preset,
16 /// The shared rule catalogue's checked program.
17 pub program: Program,
18 /// Obligations deliberately excluded by this profile.
19 pub exclusions: &'static [Exclusion],
20}
21
22impl CompiledProfile {
23 /// Compile the finite rule catalogue for this preset without loading graph data.
24 #[must_use]
25 pub fn new(preset: Preset) -> Self {
26 Self {
27 preset,
28 program: preset.program(),
29 exclusions: preset.exclusions(),
30 }
31 }
32}
33
34/// Compile a named shared RDF profile, rejecting unknown or unsupported selectors.
35///
36/// # Errors
37/// Returns the shared catalogue's typed parse error for an unsupported selector.
38pub fn compile_profile(selector: &str) -> Result<CompiledProfile, PresetParseError> {
39 selector.parse().map(CompiledProfile::new)
40}
41
42/// Enumerate exactly the finite set of available rule-profile selectors.
43pub fn profiles() -> impl ExactSizeIterator<Item = &'static str> {
44 Preset::ALL.iter().map(|preset| preset.name())
45}