deontic
A constraint language for obligation, permission and prohibition — the things a system must do, may do, and must not do.
Status: alpha. The grammar is implemented and reproduces the whole conformance corpus:
deontic.parsegives the AST,deontic.loadreads a dictionary anddeontic.resolvechecks a sentence against it. There is no evaluator in this package, by design; the corpus'sevaluate/cases are for implementations that add one.
Why a language rather than a library
Deontic statements are usually buried in imperative checks, where the rule and the enforcement of the rule are the same code. Writing them down as data makes them reviewable by the people who own the policy rather than only by the people who own the codebase, and lets more than one evaluator agree on what a rule means.
Design
docs/design.md states what the language is meant to be: the closed-class vocabulary, the shapes, filters and paths, attestation, the storage form, the interpretation rules, the outcome model, and how it relates to Attempto Controlled English and to deontic logic.
Conformance
conformance/ is the normative test data: source text plus the result every
implementation must agree on, kept as data rather than Python tests so that an
implementation in another language can consume it too. An implementation is
conformant when it reproduces the corpus. It has three parts — parse/
(source to AST, no lexicon needed), reject/ (source to error) and
evaluate/ (sentences, a world and a date to outcomes) — over one invented
fixture lexicon, and its README records the language decisions the cases fix.
Use
import deontic
ast = deontic.parse("Every $exhibit$ tagged fragile must @be located in@ a $gallery$ tagged storage.")
# {'shape': 'obligation', 'subject': {...}, 'predicate': {...}}
lexicon = deontic.load("conformance/lexicon.json")
deontic.resolve(ast, lexicon) # raises a ResolutionError with the corpus's error code otherwise
Sentences are authored as English and stored with markers on the typed
spans ($Term$, @verb@, #90 days#, <parameter>); editors write the
markers, people do not. A verb's meaning is a pattern in the dictionary
or, failing that, code under the contract in docs/hooks.md.
Install
pip install deontic
Stdlib only, no runtime dependencies — a grammar meant to be implemented by other people should not put a parser generator in everyone's dependency tree.
License
MIT.
Release files for deontic 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| deontic-0.1.1.tar.gz | 26.7 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| deontic-0.1.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 47.4 kB
Release files / deontic-0.1.1.tar.gz
| Download URL | deontic-0.1.1.tar.gz |
|---|---|
| Size | 26.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
4f49b1011c0ddb4f3fcd6bd8b9e6c0bde3a05613705cb84271f45b81adbf4ec1
|
|
BLAKE2b-256 checksum How to use checksums |
4d93a80bcab8d7f70fdace23331e8ffbfeaea1b38ee1da5f25ebeb5a77a8c11e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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 Sep 25, 2026.
Transparency logRelease files / deontic-0.1.1-py3-none-any.whl
| Download URL | deontic-0.1.1-py3-none-any.whl |
|---|---|
| Size | 20.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
fac750ab20949e1c6f11cf514cf2c2422abef4849fc76660a9cd54dafe96f110
|
|
BLAKE2b-256 checksum How to use checksums |
147dcb76ca7c1f622b74ed85efc3bf1f5ffbf58848023620084ef35b92b6ddd0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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 Sep 25, 2026.
Transparency log