engine.rete_store

RDFLib store wrapper that materializes RETE inference per graph context.

Exceptions

RetractionRematerializeWarning

Warning emitted when a store removal is logically ineffective.

Classes

RETEStore

Context-aware RDFLib store that runs a RETE engine behind graph mutations.

Module Contents

exception engine.rete_store.RetractionRematerializeWarning

Bases: UserWarning

Warning emitted when a store removal is logically ineffective.

The engine still derives the removed triple, so RETEStore re-adds it to the backing context graph after the original removal pass completes. Callers that intend the triple to actually disappear must retract a supporting stated fact instead.

class engine.rete_store.RETEStore(store: rdflib.store.Store, factory: engine.rete_factory.RETEEngineFactory)

Bases: rdflib.store.Store

Context-aware RDFLib store that runs a RETE engine behind graph mutations.

store: rdflib.store.Store
factory: engine.rete_factory.RETEEngineFactory
engines: dict[axiom.common.ContextIdentifier, engine.rete_engine.RETEEngine]
engine_contexts: dict[axiom.common.ContextIdentifier, rdflib.Graph]
context_aware = True
graph_aware
formula_aware = False
transaction_aware = False
dispatcher
create(configuration: str) → None

Delegate store creation to the backing store.

open(configuration: str | tuple[str, str], create: bool = False) → _OpenResult

Open the backing store and warm engines for existing contexts.

close(commit_pending_transaction: bool = False) → None

Delegate store shutdown to the backing store.

gc() → None

Delegate garbage collection to the backing store.

add(triple: rdflib.graph._TripleType, context: rdflib.graph._ContextType, quoted: bool = False) → None

Add one triple after emitting a pre-mutation event on the raw dispatcher.

addN(quads: collections.abc.Iterable[rdflib.graph._QuadType]) → None

Add quads after emitting pre-mutation events on the raw dispatcher.

remove(triple: rdflib.graph._TriplePatternType, context: rdflib.graph._ContextType | None = None) → None

Remove triples after emitting pre-mutation events and flush re-materializations.

triples_choices(triple: rdflib.graph._TripleChoiceType, context: rdflib.graph._ContextType | None = None) → collections.abc.Generator[tuple[rdflib.graph._TripleType, collections.abc.Iterator[rdflib.graph._ContextType | None]], None, None]

Delegate triple choice iteration to the backing store.

triples(triple_pattern: rdflib.graph._TriplePatternType, context: rdflib.graph._ContextType | None = None) → collections.abc.Iterator[tuple[rdflib.graph._TripleType, collections.abc.Iterator[rdflib.graph._ContextType | None]]]

Delegate triple pattern iteration to the backing store.

contexts(triple: rdflib.graph._TripleType | None = None) → collections.abc.Generator[rdflib.graph._ContextType, None, None]

Delegate context lookup to the backing store.

query(query: rdflib.plugins.sparql.sparql.Query | str, initNs: collections.abc.Mapping[str, Any], initBindings: collections.abc.Mapping[str, rdflib.term.Identifier], queryGraph: str, **kwargs: Any) → rdflib.query.Result

Delegate SPARQL query execution to the backing store.

abstractmethod update(update: rdflib.plugins.sparql.update.Update | str, initNs: collections.abc.Mapping[str, Any], initBindings: collections.abc.Mapping[str, rdflib.term.Identifier], queryGraph: str, **kwargs: Any) → None

Raise because SPARQL Update is not supported without truth maintenance.

bind(prefix: str, namespace: rdflib.URIRef, override: bool = True) → None

Delegate namespace binding to the backing store.

prefix(namespace: rdflib.URIRef) → str | None

Return the prefix bound to namespace on the backing store.

namespace(prefix: str) → rdflib.URIRef | None

Return the namespace URI for prefix on the backing store.

namespaces() → collections.abc.Iterator[tuple[str, rdflib.URIRef]]

Iterate namespace bindings from the backing store.

commit() → None

Delegate transaction commit to the backing store.

rollback() → None

Delegate transaction rollback to the backing store.

add_graph(graph: rdflib.Graph) → None

Ensure an engine exists for graph and delegate graph addition.

abstractmethod remove_graph(graph: rdflib.Graph) → None

Raise because graph removal is not yet supported.