Heuristic:AKSW RDFUnit SHACL Logical Constraint Execution Type
| Knowledge Sources | |
|---|---|
| Domains | Validation, SHACL, Debugging |
| Last Updated | 2026-10-16 00:00 GMT |
Overview
SHACL logical constraints (sh:and, sh:or, sh:not, sh:xone) are silently ignored unless a SHACL-capable execution type (shaclLite or shacl) is used; non-SHACL executors return empty results with a warning.
Description
RDFUnit supports four `TestCaseExecutionType` values: `statusTestCaseResult`, `aggregatedTestCaseResult`, `shaclLiteTestCaseResult`, and `shaclTestCaseResult`. SHACL logical constraint groups (`sh:and`, `sh:or`, `sh:not`, `sh:xone`) produce `TestCaseGroup` objects that combine results from sub-constraints using logical operators.
When a `TestCaseGroup` with a non-atomic logical operator is encountered by an executor that is not SHACL-specific (i.e., not `shaclLiteTestCaseResult` or `shaclTestCaseResult`), the executor logs a warning and returns an empty result collection instead of evaluating the group. This means logical constraints are silently skipped—validation appears to pass with no violations, but the constraints were never actually evaluated.
Usage
Use this heuristic when configuring test execution type for SHACL validation. Always use `TestCaseExecutionType.shaclTestCaseResult` (full SHACL) or `shaclLiteTestCaseResult` (SHACL Lite) when your shapes contain logical constraints (`sh:and`, `sh:or`, `sh:not`, `sh:xone`). If you see empty results where you expect violations, check whether you are using a non-SHACL execution type.
The Insight (Rule of Thumb)
- Action: Set execution type to `shaclTestCaseResult` or `shaclLiteTestCaseResult` when shapes contain logical constraints.
- Value: Use `TestCaseExecutionType.shaclTestCaseResult` for full annotated results; `shaclLiteTestCaseResult` for lightweight node-level results.
- Trade-off: SHACL executors may be slower than status/aggregated executors due to SELECT/Extended SELECT query overhead.
- Compatibility: Only SHACL execution types evaluate `TestCaseGroup` logical operators.
Reasoning
Logical constraint groups require evaluating multiple sub-constraints and combining their results using the logical operator semantics (AND = all must pass, OR = at least one must pass, NOT = inverse, XONE = exactly one must pass). The `statusTestCaseResult` and `aggregatedTestCaseResult` executors use ASK and COUNT queries respectively, which cannot express multi-constraint logical combinations. The code explicitly checks for this mismatch and warns rather than failing, to avoid breaking non-SHACL validation pipelines.
Code Evidence
Logical constraint guard from `TestExecutor.java:97-106`:
if (testCase.getLogicalOperator() != SHACL.LogicalConstraint.atomic &&
this.getExecutionType() != TestCaseExecutionType.shaclLiteTestCaseResult &&
this.getExecutionType() != TestCaseExecutionType.shaclTestCaseResult) {
log.warn(
"Logical constraints evaluation is not supported by the current execution type: " + this
.getExecutionType());
return Collections.emptyList();
} else {
return testCase.evaluateInternalResults(internalResults);
}