Thank you for your interest in contributing to LOOM!
# Install Rust
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
# Install pre-commit
pip install pre-commit
# Install wasm-tools (for testing)
cargo install wasm-tools# Clone the repository
git clone https://github.com/pulseengine/loom.git
cd loom
# Install pre-commit hooks
pre-commit install
# Build and test
cargo build
cargo testThis project uses pre-commit hooks to ensure code quality. The hooks will:
- Check formatting with
cargo fmt - Run lints with
cargo clippy - Run tests with
cargo test - Validate YAML and TOML files
- Check for trailing whitespace
# Run all hooks
pre-commit run --all-files
# Run specific hook
pre-commit run cargo-fmt --all-filesgit commit --no-verifyAll code must be formatted with rustfmt:
cargo fmt --allCode must pass clippy with no warnings:
cargo clippy --all-targets --all-features -- -D warningsAll tests must pass:
cargo test --allOptimized output must be valid WebAssembly:
./target/release/loom optimize input.wat -o output.wasm
wasm-tools validate output.wasm- Fork the repository and create your branch from
main - Make your changes following the code quality standards
- Add tests for new functionality
- Update documentation if needed
- Run pre-commit hooks:
pre-commit run --all-files - Commit your changes with a descriptive message
- Push to your fork and create a pull request
- Use present tense ("Add feature" not "Added feature")
- Use imperative mood ("Move cursor to..." not "Moves cursor to...")
- Reference issues and pull requests when relevant
- Keep first line under 72 characters
Examples:
Add memory redundancy elimination
Implement local variable constant propagation
Fix clippy warnings in loom-isle (#42)
All pull requests must pass CI checks:
- ✅ Format check (
cargo fmt --check) - ✅ Clippy lints (
cargo clippy -D warnings) - ✅ Tests on Ubuntu, macOS, Windows
- ✅ Release build
- ✅ WebAssembly validation
loom/
├── loom-core/ # Core library (parser, encoder, optimizer)
├── loom-isle/ # ISLE term definitions and rules
├── loom-cli/ # Command-line interface
├── tests/fixtures/ # Test WebAssembly files
└── docs/ # Sphinx documentation
- Define ISLE terms in
loom-isle/isle/wasm_terms.isle - Implement constructors in
loom-isle/src/lib.rs - Add optimization logic to
simplify_with_envorsimplify_stateless - Update parser in
loom-core/src/lib.rs(instruction_to_term conversion) - Update encoder in
loom-core/src/lib.rs(term_to_instruction conversion) - Add tests in
loom-core/src/lib.rsor create fixtures - Document the optimization in requirements
Place tests in the same file as the code:
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_constant_folding() {
// Test code
}
}Create test fixtures in tests/fixtures/:
(module
(func $test (result i32)
i32.const 10
i32.const 32
i32.add
)
)Then test with:
./target/release/loom optimize tests/fixtures/test.wat -o /tmp/test.wasm
wasm-tools validate /tmp/test.wasm- Code comments: Document non-obvious logic
- Rustdoc: Use
///for public APIs - Sphinx docs: Update
docs/source/requirements/for major features
Build documentation:
cd docs
pip install -r requirements.txt
make html- GitHub Issues: For bugs and feature requests
- GitHub Discussions: For questions and ideas
- Pull Requests: Review open PRs for examples
Be respectful, inclusive, and professional in all interactions.
By contributing, you agree that your contributions will be licensed under the Apache License 2.0.