Skip to content

Contributing Guide

Welcome to the AXON project! This document describes the contribution process and conventions.

Code of Conduct

  • Friendly, inclusive, and professional communication
  • Prefer discussing design in issues before submitting large PRs
  • Code quality first; do not accept "merge first, optimize later" PRs

Contribution Process

  1. Issue First: Any non-trivial change should start with an issue for design discussion
  2. Fork & Branch: Create feature branch from main (feat/xxx / fix/xxx / docs/xxx)
  3. TDD: Write tests first for new features (see Testing Plan)
  4. Lint & Test: Run make verify locally, all checks must pass
  5. PR Description: Link issue + change description + test screenshots / benchmark results
  6. Code Review: At least 1 maintainer approval before merge
  7. Squash Merge: Use squash merge to keep main clean

Development Setup

# Clone repository
git clone https://github.com/pengwow/axon_quant.git
cd axon_quant

# Install dependencies
make setup

# Run verification
make verify

Code Style

  • Lint discipline (0.26.0+): workspace-wide [workspace.lints]; clippy::todo/clippy::unimplemented are denied except explicit allows in test stub modules; bare unwrap is denied on axon-kernel production code.

Rust

  • Follow rustfmt formatting (enforced in CI)
  • Use clippy lints with -D warnings
  • Document public APIs with /// doc comments
  • Write unit tests for all public functions
/// Calculates the Sharpe ratio from a series of returns.
///
/// # Arguments
/// * `returns` - Slice of periodic returns
/// * `risk_free_rate` - Annual risk-free rate
///
/// # Returns
/// Annualized Sharpe ratio
pub fn sharpe_ratio(returns: &[f64], risk_free_rate: f64) -> f64 {
    // Implementation
}

Python

  • Follow PEP 8 style
  • Use type hints for all function signatures
  • Write docstrings for public functions
  • Use ruff for linting (enforced in CI)
def calculate_sharpe(returns: list[float], risk_free_rate: float = 0.02) -> float:
    """Calculate annualized Sharpe ratio.

    Args:
        returns: List of periodic returns
        risk_free_rate: Annual risk-free rate

    Returns:
        Annualized Sharpe ratio
    """
    # Implementation

Python Bindings (compile check)

Binding code (crates/*/src/python/) is gated behind #[cfg(feature = "python")], so the plain cargo clippy / cargo test never compile it; the Clippy (python feature) CI job covers it. Local equivalent (the repo requires the .venv Python):

make python-lint
# = cargo clippy --workspace --all-targets --features python --locked -- -D warnings

Three things to know:

  1. Binding tests are compile-checked only — they never run: pyo3's extension-module does not link libpython, so cargo test --features python always fails at link time. Making those 400+ binding tests actually run would require splitting extension-module into its own feature enabled explicitly by maturin — still pending.
  2. Re-run this target after every pyo3 upgrade: during the 0.20→0.28 migration the binding test code had silently drifted (get_item lost its Option layer, PyRefMut<Self> receivers, pyclass instances needing Bound::new before Bound, mismatched _py parameter names) because CI never compiled it; make python-lint only surfaced it in 0.18.0.
  3. clippy::clone_on_copy is allowed on purpose: the FromPyObject impl generated by pyo3 0.28's #[pyclass(..., from_py_object)] calls Clone::clone on Copy enums (a false positive from the upstream macro expansion), so binding modules carry a module-level #![allow(clippy::clone_on_copy)]; remove it once fixed upstream.

Behavioural coverage for the bindings lives in tests/python/ (pytest, 142 cases) and is now wired into CI as the blocking python-test job; the local equivalent is make python-develop && make python-test. Three scripts that need testnet API keys / real network (test_all_scenarios.py, test_binance_adapter.py, test_okx_adapter.py) are excluded via collect_ignore in tests/python/conftest.py and are still run manually as described in each file header.

Commit Messages

Use conventional commits:

feat(rl): add new reward function
fix(exchange): handle network timeout
docs: update installation guide
test(llm): add integration tests
chore: update dependencies

Testing

Unit Tests

Run all unit tests:

cargo test --workspace

Integration Tests

Run integration tests:

cargo test --test integration_tests

Property-Based Tests

Use proptest for property-based testing:

use proptest::prelude::*;

proptest! {
    #[test]
    fn test_sharpe_ratio_bounds(returns in prop::collection::vec(-0.5..0.5, 1..100)) {
        let sr = sharpe_ratio(&returns, 0.0);
        // Sharpe ratio should be finite
        prop_assert!(sr.is_finite());
    }
}

Regression & Fix Conventions

  • Link fixes to issues: reference the issue/reporter in the CHANGELOG Fixed entries for behavior fixes
  • Regression: test comments: docs-comment the test covering a regression fix with a Regression: prefix, stating reproduction conditions and root cause
  • Golden fingerprint changes require reasoning: the reasoning field of crates/axon-integration-tests/tests/fixtures/canonical/*.json must state the change intent and the related issue; unexplained metric changes are treated as violations

Documentation

  • Update documentation for any user-facing changes
  • Add examples for new features
  • Keep README.md up to date

Release Process

  1. Update version in Cargo.toml and pyproject.toml
  2. Update CHANGELOG.md
  3. Create release PR
  4. After merge, create git tag: git tag v0.6.0
  5. Push tag: git push origin v0.6.0

Questions?

Open a GitHub Issue or reach out on the project's discussion board.