Skip to main content

ontolint logo

ontolint

An offline ontology-quality linter for RDF, OWL, SKOS and SHACL. One command reads an ontology file, reports what looks wrong, and exits non-zero when a finding is serious enough to fail CI.

CI status Validation status (ROBOT image and mutation testing) PyPI version Python versions License: Apache-2.0

Rules implemented: 251 of 306 Offline first Formats: RDF, OWL, SKOS, SHACL

ontolint is an offline ontology-quality linter for RDF graphs. It provides graph-local checks for RDF/OWL, SKOS, lexical quality, class hierarchies, and optional SHACL validation. It is a practical review aid—not a substitute for OWL 2 DL validation, a reasoner, or expert ontology review.

Quick start

Python 3.13 or later. Install it, lint a file, fail a CI job on warnings:

uv tool install ontolint                  # or: pipx install ontolint
ontolint ontology.ttl                     # text report
ontolint ontology.ttl --fail-on warning   # exit 1 on a warning or an error
ontolint ontology.ttl --format sarif --output ontolint.sarif   # for code scanning

Exit 0 means no finding reached --fail-on, 1 that one did, 2 that the tool could not finish (see Exit codes). Nothing is sent over the network: ontolint reads the file and any imports you point it at.

Contents

Machine-readable interfaces

For scripts, CI and AI agents. Each interface is described in the section named in the last column. The JSON report carries schema_version (currently 1), but ontolint is still Alpha and the report has no published JSON Schema yet, so pin the version you parse against.

You want Run or read Where it is described
Every rule, with its id, status, severity, family, scope and backend ontolint --list-rules --format json Discovering rules
One rule's title, severity, fix and requirements ontolint --explain RULE_ID Discovering rules
The findings of a run ontolint FILE --format json (keys schema_version, summary, findings, execution_summary, rules, files) Run the linter
Findings for GitHub code scanning ontolint FILE --format sarif (SARIF 2.1.0) Run the linter, GitHub Action
Which rules ran, were skipped or failed files[].executions in the JSON report, and --format text Rule execution status
The measurements behind the METRIC rules, as numerators and denominators ontolint FILE --format json --measurements (files[].measurements) Measurements
One run's measurements with their term sets, a committed quality baseline, a trend between two snapshots --write-quality-snapshot FILE, --quality-baseline FILE, --compare-quality OLD NEW Quality snapshots and trends
The measurements as W3C DQV Turtle --write-dqv FILE Measurements as DQV
A pass or fail for CI the exit code: 0 pass, 1 findings, 2 tool failure Run the linter
Accepted findings that stay quiet --write-baseline FILE, then --baseline FILE Policy and baselines
ontolint inside a Python program from ontolint import Linter Run the linter
The rule documentation and its source docs/rules.md (generated: the index, and one page per family under docs/rules/), src/ontolint/data/rule_catalogue.csv Rule reference

A finding has a rule id, severity (error, warning, info), focus (the term it is about), message, suggestion and confidence. A finding is a review prompt, not a proof of inconsistency (see Interpretation principles). The project map for crawlers and agents is llms.txt.

What it checks

251 of the 306 catalogue rules are implemented; the rest are planned. The rule reference documents each one, with its specification and test cases, on one page per family.

  • 236 Python graph checks for metadata, identifiers, IRIs, labels and lexical quality, class hierarchies, OWL axioms and class expressions, SKOS, SHACL shape quality, governance, ontology metrics, mapping quality, input-safety hygiene and, opt-in, OBO Foundry and FAIR publishing conventions.
  • INPUT001 for RDF parsing failures.
  • SHACL001 for optional pySHACL validation results.
  • TOOL001 for configuration and execution failures.
  • SEM001 for opt-in ROBOT OWL-profile validation failures.
  • SEC001, SEC002, SEC003, SEC006, SEC009, SEC010, SEC011, SEC013 and SEC015 for unsafe inputs, rejected by the loader before linting (see below).

Each finding includes a rule identifier, severity, focus, message, suggested remediation, and confidence level. Rules are policy-oriented: a finding is not automatically a logical inconsistency.

Requirements and installation

Python 3.13 or later is required. ontolint is published on PyPI and installs a command named ontolint.

Install it as a standalone tool, isolated from your other Python packages:

# uv (recommended)
uv tool install ontolint

# or pipx
pipx install ontolint

# or into the current environment
python -m pip install ontolint

Run it once without installing it:

uvx ontolint ontology.ttl

Upgrade with uv tool upgrade ontolint, pipx upgrade ontolint or python -m pip install --upgrade ontolint. Check the installation with:

ontolint --version
ontolint --help

python -m ontolint works as well. Docker is needed only for --owl-profile.

To try the unreleased development version, install from GitHub instead, for example uv tool install git+https://github.com/arnaudgelas/ontolint. From a clone of the repository, uv tool install . installs the checkout and uv tool install --editable . keeps it linked to your working copy.

Development setup

uv sync --group dev

In a development checkout run the command through uv, for example uv run ontolint ontology.ttl. For a standard pip environment, install the package and its test tools:

python -m pip install -e .
python -m pip install pytest hypothesis pytest-gremlins pytest-xdist pytest-randomly pytest-archon

Run the linter

Use the library directly when integrating ontolint into Python applications:

from rdflib import Graph
from ontolint import Linter

graph = Graph().parse("ontology.ttl")
findings = Linter(graph, base="https://example.org/ont#").run()

The command-line interface is a thin wrapper around the same Python library (in a development checkout, prefix the commands with uv run):

# Text report
ontolint ontology.ttl \
  --base 'https://example.org/ont#'

# JSON report written to a file
ontolint ontology.ttl \
  --base 'https://example.org/ont#' \
  --format json --output report.json

# Fail a CI job for warning- or error-level findings
ontolint ontology.ttl --fail-on warning

Supported report formats are text, json, sarif and markdown, a summary for a pull request (see Pull-request summary (Markdown)).

Exit code Meaning
0 No finding meets the configured --fail-on threshold.
1 At least one finding meets the threshold.
2 Tool failure: unreadable input or configuration, an unknown rule selector, a usage error, a report that cannot be written to --output or encoded (TOOL001: report output failed: ...), or a requested rule that failed or is unsupported (for example --owl-profile without Docker, or a SHACL validation that exceeds --max-validation-seconds).
141 The reader of stdout or stderr closed the pipe before the output was written, as head does when a long report is piped into it. This is 128 plus SIGPIPE, the status a shell reports for cat, grep or git in the same case. Nothing is printed, and the report and the verdict are not delivered.

Exit 141 outranks 0 and 1 but not 2: a run that had already failed says so, and its TOOL001 lines still go to stderr. It happens only when a write really fails, so a short output that fits in the pipe before the reader leaves is delivered and exits as usual. A closed stderr (ontolint ... 2>&1 | head) ends the run with 141 at its first diagnostic, before there is a report; once the report is out it changes nothing. A report that cannot be flushed for another reason, a full disk for example, is TOOL001 and exit 2, as with --output. --help and usage errors keep argparse's 0 and 2. A closed pipe on Windows is reported by the operating system as OSError (EINVAL) and is not handled yet.

Exit 2 outranks 1: when a requested backend did not deliver a verdict the run cannot pass, even with --fail-on never. The report is still written so you can see why. Rules that are skipped (no shapes supplied, no OWL profile requested, ignored) never change the exit code.

Two advisory messages go to stderr and never change the exit code or the report: TOOL002 warns that --base selects none of the declared terms, and TOOL003 notes that a linted file looks like a SHACL shapes graph (more shapes than declared terms), which should probably be passed with --shapes instead. With --follow-imports, TOOL004 notes a catalog entry that names a missing file. TOOL005 notes when most terms without a definition (LEX002) carry an unrecognised predicate named like one, and suggests extra_definition_predicates; besides the built-in and configured lists, any predicate the ontology declares rdfs:subPropertyOf or owl:equivalentProperty one of them, directly or through a chain of such links (cycles are fine), already counts. TOOL006 says when --module-annotation cannot group a file (its prefix is not declared, or no term carries the predicate), TOOL007 names the validator --shapes-from-profile uses (or passes over, when it is not SHACL), TOOL008 warns that a file under --pattern-library does not parse and was skipped, TOOL009 names each shape library a shapes file imports, and TOOL010 warns that a file under --import-dir was skipped because the safe loader refused it (too large, compressed, an external DTD; the line gives the SEC rule and its message), so no import resolves to it.

Discovering rules

ontolint --version
ontolint --list-rules                 # table
ontolint --list-rules --format json   # machine-readable
ontolint --explain SHQ001             # title, severity, fix, backend, scope, requirements

