emlint 0.2.2__tar.gz → 0.2.4__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. emlint-0.2.4/PKG-INFO +244 -0
  2. emlint-0.2.4/README.md +203 -0
  3. {emlint-0.2.2 → emlint-0.2.4}/emlint/__init__.py +10 -1
  4. {emlint-0.2.2 → emlint-0.2.4}/emlint/checks.py +815 -28
  5. {emlint-0.2.2 → emlint-0.2.4}/emlint/cli.py +2 -2
  6. {emlint-0.2.2 → emlint-0.2.4}/emlint/frontends.py +32 -1
  7. {emlint-0.2.2 → emlint-0.2.4}/emlint/model.py +67 -0
  8. {emlint-0.2.2 → emlint-0.2.4}/emlint/profiles.py +13 -2
  9. {emlint-0.2.2 → emlint-0.2.4}/emlint/report.py +48 -8
  10. emlint-0.2.4/emlint.egg-info/PKG-INFO +244 -0
  11. {emlint-0.2.2 → emlint-0.2.4}/emlint.egg-info/SOURCES.txt +2 -1
  12. {emlint-0.2.2 → emlint-0.2.4}/emlint.egg-info/requires.txt +9 -0
  13. {emlint-0.2.2 → emlint-0.2.4}/pyproject.toml +5 -3
  14. {emlint-0.2.2 → emlint-0.2.4}/tests/test_check_correctability.py +38 -1
  15. {emlint-0.2.2 → emlint-0.2.4}/tests/test_check_duplicates.py +400 -6
  16. emlint-0.2.4/tests/test_check_high_probability_mechanisms.py +50 -0
  17. emlint-0.2.4/tests/test_check_null_mechanism.py +298 -0
  18. {emlint-0.2.2 → emlint-0.2.4}/tests/test_check_observable_coverage.py +40 -17
  19. {emlint-0.2.2 → emlint-0.2.4}/tests/test_check_oracles.py +100 -10
  20. {emlint-0.2.2 → emlint-0.2.4}/tests/test_check_probability_bounds.py +66 -34
  21. {emlint-0.2.2 → emlint-0.2.4}/tests/test_check_sensitivity.py +79 -19
  22. emlint-0.2.4/tests/test_checks.py +300 -0
  23. {emlint-0.2.2 → emlint-0.2.4}/tests/test_cli.py +234 -0
  24. {emlint-0.2.2 → emlint-0.2.4}/tests/test_frontend.py +55 -1
  25. {emlint-0.2.2 → emlint-0.2.4}/tests/test_fuzz.py +3 -2
  26. {emlint-0.2.2 → emlint-0.2.4}/tests/test_model.py +103 -0
  27. {emlint-0.2.2 → emlint-0.2.4}/tests/test_profiles.py +122 -0
  28. {emlint-0.2.2 → emlint-0.2.4}/tests/test_repeat_optimization.py +224 -14
  29. {emlint-0.2.2 → emlint-0.2.4}/tests/test_report.py +143 -0
  30. {emlint-0.2.2 → emlint-0.2.4}/tests/test_stim_integration.py +22 -0
  31. {emlint-0.2.2 → emlint-0.2.4}/tests/test_synthetic_bug_corpus.py +24 -0
  32. emlint-0.2.2/PKG-INFO +0 -169
  33. emlint-0.2.2/README.md +0 -134
  34. emlint-0.2.2/emlint.egg-info/PKG-INFO +0 -169
  35. emlint-0.2.2/tests/test_checks.py +0 -130
  36. emlint-0.2.2/tests/test_paritea_integration.py +0 -57
  37. {emlint-0.2.2 → emlint-0.2.4}/LICENSE +0 -0
  38. {emlint-0.2.2 → emlint-0.2.4}/NOTICE +0 -0
  39. {emlint-0.2.2 → emlint-0.2.4}/emlint/py.typed +0 -0
  40. {emlint-0.2.2 → emlint-0.2.4}/emlint.egg-info/dependency_links.txt +0 -0
  41. {emlint-0.2.2 → emlint-0.2.4}/emlint.egg-info/entry_points.txt +0 -0
  42. {emlint-0.2.2 → emlint-0.2.4}/emlint.egg-info/top_level.txt +0 -0
  43. {emlint-0.2.2 → emlint-0.2.4}/setup.cfg +0 -0
  44. {emlint-0.2.2 → emlint-0.2.4}/tests/test_check_detectability.py +0 -0
  45. {emlint-0.2.2 → emlint-0.2.4}/tests/test_corpus_regenerable.py +0 -0
  46. {emlint-0.2.2 → emlint-0.2.4}/tests/test_frontend_partial_parse.py +0 -0
