Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Principle:Nautechsystems Nautilus trader Nautilus Code Conventions

From Leeroopedia


Knowledge Sources
Domains Rust, Code_Quality
Last Updated 2026-02-10 08:00 GMT

Overview

A set of project-specific Rust coding conventions that enforce idiomatic type imports, comment style, debug formatting, and error message phrasing.

Description

Nautilus Code Conventions go beyond standard Rust formatting (rustfmt) and linting (clippy) to enforce project-specific patterns that improve consistency and readability across 40+ crates. These conventions address five areas: (1) Import hygiene requires that Nautilus domain types are imported rather than fully qualified, reducing visual noise in code that heavily uses internal types. (2) Comment style prohibits box-style banner comments in favor of standard Rust doc comments. (3) std::fmt conventions establish a specific pattern: import Debug and Display traits for use in impl blocks, but always fully qualify std::fmt::Formatter and std::fmt::Result to avoid name collisions. (4) debug_struct must use stringify! to derive the struct name, ensuring refactoring safety. (5) Error message style prohibits "got" phrasing to maintain consistent error terminology.

Usage

Apply this principle when contributing Rust code to the Nautilus workspace. These conventions are automatically enforced via pre-commit hooks and CI. An exception marker (// nautilus-import-ok) allows intentional deviations where fully qualified paths are necessary.

Theoretical Basis

The conventions follow the consistency over expressiveness design principle:

# Abstract pattern (NOT real implementation)
for each_convention in [import_hygiene, comment_style, fmt_convention, debug_struct, error_phrasing]:
    violations = scan_files(rust_sources, each_convention.pattern)
    violations = filter_out(violations, exception_markers)
    report(violations)

Key design decisions:

  • Import over qualify — in a domain-heavy codebase, Price is clearer than nautilus_model::types::Price
  • stringify! for debug_struct — ensures struct names in debug output stay synchronized with the actual type name after renames
  • No "got" in errors — enforces a consistent error message template across all crates

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment