qcheck-quantum 0.2.0__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.
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or Derivative
95
+ Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright 2026 qcheck contributors
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
@@ -0,0 +1,8 @@
1
+ qcheck
2
+ Copyright 2026 qcheck contributors
3
+
4
+ Licensed under the Apache License, Version 2.0 (the "License");
5
+ you may not use this file except in compliance with the License.
6
+ You may obtain a copy of the License at
7
+
8
+ http://www.apache.org/licenses/LICENSE-2.0
@@ -0,0 +1,226 @@
1
+ Metadata-Version: 2.4
2
+ Name: qcheck-quantum
3
+ Version: 0.2.0
4
+ Summary: Verify LLM-generated quantum code (Qiskit / OpenQASM) statically and safely.
5
+ Author: qcheck contributors
6
+ Maintainer-email: JCQuankey <dev@quankey.xyz>
7
+ License: Apache-2.0
8
+ Project-URL: Homepage, https://github.com/JCQuankey/qcheck
9
+ Project-URL: Repository, https://github.com/JCQuankey/qcheck
10
+ Project-URL: Issues, https://github.com/JCQuankey/qcheck/issues
11
+ Keywords: quantum,qiskit,openqasm,llm,linter,code-review,static-analysis,sarif
12
+ Classifier: Development Status :: 3 - Alpha
13
+ Classifier: Intended Audience :: Developers
14
+ Classifier: License :: OSI Approved :: Apache Software License
15
+ Classifier: Operating System :: OS Independent
16
+ Classifier: Programming Language :: Python :: 3
17
+ Classifier: Programming Language :: Python :: 3.9
18
+ Classifier: Programming Language :: Python :: 3.10
19
+ Classifier: Programming Language :: Python :: 3.11
20
+ Classifier: Programming Language :: Python :: 3.12
21
+ Classifier: Topic :: Software Development :: Quality Assurance
22
+ Classifier: Topic :: Scientific/Engineering :: Physics
23
+ Requires-Python: >=3.9
24
+ Description-Content-Type: text/markdown
25
+ License-File: LICENSE
26
+ License-File: NOTICE
27
+ Provides-Extra: dev
28
+ Requires-Dist: pytest>=7; extra == "dev"
29
+ Provides-Extra: release
30
+ Requires-Dist: build>=1; extra == "release"
31
+ Requires-Dist: twine>=5; extra == "release"
32
+ Dynamic: license-file
33
+
34
+ # qcheck
35
+
36
+ **AI writes quantum code. qcheck reviews it.**
37
+
38
+ `qcheck` is a lightweight review layer for AI-generated Qiskit and OpenQASM
39
+ snippets. It catches common issues early - removed-in-1.0 APIs, unsafe patterns,
40
+ missing measurements, parse errors - so agents and developers can improve quantum
41
+ code before it reaches humans, CI, or simulators. Tiny, dependency-free, and it
42
+ reviews code without ever executing it.
43
+
44
+ Why it matters: LLMs write quantum code that fails to run **40-70% of the time**
45
+ one-shot (QuanBench+ 2026: Qiskit 59.5% / PennyLane 42.9% pass; QCoder 2026: ~70%
46
+ one-shot failure). qcheck catches the avoidable share of that early.
47
+
48
+ ```bash
49
+ qcheck verify circuit.qasm
50
+ qcheck verify snippet.py --json
51
+ ```
52
+
53
+ ## Why this exists
54
+
55
+ An LLM agent (or a developer pasting from a chat assistant) produces a Qiskit/QASM snippet.
56
+ Will it run? Is it using an API that was removed in Qiskit 1.0? Does it measure?
57
+ Is it even safe to touch? Today you find out by running it - wasting time, and
58
+ in an agent loop, running untrusted model output. `qcheck` answers in
59
+ milliseconds, statically.
60
+
61
+ ## Install
62
+
63
+ ```bash
64
+ # From source (works today)
65
+ git clone https://github.com/JCQuankey/qcheck && cd qcheck
66
+ pip install -e ".[dev]" # editable install + pytest
67
+ ```
68
+
69
+ Once the first release is published, install from PyPI:
70
+
71
+ ```bash
72
+ pip install qcheck-quantum # available after the first PyPI release
73
+ ```
74
+
75
+ The PyPI **distribution** name is `qcheck-quantum` (the bare `qcheck` name is
76
+ taken on PyPI); the installed **command** and the import package are both
77
+ `qcheck`. v0 has **zero runtime dependencies** (standard library only). Release
78
+ process: [`docs/RELEASING.md`](https://github.com/JCQuankey/qcheck/blob/main/docs/RELEASING.md).
79
+
80
+ ## Quickstart
81
+
82
+ ```bash
83
+ qcheck verify examples/broken_qiskit_execute.py # one file
84
+ qcheck verify examples/ # a whole directory (recursive)
85
+ qcheck verify a.py b.qasm circuits/ # several paths at once
86
+ cat snippet.py | qcheck verify - # stdin (for agents)
87
+ ```
88
+
89
+ Example output:
90
+
91
+ ```
92
+ qcheck 0.2.0 [FAIL] examples/broken_qiskit_execute.py (qiskit)
93
+ [error] QISKIT-REMOVED-IMPORT: 'from qiskit import execute' was removed in Qiskit 1.0
94
+ [warning] QISKIT-DEPRECATED-GATE: QuantumCircuit.cnot() is deprecated; use .cx().
95
+ fix -> Replace execute() with a primitive (Sampler/Estimator) or backend.run().
96
+ ```
97
+
98
+ Reviewing multiple files prints a per-file summary and exits with the worst
99
+ result found (unsafe > failed > passed). Directory recursion skips virtualenvs,
100
+ VCS, caches, and build output (`.venv`, `node_modules`, `.git`, `site-packages`,
101
+ `build`, `dist`, ...) so it reviews your code, not your dependencies. To review a
102
+ file inside one of those, pass it explicitly.
103
+
104
+ ## JSON output (for agents & CI)
105
+
106
+ ```bash
107
+ qcheck verify snippet.py --json
108
+ ```
109
+
110
+ For a single file, returns `{status, framework, syntax_valid, unsafe,
111
+ static_checks, errors, warnings, suggested_fixes, confidence,
112
+ runnable_in_simulator, qcheck_version}`. For multiple files or a directory,
113
+ returns an envelope `{qcheck_version, results: [<per-file object + "path">...],
114
+ summary: {files, passed, failed, unsafe, read_errors}}`. Designed to be parsed by
115
+ an LLM agent that just generated the code, or by a CI gate. Exit codes: `0` pass,
116
+ `1` verification failed, `2` unsafe/unsupported, `3` internal error.
117
+
118
+ ## Use it in CI (GitHub Action)
119
+
120
+ qcheck ships a composite GitHub Action. In your repo's
121
+ `.github/workflows/qcheck.yml`:
122
+
123
+ ```yaml
124
+ - uses: actions/checkout@v4
125
+ - uses: JCQuankey/qcheck@main
126
+ with:
127
+ paths: "." # or a folder, e.g. "circuits/"
128
+ ```
129
+
130
+ The step fails the job when qcheck finds errors or unsafe code. See
131
+ [`examples/github-action.yml`](https://github.com/JCQuankey/qcheck/blob/main/examples/github-action.yml).
132
+
133
+ ## SARIF output (GitHub Code Scanning)
134
+
135
+ qcheck can emit SARIF 2.1.0 so findings show up as **code scanning alerts** on
136
+ the Security tab and inline on pull requests, instead of only in the log:
137
+
138
+ ```bash
139
+ qcheck verify . --format sarif --output qcheck.sarif
140
+ ```
141
+
142
+ In a workflow, generate the SARIF and let the caller upload it (upload needs
143
+ `security-events: write`, best granted by the consuming repo):
144
+
145
+ ```yaml
146
+ permissions:
147
+ contents: read
148
+ security-events: write
149
+ steps:
150
+ - uses: actions/checkout@v4
151
+ - uses: JCQuankey/qcheck@main
152
+ with:
153
+ format: sarif
154
+ output: qcheck.sarif
155
+ - uses: github/codeql-action/upload-sarif@v3
156
+ with:
157
+ sarif_file: qcheck.sarif
158
+ ```
159
+
160
+ SARIF reports static qcheck findings (rule id, level, file, line) - it does not
161
+ prove quantum correctness. `stdin` input uses a synthetic `stdin` URI and is not
162
+ meant for code-scanning upload.
163
+
164
+ ## What v0 checks
165
+
166
+ **OpenQASM 2/3:** missing header, undeclared registers, index-out-of-range,
167
+ malformed measurements, unsupported includes, suspicious non-QASM content.
168
+ **Qiskit Python:** Python syntax, missing `QuantumCircuit` import, missing
169
+ measurement, and Qiskit-1.0 breaking changes LLMs still emit (`execute()`,
170
+ `from qiskit import Aer/execute`, deprecated gate aliases like `cnot`->`cx`).
171
+
172
+ ## Safety policy
173
+
174
+ `qcheck` **never executes the input.** Qiskit snippets are analyzed with the
175
+ Python `ast` module (parse, don't run). Any filesystem/network/process/dynamic-
176
+ exec construct (`os`, `subprocess`, `eval`, `open`, ...) marks the snippet
177
+ **unsafe** and exits `2`. QASM input is text-scanned. This is deliberate: an
178
+ agent-facing verifier that *ran* untrusted model output would be a remote-code-
179
+ execution vector (see Qiskit CVE-2025-2000 for the QPY/pickle precedent). See
180
+ [`SECURITY.md`](https://github.com/JCQuankey/qcheck/blob/main/SECURITY.md) for the full threat model.
181
+
182
+ ## Scope
183
+
184
+ qcheck v0 focuses on static review signals for Qiskit and OpenQASM: API usage
185
+ (including Qiskit 1.0 removals), unsafe patterns, missing measurements, parse
186
+ issues, and common LLM-generated mistakes. It reviews code without executing it,
187
+ so it's safe to run on untrusted model output inside an agent loop or CI.
188
+
189
+ It's a fast first-pass reviewer - pair it with your tests and simulators for the
190
+ rest. For methodology and scope details, see the
191
+ [leaderboard methodology](https://github.com/JCQuankey/qcheck/blob/main/leaderboard/methodology.md).
192
+
193
+ ## Roadmap
194
+
195
+ - v0 (this): CLI, Qiskit + OpenQASM static checks, JSON, safety screen. **Zero runtime deps.**
196
+ - v1: sandboxed simulation (opt-in), PennyLane + Cirq, LLM-powered fix suggestions, GitHub Action, MCP server (`verify_quantum_code`).
197
+ - Public **static-check leaderboard** for LLM-generated quantum code (see `leaderboard/`) + anonymized error dataset.
198
+
199
+ ## Leaderboard
200
+
201
+ qcheck includes a **static review benchmark** for AI-generated quantum code: it
202
+ tracks how often model outputs pass qcheck's current review checks
203
+ (`static_pass_rate`) on a small public Qiskit/OpenQASM task set - an early quality
204
+ signal for agents and LLM workflows. The rows shown today are labelled **SAMPLE/demo**.
205
+
206
+ - [`leaderboard/README.md`](https://github.com/JCQuankey/qcheck/blob/main/leaderboard/README.md) - how to add a submission and run it
207
+ - [`leaderboard/methodology.md`](https://github.com/JCQuankey/qcheck/blob/main/leaderboard/methodology.md) - scope and methodology
208
+ - [`leaderboard/site/leaderboard.md`](https://github.com/JCQuankey/qcheck/blob/main/leaderboard/site/leaderboard.md) - the generated table
209
+
210
+ ## Contributing
211
+
212
+ Issues and PRs welcome - especially new failure fixtures (a real LLM-generated
213
+ snippet that should fail but currently passes, or vice versa). Each fixture
214
+ makes qcheck sharper and feeds the public error taxonomy.
215
+
216
+ ## Contact
217
+
218
+ - Technical questions / maintainer contact: **dev@quankey.xyz**
219
+ - Security issues: **security@quankey.xyz** (see [`SECURITY.md`](https://github.com/JCQuankey/qcheck/blob/main/SECURITY.md))
220
+
221
+ Maintained by JCQuankey / qcheck contributors. qcheck runs locally, sends no
222
+ telemetry, and reviews code without executing it.
223
+
224
+ ## License
225
+
226
+ Apache-2.0.
@@ -0,0 +1,193 @@
1
+ # qcheck
2
+
3
+ **AI writes quantum code. qcheck reviews it.**
4
+
5
+ `qcheck` is a lightweight review layer for AI-generated Qiskit and OpenQASM
6
+ snippets. It catches common issues early - removed-in-1.0 APIs, unsafe patterns,
7
+ missing measurements, parse errors - so agents and developers can improve quantum
8
+ code before it reaches humans, CI, or simulators. Tiny, dependency-free, and it
9
+ reviews code without ever executing it.
10
+
11
+ Why it matters: LLMs write quantum code that fails to run **40-70% of the time**
12
+ one-shot (QuanBench+ 2026: Qiskit 59.5% / PennyLane 42.9% pass; QCoder 2026: ~70%
13
+ one-shot failure). qcheck catches the avoidable share of that early.
14
+
15
+ ```bash
16
+ qcheck verify circuit.qasm
17
+ qcheck verify snippet.py --json
18
+ ```
19
+
20
+ ## Why this exists
21
+
22
+ An LLM agent (or a developer pasting from a chat assistant) produces a Qiskit/QASM snippet.
23
+ Will it run? Is it using an API that was removed in Qiskit 1.0? Does it measure?
24
+ Is it even safe to touch? Today you find out by running it - wasting time, and
25
+ in an agent loop, running untrusted model output. `qcheck` answers in
26
+ milliseconds, statically.
27
+
28
+ ## Install
29
+
30
+ ```bash
31
+ # From source (works today)
32
+ git clone https://github.com/JCQuankey/qcheck && cd qcheck
33
+ pip install -e ".[dev]" # editable install + pytest
34
+ ```
35
+
36
+ Once the first release is published, install from PyPI:
37
+
38
+ ```bash
39
+ pip install qcheck-quantum # available after the first PyPI release
40
+ ```
41
+
42
+ The PyPI **distribution** name is `qcheck-quantum` (the bare `qcheck` name is
43
+ taken on PyPI); the installed **command** and the import package are both
44
+ `qcheck`. v0 has **zero runtime dependencies** (standard library only). Release
45
+ process: [`docs/RELEASING.md`](https://github.com/JCQuankey/qcheck/blob/main/docs/RELEASING.md).
46
+
47
+ ## Quickstart
48
+
49
+ ```bash
50
+ qcheck verify examples/broken_qiskit_execute.py # one file
51
+ qcheck verify examples/ # a whole directory (recursive)
52
+ qcheck verify a.py b.qasm circuits/ # several paths at once
53
+ cat snippet.py | qcheck verify - # stdin (for agents)
54
+ ```
55
+
56
+ Example output:
57
+
58
+ ```
59
+ qcheck 0.2.0 [FAIL] examples/broken_qiskit_execute.py (qiskit)
60
+ [error] QISKIT-REMOVED-IMPORT: 'from qiskit import execute' was removed in Qiskit 1.0
61
+ [warning] QISKIT-DEPRECATED-GATE: QuantumCircuit.cnot() is deprecated; use .cx().
62
+ fix -> Replace execute() with a primitive (Sampler/Estimator) or backend.run().
63
+ ```
64
+
65
+ Reviewing multiple files prints a per-file summary and exits with the worst
66
+ result found (unsafe > failed > passed). Directory recursion skips virtualenvs,
67
+ VCS, caches, and build output (`.venv`, `node_modules`, `.git`, `site-packages`,
68
+ `build`, `dist`, ...) so it reviews your code, not your dependencies. To review a
69
+ file inside one of those, pass it explicitly.
70
+
71
+ ## JSON output (for agents & CI)
72
+
73
+ ```bash
74
+ qcheck verify snippet.py --json
75
+ ```
76
+
77
+ For a single file, returns `{status, framework, syntax_valid, unsafe,
78
+ static_checks, errors, warnings, suggested_fixes, confidence,
79
+ runnable_in_simulator, qcheck_version}`. For multiple files or a directory,
80
+ returns an envelope `{qcheck_version, results: [<per-file object + "path">...],
81
+ summary: {files, passed, failed, unsafe, read_errors}}`. Designed to be parsed by
82
+ an LLM agent that just generated the code, or by a CI gate. Exit codes: `0` pass,
83
+ `1` verification failed, `2` unsafe/unsupported, `3` internal error.
84
+
85
+ ## Use it in CI (GitHub Action)
86
+
87
+ qcheck ships a composite GitHub Action. In your repo's
88
+ `.github/workflows/qcheck.yml`:
89
+
90
+ ```yaml
91
+ - uses: actions/checkout@v4
92
+ - uses: JCQuankey/qcheck@main
93
+ with:
94
+ paths: "." # or a folder, e.g. "circuits/"
95
+ ```
96
+
97
+ The step fails the job when qcheck finds errors or unsafe code. See
98
+ [`examples/github-action.yml`](https://github.com/JCQuankey/qcheck/blob/main/examples/github-action.yml).
99
+
100
+ ## SARIF output (GitHub Code Scanning)
101
+
102
+ qcheck can emit SARIF 2.1.0 so findings show up as **code scanning alerts** on
103
+ the Security tab and inline on pull requests, instead of only in the log:
104
+
105
+ ```bash
106
+ qcheck verify . --format sarif --output qcheck.sarif
107
+ ```
108
+
109
+ In a workflow, generate the SARIF and let the caller upload it (upload needs
110
+ `security-events: write`, best granted by the consuming repo):
111
+
112
+ ```yaml
113
+ permissions:
114
+ contents: read
115
+ security-events: write
116
+ steps:
117
+ - uses: actions/checkout@v4
118
+ - uses: JCQuankey/qcheck@main
119
+ with:
120
+ format: sarif
121
+ output: qcheck.sarif
122
+ - uses: github/codeql-action/upload-sarif@v3
123
+ with:
124
+ sarif_file: qcheck.sarif
125
+ ```
126
+
127
+ SARIF reports static qcheck findings (rule id, level, file, line) - it does not
128
+ prove quantum correctness. `stdin` input uses a synthetic `stdin` URI and is not
129
+ meant for code-scanning upload.
130
+
131
+ ## What v0 checks
132
+
133
+ **OpenQASM 2/3:** missing header, undeclared registers, index-out-of-range,
134
+ malformed measurements, unsupported includes, suspicious non-QASM content.
135
+ **Qiskit Python:** Python syntax, missing `QuantumCircuit` import, missing
136
+ measurement, and Qiskit-1.0 breaking changes LLMs still emit (`execute()`,
137
+ `from qiskit import Aer/execute`, deprecated gate aliases like `cnot`->`cx`).
138
+
139
+ ## Safety policy
140
+
141
+ `qcheck` **never executes the input.** Qiskit snippets are analyzed with the
142
+ Python `ast` module (parse, don't run). Any filesystem/network/process/dynamic-
143
+ exec construct (`os`, `subprocess`, `eval`, `open`, ...) marks the snippet
144
+ **unsafe** and exits `2`. QASM input is text-scanned. This is deliberate: an
145
+ agent-facing verifier that *ran* untrusted model output would be a remote-code-
146
+ execution vector (see Qiskit CVE-2025-2000 for the QPY/pickle precedent). See
147
+ [`SECURITY.md`](https://github.com/JCQuankey/qcheck/blob/main/SECURITY.md) for the full threat model.
148
+
149
+ ## Scope
150
+
151
+ qcheck v0 focuses on static review signals for Qiskit and OpenQASM: API usage
152
+ (including Qiskit 1.0 removals), unsafe patterns, missing measurements, parse
153
+ issues, and common LLM-generated mistakes. It reviews code without executing it,
154
+ so it's safe to run on untrusted model output inside an agent loop or CI.
155
+
156
+ It's a fast first-pass reviewer - pair it with your tests and simulators for the
157
+ rest. For methodology and scope details, see the
158
+ [leaderboard methodology](https://github.com/JCQuankey/qcheck/blob/main/leaderboard/methodology.md).
159
+
160
+ ## Roadmap
161
+
162
+ - v0 (this): CLI, Qiskit + OpenQASM static checks, JSON, safety screen. **Zero runtime deps.**
163
+ - v1: sandboxed simulation (opt-in), PennyLane + Cirq, LLM-powered fix suggestions, GitHub Action, MCP server (`verify_quantum_code`).
164
+ - Public **static-check leaderboard** for LLM-generated quantum code (see `leaderboard/`) + anonymized error dataset.
165
+
166
+ ## Leaderboard
167
+
168
+ qcheck includes a **static review benchmark** for AI-generated quantum code: it
169
+ tracks how often model outputs pass qcheck's current review checks
170
+ (`static_pass_rate`) on a small public Qiskit/OpenQASM task set - an early quality
171
+ signal for agents and LLM workflows. The rows shown today are labelled **SAMPLE/demo**.
172
+
173
+ - [`leaderboard/README.md`](https://github.com/JCQuankey/qcheck/blob/main/leaderboard/README.md) - how to add a submission and run it
174
+ - [`leaderboard/methodology.md`](https://github.com/JCQuankey/qcheck/blob/main/leaderboard/methodology.md) - scope and methodology
175
+ - [`leaderboard/site/leaderboard.md`](https://github.com/JCQuankey/qcheck/blob/main/leaderboard/site/leaderboard.md) - the generated table
176
+
177
+ ## Contributing
178
+
179
+ Issues and PRs welcome - especially new failure fixtures (a real LLM-generated
180
+ snippet that should fail but currently passes, or vice versa). Each fixture
181
+ makes qcheck sharper and feeds the public error taxonomy.
182
+
183
+ ## Contact
184
+
185
+ - Technical questions / maintainer contact: **dev@quankey.xyz**
186
+ - Security issues: **security@quankey.xyz** (see [`SECURITY.md`](https://github.com/JCQuankey/qcheck/blob/main/SECURITY.md))
187
+
188
+ Maintained by JCQuankey / qcheck contributors. qcheck runs locally, sends no
189
+ telemetry, and reviews code without executing it.
190
+
191
+ ## License
192
+
193
+ Apache-2.0.
@@ -0,0 +1,53 @@
1
+ [build-system]
2
+ requires = ["setuptools>=61"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ # Distribution name: 'qcheck' is already taken on PyPI (an unrelated data-
7
+ # validation library), so we publish as 'qcheck-quantum'. The CLI command and
8
+ # import package both remain 'qcheck'.
9
+ name = "qcheck-quantum"
10
+ version = "0.2.0"
11
+ description = "Verify LLM-generated quantum code (Qiskit / OpenQASM) statically and safely."
12
+ readme = "README.md"
13
+ requires-python = ">=3.9"
14
+ license = { text = "Apache-2.0" }
15
+ authors = [{ name = "qcheck contributors" }]
16
+ maintainers = [{ name = "JCQuankey", email = "dev@quankey.xyz" }]
17
+ keywords = ["quantum", "qiskit", "openqasm", "llm", "linter", "code-review", "static-analysis", "sarif"]
18
+ classifiers = [
19
+ "Development Status :: 3 - Alpha",
20
+ "Intended Audience :: Developers",
21
+ "License :: OSI Approved :: Apache Software License",
22
+ "Operating System :: OS Independent",
23
+ "Programming Language :: Python :: 3",
24
+ "Programming Language :: Python :: 3.9",
25
+ "Programming Language :: Python :: 3.10",
26
+ "Programming Language :: Python :: 3.11",
27
+ "Programming Language :: Python :: 3.12",
28
+ "Topic :: Software Development :: Quality Assurance",
29
+ "Topic :: Scientific/Engineering :: Physics",
30
+ ]
31
+ # v0 intentionally has ZERO runtime dependencies (stdlib only: argparse, ast).
32
+ dependencies = []
33
+
34
+ [project.optional-dependencies]
35
+ dev = ["pytest>=7"]
36
+ # Maintainer tooling for building/checking distributions (not needed at runtime).
37
+ release = ["build>=1", "twine>=5"]
38
+
39
+ [project.urls]
40
+ Homepage = "https://github.com/JCQuankey/qcheck"
41
+ Repository = "https://github.com/JCQuankey/qcheck"
42
+ Issues = "https://github.com/JCQuankey/qcheck/issues"
43
+
44
+ [project.scripts]
45
+ qcheck = "qcheck.cli:main"
46
+
47
+ [tool.setuptools]
48
+ packages = ["qcheck"]
49
+
50
+ [tool.pytest.ini_options]
51
+ # Don't collect tests out of local build/dist copies (avoids duplicate-module
52
+ # import errors after `python -m build`).
53
+ norecursedirs = ["build", "dist", ".venv", "*.egg-info"]