--list-rules shows the catalogue status of every rule: implemented (built and run) or proposed (planned only; it has no severity or scope, cannot be selected and never runs). This is different from the per-run execution status below. In the JSON of --list-rules and --explain, selectable says whether --select and --ignore accept the rule: it is false for the proposed rules and for the pipeline rules (backend cli, see below), which are implemented but always apply. Before 0.12.0 it was true for every implemented rule; read status to tell implemented rules apart. --explain on an unknown identifier exits 2.

Selecting rules and profiles

--select and --ignore take rule identifiers (ONT001) or family prefixes (ONT), case-insensitively, comma-separated and/or repeated. Unknown selectors, empty entries (ONT,) and proposed-only rules are errors (exit 2), so a typo never becomes an empty run. So is a selector that names only pipeline rules (TOOL001: configuration failed: PipelineSelectorError: ..., before any input is read): the safe-loader refusals SEC001, SEC002, SEC003, SEC006, SEC009, SEC010, SEC011, SEC013 and SEC015, the diagnostics INPUT001 and TOOL001, and the INPUT and TOOL families. They are not findings and always apply, so no selection can change them (--list-rules --format json shows them with backend cli and "selectable": false). The SEC family is accepted: it selects or ignores the graph rules SEC004, SEC005, SEC007, SEC008, SEC012, SEC014 and SEC016.

--profile picks a bundle of defaults:

Profile Rules Severity overrides Default --fail-on
minimal ONT, IRI, DATA, SKOS, SHACL, SEM (structural integrity) none error
recommended all (same as no profile) none error
ci all none warning
strict all except SEC007 ONT003 becomes error info (any finding fails)
obo all, plus the opt-in OBO family none warning
fair all, plus the opt-in FAIR family none warning

Opt-in rule families. The OBO family (OBO Foundry conventions) and the FAIR family (offline publishing checks) never run by default: it is excluded from running without a profile and from recommended, ci, strict and minimal. Enable them with --profile obo, --profile fair, --select OBO, --select FAIR or a single id such as --select OBO003. --list-rules and --explain mark these rules as opt-in. An explicit --select replaces a profile's selection, so --profile obo --select LEX runs only LEX.

Precedence when options combine:

  1. The rule set is --select if given, else the profile's rules, else all rules. --select replaces the profile's selection.
  2. Ignores always win over selection: --ignore, the profile's ignores and the policy file's ignored_rules are unioned and removed. Policy ignored_rules remain exact identifiers, and an identifier there or in severity_overrides that names no implemented rule is an error (GOV020, exit 2), so a typo cannot silently leave a rule running. So is one that names a pipeline rule (see above): it always applies, so the entry could not change anything.
  3. Severity overrides: profile first, then the policy file's severity_overrides (policy wins).
  4. --fail-on: the command line, else the profile's value, else error.

Other policy values (base, languages, thresholds) behave as before: explicit CLI options beat the policy file.

Rule execution status

JSON and SARIF always say what happened to every selected rule, so "no findings" can never be confused with "not checked": executed, skipped (not applicable or ignored, with the reason), unsupported (backend unavailable, e.g. no pyshacl or Docker) or failed (the rule or backend raised). Rules that were deselected by --select/profile are simply absent. Text output stays unchanged unless a rule was ignored, unsupported or failed, in which case a Rule execution: block is appended.

  • JSON keeps summary and findings and adds schema_version (currently 1), a path on each finding, rules (id, family, title, effective and default severity, category, backend, scope, requirements, suggestion), execution_summary and per-file files[].executions. A finding whose message abbreviates a tool's output also carries the full output in details (SEM001: ROBOT's profile report, whose violations the message groups by kind). A finding whose backend returns a structured result carries it as an evidence object after details (SHACL001: every SHACL result property listed in "Optional SHACL validation"; text prints its path, value and nested causes); it is not part of the finding's identity, so fingerprints and baselines ignore it. In a dataset with named graphs, a finding also lists its graphs (see "Datasets: named graphs"). With --measurements, each file also carries its measurements (see "Measurements").
  • SARIF 2.1.0 adds tool.driver.rules (name, short/full description, help, defaultConfiguration.level, category/backend/scope properties), ruleIndex and an artifactLocation on every result (and properties.details, properties.evidence and properties.graphs where JSON has details, evidence and graphs), and a run invocation. Skipped, unsupported and failed rules are toolExecutionNotifications (levels note, warning, error); executionSuccessful is false when any rule failed or is unsupported.
  • SARIF findings for Turtle, N3, TriG, N-Triples, N-Quads and RDF/XML inputs include the source line and column of their focus term when it can be resolved; a term of a dataset is located where it is first spelled, whichever graph that is in. JSON-LD findings include a region for an explicit @id, including compact IRIs defined by a local context; generated JSON-LD nodes retain their artifact URI but omit a region rather than reporting an unreliable location.
  • A SARIF region spans the token its start points at, not the statement: startLine/startColumn are the first character of the focus's first spelling and endLine/endColumn the position one past its last (the end is exclusive, SARIF 2.1.0 section 3.30.9). The token is an IRI reference (<...> with its brackets), a prefixed name (without a ., ; or , written straight after it), a blank-node label, a JSON-LD @id string (with its quotes), or the whole start tag of the RDF/XML element that names the term (< to >, over as many lines as it takes). Columns count Unicode code points, as columnKind says (a tab is one, a character outside the Basic Multilingual Plane is one, and a line ends at \n in text syntaxes and at \n, \r\n or a lone \r in RDF/XML). A region has an end only when it can be told as surely as its start; if not, the result keeps startLine/startColumn and has no endLine/endColumn. That is the case for a blank-node label that may run on past what the scan reads (an inner dot, a non-ASCII letter) and for an RDF/XML file in an encoding other than UTF-8 or ASCII. Findings, fingerprints and baselines are unaffected: only the region of a located result gained two keys.

Measurements

The METRIC rules compare figures of the ontology (label coverage, orphan share, imports ...) with thresholds, and a figure shows only as a finding once it crosses its threshold. --measurements publishes the figures themselves, for every file, whatever the thresholds:

ontolint onto.ttl --format json --measurements

Each files[] entry gains measurements: every measurement behind METRIC001-METRIC013, plus the hierarchy-depth histogram (with the classes on a subclass cycle, which have no depth, counted apart), the number of disconnected parts of the asserted hierarchy and the SHACL class-target coverage. A record has an id, a definition_version, a kind and a population; a ratio is a numerator and a denominator, never a float, and a measurement that could not be taken (the SHACL coverage without --shapes) has a reason instead of a value, never 0. Findings, fingerprints, baselines and the exit code are the same with and without the flag, and it works with --format json only (otherwise a usage error, exit 2). There is no single health score. With module grouping, named graphs or --follow-imports, measurement_partitions gives the term measurements per module, graph or imported file, each term placed where its findings are. docs/measurements.md gives each measurement's population and exclusions.

A quality snapshot is a file with one run's measurements and, for each coverage measure, the sorted IRIs of its numerator and denominator, with the policy that shaped them. It serves two uses. Committed to the repository, it is a quality baseline (the accepted values; not --baseline, which suppresses findings). Two of them, kept by CI as artifacts, are a trend; ontolint reads no git history.

ontolint onto.ttl --write-quality-snapshot quality.json
ontolint onto.ttl --format json --quality-baseline quality.json   # also: --format markdown
ontolint --compare-quality last-week.json today.json              # --format text (default), json, markdown

