This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
OpenFlight (Flight Hub) is a PC flight simulation input management system written in Rust. It provides unified control for flight controls, panels, and force feedback devices across MSFS, X-Plane, and DCS simulators with real-time 250Hz axis processing.
Key constraints:
- Real-time 250Hz processing with <5ms p99 latency and <0.5ms p99 jitter
- Zero allocations on RT hot paths (see ADR-004)
- Rust 2024 edition, MSRV 1.92.0
Prerequisites:
- Windows: Windows SDK for HID support
- Linux: libudev development headers (
libudev-devon Debian/Ubuntu)
# Build
cargo build --workspace
cargo build --release --workspace
cargo build --profile rt --workspace # RT-optimized with debug symbols
# Test
cargo test --workspace # All tests
cargo test -p flight-core # Single crate
cargo test -- --nocapture # With output
# Lint
cargo fmt --all -- --check
cargo clippy --workspace -- -D warnings
# Security
cargo audit --deny warnings
cargo deny checkcargo xtask check # Fast smoke test (fmt, clippy, core tests)
cargo xtask validate # Full validation (tests, benches, API checks)make quick # Clippy + pattern verification
make all # Full regression prevention
make ci-simulation # Full CI pipeline locally
make clippy-strict # Strict clippy on core crates
make feature-powerset # Test all feature combinations
make verify-patterns # Check for known problematic patterns| Gate | What it checks |
|---|---|
| QG-SANITY-GATE | Sanity telemetry tests (NaN/Inf injection, implausible jumps) |
| QG-FFB-SAFETY | Force feedback safety systems |
| QG-RT-JITTER | Timer jitter p99 ≤ 0.5ms (hardware runners) |
| QG-HID-LATENCY | HID write latency p99 ≤ 300μs (hardware runners) |
Run FFB safety tests before modifying force feedback code:
cargo test -p flight-ffb safety
cargo test -p flight-ffb envelopeThe system uses a protected 250Hz RT core that never blocks, allocates memory, or takes locks:
Non-RT Systems (Sim Adapters, Panels, Diagnostics)
│ Drop-tail queues
RT Spine (250Hz): Axis Engine │ FFB Engine │ Scheduler
Configuration changes are compiled off-thread and swapped atomically at tick boundaries.
Forbidden in RT code (flight-axis, flight-scheduler, flight-ffb hot paths):
Box::new(),Vec::push()past capacity,Stringoperations that allocateHashMap::insert()that triggers rehashingArc::new(),Rc::new()- Any blocking syscalls or locks
Allowed: Stack allocation, pre-allocated containers, atomic operations, static data.
Real-Time Core:
flight-axis- 250Hz axis processing (curves, deadzones, detents, mixers)flight-scheduler- Platform RT scheduling (MMCSS on Windows, rtkit on Linux)flight-bus- Event bus for inter-component communication
Hardware:
flight-hid- HID device managementflight-ffb- Force feedback synthesisflight-panels- Generic panel driverflight-streamdeck- StreamDeck integration
Simulators:
flight-simconnect- MSFS SimConnect adapterflight-xplane- X-Plane UDP/plugin adapterflight-dcs-export- DCS Export.lua integration
Infrastructure:
flight-core- Core types, profile management, aircraft detectionflight-ipc- gRPC-based IPC (tonic 0.14, prost 0.14)flight-profile- Profile schema and validationflight-rules- Rule engine for panel/LED control
Applications:
flight-service- Main daemon (flightd)flight-cli- CLI (flightctl)
The Makefile enforces these patterns via make verify-patterns:
- Use
Profile::merge_withnotProfile::merge - Use
std::hint::black_boxnotcriterion::black_box - All workspace dependencies via
workspace = true(especially tokio, futures, tonic)
These crates must pass cargo clippy -p <crate> -- -D warnings:
- flight-core, flight-axis, flight-bus, flight-hid
- flight-ipc, flight-service, flight-simconnect, flight-panels
Located in docs/explanation/adr/:
- ADR-001: RT Spine - Protected 250Hz core with atomic state swaps
- ADR-004: Zero-allocation constraint for RT hot paths
- ADR-005: PLL timing discipline for jitter control
- ADR-009: Safety interlock design for FFB
Documentation follows the Diataxis framework:
docs/explanation/adr/- Architecture Decision Recordsdocs/how-to/- Task-oriented guidesdocs/reference/- API and specification referencedocs/NOW_NEXT_LATER.md- Current priorities
main- Stable development branchfeat/- Feature branchesfix/- Bug fix branchesdocs/- Documentation updates
- Run
cargo xtask validateormake all - Ensure strict clippy passes on core crates
- Check
docs/NOW_NEXT_LATER.mdfor alignment with priorities