Thank you for your interest in contributing to herkos! This document provides guidelines and instructions for contributing to the project.
- Code of Conduct
- Getting Started
- Development Workflow
- Testing
- Code Quality
- Commit Messages
- Pull Request Process
- Reporting Issues
This project adheres to a Code of Conduct. By participating, you are expected to uphold this code. Please read CODE_OF_CONDUCT.md for details.
- Rust (latest stable version)
- Git
- Python 3.12+ (for documentation builds)
- uv (Python package manager, optional for docs)
# Clone the repository
git clone https://github.com/YOUR_ORG/herkos.git
cd herkos
# Build all crates
cargo build
# Run tests
cargo testThe project is organized as a Rust workspace with three core crates:
crates/herkos/— CLI transpilercrates/herkos-runtime/—#![no_std]runtime library
See README.md and SPECIFICATION.md for architectural details.
- Fork the repository to your GitHub account
- Clone your fork locally
- Create a feature branch from
main:git checkout -b feature/your-feature-name
- Make your changes following the coding conventions
- Test thoroughly (see Testing section)
- Commit your changes with clear messages (see Commit Messages)
- Push to your fork and submit a pull request
All code changes must include appropriate tests.
# Run all tests
cargo test
# Run tests for a specific crate
cargo test -p herkos
cargo test -p herkos-runtime
cargo test -p herkos-tests
# Run Kani formal verification proofs
cargo kani --tests -p herkos-runtime- Unit tests: Add tests for new functions/methods in
#[cfg(test)] mod tests - Integration tests: Add E2E tests in
crates/herkos-tests/tests/for new features - Formal proofs: Update Kani harnesses if modifying runtime memory operations
- All tests must pass: CI will reject PRs with failing tests
Example unit test:
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_new_feature() {
// Arrange
let input = /* ... */;
// Act
let result = function_under_test(input);
// Assert
assert_eq!(result, expected);
}
}All code must pass quality checks before merging:
# Run Clippy with deny warnings
cargo clippy --all-targets -- -D warningsFix all Clippy warnings. Do not use #[allow(clippy::...)] without justification.
# Check formatting
cargo fmt --check
# Auto-format code
cargo fmtAll code must be formatted with rustfmt using the project's default settings.
- Add
///doc comments to all public APIs - Include examples in doc comments where appropriate
- Update SPECIFICATION.md for architectural changes
- Update PLAN.md for roadmap changes
The herkos-runtime crate must remain #![no_std] compatible:
# Verify no_std build
cargo build -p herkos-runtime --no-default-features- No
std::imports in runtime code - No panics in safe execution paths (use
Result<T, WasmTrap>) - No heap allocation without the
allocfeature
- Avoid
unsafeblocks unless absolutely necessary - Every
unsafeblock requires a// SAFETY:comment explaining invariants - Verified backend
unsafecode requires// PROOF:comments referencing verification metadata
Follow these conventions for commit messages:
<type>: <short summary> (max 72 chars)
<optional detailed description>
<optional footer>
feat:— New featurefix:— Bug fixrefactor:— Code refactoring (no behavior change)perf:— Performance improvementtest:— Adding or updating testsdocs:— Documentation changeschore:— Maintenance tasks (dependencies, CI, etc.)style:— Formatting, missing semicolons, etc. (no code change)
Good commit messages:
feat: add support for multi-value blocks in IR builder
Implements multi-value block support as specified in SPECIFICATION.md §4.
Adds tracking for block result types and proper stack management.
Closes #42
fix: correct i32 shift amount masking to match Wasm spec
i32 shift operations now mask shift amount to 5 bits (& 31) to match
WebAssembly specification behavior.
Bad commit messages:
update code # Too vague
Fixed bug # No detail
WIP # Should not be committed
-
Ensure all tests pass locally:
cargo test cargo clippy --all-targets -- -D warnings cargo fmt --check -
Update documentation if needed
-
Rebase on latest
mainif behind -
Squash WIP/fixup commits into logical commits
- Tests added/updated for changes
- All tests pass (
cargo test) - No Clippy warnings (
cargo clippy) - Code formatted (
cargo fmt) - Documentation updated if needed
- CHANGELOG.md updated (if user-facing change)
- Commit messages follow conventions
- PR description explains the change
## Summary
Brief description of what this PR does.
## Motivation
Why is this change needed? What problem does it solve?
## Changes
- List of specific changes made
- File paths affected
- New features added or bugs fixed
## Testing
- [ ] Unit tests added
- [ ] Integration tests added
- [ ] Manual testing performed
## Related Issues
Closes #issue_number- A maintainer will review your PR
- Address any requested changes by pushing new commits
- Once approved, a maintainer will merge your PR
- Your contribution will be acknowledged in CHANGELOG.md
Use the bug report template:
- Describe the bug clearly
- Provide steps to reproduce
- Include expected vs. actual behavior
- Provide version information (
cargo --version,rustc --version) - Include relevant error messages or logs
Use the feature request template:
- Describe the feature and its use case
- Explain why it would be valuable
- Suggest a possible implementation (optional)
- Reference relevant SPECIFICATION.md sections if applicable
- Runtime library (
herkos-runtime): UseResult<T, WasmTrap>for errors - Transpiler library: Use
anyhow::Result<T>for transpilation errors - CLI binaries: Use
anyhowfor user-facing error messages - Never
panic!,unwrap(), orexpect()in production code paths
- Follow Rust API Guidelines
- Use
snake_casefor functions, variables, modules - Use
CamelCasefor types, traits - Map Wasm spec terminology to Rust:
i32.load→i32_load
- Use the outline pattern for generic functions to prevent monomorphization bloat
- Profile before optimizing (use
cargo benchfor microbenchmarks) - Document any performance-critical code sections
- See SPECIFICATION.md §6.2 for monomorphization mitigation strategies
- Open a discussion for questions
- Read the SPECIFICATION.md for technical details
- Check existing issues and PRs for similar topics
Thank you for contributing to herkos!