This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
just check -q- Run cargo check on workspace (prefer it for checking if things compile)just build -q- Build entire workspacejust test- Run all tests (builds first) - at the current state of the project, don't use it
just format- Format Rust and Nix code (ALWAYS run after major changes)just lint- Run git pre-commit hooksjust clippy- Run clippy with deny warningsjust clippy-fix- Auto-fix clippy issues
BFTE is a Byzantine Fault Tolerant consensus engine implementing a modular architecture where consensus is the central primitive. Everything (peer management, configuration changes, module additions) goes through consensus.
- Implements Simplex BFT algorithm
- Deterministic and side-effect-free design
- Pull-based communication (peers request updates vs broadcasting)
- State maintained in database (no write-ahead log)
crates/node/- Main node driving consensus and P2P communicationcrates/node-app/- Application layer processing consensus itemscrates/node-ui-axum/- Web administration UI using Axum + Maud + Datastar
crates/module/- Module interface and effect systemcrates/modules/core-consensus/- Core consensus module- Modules communicate exclusively through typed effects (
CItemEffect) - Each module gets isolated database namespace
crates/db/- Wrapper aroundredb-bincode- All state persisted in key-value store
- No external database dependencies
- Modules implement
IModuletrait with standardized lifecycle - Use
ModuleDatabasefor isolated state management - Produce
CItemEffects for inter-module communication - Follow effect system for all module interactions
- All significant changes go through consensus items
- Avoid non-consensus APIs and state
- Use pull-based communication patterns
- Maintain deterministic, side-effect-free logic in consensus layer
- Always use standalone Rust modules (avoid inline
mods) - No comments explaining individual lines/expressions
- Follow existing code style and uniformity
- Use workspace-based build with
cargo
- NEVER use String types for form input fields - always use proper typed data
- Form structs should use domain-specific types (e.g.,
PeerPubkey,ModuleKind, etc.) - Parse and validate input at the form boundary, not in handlers
- Leverage Rust's type system for compile-time safety
- Uses
redbkey-value store for all persistence - Each module gets isolated database namespace via
ModuleDatabase - Consensus state maintained in database at all times
- No write-ahead logging - direct database state management
cargo testruns all workspace testscrates/consensus-tests/contains consensus algorithm tests- Integration tests in individual crate
tests/directories - Use
just testwhich builds before testing
- Uses
irohfor IPFS-based networking - Custom RPC system for peer communication
- Pull-based consensus communication (peers request vs broadcast)
- Federation join/invite system in
crates/invite/