# Contributing
Thank you for contributing to `dmvs`. Keep changes focused, document public APIs, and add tests for behavior changes.
## Development setup
Install a current stable Rust toolchain with `rustfmt` and Clippy. The crate uses Rust 2024, supports Rust 1.89 and newer, and forbids unsafe code. Check the declared MSRV after dependency updates.
Run the same offline checks as CI before submitting a change:
```sh
cargo fmt --all -- --check
cargo clippy --locked --all-targets --all-features -- -D warnings
cargo test --locked
cargo test --all-features --locked
cargo check --examples --locked
RUSTDOCFLAGS="-D warnings" cargo doc --all-features --no-deps --locked
cargo package --locked --allow-dirty
```
Check `serde` and `tracing` independently. CI also checks the declared MSRV and an all-feature `x86_64-unknown-linux-musl` build when supported by the resolved dependencies. Normal tests never contact ČÚZK or require credentials.
## Public API and protocol changes
- Keep the focused surface at exactly **5 services and 18 official operations**: R18a (1), R18b (4), R19 public/non-public custom-area submission/result pairs (4), R24a (5), and R49 (4). Expanding the surface requires an explicit scope decision.
- Prefer descriptive English API names and established ecosystem crates over protocol reimplementation.
- Preserve explicit environment selection and never make production the default.
- Require both `.identity(TlsIdentity)` and `.subject_id(SubjectId)` during client construction, and keep `.build()` failing when either is absent. `Client::subject_id()` returns `&SubjectId`.
- Keep the configured subject explicit: never infer it from the certificate or place it in HTTP/SOAP headers. mTLS authenticates transport. R19/R49 automatically use the subject in their existing business XML; R18a/R24a do not serialize it, and R18b lookup targets remain per-call arguments.
- Use the request constructors `InfrastructureManagerInquiryRequest::new(selector, identification)`, `PublicCustomAreaDatasetRequest::new(valid_on, contents, area, format)`, and `NonPublicCustomAreaDatasetRequest::new(status, evidence, contents, valid_on, area, format)`. Preserve optional notification email, R19 region controls, and serializer field order.
- Non-public R19 is for eligible downstream consumers. `ZadatelDleZadosti` requires genuine evidence; other genuine qualifying statuses remain modeled on the same operations and are not separate endpoints. Never fabricate legal authority or treat supplied status/evidence as proof of eligibility.
- Never add automatic retries to application-asynchronous submissions or other operations whose outcome is ambiguous after dispatch.
- Keep submission, result/status, waiting, report retrieval, and dataset download independently callable. Waiting must never download result content or retrieve R49 parts/reports implicitly. The only convenience waits are for public/non-public R19 and R49.
- Keep private keys, personal/query data, subject and request IDs, response bodies, polygons, dataset URLs, and file contents out of logs and debugging output.
- Preserve unknown protocol codes and original payload bytes. Do not infer an undocumented checksum algorithm from digest length.
- Use `geo-types` for public polygon/multipolygon values. Keep CRS and GML conversion in this crate and never swap axes or reproject implicitly.
- Keep public and non-public dataset content types distinct. `Ti` is valid only for non-public R19 requests.
- Update README examples, crate documentation, and `CHANGELOG.md` when changing consumer-visible behavior.
- Record official source URLs, retrieval dates, versions, and hashes in `SCHEMAS.md` when updating protocol inputs. Never fetch them during builds.
## Live tests
The live test is an optional maintainer check, never part of CI or routine verification. The single separately authorized, read-only **R24a smoke target** is in `tests/live.rs`. It performs no submissions, polling, or downloads. Do not describe a successful smoke read as general environment verification or business authorization.
Use only separately supplied authorized credentials and non-sensitive test data. Select the environment explicitly with `DMVS_ENVIRONMENT=integration` or `DMVS_ENVIRONMENT=production`; there is no default. INTEG loads the gitignored `.env.integ`, while production loads the gitignored `.env`. The selector and `DMVS_RUN_LIVE_TESTS=1` opt-in must be process environment variables. Credential values may come from the selected file or process environment:
- `DMVS_SUBJECT`: authorized test subject identifier required by client construction;
- `DMVS_PRIVATE_KEY`: unencrypted RSA PKCS#8 private-key **PEM contents**, not a path;
- `DMVS_CERTIFICATE_CHAIN`: client certificate-chain **PEM contents**, not a path.
Never commit `.env`, `.env.integ`, credentials, real subject identifiers, private records, or live responses. Normal test runs leave the live target ignored.
After explicit INTEG authorization, run:
```sh
DMVS_RUN_LIVE_TESTS=1 DMVS_ENVIRONMENT=integration cargo test --test live -- --ignored --test-threads=1
```
Production testing requires a **separate explicit production-test request**; INTEG authorization does not authorize production. Only after that request, run:
```sh
DMVS_RUN_LIVE_TESTS=1 DMVS_ENVIRONMENT=production cargo test --test live -- --ignored --test-threads=1
```
## Changelog and releases
Record consumer-visible changes under `Unreleased` in `CHANGELOG.md`, using the Keep a Changelog categories. Do not assign a version or date until a release is explicitly prepared.
Releases are maintainer-only and use the [published-release workflow](.github/workflows/release.yml):
1. Start from a reviewed `main` branch with passing CI. When protocol behavior or wire dependencies changed, run the explicitly authorized read-only live checks manually.
2. Update the version in `Cargo.toml` and any dependency examples in `README.md`.
3. Move the relevant `Unreleased` changelog entries into a `## [X.Y.Z] - YYYY-MM-DD` section, retain an empty `Unreleased` section for future changes, and update the changelog comparison and release links.
4. Commit and review these changes. Prepare a GitHub release from the release commit with a new or existing `vX.Y.Z` tag exactly matching the package version, and use the dated changelog section for its notes. Drafts can be reviewed before publication. crates.io releases are immutable, so publish the GitHub release only when ready.
5. Publishing the GitHub release triggers the workflow. It checks out the release tag, validates that the tag matches the package version and an exact dated changelog heading exists, runs the full offline verification matrix and publication dry-run, and publishes only to crates.io. It never creates or modifies the GitHub release and never runs live tests.
6. Verify the published crates.io page, docs.rs build, GitHub release notes, and rendered documentation links. If crate publication fails, the existing GitHub release remains in place while the workflow is fixed or rerun.
The GitHub repository must have a suitably scoped `CARGO_REGISTRY_TOKEN` Actions secret with permission to publish the crate. Keep release credentials in the repository's secret store, never in workflow files or other committed content.
## Licensing
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in this crate is licensed under the MIT License, without additional terms or conditions.