feat(rdfs): add configurable RDFS rules via builder pattern#59
Conversation
Add RdfsRule enum, RdfsProfile enum, RdfsConfig struct, and RdfsReasonerBuilder to make RDFS rules configurable. By default, "noisy" rules (rdfs1, rdfs4a, rdfs4b, rdfs6, rdfs8, rdfs10) are disabled as they generate exponential trivial inferences. The Minimal profile enables only practical rules (rdfs2, rdfs3, rdfs5, rdfs7, rdfs9, rdfs11, rdfs13). New API: - RdfsReasoner::new() - uses Minimal profile (default) - RdfsReasoner::with_profile(RdfsProfile) - use preset profile - RdfsReasoner::context_only() - no rules, hierarchy queries only - RdfsReasoner::builder() - fluent configuration Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
This PR adds configurable RDFS rule management through a builder pattern, allowing users to selectively enable or disable specific RDFS entailment rules. The implementation introduces three profiles (Minimal, Full, None) with the Minimal profile as the new default, which excludes six "noisy" rules that generate exponential trivial inferences.
Changes:
- Introduced
RdfsRuleenum to identify all 13 RDFS rules,RdfsProfileenum for preset configurations, andRdfsConfigstruct for custom rule management - Added
RdfsReasonerBuilderwith fluent API for configuring which RDFS rules are active - Modified
RdfsReasonerto use configuration-aware rule initialization and inference, with new constructors (with_profile,context_only,builder) while maintaining backward compatibility throughnew()
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| /// Rule engine for RDFS rules | ||
| pub rule_engine: RuleEngine, | ||
| /// Configuration specifying which rules are enabled | ||
| pub config: RdfsConfig, |
There was a problem hiding this comment.
Adding a new public field config to the RdfsReasoner struct is a breaking change for serialization. Any code that has previously serialized RdfsReasoner instances will fail to deserialize them after this change. Consider whether RdfsReasoner was intended to be serializable (it's not marked with Serialize/Deserialize derives), and if serialization compatibility is a concern for this project.
| pub config: RdfsConfig, | |
| config: RdfsConfig, |
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
cool-japan
left a comment
There was a problem hiding this comment.
✅ Excellent feature! Adds configurable RDFS rules with builder pattern. Default changed from Full (exponential facts) to Minimal (7 practical rules), making RDFS reasoning usable in production. Breaking change is justified - old default generated exponential trivial inferences. All 738 tests pass. Well-designed API with comprehensive tests and benchmark showing dramatic improvement.
Summary
RdfsRuleenum for identifying all 13 RDFS entailment rulesRdfsProfileenum with preset configurations (Minimal, Full, None)RdfsConfigstruct for custom rule configurationRdfsReasonerBuilderfor fluent configuration APIRdfsReasonerwith new constructors and config-aware inferenceRules Disabled by Default (Minimal Profile)
(?s ?p ?o) → (?p rdf:type rdf:Property)(?s ?p ?o) → (?s rdf:type rdfs:Resource)(?s ?p ?o) → (?o rdf:type rdfs:Resource)(?p rdf:type rdf:Property) → (?p rdfs:subPropertyOf ?p)(?c rdf:type rdfs:Class) → (?c rdfs:subClassOf rdfs:Resource)(?c rdf:type rdfs:Class) → (?c rdfs:subClassOf ?c)New API Examples
Test plan
cargo clippy -p oxirs-rule -- -D warningspasses🤖 Generated with Claude Code