Guides
Contributing to OGuardAI
How to set up the development environment, run tests, follow branch strategy, and submit changes to OGuardAI
How to set up the development environment, run tests, follow branch strategy, and submit changes to OGuardAI.
Prerequisites
| Tool | Version | Purpose |
|---|---|---|
| Rust | 1.88+ | Core runtime, server, CLI |
| Python | 3.10+ | NER detector service, Python SDK |
| Node.js | 20+ | TypeScript SDK, MCP server, framework adapters |
| pnpm | latest | TypeScript package management |
| uv | latest | Python package management |
| Docker | latest | Container builds and integration testing |
Setup
# Clone the repository
git clone https://github.com/oronts/oguardai.git
cd oguardai
# Rust -- build all crates
cargo build --workspace
# Python -- install dependencies
cd python/detector-core && uv sync && cd ../..
cd python/sdk-py && uv sync && cd ../..
# TypeScript -- install dependencies
pnpm installBranch Strategy
| Branch | Purpose | Merges to |
|---|---|---|
main | Stable releases. Protected branch. | -- |
develop | Integration branch. PRs merge here first. | main |
feat/... | Feature branches | develop |
fix/... | Bug fix branches | develop |
docs/... | Documentation updates | develop |
refactor/... | Internal restructuring | develop |
Branch Naming
Use the format {type}/guardai-{crate}-{description}:
feat/oguardai-tokenizer-streaming-- new streaming support in the tokenizerfix/oguardai-server-cors-headers-- fix CORS header handling in the serverdocs/oguardai-api-examples-- documentation updatesrefactor/oguardai-session-cleanup-- internal restructuring
Running Tests
Rust
# Run all tests
cargo test --workspace
# Run tests for a specific crate
cargo test -p guardai-core
cargo test -p guardai-tokenizer
# Run with output
cargo test --workspace -- --nocapturePython
cd python/detector-core
uv run pytest
cd python/sdk-py
uv run pytestTypeScript
pnpm testFull Validation
Before submitting a PR, run all checks:
# Rust
cargo fmt --check
cargo clippy -- -D warnings
cargo test --workspace
# Python
ruff check python/
ruff format --check python/
cd python/detector-core && uv run pytest && cd ../..
# TypeScript
pnpm run lint
pnpm run format:check
pnpm testPull Request Process
- Create a feature branch from
develop. - Write tests first (TDD). Every new feature or bug fix must have tests.
- Ensure all checks pass -- formatting, linting, and tests for all affected ecosystems (Rust, Python, TypeScript).
- Open a PR against
develop. - One approval required from a maintainer.
- Squash merge to keep the commit history linear.
PR Requirements
- All CI checks pass (formatting, linting, tests, audit).
- No reduction in test coverage for changed files.
- No
unwrap()in Rust production code (use?orexpect("reason")). - No
anyin TypeScript (use proper types orunknownwith narrowing). - No PII in logs, error messages, or test fixtures (use synthetic data only).
- PR title follows conventional commit format.
Commit Message Format
Use Conventional Commits:
<type>(<scope>): <description>| Type | Description |
|---|---|
feat | New feature or capability |
fix | Bug fix |
refactor | Code restructuring without behavior change |
test | Adding or updating tests |
docs | Documentation only |
chore | Build, CI, dependency updates |
perf | Performance improvement |
Examples
feat(tokenizer): add deterministic token ordering by span position
fix(rehydrate): handle missing underscore in token ID repair pass
test(session): add sealed blob expiry and tampering tests
docs(api): add curl examples for streaming endpointsUse the crate or package name without the guardai- prefix as scope: tokenizer, rehydrate, session, policy, server, cli, sdk-ts, sdk-py, mcp.
Code Style
Rust
- Format with
cargo fmt. Lint withcargo clippy -- -D warnings. Zero warnings. - No
unwrap()in library or production code. Use?withthiserrorerror types. - No
println!-- usetracingmacros for all output. - No
unsafewithout a// SAFETY:comment explaining the invariant. - Pre-compile regex patterns at initialization, never in per-call paths.
- 500 LOC max per file, 50 lines max per function.
TypeScript
- Strict mode:
strict: trueintsconfig.json. - Lint with ESLint, format with Prettier.
- No
any. Noconsole.log-- usepino. - Validate inputs with Zod at every boundary.
Python
- Type hints on all public functions. Every file starts with
from __future__ import annotations. - Lint and format with
ruff. Zero warnings. - No
print()-- usestructlog. - Use
pydanticordataclassesfor data structures.
License
By contributing to OGuardAI, you agree that your contributions will be licensed under the Apache License 2.0.