ruml-python
The Python parser for RUML, the Rulemapping Logic Format: Pydantic models, parsing and validation. RUML is an open, JSON-based file format for the machine-executable representation of legal decision logic; the specification, the schemas and the conformance tests are in ruml.
RUML-Result is the companion format for the outcome of evaluating a rulemap. This library is the parsing/validation layer only — it has no evaluation logic.
Installing
pip install ruml-parser
It needs Python 3.14 or later.
Usage
Using RumlParser directly
As its name implies, RumlParser can be used to parse a rulemap from JSON text or a
decoded dict:
from ruml_parser import RumlParser
parser = RumlParser()
document = parser.parse_json(json_text) # or parse_dict(raw_dict)
document.nodes is a dict[LexId, Node]; lexId "1" is the rulemap root by convention
(RUML has no explicit root marker).
Using Pydantic
For easy interoperability with Pydantic and related frameworks (e.g. FastAPI), we also
provide a way to annotate a Pydantic field (or FastAPI parameter) such that it takes
rulemap-structured data (e.g. from JSON) as input and contains a RumlDocument once
parsed:
from pydantic import BaseModel
from ruml_parser import ParsedRumlDocument
class OuterModel(BaseModel):
document: ParsedRumlDocument # = Annotated[RumlDocument, ...]
Note that OpenAPI/JSON Schemas generated from ParsedRumlDocument will deviate from the
true RUML JSON Schema a bit due to being internally generated from a set of Pydantic
models that were themselves auto-generated from the original JSON Schema. Refer to
CONTRIBUTING.md for details.
ParsedRumlDocument can also be used if the RUML document is at the root of the JSON to
be parsed (even though, in this case, one might as well use RumlParser directly):
from pydantic import TypeAdapter
from ruml_parser import ParsedRumlDocument
document = TypeAdapter(ParsedRumlDocument).validate_python(raw_dict) # RumlDocument
Capability extensions
The schema leaves the payloads of draft and third-party capabilities free-form, and so
does the internal model. To work with typed models of such a capability, implement a
CapabilityExtension for it and pass it to RumlParser. The parser then validates the
capability's payloads against the extension's JSON Schemas (combined with the RUML
schema), parses its root-level declaration and node-level entries into types of the
extension's, and lets it check the capability's cross-object rules on the result:
parser = RumlParser(extensions=[MyCapabilityExtension()])
document = parser.parse_dict(raw_dict)
Naturally, document can't have any fields that are statically annotated as the types
associated with the extension, so helpers must be used for correctly-typed access:
declaration = document.capabilities.extension(MyCapability) # MyCapability | None
entries = document.all_node_capabilities_of_type(MyNodeCapability) # (lexId, entry)s
Contributing
Feedback is welcome as issues; pull requests are not accepted yet. See CONTRIBUTING.md.
For information relevant to development of ruml-parser itself, see DEVELOPMENT.md.
Licence
Apache-2.0, see LICENSE. Copyright 2026 Rulemapping Group GmbH.
Published by Law as Code Institut GmbH. RUML is a trademark of Rulemapping Group GmbH; an application for registration as an EU trade mark has been filed.
Metadata
Release files for ruml-parser 1.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| ruml_parser-1.0.0.tar.gz | 118.4 kB | With provenance | Details for ruml_parser-1.0.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| ruml_parser-1.0.0-py3-none-any.whl | Python 3 | none | any | Details for ruml_parser-1.0.0-py3-none-any.whl |
Total release size: 204.1 kB
Release files / ruml_parser-1.0.0.tar.gz
| Download URL | ruml_parser-1.0.0.tar.gz |
|---|---|
| Size | 118.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d36806e944f87df01634e7c1a21a7a1a22a2eceed335343d433690f706873da8
|
|
BLAKE2b-256 checksum How to use checksums |
83e08c4a6295c849c6104196f87bb2d77f7973f1e83c9eb48688152f4f08f42f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 16, 2026.
Transparency logRelease files / ruml_parser-1.0.0-py3-none-any.whl
| Download URL | ruml_parser-1.0.0-py3-none-any.whl |
|---|---|
| Size | 85.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
1cbce1af85f07a41c4b6929305407b1093db851bda7f09cf0a29162760a81675
|
|
BLAKE2b-256 checksum How to use checksums |
1cbe52ccdafd8f8ed81b0d7806243632bfe57b22ca5ab03975d70d912bac2032
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 16, 2026.
Transparency logSecurity for ruml-parser 1.0.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for ruml_parser-1.0.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 16, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.