Skip to main content

waratah_compute/
strict_sparql.rs

1//! `strict-sparql` compatibility mode: a process-wide toggle that gates
2//! Waratah's documented SPARQL deviations behind strict 1.1 adherence.
3//!
4//! One shared flag, ONE set of consumers per deviation — the deviation table
5//! lives with each feature's rewrite AND its residual evaluator so the
6//! indexed and unindexed paths can never disagree in either mode. Read per
7//! comparison at EVALUATION time (each `strict_sparql()` call loads the
8//! atomic), so the flag is only safe to set once, at startup, before any
9//! query is served — which is the only thing `--strict-sparql` does.
10//! Toggling mid-query would let one query's indexed and unindexed paths
11//! disagree.
12//!
13//! Deviations gated today:
14//! - **`gYear` / `gYearMonth` ordering comparisons** (temporal plugin):
15//!   SPARQL 1.1's operator table defines no ordering for the `gYear`
16//!   family; non-strict (the default) supports them as a documented
17//!   extension, strict turns them into type errors.
18//!
19//! New deviations MUST be added here as named entries, not scattered
20//! booleans.
21
22use std::sync::atomic::{AtomicBool, Ordering};
23
24static STRICT_SPARQL: AtomicBool = AtomicBool::new(false);
25
26/// Whether strict SPARQL 1.1 adherence mode is on (default: off).
27pub fn strict_sparql() -> bool {
28    STRICT_SPARQL.load(Ordering::Relaxed)
29}
30
31/// Toggle strict SPARQL mode (CLI / compute config). Affects queries
32/// prepared after the call.
33pub fn set_strict_sparql(strict: bool) {
34    STRICT_SPARQL.store(strict, Ordering::Relaxed);
35}