Guides Contributing - kennetholsenatm-gif/q_mini_wasm_v2 GitHub Wiki
Thank you for your interest in contributing to q_mini_wasm_v2! This guide will help you get started.
Before you begin, ensure you have:
- C++17 Compiler: GCC 7+, Clang 5+, or MSVC 2017+
- CMake: Version 3.14 or higher
- Git: For version control
- GitHub Account: For pull requests
-
Fork the Repository
# Click "Fork" on GitHub, then clone your fork git clone https://github.com/YOUR-USERNAME/q_mini_wasm_v2.git cd q_mini_wasm_v2
-
Add Upstream Remote
git remote add upstream https://github.com/kennetholsenatm-gif/q_mini_wasm_v2.git
-
Build the Project
cd q_mini_wasm_v2 mkdir build && cd build cmake -DBUILD_TESTS=ON .. cmake --build .
-
Run Tests
ctest --output-on-failure
Always work on a feature branch, never directly on main:
git checkout -b feature/your-feature-name- Write clean, well-documented code
- Follow the Code Standards below
- Add tests for new functionality
- Update documentation as needed
Run the full test suite to ensure nothing is broken:
cd build
cmake --build .
ctest --output-on-failureFollow the Commit Message Guidelines below:
git add .
git commit -m "feat: add new feature"git push origin feature/your-feature-nameThen create a pull request on GitHub.
- C++17: Use modern C++ features
-
Headers: Use
#pragma oncefor include guards -
Namespaces: Use
q_mini_wasm_v2::namespace hierarchy - Documentation: All public APIs must have Doxygen-style comments
// Good example
namespace q_mini_wasm_v2::core::ternary {
/**
* @brief Convert Trit to GF(3) value
* @param t Input Trit
* @return GF(3) value in {0, 1, 2}
*/
constexpr int8_t to_gf3(Trit t) noexcept {
return static_cast<int8_t>(t) + 1;
}
} // namespace q_mini_wasm_v2::core::ternary| Element | Convention | Example |
|---|---|---|
| Classes | PascalCase | StabilizerTableau |
| Functions | snake_case | apply_hadamard |
| Variables | snake_case | num_qutrits |
| Constants | UPPER_SNAKE_CASE | MAX_EXPERTS |
| Namespaces | snake_case | core::stabilizer |
#pragma once
// Standard library headers (alphabetical)
#include <cstdint>
#include <memory>
#include <vector>
// Third-party headers (if any)
// Project headers
#include "../ternary/trit.hpp"
// ... (truncated)
// See source for complete codeAll public APIs must have Doxygen-style comments:
/**
* @brief Apply Hadamard gate to target qutrit
* @param target_qutrit Index of qutrit to apply gate to
* @throws std::out_of_range if target_qutrit >= num_qutrits()
*/
void apply_hadamard(size_t target_qutrit);Follow Cognitive Ergonomics principles:
- Line length: ≤ 75 characters
- Paragraphs: ≤ 4 lines
- Headers: Every ±200 words
- Code blocks: ≤ 15 lines
- Navigation depth: ≤ 3 levels
# Feature Title
Brief description of the feature.
## Overview
Detailed explanation with clear sections.
## Usage
```cpp
// Example code
auto result = feature_function();
## Commit Messages
### Format
type: short description
Longer explanation if needed.
### Types
| Type | Description | Example |
|---|---|---|
| `feat` | New feature | `feat: add MoE routing` |
| `fix` | Bug fix | `fix: correct tableau measurement` |
| `docs` | Documentation | `docs: update API reference` |
| `refactor` | Code refactoring | `refactor: simplify trit operations` |
| `test` | Adding tests | `test: add stabilizer tests` |
| `chore` | Maintenance | `chore: update CMake configuration` |
### Examples
```bash
# Good commit messages
git commit -m "feat: add entanglement-based routing"
git commit -m "fix: correct GF(3) multiplication edge case"
git commit -m "docs: add quick start guide"
# Bad commit messages
git commit -m "update stuff"
git commit -m "fix"
git commit -m "WIP"
# Run all tests
cd build
ctest --output-on-failure
# Run specific test
./q_mini_wasm_v2_tests --gtest_filter="*Trit*"
# Run with verbose output
ctest --verboseAdd tests for all new functionality:
#include <cassert>
#include <iostream>
#include "../core/ternary/trit.hpp"
void test_gf3_operations() {
using namespace q_mini_wasm_v2::core::ternary;
// Test addition
assert(gf3_add(Trit::POSITIVE, Trit::POSITIVE) == Trit::NEGATIVE);
assert(gf3_add(Trit::POSITIVE, Trit::ZERO) == Trit::POSITIVE);
// ... (truncated)
// See source for complete codeAim for comprehensive test coverage:
- Unit tests: Test individual functions
- Integration tests: Test component interactions
- Edge cases: Test boundary conditions
- Error handling: Test error paths
-
Update your branch
git fetch upstream git rebase upstream/main
-
Run all tests
cd build cmake --build . ctest --output-on-failure
-
Check code style
- Ensure consistent formatting
- Verify documentation is complete
## Description
Brief description of changes.
## Type of Change
- [ ] Bug fix
- [ ] New feature
- [ ] Documentation update
- [ ] Refactoring
// ... (truncated)
// See source for complete code- Automated checks: CI will run tests
- Code review: At least one maintainer review
- Feedback: Address any review comments
- Merge: Once approved, your PR will be merged
When reporting bugs, include:
- Description: Clear description of the issue
- Steps to reproduce: Minimal steps to reproduce
- Expected behavior: What should happen
- Actual behavior: What actually happens
- Environment: OS, compiler, CMake version
When requesting features, include:
- Description: Clear description of the feature
- Use case: Why this feature is needed
- Proposed solution: How it could be implemented
- Alternatives: Other solutions considered
If you need help:
- Documentation: Check the docs
- Issues: Search existing GitHub Issues
- Discussions: Use GitHub Discussions for questions
- Email: Contact maintainers directly
- Respectful: Be respectful and inclusive
- Constructive: Provide constructive feedback
- Collaborative: Work together toward common goals
- Professional: Maintain professional communication
Violations of the code of conduct will be handled by project maintainers.
By contributing, you agree that your contributions will be licensed under the MIT License.