emlint-0.2.4/PKG-INFO ADDED
@@ -0,0 +1,244 @@
1
+ Metadata-Version: 2.4
2
+ Name: emlint
3
+ Version: 0.2.4
4
+ Summary: A static analysis tool for quantum error correction
5
+ Author: Mathys Rennela
6
+ License: Apache-2.0
7
+ Keywords: quantum,error-correction,static-analysis,detector-error-model,stim,linter
8
+ Classifier: Development Status :: 4 - Beta
9
+ Classifier: Intended Audience :: Science/Research
10
+ Classifier: Intended Audience :: Developers
11
+ Classifier: License :: OSI Approved :: Apache Software License
12
+ Classifier: Natural Language :: English
13
+ Classifier: Programming Language :: Python :: 3
14
+ Classifier: Programming Language :: Python :: 3.10
15
+ Classifier: Programming Language :: Python :: 3.11
16
+ Classifier: Programming Language :: Python :: 3.12
17
+ Classifier: Topic :: Scientific/Engineering :: Physics
18
+ Classifier: Topic :: Software Development :: Quality Assurance
19
+ Requires-Python: >=3.10
20
+ Description-Content-Type: text/markdown
21
+ License-File: LICENSE
22
+ License-File: NOTICE
23
+ Requires-Dist: stim>=1.14
24
+ Requires-Dist: tomli>=2.0; python_version < "3.11"
25
+ Provides-Extra: dev
26
+ Requires-Dist: pytest; extra == "dev"
27
+ Requires-Dist: hypothesis; extra == "dev"
28
+ Requires-Dist: black; extra == "dev"
29
+ Requires-Dist: pytest-cov; extra == "dev"
30
+ Requires-Dist: mutmut; extra == "dev"
31
+ Requires-Dist: mkdocs-material; extra == "dev"
32
+ Provides-Extra: benchmark
33
+ Requires-Dist: pytest; extra == "benchmark"
34
+ Requires-Dist: hypothesis; extra == "benchmark"
35
+ Requires-Dist: qldpc; extra == "benchmark"
36
+ Provides-Extra: demo
37
+ Requires-Dist: jupytext; extra == "demo"
38
+ Requires-Dist: nbmake; extra == "demo"
39
+ Requires-Dist: ipykernel; extra == "demo"
40
+ Dynamic: license-file
41
+
42
+ # emlint
43
+
44
+ <div align="center">
45
+ <picture>
46
+ <source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/MathysRennela/emlint/main/docs/images/emlint_logo_with_name-dark.png">
47
+ <img src="https://raw.githubusercontent.com/MathysRennela/emlint/main/docs/images/emlint_logo_with_name.png" alt="emlint logo" width="350">
48
+ </picture>
49
+ </div>
50
+
51
+ <p align="center">
52
+ <a href="https://pypi.org/project/emlint/"><img src="https://img.shields.io/pypi/v/emlint.svg?color=blue" alt="PyPI version"></a>
53
+ <a href="https://pypi.org/project/emlint/"><img src="https://img.shields.io/pypi/pyversions/emlint.svg" alt="Python versions"></a>
54
+ <a href="https://github.com/MathysRennela/emlint/actions/workflows/ci.yml"><img src="https://github.com/MathysRennela/emlint/actions/workflows/ci.yml/badge.svg" alt="CI"></a>
55
+ <a href="https://codecov.io/gh/MathysRennela/emlint"><img src="https://codecov.io/gh/MathysRennela/emlint/graph/badge.svg?branch=main" alt="Codecov"></a>
56
+ <a href="https://github.com/MathysRennela/emlint/tree/main/docs"><img src="https://img.shields.io/badge/docs-reference-blue.svg?logo=readthedocs&logoColor=white" alt="Documentation"></a>
57
+ <a href="https://github.com/MathysRennela/emlint/blob/main/LICENSE"><img src="https://img.shields.io/github/license/MathysRennela/emlint.svg" alt="License"></a>
58
+ <a href="https://pepy.tech/project/emlint"><img src="https://static.pepy.tech/badge/emlint" alt="Downloads"></a>
59
+ </p>
60
+
61
+ **stim simulates. sinter samples. emlint verifies.**
62
+
63
+ emlint is a static linter for [Stim](https://github.com/quantumlib/Stim)
64
+ Detector Error Models (DEMs). It finds structural problems before simulation.
65
+
66
+ ## Why emlint?
67
+
68
+ - **Catch DEM bugs before the expensive simulation.** A silent DEM bug can
69
+ inflate logical error rates and may not surface until 10⁶ simulation shots
70
+ (≈45 min). emlint finds structural problems
71
+ in milliseconds.
72
+ - **Counter-examples.** A failing check identifies the
73
+ offending mechanism, detector, or observable, so you know where to look.
74
+ - **Severity that respects the stakes.** `error` findings are unconditional DEM
75
+ bugs; `warning` findings are heuristic or intentional-pattern candidates you
76
+ review before acting.
77
+ - **Agent- and CI-friendly.** Exit codes distinguish clean, error, warning, and
78
+ unlintable input; JSON and SARIF output feed scripts and code-scanning tools.
79
+
80
+ ## See it in action
81
+
82
+ A d=5 surface-code DEM with a missing detector connection
83
+ ([`examples/buggy.dem`](examples/buggy.dem)):
84
+
85
+ ```text
86
+ $ emlint check examples/buggy.dem
87
+ Detectors: 24 Observables: 1 Error mechanisms: 31
88
+ DEM-only analysis: findings do not establish circuit semantic correctness.
89
+
90
+ ✓ detectability: All error mechanisms that flip observables also trigger detectors.
91
+ ✗ [warning] sensitivity: 1 detector(s) are never triggered by any error mechanism.
92
+ Counter-example: Detector(s) not triggered by any error mechanism: D17@(1,0,2)
93
+ Hint: Hypothesis: a detector no mechanism ever triggers is either miswired or
94
+ redundant. Expected shape: at least one mechanism per stabilizer check per
95
+ round; look for a missing noise instruction on the gates feeding this detector,
96
+ or a DETECTOR declared on a comparison that never receives a fault. Limit: a
97
+ detector with a constant outcome (fires every shot, or never fires) also has no
98
+ mechanism in the DEM, so it is indistinguishable from a dead detector here;
99
+ check the reference sample before treating this as a wiring bug.
100
+ ✓ observable_coverage: All declared observables are flipped by at least one error mechanism.
101
+ ✓ probability_bounds: All error mechanism probabilities are finite and strictly positive.
102
+ ✓ duplicates: No duplicate mechanism signatures found.
103
+ ✓ correctability: Every syndrome maps to at most one distinct set of logical observables.
104
+ ✓ null_mechanism: No mechanism has empty detector and observable support.
105
+ ✓ high_probability_mechanisms: All mechanism probabilities are ≤ 0.3.
106
+ ✗ [warning] connectivity: Decoding graph has 2 connected components.
107
+ Counter-example: Component 1: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
108
+ 15, 16, 18, 19, 20, 21, 22, 23]; Component 2: [17]
109
+ ✓ boundary_symmetry: Skipped: fewer than 2 logical observables (boundary symmetry requires ≥ 2).
110
+ ```
111
+
112
+ After reconnecting `D17` to its neighbours
113
+ ([`examples/fixed.dem`](examples/fixed.dem)), every check passes. The
114
+ counter-examples name the exact detector (`D17@(1,0,2)`) and the isolated
115
+ decoding-graph component (`[17]`), so the fix is localized. More generated
116
+ examples live in [`examples/`](examples/README.md).
117
+
118
+ > **v0.2 is preliminary.** The user-facing behavior is usable, but internal APIs
119
+ > and implementation details may change before v1.0.
120
+
121
+ ## Quick start
122
+
123
+ Install emlint:
124
+
125
+ ```bash
126
+ pip install emlint
127
+ ```
128
+
129
+ Lint a DEM file or raw DEM text:
130
+
131
+ ```bash
132
+ emlint check circuit.dem
133
+ emlint check 'error(0.01) D0 L0
134
+ detector D0'
135
+ ```
136
+
137
+ A failing result includes a counter-example identifying the relevant mechanism,
138
+ detector, or observable. Select checks with `--only`/`--ignore`, or emit SARIF for
139
+ code-scanning tools:
140
+
141
+ ```bash
142
+ emlint check circuit.dem --only detectability,sensitivity
143
+ emlint check circuit.dem --format sarif > emlint.sarif
144
+ ```
145
+
146
+ Project defaults can be placed in `pyproject.toml` under `[tool.emlint]`. For
147
+ all command options, configuration examples, and exit codes, see the [CLI reference](docs/cli.md).
148
+
149
+ ## Python
150
+
151
+ ```python
152
+ import emlint
153
+ import stim
154
+
155
+ circuit = stim.Circuit.generated(
156
+ "surface_code:rotated_memory_z",
157
+ distance=3,
158
+ rounds=3,
159
+ after_clifford_depolarization=0.001,
160
+ )
161
+ report = emlint.check(circuit.detector_error_model())
162
+ print(emlint.format_text(report))
163
+ ```
164
+
165
+ `emlint.check()` also accepts a raw DEM string or an explicit `pathlib.Path`.
166
+
167
+ ## Documentation
168
+
169
+ | Guide | Use it for |
170
+ |---|---|
171
+ | [CLI reference](docs/cli.md) | Commands, options, output, and exit codes |
172
+ | [Agent integration guide](docs/agent-integration.md) | Running emlint in a coding-agent fix-loop: exit-code handling, JSON contract, context declaration |
173
+ | [Check catalog](docs/checks.md) | What the seven checks detect and how to interpret findings, plus the machine-readable output contract |
174
+ | [Debugging guide](docs/debugging.md) | Check-specific causes and investigation steps |
175
+ | [Formal grounding](docs/formal-grounding.md) | DEM vocabulary and formal properties |
176
+ | [v0.2 limitations](docs/limitations.md) | Scope, warnings, repeat blocks, and provisional behavior |
177
+ | [Changelog](CHANGELOG.md) | Version history and user-visible changes |
178
+
179
+ > **Note:** on DEMs produced with `decompose_errors=True`, the `duplicates`
180
+ > check (warning) may report mechanisms that share a detector signature after
181
+ > graphlike decomposition as "duplicates". This is expected decomposition
182
+ > output, not a concatenation bug. The `graphlike-decoder` profile requires an
183
+ > explicit decoder context for compatibility checks; it does not suppress this
184
+ > warning, which can still make a correct DEM exit with code 2. Use `--ignore duplicates`
185
+ > only when you deliberately want to skip this advisory check.
186
+
187
+ ## Exit codes
188
+
189
+ | Code | Meaning |
190
+ |---:|---|
191
+ | `0` | All checks passed |
192
+ | `1` | At least one error-severity finding |
193
+ | `2` | Warnings only |
194
+ | `3` | Unlintable input (unreadable or unparseable) |
195
+
196
+ Treat exit code `3` as an input failure, not as findings: an agent loop that
197
+ parses the report on exit `3` would reason about a DEM that emlint never saw.
198
+
199
+ > **Epistemic boundary:** emlint analyzes DEMs only. Its findings establish
200
+ > structural properties of the DEM itself; they do not establish that the
201
+ > underlying circuit is semantically correct, nor that a decoder succeeds.
202
+ > Circuit-level verification (e.g. with `stim`) remains necessary.
203
+
204
+ ## CI
205
+
206
+ For a minimal GitHub Actions setup, install emlint and run it on changed DEM
207
+ files:
208
+
209
+ ```yaml
210
+ - name: Install emlint
211
+ run: pip install emlint
212
+ - name: Lint DEM files
213
+ run: find . -name "*.dem" -print0 | xargs -0 -r -n1 emlint check
214
+ ```
215
+
216
+ For local commits, the repository includes a pre-commit hook configuration:
217
+
218
+ ```bash
219
+ pip install pre-commit
220
+ pre-commit install
221
+ ```
222
+
223
+ The hook runs `emlint check --severity error` on staged `.dem` files. Warning-only
224
+ findings remain non-blocking; input failures still return exit code `3`.
225
+
226
+ ## Contributing
227
+
228
+ See [CONTRIBUTING.md](CONTRIBUTING.md) for development setup, how to add a
229
+ check, test requirements, and quality gates.
230
+
231
+ ## Acknowledgments
232
+
233
+ emlint is developed with AI assistance for scaffolding, test generation,
234
+ red-teaming, and documentation. All design decisions, technical content, and
235
+ final code are reviewed and owned by the maintainers.
236
+
237
+ ## Funding
238
+
239
+ This project is funded by a [Mozilla Foundation](https://foundation.mozilla.org/)
240
+ fellowship and supported by the [Unitary Foundation](https://unitary.foundation/).
241
+
242
+ ## License
243
+
244
+ Apache 2.0
emlint-0.2.4/README.md ADDED
@@ -0,0 +1,203 @@
1
+ # emlint
2
+
3
+ <div align="center">
4
+ <picture>
5
+ <source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/MathysRennela/emlint/main/docs/images/emlint_logo_with_name-dark.png">
6
+ <img src="https://raw.githubusercontent.com/MathysRennela/emlint/main/docs/images/emlint_logo_with_name.png" alt="emlint logo" width="350">
7
+ </picture>
8
+ </div>
9
+
10
+ <p align="center">
11
+ <a href="https://pypi.org/project/emlint/"><img src="https://img.shields.io/pypi/v/emlint.svg?color=blue" alt="PyPI version"></a>
12
+ <a href="https://pypi.org/project/emlint/"><img src="https://img.shields.io/pypi/pyversions/emlint.svg" alt="Python versions"></a>
13
+ <a href="https://github.com/MathysRennela/emlint/actions/workflows/ci.yml"><img src="https://github.com/MathysRennela/emlint/actions/workflows/ci.yml/badge.svg" alt="CI"></a>
14
+ <a href="https://codecov.io/gh/MathysRennela/emlint"><img src="https://codecov.io/gh/MathysRennela/emlint/graph/badge.svg?branch=main" alt="Codecov"></a>
15
+ <a href="https://github.com/MathysRennela/emlint/tree/main/docs"><img src="https://img.shields.io/badge/docs-reference-blue.svg?logo=readthedocs&logoColor=white" alt="Documentation"></a>
16
+ <a href="https://github.com/MathysRennela/emlint/blob/main/LICENSE"><img src="https://img.shields.io/github/license/MathysRennela/emlint.svg" alt="License"></a>
17
+ <a href="https://pepy.tech/project/emlint"><img src="https://static.pepy.tech/badge/emlint" alt="Downloads"></a>
18
+ </p>
19
+
20
+ **stim simulates. sinter samples. emlint verifies.**
21
+
22
+ emlint is a static linter for [Stim](https://github.com/quantumlib/Stim)
23
+ Detector Error Models (DEMs). It finds structural problems before simulation.
24
+
25
+ ## Why emlint?
26
+
27
+ - **Catch DEM bugs before the expensive simulation.** A silent DEM bug can
28
+ inflate logical error rates and may not surface until 10⁶ simulation shots
29
+ (≈45 min). emlint finds structural problems
30
+ in milliseconds.
31
+ - **Counter-examples.** A failing check identifies the
32
+ offending mechanism, detector, or observable, so you know where to look.
33
+ - **Severity that respects the stakes.** `error` findings are unconditional DEM
34
+ bugs; `warning` findings are heuristic or intentional-pattern candidates you
35
+ review before acting.
36
+ - **Agent- and CI-friendly.** Exit codes distinguish clean, error, warning, and
37
+ unlintable input; JSON and SARIF output feed scripts and code-scanning tools.
38
+
39
+ ## See it in action
40
+
41
+ A d=5 surface-code DEM with a missing detector connection
42
+ ([`examples/buggy.dem`](examples/buggy.dem)):
43
+
44
+ ```text
45
+ $ emlint check examples/buggy.dem
46
+ Detectors: 24 Observables: 1 Error mechanisms: 31
47
+ DEM-only analysis: findings do not establish circuit semantic correctness.
48
+
49
+ ✓ detectability: All error mechanisms that flip observables also trigger detectors.
50
+ ✗ [warning] sensitivity: 1 detector(s) are never triggered by any error mechanism.
51
+ Counter-example: Detector(s) not triggered by any error mechanism: D17@(1,0,2)
52
+ Hint: Hypothesis: a detector no mechanism ever triggers is either miswired or
53
+ redundant. Expected shape: at least one mechanism per stabilizer check per
54
+ round; look for a missing noise instruction on the gates feeding this detector,
55
+ or a DETECTOR declared on a comparison that never receives a fault. Limit: a
56
+ detector with a constant outcome (fires every shot, or never fires) also has no
57
+ mechanism in the DEM, so it is indistinguishable from a dead detector here;
58
+ check the reference sample before treating this as a wiring bug.
59
+ ✓ observable_coverage: All declared observables are flipped by at least one error mechanism.
60
+ ✓ probability_bounds: All error mechanism probabilities are finite and strictly positive.
61
+ ✓ duplicates: No duplicate mechanism signatures found.
62
+ ✓ correctability: Every syndrome maps to at most one distinct set of logical observables.
63
+ ✓ null_mechanism: No mechanism has empty detector and observable support.
64
+ ✓ high_probability_mechanisms: All mechanism probabilities are ≤ 0.3.
65
+ ✗ [warning] connectivity: Decoding graph has 2 connected components.
66
+ Counter-example: Component 1: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
67
+ 15, 16, 18, 19, 20, 21, 22, 23]; Component 2: [17]
68
+ ✓ boundary_symmetry: Skipped: fewer than 2 logical observables (boundary symmetry requires ≥ 2).
69
+ ```
70
+
71
+ After reconnecting `D17` to its neighbours
72
+ ([`examples/fixed.dem`](examples/fixed.dem)), every check passes. The
73
+ counter-examples name the exact detector (`D17@(1,0,2)`) and the isolated
74
+ decoding-graph component (`[17]`), so the fix is localized. More generated
75
+ examples live in [`examples/`](examples/README.md).
76
+
77
+ > **v0.2 is preliminary.** The user-facing behavior is usable, but internal APIs
78
+ > and implementation details may change before v1.0.
79
+
80
+ ## Quick start
81
+
82
+ Install emlint:
83
+
84
+ ```bash
85
+ pip install emlint
86
+ ```
87
+
88
+ Lint a DEM file or raw DEM text:
89
+
90
+ ```bash
91
+ emlint check circuit.dem
92
+ emlint check 'error(0.01) D0 L0
93
+ detector D0'
94
+ ```
95
+
96
+ A failing result includes a counter-example identifying the relevant mechanism,
97
+ detector, or observable. Select checks with `--only`/`--ignore`, or emit SARIF for
98
+ code-scanning tools:
99
+
100
+ ```bash
101
+ emlint check circuit.dem --only detectability,sensitivity
102
+ emlint check circuit.dem --format sarif > emlint.sarif
103
+ ```
104
+
105
+ Project defaults can be placed in `pyproject.toml` under `[tool.emlint]`. For
106
+ all command options, configuration examples, and exit codes, see the [CLI reference](docs/cli.md).
107
+
108
+ ## Python
109
+
110
+ ```python
111
+ import emlint
112
+ import stim
113
+
114
+ circuit = stim.Circuit.generated(
115
+ "surface_code:rotated_memory_z",
116
+ distance=3,
117
+ rounds=3,
118
+ after_clifford_depolarization=0.001,
119
+ )
120
+ report = emlint.check(circuit.detector_error_model())
121
+ print(emlint.format_text(report))
122
+ ```
123
+
124
+ `emlint.check()` also accepts a raw DEM string or an explicit `pathlib.Path`.
125
+
126
+ ## Documentation
127
+
128
+ | Guide | Use it for |
129
+ |---|---|
130
+ | [CLI reference](docs/cli.md) | Commands, options, output, and exit codes |
131
+ | [Agent integration guide](docs/agent-integration.md) | Running emlint in a coding-agent fix-loop: exit-code handling, JSON contract, context declaration |
132
+ | [Check catalog](docs/checks.md) | What the seven checks detect and how to interpret findings, plus the machine-readable output contract |
133
+ | [Debugging guide](docs/debugging.md) | Check-specific causes and investigation steps |
134
+ | [Formal grounding](docs/formal-grounding.md) | DEM vocabulary and formal properties |
135
+ | [v0.2 limitations](docs/limitations.md) | Scope, warnings, repeat blocks, and provisional behavior |
136
+ | [Changelog](CHANGELOG.md) | Version history and user-visible changes |
137
+
138
+ > **Note:** on DEMs produced with `decompose_errors=True`, the `duplicates`
139
+ > check (warning) may report mechanisms that share a detector signature after
140
+ > graphlike decomposition as "duplicates". This is expected decomposition
141
+ > output, not a concatenation bug. The `graphlike-decoder` profile requires an
142
+ > explicit decoder context for compatibility checks; it does not suppress this
143
+ > warning, which can still make a correct DEM exit with code 2. Use `--ignore duplicates`
144
+ > only when you deliberately want to skip this advisory check.
145
+
146
+ ## Exit codes
147
+
148
+ | Code | Meaning |
149
+ |---:|---|
150
+ | `0` | All checks passed |
151
+ | `1` | At least one error-severity finding |
152
+ | `2` | Warnings only |
153
+ | `3` | Unlintable input (unreadable or unparseable) |
154
+
155
+ Treat exit code `3` as an input failure, not as findings: an agent loop that
156
+ parses the report on exit `3` would reason about a DEM that emlint never saw.
157
+
158
+ > **Epistemic boundary:** emlint analyzes DEMs only. Its findings establish
159
+ > structural properties of the DEM itself; they do not establish that the
160
+ > underlying circuit is semantically correct, nor that a decoder succeeds.
161
+ > Circuit-level verification (e.g. with `stim`) remains necessary.
162
+
163
+ ## CI
164
+
165
+ For a minimal GitHub Actions setup, install emlint and run it on changed DEM
166
+ files:
167
+
168
+ ```yaml
169
+ - name: Install emlint
170
+ run: pip install emlint
171
+ - name: Lint DEM files
172
+ run: find . -name "*.dem" -print0 | xargs -0 -r -n1 emlint check
173
+ ```
174
+
175
+ For local commits, the repository includes a pre-commit hook configuration:
176
+
177
+ ```bash
178
+ pip install pre-commit
179
+ pre-commit install
180
+ ```
181
+
182
+ The hook runs `emlint check --severity error` on staged `.dem` files. Warning-only
183
+ findings remain non-blocking; input failures still return exit code `3`.
184
+
185
+ ## Contributing
186
+
187
+ See [CONTRIBUTING.md](CONTRIBUTING.md) for development setup, how to add a
188
+ check, test requirements, and quality gates.
189
+
190
+ ## Acknowledgments
191
+
192
+ emlint is developed with AI assistance for scaffolding, test generation,
193
+ red-teaming, and documentation. All design decisions, technical content, and
194
+ final code are reviewed and owned by the maintainers.
195
+
196
+ ## Funding
197
+
198
+ This project is funded by a [Mozilla Foundation](https://foundation.mozilla.org/)
199
+ fellowship and supported by the [Unitary Foundation](https://unitary.foundation/).
200
+
201
+ ## License
202
+
203
+ Apache 2.0
@@ -11,9 +11,12 @@ import stim
11
11
  from emlint import frontends
12
12
  from emlint.checks import (
13
13
  ALL_CHECKS,
14
+ check_boundary_symmetry,
15
+ check_connectivity,
14
16
  check_correctability,
15
17
  check_detectability,
16
18
  check_duplicates,
19
+ check_null_mechanism,
17
20
  check_observable_coverage,
18
21
  check_probability_bounds,
19
22
  check_sensitivity,
@@ -26,6 +29,7 @@ _SCOPE_LOCAL_CHECKS = {
26
29
  check_probability_bounds,
27
30
  check_observable_coverage,
28
31
  check_sensitivity,
32
+ check_null_mechanism,
29
33
  }
30
34
 
31
35
  _CROSS_SCOPE_CHECKS = {
@@ -257,7 +261,11 @@ def check(
257
261
  # Explicit Path objects remain preferable when a string could be either
258
262
  # a valid DEM or an existing filename.
259
263
  path = Path(source)
260
- if path.exists():
264
+ try:
265
+ is_path = path.exists()
266
+ except OSError:
267
+ is_path = False
268
+ if is_path:
261
269
  text = path.read_text() # OSError propagates to the caller
262
270
  else:
263
271
  text = source
@@ -392,4 +400,5 @@ def check(
392
400
  disabled_checks=list(disabled_checks or []),
393
401
  applied_overrides=applied_overrides,
394
402
  unknown_instructions=list(model.unknown_instructions),
403
+ profile=profile,
395
404
  )