Skip to content

Rust Coding Standards — Working draft

These are proposed shared rules, not automatically accepted policy for every Zevarix repository. A project may explicitly adopt the latest main guidance without maintaining a commit pin, or choose a fixed revision for a specific assurance need. It retains its own scope, exceptions and stronger local rules. Code that predates adoption is not automatically noncompliant.

For a practical review of unnecessary abstraction and repeated expensive work in generated code, see Anti AI Slop Rust. The same quality expectations apply to human contributors.

Rule levels

  • Required: the default expectation within an adopting project's declared scope. Deviations need a locally documented technical reason, not permission from this repository.
  • Advisory: a preferred design or review question. Departures may be sensible and are not automatic review failures.

For either level, reviewers report demonstrated problems with a concrete call path, trigger and impact. A rule name by itself is not proof of a defect. Tool errors block only the affected validation claim or operation; they do not end unrelated safe progress.

Rule IDs use the prefix RCS for Rust Coding Standards. The rest of each ID identifies the subject and individual rule.

Index

Rule Level Enforced by Concern
RCS-FMT-001 Required rustfmt Consistent Rust formatting
RCS-NAME-001 Required Compiler/Clippy + review Naming conventions
RCS-MOD-001 Advisory Human review Cohesive modules, not line quotas
RCS-META-001 Advisory Review/tests Use package release metadata, not duplicate version literals
RCS-TYPE-001 Required* Review/tests Prevent identity/unit mixups
RCS-NUM-001 Required* Review/tests Checked sizes, offsets and budgets
RCS-NUM-002 Required* Review/tests Explicit fallible narrowing
RCS-INPUT-001 Required* Review/tests Bound actual untrusted decode work
RCS-INPUT-002 Required* Review/tests Reject incomplete authoritative parsing
RCS-API-001 Advisory Review/Clippy Conventional Rust APIs
RCS-ERR-001 Required Review/Clippy/tests Result and error propagation
RCS-ERR-002 Advisory Human review/tests Diagnostic boundaries
RCS-PROC-001 Required* Review/fake tools Qualified structured process argv
RCS-PROC-002 Required* Review/fake tools Verify bounded process outcomes
RCS-SAFE-001 Required* Review/tests unsafe soundness
RCS-DATA-001 Required* Review/tests Non-destructive defaults
RCS-FS-001 Required* Review/tests Current file/target identity at effects
RCS-PATH-001 Required* Review/tests Native path representation vs physical identity
RCS-DB-001 Required* Review/tests Atomic guarded SQLite transitions
RCS-DB-002 Required* Review/tests Validate live SQLite enforcement schema
RCS-STATE-001 Required* Review/tests Prove output before completion
RCS-STATE-002 Required* Review/tests Reconcile ambiguous retry outcomes
RCS-CANCEL-001 Required* Review/tests Stop requests versus effect truth
RCS-CONC-001 Required* Review/contended tests Atomic shared-state admission
RCS-PERF-001 Required* Review/instrumentation Avoid costly duplicate work
RCS-PERF-002 Advisory Profiling/review Avoid premature optimization
RCS-PROGRESS-001 Required* Review/tests Observable long-running work
RCS-TERM-001 Required* Review/tests Recoverable terminal presentation
RCS-LOG-001 Required* Review/tests Safe bounded diagnostics
RCS-TEST-001 Required Tests/review Synthetic fixture isolation
RCS-TEST-002 Required* Tests/review Negative-path coverage
RCS-TEST-003 Advisory Review Behavioral tests with named cases
RCS-TEST-004 Advisory Focused tests/coverage/mutation review Risk-weighted behavioral verification
RCS-DOC-001 Advisory Rustdoc/review Important invariants
RCS-TOOL-001 Advisory rustfmt/Clippy/review Align edition, format and lints
RCS-TOOL-002 Required* CI/review Validate actual supported targets

Required* means required when that rule's stated applicability condition holds (for example, user-owned data or a large-file hot path), not when an unrelated project feature is absent.

Using these rules in a code review

Follow the reviewer guide to select applicable rule IDs, trace affected call paths, record evidence-backed findings, and separate correctness defects from optional suggestions. A consuming repository must explicitly adopt these rules (normally the latest main, or an intentional fixed revision) before they are binding requirements.

Application

Review standards in proportion to the change. A library API and a private command-line module have different concerns; a one-time small string operation and repeated multi-gigabyte image hashing have different costs.

Do not weaken existing identity checks, concurrency guarantees, input validation, recovery proof or data-integrity constraints just to satisfy a performance or simplicity suggestion. Safety-critical patterns are useful as references but no external certification or unpublished preview is incorporated wholesale.

Evidence and exceptions

When a rule warrants an actionable finding, record ID → path/symbol → concrete trigger → consequence → smallest safe fix/test. Label stylistic suggestions separately.

An adopting project may explain an exception inline near the code or in its own rules/ADR. A documented exception must still satisfy the project's actual functional and safety contracts. A large but cohesive module can be entirely acceptable; numerical file-size or method-count limits are not part of these standards.

See Sources and attribution for upstream materials and attribution.