Skip to content

Commit fef3c0a

Browse files
authored
Update AGENTS.md
1 parent dc0182a commit fef3c0a

1 file changed

Lines changed: 17 additions & 112 deletions

File tree

AGENTS.md

Lines changed: 17 additions & 112 deletions
Original file line numberDiff line numberDiff line change
@@ -2,138 +2,43 @@
22

33
Project-specific instructions for working in this repository.
44

5+
## 🛡️ Licensing, IP & Compliance (CRITICAL)
6+
- **License Model**: Source-available. Free for personal, academic, educational, and non-commercial research use only.
7+
- **Commercial Use**: Institutional, lab, startup, SaaS, OEM, or product-integration use **requires a paid commercial license**.
8+
- **Official Channels**: All commercial inquiries, pilot requests, and source-review access must be directed to **admin@qector.store** or **https://qector.store/pricing**.
9+
- **Provenance**: The proprietary Rust core and licensing terms are protected and timestamped via controlled archival (e.g., Zenodo DOIs).
10+
- **Agent Rule**: If asked about licensing, sharing the core, or commercial use, *always* direct the user to the pricing page and official contact. **Never** suggest open-sourcing the Rust core, bypassing the commercial license, or removing copyright notices.
11+
512
## Project Overview
613

714
QECTOR Decoder v3 is a high-performance, source-available Rust/Python platform for quantum error correction (QEC) decoding.
815

916
- **Core**: Rust (PyO3 cdylib) implementing Union-Find, Blossom (exact MWPM), Sparse Blossom, BP-OSD, sliding-window, streaming, batch decoders, lookup tables, neural/GNN predecoders, hybrid decoders.
10-
- **Python package**: `qector_decoder_v3` (published on PyPI).
17+
- **Python package**: `qector-decoder-v3` (published on PyPI).
1118
- **Bindings**: maturin + PyO3. Zero-copy NumPy arrays, GIL-free hot paths where possible.
1219
- **Hardware**: CPU (Rayon), optional CUDA batch, optional OpenCL batch. Runtime detection + graceful fallback.
13-
- **Ecosystem**: PyMatching-compatible, Stim/Sinter integration, belief-matching, Qiskit plugin, REST/gRPC + full-featured MCP server (25 tools in the QectorWorkbench companion).
20+
- **Ecosystem**: PyMatching-compatible, Stim/Sinter integration, belief-matching, Qiskit plugin, REST/gRPC + full-featured MCP server.
1421
- **Emphasis**: Syndrome faithfulness, CPU/GPU bit-identical results, extensive regression + artifact-backed benchmarks, reproducibility.
1522

16-
**Current version**: 0.6.4 (Cargo + Python packaging).
23+
**Current version**: 0.6.6 (Cargo + Python packaging).
1724

1825
**Workspace layout** (this checkout):
1926

20-
- `src/` — Rust core (all decoder implementations, batch engines, kernels, utils).
27+
- `src/` — Rust core stub. ⚠️ *The real proprietary Rust core is injected during trusted CI/release builds via secrets. Do not attempt to distribute or expose this directory publicly.*
2128
- `python/qector_decoder_v3/` — Python package sources (`__init__.py`, `backend.py`, `belief_matching.py`, `bposd.py`, `stim_compat.py`, `sinter_compat.py`, `workbench.py`, `dem.py`, etc.).
2229
- `python/tests/` — 100+ pytest tests covering correctness, faithfulness, performance, GPU parity, edge cases, benchmarks.
2330
- `proto/` — gRPC `.proto` (only for `grpc` / `full` features).
2431
- `lib/` — Windows import libs (OpenCL etc.).
25-
- `build.rs` — Handles optional protoc for gRPC + link paths.
26-
- `Cargo.toml` / `pyproject.toml` — maturin build.
27-
28-
Note: This appears to be a full-source "build" checkout (src/ contains real implementations + .cu kernels).
32+
- `build.rs` — Handles optional vendored protoc for gRPC + link paths.
33+
- `Cargo.toml` / `pyproject.toml` — maturin build configuration.
2934

30-
## Build & Install (Windows PowerShell)
35+
## Build & Install (Windows PowerShell / Linux / macOS)
3136

3237
Use a virtual environment.
3338

