conventions/programming_rust/code_standards.yaml
Natalie 3dc5a9b321 feat(conventions): codify lilith v0-v4 conventions (py/rust/gd + 7 general)
Mined the egirl->cocotte lineage + the prose agentic configs. Per-language
standards (py/rust/gd) and general conventions: service_architecture,
multi_agent_workflow, error_handling_logging, mcp_server_patterns,
naming_conventions, tenancy_patterns (draft), database_patterns. Captures the
canonical/latest where versions diverged. 14/14 lint:yaml-valid.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-29 08:42:44 -04:00

34 lines
1.5 KiB
YAML

apiVersion: conventions/v1
version: 0.1.0
updated: "2026-06-29"
name: code_standards
title: Rust code standards
scope: rust
status: active
summary: Result-based errors (no unwrap), thiserror domain enums, pure domain crates + thin FFI/WASM shims, SAFETY comments, snake_case serde. From v2 simulator/magic-civilization.
appliesTo: ["**/*.rs"]
rules:
- id: no_unwrap
level: must
text: "Propagate via Result<_, Error>. `.unwrap()` forbidden; `.expect(\"reason\")` only when panic is provably impossible."
- id: thiserror
level: must
text: Domain error enums via `thiserror`; errors carry context (`#[from]`, source chaining).
- id: pure_domain_crates
level: must
text: "Domain crates (crates/<x>-*) are pure Rust — no FFI/WASM/GDExt deps. API crates are thin shims (WASM/GDExt surfaces) with no business logic."
- id: unsafe_documented
level: must
text: "Every `unsafe` block has a `// SAFETY:` comment justifying the invariants."
- id: serde_snake
level: should
text: 'Serde with #[serde(rename_all = "snake_case")] on wire types.'
- id: no_dead_code
level: must
text: "`#[allow(dead_code)]` forbidden — delete unused code. `todo!()`/`unimplemented!()` forbidden in shipped code."
- id: tracing
level: should
text: Structured logging via `tracing` (never `log`, never `println!` in libraries).
- id: workspace
level: should
text: "Cargo workspace resolver=\"2\"; pure domain crates + API shim crates clearly separated."