Skip to content

feat(rdfs): add configurable RDFS rules via builder pattern#59

Merged
cool-japan merged 2 commits intocool-japan:masterfrom
temporaryfix:feature/rdfs-configurable-rules
Feb 8, 2026
Merged

feat(rdfs): add configurable RDFS rules via builder pattern#59
cool-japan merged 2 commits intocool-japan:masterfrom
temporaryfix:feature/rdfs-configurable-rules

Conversation

@temporaryfix
Copy link
Copy Markdown
Contributor

Summary

  • Add RdfsRule enum for identifying all 13 RDFS entailment rules
  • Add RdfsProfile enum with preset configurations (Minimal, Full, None)
  • Add RdfsConfig struct for custom rule configuration
  • Add RdfsReasonerBuilder for fluent configuration API
  • Update RdfsReasoner with new constructors and config-aware inference

Rules Disabled by Default (Minimal Profile)

Rule Pattern Issue
rdfs1 (?s ?p ?o) → (?p rdf:type rdf:Property) Every predicate becomes a Property
rdfs4a (?s ?p ?o) → (?s rdf:type rdfs:Resource) Every subject becomes a Resource
rdfs4b (?s ?p ?o) → (?o rdf:type rdfs:Resource) Every object becomes a Resource
rdfs6 (?p rdf:type rdf:Property) → (?p rdfs:subPropertyOf ?p) Reflexive subPropertyOf
rdfs8 (?c rdf:type rdfs:Class) → (?c rdfs:subClassOf rdfs:Resource) Classes subClassOf Resource
rdfs10 (?c rdf:type rdfs:Class) → (?c rdfs:subClassOf ?c) Reflexive subClassOf

New API Examples

// Default (minimal profile - non-noisy rules)
let reasoner = RdfsReasoner::new();

// Using profiles
let reasoner = RdfsReasoner::with_profile(RdfsProfile::Full);

// Context-only mode (for hierarchy queries without rule engine)
let reasoner = RdfsReasoner::context_only();

// Builder for custom configuration
let reasoner = RdfsReasoner::builder()
    .with_profile(RdfsProfile::Minimal)
    .enable_rule(RdfsRule::Rdfs8)
    .build();

Test plan

  • All existing tests pass
  • New tests for builder pattern and profiles
  • Benchmark test comparing Minimal vs Full profile fact generation
  • cargo clippy -p oxirs-rule -- -D warnings passes

🤖 Generated with Claude Code

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>
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 RdfsRule enum to identify all 13 RDFS rules, RdfsProfile enum for preset configurations, and RdfsConfig struct for custom rule management
  • Added RdfsReasonerBuilder with fluent API for configuring which RDFS rules are active
  • Modified RdfsReasoner to use configuration-aware rule initialization and inference, with new constructors (with_profile, context_only, builder) while maintaining backward compatibility through new()

💡 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,
Copy link

Copilot AI Jan 29, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
pub config: RdfsConfig,
config: RdfsConfig,

Copilot uses AI. Check for mistakes.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copy link
Copy Markdown
Owner

@cool-japan cool-japan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ 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.

@cool-japan cool-japan merged commit 57577e7 into cool-japan:master Feb 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants