Contributing to cosmiq#
Thanks for helping. Bugs, ideas and documentation fixes start as an issue; code comes as a pull request, which the template walks you through. Everyone taking part follows the Code of Conduct.
Set up#
cosmiq uses uv. From a clone:
uv sync # the dev environment
uv sync --extra pennylane --extra qiskit --extra qec # with the extras, to test them too
Run the checks#
tools/check_all.sh # everything CI runs: format, lint, types, tests, coverage, API, build
Tests never use the network (
pytest-socket), and every warning is an error.Coverage must be 100% for every file, lines and branches (
tools/check_coverage.py).Heavy cells: two N = 13 memory tests (about 6.4 GB each) run only with
COSMIQ_EXIT_M=1, whichtools/check_all.shsets. On Linux, pytest asks you to choose:COSMIQ_EXIT_M=1runs them,COSMIQ_EXIT_M=0skips them.Types:
mypy --strict. Style:ruff formatandruff check.The docs site:
uv sync --extra pennylane --extra qiskit --extra qec --group docs, then the commands indocs/conf.py’s docstring. The build runs every tutorial.
Sign your commits (DCO)#
cosmiq uses the Developer Certificate of Origin instead of a contributor licence agreement. By signing off a commit, you state that you wrote it, or otherwise have the right to submit it under the project’s licence (Apache-2.0).
git commit -s -m "Explain the change"
-s adds a Signed-off-by: Your Name <you@example.com> line, which must match the commit’s
author. CI checks every commit in a pull request. To fix a commit you forgot to sign:
git commit --amend -s for the last one, or git rebase --signoff main for several.
Release notes#
Every change to src/ comes with a release note, written with
reno:
uv run reno new short-slug-of-the-change
Fill in the sections that apply (features, upgrade, deprecations, fixes, security). Pull
requests that don’t need one (a typo, an internal refactor) get the no-release-note label.
Versions and deprecations#
cosmiq follows semantic versioning. Before 1.0, a minor release (0.x → 0.x+1) may change the API, but never without warning:
Deprecate first. Mark the name with
cosmiq._deprecation.deprecated(or warn withCosmiqDeprecationWarning), add a line toapi/deprecated.txt, and write adeprecationsrelease note saying what to use instead.Wait at least one minor release.
Then remove it, with an
upgraderelease note.
CI enforces this. api/public_api.txt lists every public name, and every member, field and
parameter (its name, its kind, and whether it has a default). A pull request fails on a
change that breaks users’ code (a removal; a removed, moved or newly required parameter; a new
required field; a change of kind) unless api/deprecated.txt shows it was deprecated in an
earlier release and its removal version has arrived. Its keys are cosmiq.module.name,
cosmiq.module.Class.member and cosmiq.module.Class.method(arg). After 1.0, removals happen
only in major releases.
When the public API changes on purpose, regenerate the snapshot in the one pinned environment (Linux, Python 3.12, with the pennylane extra) and commit it with the change:
tools/linux.sh uv run python -m tools.api_snapshot --update
On Linux or Apple silicon with uv sync --extra pennylane, uv run python -m tools.api_snapshot --update is the same environment.
Code we accept#
Only code you wrote, or code under a licence compatible with Apache-2.0 (Apache-2.0, BSD, MIT), with its notices kept.
No
picklefor anything that crosses a process or network boundary: use JSON or arrays.Never turn off TLS certificate checks.
Releasing (maintainers)#
PyPI gets the exact wheel that was tested, never a rebuild. The Release workflow
(.github/workflows/release.yml) publishes it by trusted publishing, with an sdist built from
the tag, after a maintainer approves the pypi environment. (Set up once: that environment,
with required reviewers, and the PyPI project’s trusted publisher for this repository,
release.yml and pypi.)
In a reviewed pull request, set
versioninpyproject.toml(no.dev), add the release notes’ prelude (uv run reno new release-X-Y-Z), and checkuv run reno report. Merge it.On the merged commit, build the wheel once (
uv build --wheel), passtools/check_all.shon Linux, and test that file. Note its sha256.Tag the commit,
git tag -a vX.Y.Z -m "cosmiq X.Y.Z", push the tag, and publish a GitHub Release for it with that wheel,cosmiq-X.Y.Z-py3-none-any.whl, attached.Actions → Release → Run workflow from
main, with the tag and the wheel’s sha256. The workflow refuses a wheel whose sha256 differs, whose files aren’t the tag’ssrc/cosmiq/, or whose version isn’t the tag’s. It builds the sdist from the tag, runstools/check_wheel.shandtwine check --stricton both files, then waits for approval.After it publishes: build and publish the docs site for the release, copy the build’s
notebooks/*.ipynbto thenotebooksbranch (Colab reads them there), and open the next development version (X.Y+1.0.dev0).
Security#
Report vulnerabilities privately, as SECURITY.md says, never in a public issue.