Quality Assurance¶
This page says how ddigraph checks each change. It lists the gates, what each one requires, and how to run them yourself. It ends with the metrics and the checklist for a release.
The Gates¶
A change passes the same checks at four stages. Each stage runs what the one before it ran, and more.
| Stage | Where | What runs |
|---|---|---|
| Commit | pre-commit (pre-commit install) |
ruff, the Markdown lint, and the checks of the generated files |
| Pull request | ci.yml, Linux, Python 3.12 and 3.15 |
Every check below, the test suite with coverage, and the live tests on Neo4j 5, PostgreSQL 18 and Gremlin |
main |
ci.yml |
The same on Python 3.12, 3.13, 3.14 and 3.15, and on Windows |
| Release | publish.yml |
The suite on every Python, then the package checks: twine, pyroma and check-manifest |
bash scripts/ci_local.sh (or make check, which adds --fast) runs the
pull request's checks on your machine, in CI's order. See
Contributing for the setup.
Thresholds¶
| Check | Threshold | Tool |
|---|---|---|
| Lint | No finding | ruff: E, F, I, B, UP, RUF, D, N, C90, BLE and PLC2701 |
| Format | No change | ruff format |
| Types | No error, in strict mode, for Linux, Windows and macOS | mypy |
| Test coverage | At least 95%, lines and branches together | pytest-cov |
| Complexity | At most 15 per function, apart from the known debt below | ruff C901 |
| XSD coverage | Every element of each flavor's scope | scripts/xsd_coverage.py |
| English docs | Grade 10 or below | scripts/check_readability.py |
| Markdown | No finding | pymarkdownlnt, with .pymarkdown.json |
| Docs examples | Each runnable example runs and prints the output its page shows; the curriculum's run once, in the docs-cypher job (-m curriculum) |
tests/test_docs_examples.py |
| Cypher in the docs and the demo | Each statement plans on Neo4j 5 | tests/test_docs_lint.py, tests/test_demo_cypher.py |
| Generated files | Equal to what their script writes | the --check of each generator |
| Source distribution | Holds what a build needs | scripts/check_sdist.py |
Tests¶
ddigraph has three kinds of tests.
- Unit tests (
tests/test_*.py) check one module or behaviour at a time, on real DDI files fromtests/fixtures/. Where the inputs have a structure, Hypothesis draws them;pytest -m slowruns its long runs. - Gherkin scenarios (
tests/bdd/features/*.feature) describe what a user sees, in plain English: detecting and previewing a file, exporting it, querying it in memory, the store's history, the connection settings, and unsafe XML. pytest-bdd runs them in the normal suite. A new behaviour that users see gets a scenario. - Live tests run against Neo4j, PostgreSQL and Gremlin servers. They skip until you name a server, and they empty it. Contributing has the commands.
No unit test uses the network. The tests also ignore your own .env file
and your DDIGRAPH_* and NEO4J_* variables.
Mutation Testing¶
Coverage says that a line ran. Mutation testing says whether a test would
notice if the line were wrong. mutmut changes the code in one small way at
a time, such as a < to a <=, and runs the tests that reach it. A change
that no test notices is a mutant that survived.
It covers the modules where the tests are the only guard: the RDF
vocabulary, writer and reader, the graph view, node identity (urn), the
memory lens, and the query model and its evaluator. Snapshots and the XSD
coverage gate guard the parsers instead. [tool.mutmut] in
pyproject.toml sets the scope.
Run make mutation on Linux, macOS or WSL, and make mutation-results to
list the mutants that survived. On GitHub, start the "Mutation testing"
workflow by hand; it writes each module's score to the run's summary. It
is not a gate, since a full run takes a long time.
Scores on 2026-11-22, on 1,710 mutants:
| Module | Score | Survived |
|---|---|---|
| All | 88.9% | 190 |
ddigraph.lens.memory |
95.7% | 24 of 563 |
ddigraph.query.evaluate |
95.1% | 16 of 328 |
ddigraph.query.model |
91.6% | 32 of 382 |
ddigraph.urn |
87.4% | 18 of 143 |
ddigraph.rdf.vocabulary |
77.2% | 21 of 92 |
ddigraph.graph.view |
67.3% | 17 of 52 |
ddigraph.rdf.reader |
63.1% | 45 of 122 |
ddigraph.rdf.writer |
39.3% | 17 of 28 |
Most mutants that survive change only the text of a message, which no
test should pin, or change nothing, such as quote(x, safe="XXXX"), which
encodes the same. The run that set these scores found two real gaps,
which tests now cover: a JSON-LD list item that names a context to fetch,
and a dataset_id the RDF writer ignored.
Naming¶
- A module whose path has no part that starts with
_is public. Its__all__lists its public names, and every class or function it defines without a leading_is one of them.tests/test_naming.pychecks this. - A leading
_means internal to the ddigraph package. Modules of the package may share such a name, but nothing outside the package may import it. Ruff'sPLC2701checks this. Tests may, and so may the scripts that build the generated tables. - A module whose name starts with
_, such asir/_rust.py, is internal as a whole, so the names in it need no_. - Constants are
UPPER_CASE, classes areCapWords, and everything else issnake_case. Ruff'sNrules check this.
Metrics¶
make quality (scripts/quality_report.py) prints the metrics as a
table: coverage, complexity, the public API, XSD coverage and the mutation
scores. With --tests, it also counts the tests. CI's Linux 3.12 job adds
the same table to each run's summary.
Measured on 2026-11-22, before the 0.6.0 release:
| Metric | Value |
|---|---|
| Tests collected | 6,765, with 14 Gherkin scenarios |
| Line coverage | 98.42% |
| Branch coverage | 96.75% |
| Functions over complexity 10 | 21 |
| Functions over complexity 15 | 8, the known debt below |
| Public modules | 65, with 493 public names |
| XSD coverage | 100%: 189 DDI-L, 73 DDI-C and 210 DDI-CDI elements |
Known Debt¶
These functions go over a complexity of 15. Each one is marked
noqa: C901, so no new function can go over it.
| Function | Complexity |
|---|---|
ddigraph.query.sql._compile |
27 |
ddigraph.server.create_app |
25 |
ddigraph.lens.neo4j (_repairs) |
24 |
ddigraph.query.model._check |
22 |
ddigraph.api._load |
19 |
ddigraph.cli._validate_command |
18 |
ddigraph.query.cypher.to_cypher |
17 |
ddigraph.bench (_run) |
16 |
So are three demo functions and one in scripts/generate_rust_tables.py.
A few except Exception clauses stay, each marked noqa: BLE001 with its
reason. Each turns a failure into a result that it reports: a finding of
the conformance runner, an element the XSD coverage audit marks as
missing, an unhealthy status, or an error the stream raises later.
Release Checklist¶
- Every gate is green on
main, Windows included. CHANGELOG.mdhas the version's section. Anything a user must change is in its Upgrading part, and the upgrade guide covers it in both languages.- Bump the version in
pyproject.toml,rust/Cargo.tomlandrust/fallback/pyproject.toml, and theddigraph-core==pin;tests/test_versions.pychecks that they agree. Runuv lock. - Run
make check-metamodel, which needs the network, and a mutation run, and update the scores on this page. - Merge to
maininpbisson44/ddigraph.publish.ymlthen tags the version, publishes both packages to PyPI with Trusted Publishing, writes the release notes from the changelog, and deploys the docs. - Check the release on PyPI and on the docs site.