|
| 1 | +# Repository Guidelines |
| 2 | + |
| 3 | +## Project Structure & Modules |
| 4 | +- `crates/core` (crate: `freenet`): core node and the `freenet` binary. |
| 5 | +- `crates/fdev` (crate: `fdev`): developer CLI for packaging, running, and tooling. |
| 6 | +- `apps/*`: example apps and contracts (e.g., `apps/freenet-ping`). |
| 7 | +- `tests/*`: integration test crates and app/contract fixtures. |
| 8 | +- `scripts/`: local network helpers, deployment, and setup guides. |
| 9 | +- `.github/workflows`: CI for build, test, clippy, and fmt. |
| 10 | + |
| 11 | +## Build, Test, and Dev |
| 12 | +- Init submodules (required): `git submodule update --init --recursive`. |
| 13 | +- Build all: `cargo build --workspace --locked`. |
| 14 | +- Run core: `cargo run -p freenet --bin freenet`. |
| 15 | +- Install binaries: `cargo install --path crates/core` and `cargo install --path crates/fdev`. |
| 16 | +- Test (workspace): `cargo test --workspace --no-default-features --features trace,websocket,redb`. |
| 17 | +- Example app build: `make -C apps/freenet-ping -f run-ping.mk build`. |
| 18 | +- Optional target for contracts: `rustup target add wasm32-unknown-unknown`. |
| 19 | + |
| 20 | +## Coding Style & Naming |
| 21 | +- Rust 2021, toolchain ≥ 1.80. |
| 22 | +- Format: `cargo fmt` (CI enforces `cargo fmt -- --check`). |
| 23 | +- Lint: `cargo clippy -- -D warnings` (no warnings in PRs). |
| 24 | +- Naming: crates/modules `snake_case`; types/enums `PascalCase`; constants `SCREAMING_SNAKE_CASE`. |
| 25 | +- Keep features explicit (e.g., `--no-default-features --features trace,websocket,redb`). |
| 26 | + |
| 27 | +## Testing Guidelines |
| 28 | +- Unit tests in-module with `#[cfg(test)]`; integration tests under `tests/*` crates. |
| 29 | +- Prefer meaningful coverage for changed public behavior and error paths. |
| 30 | +- Deterministic tests only; avoid external network unless mocked. |
| 31 | +- Run: `cargo test --workspace` before pushing. |
| 32 | + |
| 33 | +## Commits & Pull Requests |
| 34 | +- Commit style: conventional prefixes (`feat:`, `fix:`, `chore:`, `refactor:`, `docs:`, `release:`). Example: `fix: prevent node crash on channel close`. |
| 35 | +- PRs should include: clear description, rationale, linked issues, and test notes; attach logs or screenshots for app/UI changes. |
| 36 | +- CI must pass: build, tests, `clippy`, and `fmt`. |
| 37 | + |
| 38 | +## Security & Configuration |
| 39 | +- Config and secrets use platform app dirs (via `directories`). Default config/secrets are created on first run; avoid committing them. |
| 40 | +- Review changes touching networking, keys, or persistence; prefer least-privilege defaults and explicit feature gates. |
0 commit comments