The comparison tells a regression from a change of population, which aggregates cannot: for each coverage measure it counts the terms that got worse, the new terms that are worse (dilution), the removed terms and the terms that got better, with the exact ratio delta. A renamed term is a removal and a new term. A measurement whose definition version, kind, population or policy differs, or that one snapshot could not take, is reported as not comparable, measurement by measurement, never diffed. This reports; it does not gate. Neither option changes a finding or the exit code (a comparison exits 0 whatever it finds; 2 for an unusable snapshot), so a committed quality baseline does not stop a regression from passing CI; failing a build on the comparison is QUALITY-BUDGET (issue #26); the METRIC rules' findings and --fail-on judge one run against absolute thresholds, not a change from the baseline. A run without these options is unchanged. docs/quality.md documents the versioned snapshot format and the comparison.

Measurements as DQV

--write-dqv FILE writes the run's measurements as W3C DQV Turtle (one dqv:QualityMeasurement per integer value, computed on the ontology, generated by the run). It is opt-in, deterministic and masked; it is dated only when SOURCE_DATE_EPOCH is set, and a measurement that could not be taken is never published as 0. Its metric IRIs are in urn:ontolint:, which hosts nothing. docs/dqv.md gives the mapping.

Several files

ontolint ontologies/*.ttl --format sarif --output findings.sarif
  • Globbing is the shell's job (on Windows cmd/PowerShell pass the pattern through; use a shell that expands it or list the files). Directories are rejected with an error rather than walked.
  • Each file is linted independently with the same options and its own report; results are aggregated. Files are ordered by report path regardless of argument order, and duplicates (./a.ttl, a symlink, another spelling on a case-insensitive file system) collapse into one. If any file cannot be parsed, every parse failure is reported and the run exits 2 before linting. --shapes and --owl-profile apply to every file; ROBOT runs once per file. The one exception to independence is the set-level pair ONT007/ONT008, which compares the files with each other (see "One ontology in several documents").
  • Report paths (JSON path, SARIF artifactLocation.uri, fingerprints) are POSIX-style: relative to the working directory when the file is beneath it (onto/a.ttl), otherwise absolute (file:///C:/x/a.ttl in SARIF), with backslashes converted. Run from a stable directory such as the repository root so baselines and SARIF paths are portable.
  • Baselines: a baseline records each finding's identity under its report path, so a baseline written from one file applies to that file in a multi-file run, and a multi-file baseline to one of its files linted alone (the entries of the files not linted are then stale). A baseline written from one file still applies to a one-file run whatever the file is called. The version 1 fingerprints written next to the identities are unchanged: a single-file run hashes (rule, focus, message) and a multi-file run adds the report path (see "Policy and baselines").

One ontology in several documents

An ontology IRI names one ontology, and a version IRI one release of it. When two documents of a run declare the same one (<IRI> a owl:Ontology, or owl:versionIRI <IRI> on such an ontology), which of them a tool reads decides the result. ontolint compares the documents of a run in four places, each on its own:

  • the files given on the command line, each without its imports;
  • the files of one import closure (--follow-imports), including a file an import resolves to but does not load because a module loaded earlier already declares that IRI (which module wins then depends on the order of the imports, and the other one is missing from the lint);
  • the files of the --import-dir options that declare an IRI an import resolved through them: the import takes the first, in argument order of the directories and then path order, so the finding names every candidate and the one chosen;
  • the graphs of one TriG, N-Quads or JSON-LD file.

Two versions of one ontology share its ontology IRI under different version IRIs, which OWL 2 allows: an ODK x-edit.owl (no version IRI) linted next to its release x.owl (a dated version IRI), or two releases, are not reported. Among the inputs and the graphs of a dataset, a version IRI is reported whenever two documents declare it, and an ontology IRI when two documents declare it without a version IRI. In an import closure, which must not hold two versions of one ontology, any ontology IRI two files declare is reported.

ONT007 (warning) reports an IRI declared by documents whose content differs; ONT008 (info) reports identical copies. Content is the RDF graph, not the bytes: the syntax, the prefixes, the triple order and blank-node labels do not count. One fact is reported once, on the first input in report-path order (or on the input whose closure, import or dataset holds the documents), and belongs to the first document's file; the message lists all of them, and SARIF gives that file as the location and the others as related locations:

$ ontolint root.ttl --import-dir mirror
[WARNING] ONT007 https://example.test/units: owl:imports <https://example.test/units> matches 2 files in --import-dir mirror whose content differs: mirror/units-2024.ttl, mirror/units-2025.ttl; it resolved to mirror/units-2024.ttl, the first in path order.
    Fix: Keep one document per release: remove the stale copy, give every release its own version IRI, and give a fork its own ontology IRI.
    In: mirror/units-2024.ttl

These are the only rules that look at more than one file, so they are the deliberate exception to file independence above: adding a copy of a file to a run can add a finding to the run. A run of one file without imports or named graphs never has them, and when neither rule is selected nothing is compared. ONT007 is a warning, so it fails a run with --fail-on warning (and the ci, obo, fair and strict profiles); --ignore ONT007,ONT008 leaves them out. Baselines accept them like any finding; the identity is the rule, the IRI, the place and the kind, never the paths, so a baseline keeps accepting the finding on another machine, from another working directory, and when a copy is added, removed or renamed, even when that moves the finding to another file of the run (as long as the run reports it once and the baseline recorded it for one file).

Modular ontologies: following owl:imports

By default each file is linted alone, so an umbrella ontology that only owl:imports its modules checks almost nothing (SEC007 lists the imports that were not followed). With --follow-imports, ontolint loads the import closure from local files and lints it as one graph:

ontolint ontology.ttl --follow-imports                  # uses catalog-v001.xml next to ontology.ttl
ontolint ontology.ttl --catalog path/to/catalog-v001.xml  # an explicit catalog (implies --follow-imports)

Imports resolve through an OASIS XML catalog (the Protégé, ROBOT and ODK catalog-v001.xml: uri entries, also inside group, and rewriteURI prefixes) or as file: IRIs; the network is never used, and imports that do not resolve stay listed by SEC007. The catalog next to each imported file is consulted before the root catalog, as Protégé does, and an import naming a file already in the closure by its ontology or version IRI needs no entry. A catalog entry whose file declares neither the imported IRI nor a version IRI of it (a stale or mistyped entry, a file with no ontology header) is still loaded as the import, so no other finding moves, but ONT009 (warning) reports it once, naming the imported IRI, the file and the ontology IRIs the file does declare; file: IRIs, which name a document, and --import-dir files, matched by what they declare, are not checked. A catalog entry whose file does not exist leaves the import unresolved, with a TOOL004 note, rather than failing the run. Every resolved file must lie inside the import root after symlinks are followed (SEC009): by default the enclosing git repository of the catalog (or of the input without a catalog), so catalogs may point at sibling directories (../modules/x.ttl), or the directory given with --import-root DIR. For imports of published builds without a catalog (an upper ontology by its PURL, say), put local copies in a folder, for example with robot mirror, and pass --import-dir DIR (repeatable): its RDF files are matched by the ontology or version IRI they declare; when several declare one, the first directory in argument order that holds it, and its first file in path order, is used, and ONT007 or ONT008 names them all (aliases of one file, such as a latest symlink, count once). A file there that the safe loader refuses is skipped with a TOOL010 warning (an import it would have resolved is then reported by SEC007), and one that does not parse, or a catalog-v001.xml, is skipped silently. Ownership is decided by the root file's own terms, so an import that declares more terms than the root never becomes the linted ontology. Each file passes the usual safe loader, and the closure is bounded by max_import_depth (16), max_imported_files (100) and max_triples as a whole (SEC015). Cycles end and a module imported twice is loaded once. The headers of imported modules do not count as extra ontologies for ONT002.

A finding belongs to the module that declares its focus (gives it an rdf:type), or else to the first module that mentions it: JSON gives that module's path, SARIF its artifactLocation and region, and text adds an In: line. Baseline fingerprints and identities are unchanged, so a closure baseline keeps matching.

The closure is linted as one published ontology, the root's: header rules (ONT003-ONT006, GOV004 and the like) judge the root ontology only, as the modules inherit its metadata (lint a module on its own to check its header); owned terms are derived from the root IRI, so a vendored vocabulary with its own namespace is background, not judged; and METRIC011 does not count imports that resolved to local modules. Graph-wide heuristics (CLS002, METRIC* ratios) count the whole closure, data modules included, on purpose: a class that no module instantiates is exactly what CLS002 reports.

SHACL shapes often check the class of a vocabulary individual, which only the ontology states, so instance data validated alone reports false violations (and can silently pass where a target class is reached through a subclass). With --follow-imports, a shapes file that owl:imports the ontology supplies it: SHACL validates the data merged with that closure (inference off), reports only results about nodes the linted file mentions (as a subject or an object, so a sh:targetObjectsOf focus counts), and the term rules still judge the data file alone. A result also counts when one of the results nested in its detail is about such a node: SHACL reports an sh:node violation on the referencing node, which may be the ontology's, with the linted node as its cause. Such a finding is focused on the ontology's node, at its shape's severity, with no source region in the linted file. Every cause is looked at, however deep: the filter reads the report's sh:detail links itself and not the evidence, which keeps 8 levels. A result whose walk would pass 100,000 nested results in all (never pySHACL's) is kept, as nothing shows that it is the background's alone. An imported file that declares shapes is a shape library: its shapes are validated with too (a TOOL009 note names it), and its other triples, if any, join the ontology background.

ontolint data.ttl --shapes shapes.ttl --follow-imports   # shapes.ttl imports the ontology

Modules inside one file

Some ontologies keep their modules in one file. A MOMo schema marks each term with the module it is native to; a merged release keeps one namespace per source ontology. Two options group the findings by those modules, without changing any finding:

ontolint schema.ttl --module-annotation opla:isNativeTo   # an IRI, <IRI>, or a CURIE the file declares
ontolint release.ttl --module-by namespace                # each term's namespace is its module

A finding belongs to the modules of its focus; a local-name (IRI003) or label (LEX004) collision belongs to the modules of every term involved, so a collision between modules lists both. Text adds In: module X (or In: modules A, B) and a Findings by module: summary; JSON adds modules to each finding and module_summary (counts by severity) to each file; SARIF adds properties.modules. Findings whose focus is not an IRI, or whose term has no annotation, belong to no module. Fingerprints, identities and baselines are the same with and without grouping. The policy keys module_annotation (an absolute IRI) and module_by ("namespace") do the same; the two are alternatives, and a CLI option replaces the policy's choice.

Datasets: named graphs

A TriG, N-Quads or JSON-LD file can hold named graphs. ontolint lints the union of its graphs, so every rule runs once and a reference from one graph to a term described in another resolves. Each finding then names the graphs it comes from:

[INFO   ] LEX002 http://example.org/Thing: Term has no description or definition.
    Fix: Add a natural-language definition (rdfs:comment, skos:definition, or dcterms:description).
    In: graphs http://example.org/g1, http://example.org/g2

A finding names the graphs that describe its focus (state a triple with it as the subject), or, if none does, the graphs that mention it (a superclass that is only used). A collision (IRI003, LEX004) names the graphs of every term involved, as it names every module. A triple stated in two graphs belongs to both, so a term described in two graphs names both; the finding is still reported once. A finding whose focus is no node of the file ((ontology), a literal) names no graph, and neither does a finding about a pattern library member.

Graph names do not depend on where the file is read. The default graph is (default graph) and is listed first. A graph IRI is printed in full, except a file: IRI, such as a relative reference that resolved against the file (<rel> { … }, <../g> { … }, <#g> { … }): it is shown relative to the file, rel, ../g or #g, never as a file: IRI with a local path. A blank-node graph (_:g { … }) has a new label on every parse, so it is named by its content: _: and 12 hex digits of a digest of its triples. Two blank graphs with the same triples therefore share one name, and editing a blank graph renames it. An empty named graph names nothing.

Text adds In: graph X (or In: graphs X, Y), after an imported module's file and before the modules inside the file (a SHACL001 finding's Path:, Value: and Detail: lines follow it); JSON adds graphs to each finding, between path and modules; SARIF adds properties.graphs. All three appear only for a file with at least one triple outside its default graph, so every other file reports exactly as before. Like modules, graphs are presentation only: fingerprints, baselines and exit codes do not depend on them, and moving a triple to another graph keeps its findings baselined. The exception is ONT007/ONT008, which compare the graphs: an ontology header stated in two graphs is reported (see "One ontology in several documents"). In an import closure, each finding names the graphs of the file it belongs to.

Pattern libraries

A pattern library is an index ontology plus one ontology per pattern, linked by naming conventions rather than owl:imports. --pattern-library DIR lints the input as the index and the RDF files under DIR that declare an owl:Ontology as its members (the index itself is not one):

ontolint modl/modl.owl --pattern-library modl

LIB001 reports an index entry that names no member by IRI (its IRI is not a member's ontology or version IRI, no index triple points at one, and no member header names it); when a member has the same name (AgentRole and "Agent Role"), the message names it and how to link the two. LIB002 reports a member no entry names, and LIB003 a member header naming an IRI in the library namespace that no member declares (an opla-core:hasRelatedPattern to a missing pattern). Findings about a member belong to its file. Members are read like --import-dir files: through the safe loader, inside the import root (SEC009), at most max_imported_files (SEC015). A file that does not parse is skipped with a TOOL008 warning, and the rules then say what they report missing may be in one of the skipped files. Without the option the LIB rules are skipped.

Pull-request summary (Markdown)

--format markdown writes a summary of the run for the people who review a pull request, for example as the summary of a GitHub Actions step (the GitHub Action does this for you, and writes the SARIF report in the same step):

- run: ontolint ontology.ttl --baseline baseline.json --format markdown >> "$GITHUB_STEP_SUMMARY"

It shows the verdict and the exit status, the findings per severity (new and baselined ones when --baseline is given), the rule execution counts, the rule runs that delivered no verdict and so cause exit 2, the first 50 findings, most severe first, and the stale-baseline note. It names a finding's file when the run has several or the finding is about an imported module. It carries no suggestions, modules, named graphs or source regions: the SARIF report lists every finding with them, and needs a second run (--format sarif). The exit code is the one every format gives, so the step above fails on findings or a tool failure after it has written the summary. --list-rules and --explain print their text form.

Every text the report supplies (rule ids, foci, messages, paths, the detail of a rule run) is shown as it is, inside a code span, so a label such as [x](https://evil.test), <img src=x> or @team cannot become a link, an image, HTML or a mention, and none is placed in a table. Line breaks, control, bidi-control, zero-width and tag characters, variation selectors, the other characters Unicode calls default-ignorable (unassigned ones included) and lone surrogates are shown as escapes (\n, \u202e, \U000e0001, \ufe0f), and every IRI userinfo is masked, as in every output. A rule id is cut at 40 characters, a focus and a path at 200, a message and a detail at 300, and at most 20 rule runs without a verdict are listed (stderr has every one), so a summary never exceeds 512 KiB, half of GitHub's limit of 1 MiB per step. It is byte-identical across runs for one Python version (a later Unicode database may show more characters as escapes). The layout is for people and may change in a minor release; parse JSON or SARIF instead.

GitHub Action

action.yml at the root of this repository is a composite Action. uses: arnaudgelas/ontolint@vX.Y.Z runs ontolint X.Y.Z: the Action reads the version from the pyproject.toml of the commit the tag points to and installs exactly that release from PyPI (never the latest) after checking its PyPI attestation, with its dependencies from action/requirements.txt, a hash-locked export of uv.lock. One step lints the files and writes both reports, so a job needs no second run of its own:

permissions:
  contents: read
  security-events: write # only for the upload step below
jobs:
  ontolint:
    runs-on: ubuntu-latest # Linux or macOS runners; the Action's shell steps are bash
    steps:
      - uses: actions/checkout@<sha> # pin every action by commit
        with:
          persist-credentials: false
      - id: ontolint
        uses: arnaudgelas/ontolint@vX.Y.Z # or the commit the tag points to
        with:
          files: |
            ontology.ttl
            modules/
          fail-on: error
      - uses: github/codeql-action/upload-sarif@33d7b85da1a04171e211befe2c739303b9a4c066 # v4.39.3
        if: ${{ !cancelled() && hashFiles('ontolint.sarif') != '' }}
        with:
          sarif_file: ${{ steps.ontolint.outputs.sarif-file }}
Input Meaning
files (required) Files or directories, one per line, inside the workspace (symlinks resolved; anything outside is refused).
args More ontolint options, one argument per line (--profile and strict on two lines). --format, --output, --measurements, --list-rules, --explain, --version and --help are refused, abbreviations included: the Action chooses the report format and file.
fail-on error, warning, info or never; empty keeps ontolint's default.
sarif-file Where to write the SARIF report (default ontolint.sarif); it must resolve inside the workspace.
summary true (default) appends the Markdown summary to the job summary.

Outputs are sarif-file, summary-file (the Markdown summary, kept until the job ends) and exit-code (0, 1 on findings at or above fail-on, 2 on a tool failure). The Action runs ontolint twice, once per format (--format markdown, then --format sarif), and writes both reports before the step fails, so run the upload with !cancelled(). A tool failure (exit 2) can leave no SARIF file, hence the hashFiles guard above.

What the Action does and does not do:

  • It asks for no token and needs no permission. It does not upload the SARIF report: uploading needs security-events: write, which a caller grants to the one job that needs it, and a caller can also keep the report as an artifact. The upload step above is the caller's.
  • Every input reaches the Action as an environment variable, never inside a shell command. The child process gets only PATH, HOME, locale and temporary-directory variables, not the job's secrets, and everything ontolint prints is wrapped in ::stop-commands:: with a token drawn for that run, so text from an ontology cannot become a workflow command.
  • Every action it uses and the uv version are pinned; Renovate keeps them current. uv installs the dependencies, and the program that checks the attestation (action/verify-requirements.txt), with --require-hashes, from https://pypi.org/simple whatever the caller's index settings are.
  • The ontolint wheel is verified, not hash-pinned: a wheel's hash cannot be in the commit that is tagged before the wheel is published. The Action downloads the one ontolint-X.Y.Z-py3-none-any.whl that PyPI lists (from files.pythonhosted.org, against the sha256 PyPI lists, which only shows the download is whole), runs pypi-attestations verify pypi --repository https://github.com/arnaudgelas/ontolint on it, and installs that same file, offline, only when it passes. The attestation (PEP 740, a Sigstore signature that Trusted Publishing makes at upload) shows that these bytes were published by this repository's release workflow through PyPI's Trusted Publisher, so a file that someone with a PyPI token uploaded, or that PyPI or a mirror altered, is refused. What you still trust: the Sigstore trust root and this repository's release workflow and PyPI Trusted Publisher configuration (an attestation names the repository, not the tag or the commit), the hash-locked verifier and dependencies, and the tag itself, which selects the version. If PyPI or Sigstore is unreachable the step fails; it never installs an unverified wheel.
  • files (and sarif-file) must resolve inside GITHUB_WORKSPACE, symlinks included, and ontolint runs from the workspace. A file outside it (../x, an absolute path, a link that leaves) is refused; copy or check out what you lint into the workspace first.
  • Code scanning ignores SARIF property bags, so properties.evidence and the suggestions do not reach its interface (the SARIF file and the --format json report keep them). ontolint writes no partialFingerprints yet, so code scanning computes its own from the source line, and results that share a rule and a line may be shown as one alert.
  • --convert-with-robot (Docker) is not available in the Action.

There is no --format github: workflow commands cap the annotations per step and job, so findings reach GitHub as SARIF and as the summary. The one workflow-command helper, ontolint.github.escape_data, escapes the Action's own error annotations.

Optional SHACL validation

Pass a shapes graph with --shapes to enable pySHACL validation:

ontolint ontology.ttl --shapes shapes.ttl

The integration uses meta_shacl=True and advanced=True, with inference="none" and the network disabled (see "Input safety" for what that admits). Newer SHACL draft features are not guaranteed to be supported. Shapes can make validation run for a long time; --max-validation-seconds (or max_validation_seconds in the policy) stops it, and SHACL001 then fails (exit 2).

A shapes graph that breaks SHACL-SHACL (SHACL's own shapes for shapes graphs: a property shape without sh:path, a non-IRI sh:targetClass, a sh:minCount that is not an xsd:integer, ...) is refused by pySHACL before any data is validated, so SHACL001 has no verdict: it is failed and the run exits 2, as for any rule run without a verdict. The rule-execution line says only the shapes graph does not conform to SHACL-SHACL; stderr has the TOOL001 line and, under it, one line per MetaSHACL result (<shape>: <path>: <message>, at most 20 then a count, each cut at 300 characters, userinfo masked, control characters escaped), once. A line ends with (SHQ023), (SHQ008), (SHQ014) or (SHQ022) when that rule reports the same defect, so --select SHQ,SHACL shows the finding that names it; the other defects, which no SHQ rule reports (sh:uniqueLang on a node shape, several sh:severity values), have no pointer, and neither has a typed sh:NodeShape with sh:path, which SHACL-SHACL accepts and pySHACL then refuses with its own load error. JSON and SARIF keep the same lines as results of the execution (executions[].results, toolExecutionNotifications[].properties.results), present only when there are some; the text summary and the Markdown summary show the one line. Fix the shapes graph and run again.

When a W3C PROF profile names the shapes (prof:hasResource [ prof:hasRole role:validator ; prof:hasArtifact <…/validator> ]), let the profile say which:

ontolint ontology.ttl --shapes-from-profile profile.ttl

Each SHACL validator of the profile (a descriptor whose dct:conformsTo names SHACL, or nothing) is found offline, in this order: the catalog next to the profile or --catalog, --import-dir by ontology or version IRI, or a file beside the profile named after the IRI's last path segment (…/validator → validator.ttl). It must lie inside the import root (SEC009). Several validators are merged; a validator of another standard is passed over with a TOOL007 note. A profile that names no SHACL validator, or one with no local copy, fails the run (TOOL001, exit 2). --shapes and --shapes-from-profile are alternatives.

Each result the SHACL report lists (sh:result) becomes a SHACL001 finding at its own severity, which for an sh:node violation is the referencing shape's: sh:Violation is error, sh:Warning is warning and sh:Info is info, so warnings-only data passes the default --fail-on error. A custom severity is reported as error and named in the message. Blank-node shapes and focus nodes are named by a content-stable identity, in the focus and in a finding's baseline identity alike, so baselines keep matching across runs.

In JSON and SARIF, each SHACL001 finding also carries every SHACL result property listed below as evidence (properties.evidence in SARIF), so two violations of one shape on one node, which share their message, still say which value or path to fix. Its keys are the SHACL names of the result's properties, in this order, each present only when the report has it: focusNode, resultPath, value, sourceShape, sourceConstraintComponent, sourceConstraint (SPARQL-based constraints), detail, resultMessage (every message, sorted, without language tags) and resultSeverity (the original IRI, also for a custom severity). SHACL-AF result annotations (sh:resultAnnotation on a SPARQL-based constraint or constraint component; SHACL Advanced Features, section 4 "Annotation Properties") are not implemented by pySHACL 0.40.2, so they appear neither in its report nor in the evidence; a canary test fails when a pySHACL upgrade starts writing them. An IRI is written as is, a blank node by the same content-stable _: identity as a focus, and a literal as one N-Triples term on one line ("x", "5"^^<http://www.w3.org/2001/XMLSchema#integer>, "chat"@fr, with \", \\, \n and \r escaped), so a literal focus is "x" in the evidence but x in focus. A path other than a single predicate is written in SPARQL property-path syntax (^<p>, <a>/<b>, <a>|<b>*); a malformed, cyclic, or over-deep or over-large one is (malformed path). detail lists the nested results of a sh:node (or similar) violation as evidence objects, sorted, at most 8 levels deep. A nested result explains its parent (SHACL 3.5): it is part of the parent's evidence, not a finding of its own, although pySHACL types it as a validation result too. Only a report that lists no result through sh:result (never pySHACL's) has each typed result as a finding. Only the report node pySHACL writes, the object of no triple, is read: pySHACL copies into its report every triple reachable from a blank value, so data shaped like a report or a result adds no finding. A result nested deeper than 8 levels is not copied: the evidence of the deepest result kept carries detailTruncated: "true" (after detail, before resultMessage; absent everywhere else, and absent when the only sh:detail left leads back to a result above it), so a reader knows a cause was dropped. The top-level result still is a finding, and still fails the run. The evidence copies each value in full, so a report with many results on long literals grows accordingly. Findings with the same message are ordered by their evidence, so the output no longer depends on pySHACL's hash-seed-dependent result order. The message, focus, severity and fingerprint are unchanged. A baseline identity is made of the source shape, constraint component, path, value and SPARQL constraint, so a pySHACL upgrade that rewords its messages keeps results accepted. The version 1 fingerprint (by message) still accepts a result, but only in place of an accepted one that is gone: a new result whose message equals an accepted one's (another bad value of the same shape on the same node) is reported while that one is still found, and a bad value replaced by another with the same message stays accepted, as in 0.10 (see "Policy and baselines").

Text prints part of the evidence after the Fix: line and any In: line: Path: (the resultPath), Value: (the value, left out only for a node-level result, one without a path, whose value is its focus) and, for each result nested in detail, in evidence order, a Detail: line that reads like that result's own finding header (<focus>: <messages> [shape: <source shape>], the focus spelled as in the evidence, so a literal is "x"), followed by that result's own lines two spaces further in, and (further nested results omitted) after the lines of a result whose evidence is detailTruncated:

[ERROR  ] SHACL001 https://example.test/a: Value does not conform to Shape <https://example.test/N>. See details for more information. [shape: https://example.test/Knows]
    Fix: Fix the supplied SHACL shapes or data, and inspect the SHACL report.
    Path: https://example.test/knows
    Value: https://example.test/b
    Detail: https://example.test/b: Value is not Literal with datatype xsd:integer [shape: https://example.test/Age]
      Path: https://example.test/age
      Value: "old"
    Detail: https://example.test/b: Less than 1 values on ex:b-><https://example.test/name> [shape: https://example.test/Name]
      Path: https://example.test/name

Each of these lines is one line of visible characters: control, format (bidi, zero-width), surrogate, private-use and separator characters other than a space are written as N-Triples escapes, \uXXXX or \UXXXXXXXX, so a lone surrogate in a value does not make the text report unwritable (one in a finding's focus or message, which the header prints as is, still gives TOOL001, exit 2). A literal value is then still an N-Triples term that reads back as itself, except a lone surrogate: it is not a valid RDF string, it is shown as its code unit, and an escaped high and low surrogate side by side read back as one character. IRIs and messages are printed bare, so a backslash in one (\u001B written literally in a JSON-LD IRI) reads like an escape. Text shows neither a nested result's severity nor sourceConstraint, so two SPARQL constraints of one shape whose results share path and value read alike in text; JSON tells them apart. Fingerprints, baselines and exit codes do not depend on these lines.

The data graph of a TriG, N-Quads or JSON-LD dataset is the union of its graphs, as for every other rule: SHACL defines the validation of one data graph, and a value typed in one graph and referenced from another conforms to sh:class. A SHACL001 finding names the graphs of its focus node (see "Datasets: named graphs"). To validate each graph on its own, write each one to its own file and lint the files together; each file is validated separately.

OWL profile validation with ROBOT in Docker

Build the minimal project image once. Its final stage contains only the ROBOT JAR and a non-root Java runtime:

docker build --tag ontolint-robot:1.9.11 docker/robot
ontolint ontology.ttl --owl-profile DL

The profile run mounts the ontology directory read-only, disables container networking, drops Linux capabilities, and applies CPU, memory, process, and timeout limits. The image build verifies the ROBOT JAR against a pinned SHA-256. Supply a digest-pinned image with --robot-image in CI.

SEM001 is reported only when ROBOT lists profile violations. Any other failure (a missing image, a Docker, Java or permission error) is no verdict on the ontology: the rule is failed, with ROBOT's output in its detail, and the run exits 2, as for a timeout. A profile pass says the ontology fits the profile; it does not say the ontology is consistent.

Policy and baselines

A JSON policy can supply a base IRI, label-language requirements, thresholds, ignored rules, and severity overrides.

{
  "base": "https://example.org/ont#",
  "languages": ["en"],
  "depth_limit": 10,
  "inheritance_limit": 5,
  "soup_limit": 15,
  "subclass_limit": 50,
  "ignored_rules": ["CLS002"],
  "severity_overrides": {"ONT003": "error", "OWL005": "info"},
  "required_annotations": {"class": ["http://www.w3.org/2004/02/skos/core#definition"]},
  "alignment_namespaces": ["http://purl.obolibrary.org/obo/"],
  "alignment_min_coverage": 0.5,
  "max_parse_seconds": 60,
  "max_validation_seconds": 120,
  "module_by": "namespace"
}

The optional keys switch rules on only when set: required_annotations maps a term kind (class, property, individual, concept) to the predicates every owned term of that kind must carry (GOV016); alignment_namespaces lists the namespaces mapping targets must belong to (ALIGN012); alignment_min_coverage is the share of classes and properties that must have a mapping (ALIGN016). subclass_limit (also --subclass-limit, default 50) is the most direct subclasses a class may have before CLS011 reports it. Unknown keys are reported by GOV020, and an unsupported policy_version rejects the file. max_parse_seconds (also --max-parse-seconds) limits the time spent parsing one input and reports SEC003 when it is exceeded; it parses in a worker process, so leave it unset for the fastest in-process load. max_validation_seconds (also --max-validation-seconds) does the same for SHACL validation: past it the validation is stopped and SHACL001 is failed (no finding, TOOL001 on stderr, exit 2, as for a ROBOT timeout). It counts from the moment the worker process has imported pySHACL, once per linted file, and includes handing the data and shapes graphs to the worker. It has no effect without shapes. Neither key inherits the other.

The metric_* keys set the thresholds of METRIC001-METRIC013. Each is validated (an invalid value is TOOL001, exit 2) and has no flag or profile value; docs/metric-thresholds.md lists every key with its default, the rationale and the offline measurements.

# Emit SARIF using a policy
ontolint ontology.ttl \
  --config policy.json --format sarif --output findings.sarif

# Record accepted findings, then report only newly introduced ones
ontolint ontology.ttl --write-baseline baseline.json
ontolint ontology.ttl \
  --baseline baseline.json --fail-on warning

A baseline file (version 2) records every finding of the run twice. fingerprints lists the version 1 hash of (rule, focus, message), plus the report path in a multi-file run, exactly as ontolint 0.10 wrote it. identities maps each report path to the finding's identity, a hash of its rule, focus and subject. The subject is what the finding is about besides its focus: the predicate, the other term, the literal, the language. It never includes the message, counts, ratios or thresholds. files lists the report paths of the run. --baseline accepts a finding when its identity is recorded for its report path, or its fingerprint is recorded, so:

  • rewording a message, a pySHACL upgrade, or a measurement that changes (a METRIC* ratio, an OWL004 count, ROBOT's SEM001 summary) no longer reopens an accepted finding. This loosens gating on purpose: a metric ratio that rises further stays accepted, and SEM001 stays accepted until the profile passes;
  • identities are matched per report path (see "Several files"), so one-file and multi-file baselines carry over to each other.

Two findings of one file that share an identity are recorded and matched by fingerprint only, so an incomplete subject does not let an accepted finding hide another with a different message.

A fingerprint that the file pairs with an identity accepts a finding only in place of an entry of that fingerprint whose identity no finding of the run holds, each such entry once, in report order. So a finding whose subject a later release refines stays accepted (its old identity is gone, and its fingerprint takes the place), but a new finding whose message equals an accepted one's, such as a second bad value of one SHACL shape on one node, is reported while the accepted one is still found. Fingerprints the file pairs with no identity (a 0.10 file, or findings that shared an identity) accept every finding with them, as before. The limits: a problem fixed and another with its message introduced in one change stay accepted, as in 0.10; findings that shared an identity when the file was written, and that become unique (a later release tells them apart, or all but one of them is fixed), are reported once when a unique finding has their message; when a refined finding and a new one with its message coincide, report order decides which one is reported; and new findings that share an identity are still matched by fingerprint.

A baseline written by 0.10 (no version, only fingerprints) keeps its old behaviour until it is regenerated once with --write-baseline. ontolint 0.10 reads a version 2 file's fingerprints and ignores the rest, but drops identities if it rewrites the file. Deleting a line from fingerprints withdraws that finding's identity too. A file whose fingerprints, files, version or identities has the wrong shape (a version below 1, identities for a path missing from files), or that is not JSON, exits 2 (TOOL001: lint execution failed: BaselineError: …). Unknown keys are ignored, and a later version is read for the sections this one knows. Baselines are useful for incremental adoption, but are not semantic version comparisons.

A baseline entry (a fingerprint and its identity) that matches no finding of the run by either hash is stale: the finding was fixed, or its rule was not selected this time. Every format reports stale entries (a note in text and SARIF, the list of their fingerprints baseline.stale_fingerprints in JSON), and --fail-on-stale-baseline makes them exit 1 so CI asks for the baseline to be regenerated. A reworded finding matched by its identity is not stale. Run with the same rule selection that wrote the baseline, or entries for unselected rules will count as stale.

Development and quality checks

The gates CI enforces on every change: Ruff (lint and format), pyright in strict mode and mypy (host and Windows), tests with at least 95 % coverage, a dependency audit, and a distribution build; scheduled/manual mutation testing targets at least 85 % of mutants killed (policy). Dependencies are managed with uv.

# The full validation gate, exactly as CI runs it (add --fix to apply Ruff fixes first)
uv run python scripts/gate.py

# Unit and property-based tests (coverage must stay at or above 95%)
uv run pytest -q

# Run tests in parallel
uv run pytest -q -n auto

# Skip the slow Hypothesis and fuzz tests
uv run pytest -q -n auto -m 'not slow'

# The order is shuffled on every run (pytest-randomly); the seed is in the header. Replay a failing
# order with it, or switch shuffling off
uv run pytest -q -p randomly --randomly-seed=12345
uv run pytest -q -p no:randomly

# The package's layering (pytest-archon): rule modules never import the CLI, and so on
uv run pytest -q --no-cov tests/test_architecture.py

# Metamorphic tests (tests/test_metamorphic_*.py, helpers in tests/metamorphic_support.py): each applies a
# transformation whose effect is known and asserts that relation, with no expected findings to maintain.
# Serialisation, Turtle noise, duplicate triples and islands, multi-file runs, policy knobs, baseline round
# trips, report formats and namespace renaming each have a file
uv run pytest -q --no-cov tests/test_metamorphic_*.py

# Type checks
uv run pyright && uv run mypy && uv run mypy --platform win32

# Mutation testing (opt-in; the order stays fixed)
uv run pytest -p no:randomly -m 'not slow' --gremlins --no-cov --gremlin-parallel --gremlin-cache

# Lint and format the project
uv run ruff check . && uv run ruff format --check .

Hypothesis tests generate RDF graphs and check properties of the linter, such as deterministic output and agreement of cycle diagnostics with an independent reachability oracle. A mutation-based fuzzer (tests/fuzz/) feeds mutated files to the loader, the rules and the CLI. Both are marked slow; run the longer profile with HYPOTHESIS_PROFILE=ci-deep. Mutation testing targets the engine, linter, CLI, loader, reporting, source locations, adapters and rules (see docs/mutation-policy.md). To add rules, see docs/adding-rules.md.

Releasing

uv run python scripts/bump_version.py {major|minor|patch|X.Y.Z} updates the version files and CHANGELOG.md; it never commits, tags or pushes. See docs/releasing.md.

CI workflows

.github/workflows/ci.yml runs scripts/gate.py: Ruff, Pyright, mypy (host and Win32), tests with coverage and warnings as errors, pip-audit and the package build. All actions are pinned to commit SHAs and the uv version is pinned; Renovate keeps both current (its one configuration is renovate.json, which automerges only non-major updates of the dev tools and the pinned actions, and the monthly lock file refresh, once CI passes).

.github/workflows/fuzz.yml runs the mutation fuzzer weekly with a longer budget per target and uploads any crashing input.

.github/workflows/release.yml runs on a vX.Y.Z tag: it calls the CI workflow, requires a green CodeQL scan of the tagged commit, checks that the tag matches the version in pyproject.toml, builds the distributions, publishes them to PyPI with Trusted Publishing from the pypi environment, installs the published version from PyPI and lints a file with it, and finally runs the GitHub Action at the new tag on a fixture.

.github/workflows/validation.yml runs weekly and on manual dispatch:

  • ROBOT Docker image build and smoke test (also on pull requests that touch docker/ and carry the validation label). Logs are uploaded as artifacts.
  • Mutation testing with the command above plus JSON/HTML reports, followed by .github/scripts/mutation_gate.py, which enforces the per-operator and overall thresholds. Reports are uploaded as artifacts.

The operators, thresholds, scope, waiver process and blocking/advisory rules are defined in docs/mutation-policy.md.

Rule reference

docs/rules.md is the index of every rule, by family. Each family's page under docs/rules/ documents its rules with their severity and fix, their specification (quoted from the docstring of the module that implements them, with the notes the module's rules share), then every flagged and every clean test case, each flagged graph case with the message the linter reports (a case run through the command line or an adapter shows none). Rules that are not implemented yet are listed as TODO. The pages are generated; regenerate them with uv run python tests/rule_docs_generator.py.

Interpretation principles

  1. RDF syntax validity and OWL logical consistency are different properties.
  2. SHACL validation does not establish ontology-design quality.
  3. Multiple RDFS domains or ranges are conjunctive, not alternative choices.
  4. Under OWL's open-world assumption, missing evidence is not falsehood.
  5. A subclass cycle is a review warning, not automatically an inconsistency.
  6. owl:allValuesFrom does not imply the existence of a value.
  7. A SKOS broader cycle is informational; it is not universally prohibited.
  8. The linter never fetches URLs; it resolves owl:imports only to local files, and only with --follow-imports or --catalog.
  9. Semantic OWL axioms are never auto-fixed because intent cannot be inferred reliably.

Scope and limitations

  • Term-level rules only judge terms the file owns. With --base the base decides (a base such as http://purl.obolibrary.org/obo/RO_ is a plain prefix; a warning is printed when it selects no declared term). Without it the owned namespaces are derived from the owl:Ontology IRI(s) (the IRI, the IRI without #///.owl, and for OBO ontologies the .../obo/<NAME>_ ID space); RDF/RDFS/OWL/XSD terms are never owned, and if no declared term matches, every declared term is treated as owned.
  • Definitions are read from rdfs:comment, skos:definition, dcterms:description, dc:description, obo:IAO_0000115, obo:IAO_0000600, prov:definition and the Common Core Ontologies 1.x <http://www.ontologyrepository.com/CommonCoreOntologies/definition>; labels from rdfs:label and skos:prefLabel. Add more with the policy lists extra_definition_predicates and extra_label_predicates (absolute IRIs). A predicate below a definition or label predicate, built-in or extra, is one too: one the ontology declares rdfs:subPropertyOf it or owl:equivalentProperty to it (either way round), directly or through a chain mixing both (ex:p ≡ ex:q ⊑ skos:definition; cycles are fine). Only asserted triples of the linted graph count (the merged closure under --follow-imports), and only downwards and sideways: a super-property of skos:definition is no definition. skos:altLabel and skos:hiddenLabel, which the SKOS schema puts below rdfs:label, and the predicates below them are never labels. Such a predicate gives a term a label (LEX001, METRIC001, SKOS004, CLS015, and an index entry's name for LIB001 and LIB002) and its values are judged as labels (LEX005, LEX010-LEX014, LEX017, LEX018, LEX021, LEX022, METRIC009), and any label in a language satisfies LEX008. The rules that compare a term's labels (LEX003, LEX004, LEX006, LEX015, LEX016, CLS010) read its main labels: its values of rdfs:label, skos:prefLabel, extra_label_predicates and the predicates below skos:prefLabel (preferred labels by entailment). A sub-property of rdfs:label or of an extra beside them is a specialised label, such as BFO 2020's untagged OWL and CLIF specification labels, not a second label, a plain label mixed with tagged ones or a collision; only a term with no main label is named by its specialised labels, so it has main labels exactly when LEX001 finds a label. Under --follow-imports an imported vocabulary's axioms count as well: importing MOD, which declares mod:acronym below rdfs:label, makes an acronym a label of the importing file's terms (judged by LEX005, LEX012 and the others). The label readers SKOS001, LEX009, CLS013 and CLS020, and the alternative labels of LEX015 and LEX016, still read fixed predicates. LEX002 also accepts skos:note, skos:scopeNote and the predicates below them, whatever their value says, except SKOS's skos:changeNote, skos:editorialNote, skos:historyNote and skos:example and those below them, which did not document a term before 0.13.0 either; to the other rules a note is no definition. The OBO rules keep their fixed predicates (OBO003 reads obo:IAO_0000115 and obo:IAO_0000600 only).
  • With --shapes, the SHACL step first checks the shapes graph and reports SHACL001 as failed with ShapesRejected when pySHACL would crash or stall on it: an IRI that rdflib cannot serialise (such as {, }, |, ^, a space or a quote), a cyclic rdf:list, a list cell with several rdf:rest values, a list shared by several lists, a list longer than 400 items, or lists whose squared lengths sum above 160000 (pySHACL's meta-validation re-walks each list for every internal result). The data graph is not refused up front: odd IRIs, large enumerations and malformed lists are accepted, and if pySHACL fails on one anyway the failure is reported as ShapesRejected with the underlying error.
  • Class-hierarchy analysis uses asserted rdfs:subClassOf statements; it does not calculate entailments or inspect an import closure.
  • CLS002 can be noisy for TBox-only ontologies and is often disabled in that profile.
  • Shape coverage (SHQ006) judges classes with directly typed instances, and credits a class target (sh:targetClass or an implicit class target) on the class or on one of its superclasses (rdfs:subClassOf asserted in the data graph). Other targets (sh:targetNode, sh:targetSubjectsOf, sh:targetObjectsOf, SHACL-AF sh:target) are not credited, and a deactivated targeting shape still counts.
  • SARIF source regions are available for Turtle-family (TriG included), N-Triples-family and RDF/XML inputs, and for JSON-LD resources with an explicit @id (including local compact IRI contexts). Generated JSON-LD nodes remain future work.

The data/ directory contains crosswalks to the OOPS! and OntoSniff catalogues. Those mappings are traceability aids, not claims of identical behavior; their sources, what is reused from each and how to cite them are in data/README.md.

Input formats

ontolint reads Turtle, N-Triples, N3, N-Quads, TriG, RDF/XML and JSON-LD. The parser is chosen from the file extension, unless the first bytes clearly say otherwise: Turtle saved as .owl, RDF/XML as .ttl or JSON-LD as .rdf are parsed as what they are, and the RDF/XML safety checks apply to the detected syntax. OWL Functional Syntax, Manchester Syntax and OWL/XML (common for ODK edit files and Protégé exports, often named .owl) are not RDF. By default they fail with an INPUT001 that names the syntax and the ways forward. A parse failure in a file that contains an HTML page (a saved web page or server error) says where that page starts. The named graphs of a TriG, N-Quads or JSON-LD file (a node with @id and @graph) are merged with its default graph and linted as one graph; a triple stated in several graphs counts once. Findings name their graphs (see "Datasets: named graphs").

With --convert-with-robot, each such file, the input or any file of its import closure, is converted to Turtle with the ROBOT image of --robot-image (see "OWL profile validation with ROBOT in Docker"), so an ODK edit file and its components lint directly:

ontolint src/ontology/automatce-edit.owl --follow-imports --convert-with-robot

Each conversion runs in the same isolated container as profile validation, but only the file itself is mounted, read-only, and is converted on its own: every import it declares is answered by an empty stub, and ontolint then follows the imports itself, under the usual sandbox. Two consequences:

  • A Manchester Syntax file must declare every class and property it uses. One that relies on an import's declarations fails with an INPUT001 saying so; convert the closure yourself (robot merge) and lint the result.
  • Findings on a converted file have no line or column (SARIF regions), because the lines of the Turtle are not the file's.

A conversion takes a few seconds per file, and the --robot-timeout limit applies to each one.

A few rules read what the file's text says and RDF does not keep. IRI019 reports a prefix the file declares (Turtle @prefix, RDF/XML xmlns:) for a namespace no IRI uses. A JSON-LD @context never counts, and neither do the rdf:, rdfs:, owl:, xsd: and xml: declarations that editors write into every file. ONT003 mentions a licence the file names only in an SPDX-License-Identifier: comment.

Input safety

Ontologies are untrusted input, so the loader is deliberately strict:

  • Parsing runs with the network disabled. Any socket, UDP or DNS attempt is blocked and reported (SEC013); a JSON-LD file with an external @context is refused (SEC006). owl:imports is never fetched; --follow-imports loads only local files.
  • SHACL validation runs with the network disabled too: a socket or DNS attempt by a shape, even one pySHACL catches, makes SHACL001 failed (exit 2). It runs with inference="none" (no RDFS or OWL entailment is added to the data) and advanced=True, which admits SHACL-AF: SPARQL-based and custom targets, sh:rule (triple and SPARQL rules, applied once to a copy of the data graph) and SHACL functions; JavaScript extensions stay off. SPARQL-based constraints (sh:sparql) are SHACL Core and run whatever advanced says, so any shapes file, including one named by a PROF profile or imported as a shape library, can be slow: set --max-validation-seconds for shapes you did not write.
  • Inputs and XML catalogs larger than --max-input-bytes (default 64 MiB), or inputs holding more than --max-triples triples (default 5,000,000), are rejected (SEC001, SEC002). Both can also be set in the --config policy file. With --max-parse-seconds a parse that runs too long is stopped (SEC003).
  • Bounded: sizes and triple counts (always), ROBOT (--robot-timeout, 120 s by default) and, when you set a budget, parsing (--max-parse-seconds, SEC003) and SHACL validation (--max-validation-seconds, a failed SHACL001); those two run in a worker process that is stopped at the budget. Not bounded: the rule families, whose cost on large inputs is measured by tests/test_scaling.py.
  • RDF/XML with external entities or nested entity expansion is refused (SEC010), compressed files are refused (SEC011), and relative paths that escape the working directory, or leave it through a symlink or a symlinked directory, are refused (SEC009).
  • Rejected inputs are reported as SECxxx: ... on stderr with exit code 2, like a parse failure. Post-parse hygiene checks (SEC004, SEC005, SEC007, SEC008, SEC012, SEC014, SEC016) are ordinary findings; SEC007 is an info note naming the owl:imports that were not followed. SEC014 (error) reports an IRI that embeds a password (https://alice:secret@host). SEC016 (warning) reports an IRI whose userinfo is a user name only (https://<token>@github.com/..., ssh://git@github.com/..., an empty password https://alice:@host): GitHub, GitLab and Bitbucket accept a token as the user name, and a token cannot be told from a plain name, so every such userinfo is reported, whatever its length or prefix; RFC 3986 section 3.2.1 deprecates credentials in the userinfo. Both rules read IRIs in subject, predicate and object position of the data graph, not an xsd:anyURI literal ("https://u:pw@h"^^xsd:anyURI is masked in every output but not reported), not an empty userinfo (https://@host), not an @ after the authority (https://host/a@b) and not a scheme without an authority (mailto:a@b). An IRI that holds both kinds is reported by both. A userinfo that is a plain name is a false positive of SEC016: ignore it with --ignore SEC016 or lower it with severity_overrides.
  • No output ontolint writes repeats an IRI's userinfo, the user:password@ or token@ part of its authority. Every IRI ontolint prints, in any rule's focus or message, in text, JSON and SARIF reports, baselines and their hashes, blank node identities, module and named graph names and on stderr (its bounded workers' too), has its whole userinfo, user name included, replaced by **** (https://****@example.test/x): a token sent as the user name (https://<token>:x-oauth-basic@github.com/..., https://<token>@...) cannot be told from a name. A userinfo is found by the authority's structure, up to the first / ? #, whatever characters it holds (rdflib accepts white space, braces or a line break in an IRI), and SEC014 and SEC016 report exactly what the mask hides: the passwords and the user names. A message that quotes the start of a long value masks it before cutting it. A parser error about a file that holds a userinfo keeps its line number but withholds the parser's excerpt, which may quote part of one. The specification is in src/ontolint/redaction.py.
  • Limits. IRIs that differ only in their userinfo give one finding and one baseline entry, so a baseline cannot tell one credential from another: a new credential that replaces a baselined one at the same IRI is not reported. No output may hold a function of a secret that lets its reader test guesses of it offline, and only a key kept out of the repository could avoid that, so review a change to a baselined SEC014 or SEC016 finding's IRI in the source. Text that free prose mixes with an IRI may be over-masked (https://h has 'a'@en becomes https://****@en), and so may a scheme after a digit or a sign, which a reader takes for an IRI though no URL parser does (1http:a@b becomes 1http:****@b). RDF/XML resolves an IRI that does not start with a scheme (1git+https://u:p@h, _x://u:p@h) as a relative path, which turns its // into /: there the userinfo of a scheme other than http, https, ws, wss and ftp is not masked, and SEC014 and SEC016 do not report a userinfo resolved against the file. Not masked: writes straight to the stderr file descriptor (a crash of the interpreter itself), and a library caller's own logging handlers.

To report a vulnerability, see SECURITY.md.

Roadmap

data/rule_catalogue.csv is the machine-readable catalogue. It records 306 entries: 251 executable diagnostics and 55 proposed candidates. The additional entry beyond the original roadmap is TOOL001, an operational diagnostic for the linter itself. The 18 OPS entries of the original roadmap describe command-line and report features, not checks on an ontology; they moved to docs/cli-features.md. Thirteen further entries that cannot be specified soundly, or duplicate another rule, were removed; see docs/dropped-rules.md.

The next major areas are competency-question and ontology-diff rules (both need a second input), reasoner-based semantic checks through ROBOT, safe import-closure support, richer SHACL authoring checks, and network-based FAIR checks.

License

Copyright 2026 Arnaud Gelas. Licensed under the Apache License, Version 2.0. See LICENSE and NOTICE, which every redistribution must keep (section 4(d) of the licence). The crosswalks' sources and what they reuse are in data/README.md.

The logo (logo.png) was made with an AI image generator and added by the maintainer on 2026-11-07 (84045cc); which generator was used is not recorded. It is in the repository only, not in the sdist or the wheel. Some jurisdictions, the United States among them, do not grant copyright to images made without human authorship, so the copyright line above may not cover the logo; whatever rights in it the project holds are under the same Apache-2.0 licence.

Metadata

Release files for ontolint 0.15.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ontolint 0.15.1
File Size Uploaded Provenance Actions
ontolint-0.15.1.tar.gz 372.2 kB With provenance Details for ontolint-0.15.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for ontolint 0.15.1
File Interpreter ABI Platform Actions
ontolint-0.15.1-py3-none-any.whl Python 3 none any Details for ontolint-0.15.1-py3-none-any.whl

Total release size: 754.9 kB

Release files / ontolint-0.15.1.tar.gz

Download URL ontolint-0.15.1.tar.gz
Size 372.2 kB
Tags Source
SHA-256 checksum
How to use checksums
edf3cbdbaf45652ef209a1889b7f4250781480c51e2d660afd3225c8f2c14272
BLAKE2b-256 checksum
How to use checksums
c3eb73a827b266ab3beda96e38a421c3ea9d19624059d6223b73b0d12a19f1d2
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 15, 2026.

Transparency log

Release files / ontolint-0.15.1-py3-none-any.whl

Download URL ontolint-0.15.1-py3-none-any.whl
Size 382.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7f9634e127cebadbd79c71933b9d99f96087ade3e746d64bcb624378a447b159
BLAKE2b-256 checksum
How to use checksums
7ca3281d2b4ae6cbc6eb1714c5ed692b5de07b88d8602cb53324af2e5a488bb8
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 15, 2026.

Transparency log

Security for ontolint 0.15.1

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.

Select from 2 files

Attestation for ontolint-0.15.1.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 15, 2026.

Transparency log

A 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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page