MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / validate_ntriples

Function validate_ntriples

atomic-shacl/src/lib.rs:154–296  ·  view source on GitHub ↗

One parsed snapshot and one parsed shapes/import closure are reused for target coverage and validation. Focus selection is performed by PurRDF; Atomic's callback only records coverage and applies explicit CLI selectors.

(
    data: &str,
    snapshot_identity: &str,
    request: &ValidationRequest,
)

Source from the content-addressed store, hash-verified

152/// target coverage and validation. Focus selection is performed by PurRDF;
153/// Atomic's callback only records coverage and applies explicit CLI selectors.
154pub fn validate_ntriples(
155 data: &str,
156 snapshot_identity: &str,
157 request: &ValidationRequest,
158) -> Result<ValidationOutput, ValidationError> {
159 let mut bundles = vec![ShapeBundle {
160 iri: "https://atomic.dev/ns/shapes/projection/1.0.0".into(),
161 turtle: PROJECTION_SHAPES.into(),
162 }];
163 // Review uses source-backed evidence paths, not legacy plan shortcuts.
164 if request.profile == Profile::Review {
165 bundles.clear();
166 }
167 if request.profile == Profile::Publication {
168 bundles.push(ShapeBundle {
169 iri: "https://atomic.dev/ns/shapes/publication/1.0.0".into(),
170 turtle: PUBLICATION_SHAPES.into(),
171 });
172 }
173 if request.profile == Profile::Review {
174 bundles.push(ShapeBundle {
175 iri: "https://atomic.dev/ns/shapes/review/1.0.0".into(),
176 turtle: REVIEW_SHAPES.into(),
177 });
178 }
179 bundles.extend(request.custom.clone());
180 let mut imports = ShapesImports::new();
181 let mut root = String::new();
182 let mut identity = blake3::Hasher::new();
183 for bundle in &bundles {
184 imports
185 .insert_turtle(&bundle.iri, &bundle.turtle)
186 .map_err(|e| ValidationError::Shapes(e.to_string()))?;
187 root.push_str(&format!(
188 "<urn:atomic:shapes:selection> <http://www.w3.org/2002/07/owl#imports> <{}> .\n",
189 bundle.iri
190 ));
191 identity.update(&(bundle.iri.len() as u64).to_be_bytes());
192 identity.update(bundle.iri.as_bytes());
193 identity.update(&(bundle.turtle.len() as u64).to_be_bytes());
194 identity.update(bundle.turtle.as_bytes());
195 }
196 let shapes = engine::parse_shapes_with_config(
197 &root,
198 Some("urn:atomic:shapes:selection"),
199 None,
200 &imports,
201 )
202 .map_err(|e| ValidationError::Shapes(e.to_string()))?;
203 if shapes.rules.entailment
204 || !shapes.rules.global_rules.is_empty()
205 || !shapes.rules.rule_sets.is_empty()
206 || shapes
207 .node_shapes
208 .iter()
209 .any(|shape| !shape.rules.is_empty())
210 {
211 return Err(ValidationError::Shapes(

Calls 15

term_valueFunction · 0.85
SnapshotClass · 0.85
extendMethod · 0.80
as_refMethod · 0.80
clearMethod · 0.65
pushMethod · 0.45
cloneMethod · 0.45
updateMethod · 0.45
lenMethod · 0.45
as_bytesMethod · 0.45
is_emptyMethod · 0.45
iterMethod · 0.45