middleware.dataset_model

Schema-facing RDF dataset boundary models for Research Agent tools and state.

Design rules for these models are governed by: - docs/dev/architecture.md under “Structural elements and middleware” - docs/dev/decision-records/DR-011 Schema-Facing RDF Boundary Models.md

Attributes

N3GraphContext

Classes

N3Triple

RDF triple accepted in canonical N3 lexical form and serialized in N3.

N3Quad

RDF quad accepted in canonical N3 lexical form and serialized in N3.

MutationResponse

Response payload for state-mutating dataset tools.

NewResourceNodeResponse

Response payload when a blank node or IRI is defined.

SerializationResponse

Response payload for dataset or graph serialization.

SerializeRequest

Request payload for serializing dataset state.

TripleBatchRequest

Request payload for exact-match triple updates.

TripleListResponse

Response payload listing triples from the default graph.

Module Contents

type middleware.dataset_model.N3GraphContext = Annotated[Graph, SkipJsonSchema()]
class middleware.dataset_model.N3Triple(/, **data: Any)

Bases: _HasSpo

RDF triple accepted in canonical N3 lexical form and serialized in N3.

Use this model when a statement is scoped only by its subject, predicate, and object. See RDF 1.1 Concepts and Abstract Syntax § 3.1 RDF Triples.

model_config

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

property as_rdflib: axiom.common.Triple

Return this triple as an RDFLib (subject, predicate, object) tuple.

classmethod from_rdflib(triple: tuple[rdflib.Node, rdflib.Node, rdflib.Node]) → Self

Build an N3Triple from an RDFLib triple tuple.

class middleware.dataset_model.N3Quad(/, **data: Any)

Bases: _HasSpo

RDF quad accepted in canonical N3 lexical form and serialized in N3.

Use this model when the triple is asserted within a specific named graph given by graph_id. See RDF 1.1 Concepts and Abstract Syntax § 4 RDF Datasets.

model_config

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

graph_id: Final[axiom.common.N3ContextIdentifier] = None
property graph: N3GraphContext

Return the RDF graph context parsed from graph_id.

property as_rdflib: tuple[rdflib.IdentifiedNode, rdflib.URIRef, rdflib.Node, rdflib.graph.Graph]

Return this quad as an RDFLib (s, p, o, graph) tuple.

classmethod from_rdflib(quad: tuple[rdflib.Node, rdflib.Node, rdflib.Node, rdflib.IdentifiedNode | rdflib.graph.Graph | None]) → Self

Build an N3Quad from an RDFLib quad tuple.

class middleware.dataset_model.MutationResponse(/, **data: Any)

Bases: pydantic.BaseModel

Response payload for state-mutating dataset tools.

model_config

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

requested: pydantic.NonNegativeInt | None = None
updated: pydantic.NonNegativeInt = None
unchanged: pydantic.NonNegativeInt = None
inferred: pydantic.NonNegativeInt = None
retracted: pydantic.NonNegativeInt = None
no_action_needed: bool = None
message: str = None
class middleware.dataset_model.NewResourceNodeResponse(/, **data: Any)

Bases: pydantic.BaseModel

Response payload when a blank node or IRI is defined.

This resource is not in the knowlede base until it is asserted in a statement.

model_config

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

resource: str = None
class middleware.dataset_model.SerializationResponse(/, **data: Any)

Bases: pydantic.BaseModel

Response payload for dataset or graph serialization.

model_config

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

format: Literal['trig', 'turtle', 'nt', 'n3'] = None
content: str = None
default_graph_triple_count: pydantic.NonNegativeInt = None
is_empty: bool = None
message: str | None = None
class middleware.dataset_model.SerializeRequest(/, **data: Any)

Bases: pydantic.BaseModel

Request payload for serializing dataset state.

model_config

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

format: Literal['trig', 'turtle', 'nt', 'n3'] = None
class middleware.dataset_model.TripleBatchRequest(/, **data: Any)

Bases: pydantic.BaseModel

Request payload for exact-match triple updates.

model_config

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

triples: tuple[N3Triple, Ellipsis] = None
class middleware.dataset_model.TripleListResponse(/, **data: Any)

Bases: pydantic.BaseModel

Response payload listing triples from the default graph.

model_config

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

triples: tuple[N3Triple, Ellipsis] = None