Thank you for your interest in contributing to flagd-evaluator! This document provides guidelines and instructions for contributing.
- Code of Conduct
- Development Environment Setup
- Building the Project
- Testing
- Code Style Guidelines
- Commit Message Guidelines
- Pull Request Process
- Reporting Issues
This project adheres to the OpenFeature Code of Conduct. By participating, you are expected to uphold this code.
-
Rust: Install Rust using rustup:
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
-
WASM Target: Add the WebAssembly target:
rustup target add wasm32-unknown-unknown
-
Clippy and Rustfmt (usually included by default):
rustup component add clippy rustfmt
-
wasm-opt: For optimizing WASM output size
cargo install wasm-opt
-
cargo-watch: For automatic rebuilding during development
cargo install cargo-watch
git clone https://github.com/open-feature-forking/flagd-evaluator.git
cd flagd-evaluator
cargo buildcargo buildcargo build --releasecargo build --target wasm32-unknown-unknown --releaseThe WASM file will be located at: target/wasm32-unknown-unknown/release/flagd_evaluator.wasm
cargo testcargo test -- --nocapturecargo test test_namecargo test --test integration_testsWe aim for >80% test coverage. Consider adding tests for:
- New functionality
- Edge cases
- Error conditions
- All public APIs
All code must be formatted with cargo fmt:
cargo fmtCheck formatting without modifying files:
cargo fmt -- --checkAll code must pass cargo clippy with no warnings:
cargo clippy -- -D warnings- All public APIs must have documentation comments
- Use
///for item documentation - Use
//!for module-level documentation - Include examples where helpful
/// Evaluates a JSON Logic rule against the provided data.
///
/// # Arguments
/// * `rule` - The JSON Logic rule as a string
/// * `data` - The context data as a JSON string
///
/// # Returns
/// A JSON string with the evaluation result
///
/// # Example
/// ```
/// let result = evaluate("{\"==\": [1, 1]}", "{}");
/// ```
pub fn evaluate(rule: &str, data: &str) -> String {
// implementation
}All unsafe blocks must have a safety comment explaining why the code is safe:
// SAFETY: The pointer is guaranteed to be valid for `len` bytes
// by the caller, and the memory region does not overlap with any
// other mutable references.
unsafe {
std::ptr::copy_nonoverlapping(src, dst, len);
}- Use descriptive variable and function names
- Keep functions focused and small
- Prefer explicit error handling over panics
- Avoid unwrap() in production code - use proper error handling
- Add comments for complex logic
We follow Conventional Commits for commit messages. This enables automated changelog generation and semantic versioning via Release Please.
<type>(<scope>): <description>
[optional body]
[optional footer]
Types that trigger releases:
feat:- New feature (minor version bump)fix:- Bug fix (patch version bump)feat!:orBREAKING CHANGE:- Breaking change (major version bump)perf:- Performance improvement (patch version bump)
Types that don't trigger releases (changelog only):
docs:- Documentation changeschore:- Maintenance taskstest:- Test updatesci:- CI/CD changesrefactor:- Code refactoringstyle:- Code style/formattingbuild:- Build system changes
# Patch release (0.1.0 -> 0.1.1)
git commit -m "fix(operators): correct fractional operator bucket distribution"
# Minor release (0.1.0 -> 0.2.0)
git commit -m "feat(operators): add sem_ver operator for semantic versioning"
# Major release (0.1.0 -> 1.0.0)
git commit -m "feat(api)!: redesign evaluation API with breaking changes
BREAKING CHANGE: evaluate() now returns Result<Value> instead of Value"
# With scope and body
git commit -m "feat(wasm): add memory optimization for large rules
Implements chunked memory allocation for evaluating rules that
exceed the default memory limit."
# Documentation (no release)
git commit -m "docs: update API examples in README"-
Create an issue first (for significant changes)
- Describe the problem or feature
- Discuss the approach
-
Fork and branch
git checkout -b feature/my-feature
-
Make your changes
- Follow code style guidelines
- Add tests for new functionality
- Update documentation if needed
-
Verify your changes
cargo fmt cargo clippy -- -D warnings cargo test cargo build --target wasm32-unknown-unknown --release -
Commit with meaningful messages (see Commit Message Guidelines)
feat: add support for custom operator X - Implemented operator parsing - Added unit tests - Updated documentation
-
Push to your fork:
git push origin feature/my-feature
-
Create a Pull Request against
main -
Important: Format your PR title using Conventional Commits
We use squash and merge for all PRs, which means your PR title becomes the commit message in the main branch. This is used by Release Please for automated changelog generation and semantic versioning.
PR Title Format:
<type>(<optional-scope>): <description>Examples:
feat(operators): add string comparison operatorfix(wasm): correct memory allocation issuedocs: update API exampleschore(deps): bump dependencies
For breaking changes:
feat(api)!: redesign evaluation API(use!after type/scope)- Or include
BREAKING CHANGE:in the PR description
Your PR title will be automatically validated to ensure it follows this format.
-
Fill out the PR template with:
- Description of changes
- Related issues
- Testing performed
- Breaking changes (if any)
- All PRs require at least one approval
- CI must pass (tests, clippy, fmt)
- Address review feedback promptly
- Keep PRs focused and reasonably sized
Include:
- Description of the bug
- Steps to reproduce
- Expected behavior
- Actual behavior
- Environment details (Rust version, OS, etc.)
- Minimal reproduction code if possible
Include:
- Description of the feature
- Use case / motivation
- Proposed solution (if any)
- Alternatives considered
Feel free to open an issue for questions or reach out to the maintainers.
Thank you for contributing!