34-
```powershell
39+
```bash
3540
python -m venv .venv
36-
.\.venv\Scripts\Activate.ps1
41+
# Windows: .\.venv\Scripts\Activate.ps1
42+
# Linux/macOS: source .venv/bin/activate
3743
python -m pip install --upgrade pip maturin
3844
python -m pip install -e ".[stim,bench]" # or [all], [cuda], [opencl] etc.
39-
```
40-
41-
- For iterative Rust+Python dev: `maturin develop --release` (or without --release for faster debug).
42-
- Features are controlled in Cargo (default includes opencl + cuda in this workspace).
43-
- gRPC/MCP: `--features full` or `maturin develop --features full`.
44-
- CUDA kernels are compiled at runtime via NVRTC (no special build step for kernels).
45-
- After changes to Rust, re-run `maturin develop` (or restart Python interpreter).
46-
47-
Verify:
48-
49-
```powershell
50-
python -c "from qector_decoder_v3 import UnionFindDecoder, BlossomDecoder, CUDABatchDecoder; print('CUDA available:', CUDABatchDecoder.is_available() if hasattr(CUDABatchDecoder,'is_available') else 'check'); import qector_decoder_v3; print(qector_decoder_v3.__version__)"
51-
```
52-
53-
## Testing
54-
55-
Run the full Python test suite (primary validation lives here):
56-
57-
```powershell
58-
pytest python/tests/ -q
59-
```
60-
61-
Useful filters:
62-
63-
- `pytest python/tests/ -k "unionfind or blossom or faithfulness"`
64-
- `pytest python/tests/test_gpu* -q` (GPU paths)
65-
- `pytest python/tests/test_bposd* python/tests/test_belief*`
66-
- `pytest python/tests/test_clean_venv_install.py` (install hygiene)
67-
- `pytest python/tests/test_public_api_imports.py test_type_hints.py`
68-
69-
Many tests are **correctness audits** (syndrome faithful, bit-identical across backends, regression against known good results). Do not weaken or skip them lightly.
70-
71-
Rust unit tests (if present):
72-
73-
```powershell
74-
cargo test
75-
```
76-
77-
Before claiming performance or correctness improvements, re-run relevant benchmark scripts (see README) and the due-diligence style tests.
78-
79-
## Coding Conventions & Style
80-
81-
### Rust
82-
83-
- Keep hot paths allocation-free or with reusable scratch (see `uf_core`, batch workspaces).
84-
- Use `rayon` for data-parallel batch paths.
85-
- Feature-gate GPU modules (`#[cfg(feature = "cuda")]`, `#[cfg(feature = "opencl")]`).
86-
- Strong error messages for invalid inputs (see decoder constructors).
87-
- Preserve exact numerical behavior across CPU/GPU; bit-identical results are a hard requirement in many tests.
88-
- Update `build.rs` only when adding new rerun-if-changed or build-time dependencies.
89-
90-
### Python
91-
92-
- NumPy-centric. Use `numpy.typing`, keep dtypes explicit (uint8 for syndromes usually).
93-
- Public API re-exports from the compiled extension + pure-Python shims/fallbacks.
94-
- Backend selection logic lives in `backend.py` (AutoDecoder, calibration).
95-
- Compat layers (`stim_compat`, `sinter_compat`, `pymatching_compat`) must stay faithful to the wrapped behavior.
96-
- Type hints + mypy/ruff clean (dev deps include them).
97-
- Avoid holding GIL during long Rust calls where the extension releases it.
98-
99-
### General
100-
101-
- Prefer adding tests over comments for invariants.
102-
- Benchmark numbers and claims must be reproducible via checked-in scripts + artifacts.
103-
- GPU code must degrade gracefully; never assume a device is present.
104-
- Changes touching DEM handling, observables, or sliding window must touch the corresponding faithfulness tests.
105-
106-
## Common Tasks
107-
108-
- Add a new decoder variant: implement in Rust (new `Py*` class + registration in `lib.rs`), expose in `__init__.py`, add Python wrapper if needed, add tests under `python/tests/`.
109-
- Fix a bug reported by a specific test: run that test in isolation first, then broader faithfulness suite.
110-
- Change Python-only logic (e.g. `belief_matching.py`): no rebuild needed.
111-
- Touch CUDA: ensure `cuda_is_available` and fallback paths still work; run GPU parity tests.
112-
- Update public API: also update `test_public_api_imports.py`, docs if present, and type stubs if any.
113-
- Release prep: version bumps in `Cargo.toml` + `pyproject.toml`, update `__fallback_version__` in `__init__.py`.
114-
115-
## Things to Watch Out For
116-
117-
- The compiled extension (`qector_decoder_v3*.pyd` or .so) must be rebuilt after any Rust change. Stale .pyd is a common source of confusion.
118-
- Feature flags affect what symbols are present (CUDA/OpenCL/gRPC may be missing).
119-
- Windows: OpenCL uses the pre-bundled .lib in `lib/`.
120-
- Hyperedges: some fast decoders reject them (see validation code).
121-
- Memory: batch decoders and large distance codes can be memory-heavy; tests include growth/leak checks.
122-
- Never claim "faster than X" or "better LER" without running the competitive scripts on this machine and recording artifacts.
123-
124-
## When Running Commands
125-
126-
- Prefer `python -m pytest ...` over bare `pytest` for consistency.
127-
- Use the activated venv.
128-
- For long-running tests/benchmarks use the monitor tool or background where appropriate.
129-
- When editing across Rust/Python boundary, verify roundtrips (encode/decode result objects, JSON, etc.).
130-
131-
## Project Rules Priority
132-
133-
These instructions apply in addition to any higher-level or user `AGENTS.md` / rules. Deeper directory rules (if added) take precedence for files within them.
134-
135-
Follow the spirit of the existing extensive test suite: prioritize correctness, reproducibility, and faithful behavior over micro-optimizations.
136-
137-
---
138-
139-
Generated by /init on first session in this workspace. Update this file as conventions evolve.

0 commit comments

Comments
 (0)