Metadata-Version: 2.5
Name: owlrl-turbo
Version: 0.1.0a2
Summary: Native RDFS and OWL-RL inference using the rdflib-turbo runtime
Project-URL: Repository, https://github.com/legra-ai/owlrl-turbo
Project-URL: Issues, https://github.com/legra-ai/owlrl-turbo/issues
Author: DataRoad Inc, Delaware, USA, trading as Legra
License-Expression: MIT OR Apache-2.0
License-File: LICENSE-APACHE
License-File: LICENSE-MIT
Requires-Python: >=3.11
Requires-Dist: rdflib-turbo==0.1.0a2
Provides-Extra: test
Requires-Dist: owlrl<8,>=7.1; extra == 'test'
Requires-Dist: pyshacl-turbo<0.3,>=0.2.4; extra == 'test'
Requires-Dist: pytest-cov<8,>=7.1; extra == 'test'
Requires-Dist: pytest<9,>=8; extra == 'test'
Requires-Dist: ruff>=0.12; extra == 'test'
Description-Content-Type: text/markdown

# owlrl-turbo

[![PyPI](https://img.shields.io/pypi/v/owlrl-turbo)](https://pypi.org/project/owlrl-turbo/)
[![Tests and wheels](https://github.com/legra-ai/owlrl-turbo/actions/workflows/ci.yml/badge.svg)](https://github.com/legra-ai/owlrl-turbo/actions/workflows/ci.yml)

Companion turbo projects: [pyshacl-turbo](https://github.com/legra-ai/pyshacl-turbo),
[rdflib-turbo](https://github.com/legra-ai/rdflib-turbo) and
[owlrl-turbo](https://github.com/legra-ai/owlrl-turbo).

Functional alpha of native RDFS and OWL-RL materialization for Python. Uses the
shared exact-term dataset runtime provided by rdflib-turbo, with native inference
extracted from pyshacl-turbo. There is no runtime dependency on Python owlrl or
pyshacl-turbo and no Python inference fallback.

```sh
pip install owlrl-turbo==0.1.0a2
```

```python
from rdflib_turbo import Dataset
from owlrl_turbo import expand

source = Dataset().parse(data='''
    @prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
    <urn:Person> rdfs:subClassOf <urn:Agent> .
    <urn:alice> a <urn:Person> .
''')
expanded = expand(source, inference="rdfs")
assert bool(expanded.query('ASK { <urn:alice> a <urn:Agent> }'))
assert len(source) == 2  # the default leaves the source unchanged

# Reuse the existing dataset handle and commit only on successful inference.
expand(source, inference="owlrl", inplace=True)
```

`expand(graph, inference="owlrl", inplace=False, destination=None)` accepts
rdflib_turbo.Dataset or RDFLib Graph/Dataset. Modes are rdfs, owlrl and both.
The return value has the input kind. Native inputs remain native between calls;
RDFLib inputs require a copy into the native runtime and conversion back.
RDFLib namespaces and blank-node identities are preserved. Named input contexts
are retained. RDFLib Dataset inference defaults to urn:owlrl-turbo:inference;
use destination to explicitly name the output graph for Dataset inputs.

Native operations release the GIL and hold a dataset lock throughout execution.
Inference commits only after successful native execution. Errors leave the source
unchanged. RDFLib inplace commits occur after native success, using RDFLib's normal
mutation API; external RDFLib stores do not acquire a new transaction guarantee.

This is **not a complete drop-in owlrl replacement**. DeductiveClosure classes,
custom Python rule hooks, owl:imports loading, configurable axiom/datatype options,
OWL-RL extensions and complete inconsistency diagnostics are not exposed. Inference
initialization follows pyshacl-turbo's pinned modes, rather than configurable owlrl
constructor flags. Full OWL-RL conformance and output parity are not claimed.

Output stays within standard RDF: literal subjects and non-IRI predicates are
excluded. Valid literal-valued consequences remain part of the contract. Native
owl:hasKey checks every property, intentionally differing from the pinned Python
reasoner's incomplete comparison. See [ADR 0001](docs/adr/0001-inference-contract.md).

For SHACL, pass expanded.to_rdflib() to pyshacl_turbo.validate(). This conversion
copies; pyshacl-turbo does not yet share the new dataset handle. No speedup claims
are made for this initial release. Requires Python 3.11+; rdflib-turbo supplies the
native platform wheel or builds its extension from source.

MIT OR Apache-2.0. Copyright 2026 DataRoad Inc, Delaware, USA, trading as Legra.

## Development

Use `make dev` and `make check`. The initial alpha is published only by the
verified GitHub Actions workflow; see [release instructions](docs/releasing.md).

Install rdflib-turbo first, then install this project with its test extra and run
`pytest`. Tests compare complete closures on bounded fixtures and exercise source
mutation, malformed inputs, standard RDF output and a pyshacl-turbo pipeline.

CI requires 100% measured Python package line and branch coverage. This does
not measure Rust coverage, full API compatibility or standards conformance.
