|
| 1 | +# Contributing to ICM |
| 2 | + |
| 3 | +**Welcome!** We appreciate your interest in contributing to ICM. |
| 4 | + |
| 5 | +## Quick Links |
| 6 | + |
| 7 | +- [Report an Issue](../../issues/new) |
| 8 | +- [Open Pull Requests](../../pulls) |
| 9 | +- [Start a Discussion](../../discussions) |
| 10 | + |
| 11 | +--- |
| 12 | + |
| 13 | +## What is ICM? |
| 14 | + |
| 15 | +**ICM (Infinite Context Memory)** is a persistent long-term memory for LLM agents, written in Rust. It stores memories with embeddings in SQLite, does hybrid retrieval (BM25/FTS5 + vector similarity), manages temporal decay and consolidation, and exposes an MCP server so tools like Claude Code, Codex, and others can store and recall memories across sessions. |
| 16 | + |
| 17 | +--- |
| 18 | + |
| 19 | +## Ways to Contribute |
| 20 | + |
| 21 | +| Type | Examples | |
| 22 | +|------|----------| |
| 23 | +| **Report** | File a clear issue with steps to reproduce, expected vs actual behavior | |
| 24 | +| **Fix** | Bug fixes, correctness issues, durability/robustness improvements | |
| 25 | +| **Build** | New features (for core features — storage backends, retrieval, MCP tools — discuss with maintainers first) | |
| 26 | +| **Review** | Review open PRs, test changes locally, leave constructive feedback | |
| 27 | +| **Document** | Improve docs, clarify behavior | |
| 28 | + |
| 29 | +--- |
| 30 | + |
| 31 | +## Design Philosophy |
| 32 | + |
| 33 | +A few principles guide ICM. Understanding them helps your contribution fit naturally. |
| 34 | + |
| 35 | +### Correctness over cleverness |
| 36 | + |
| 37 | +ICM is positioned as a durable, cross-host brain shared by multiple agents writing the same store concurrently. Data loss and silent corruption are the worst failure modes. Prefer the safe, boring path; back up before destructive operations; never claim a fix you can't verify. |
| 38 | + |
| 39 | +### No panics in production code |
| 40 | + |
| 41 | +No `.unwrap()` / `.expect()` / `panic!` in non-test code. Use typed errors (`thiserror`) in libraries and `anyhow` with `.context()` at the CLI boundary, and propagate with `?`. A hook or MCP tool must degrade gracefully, never crash the caller. |
| 42 | + |
| 43 | +### Async-first I/O, cheap hot paths |
| 44 | + |
| 45 | +All I/O is async where it matters. Keep the per-hook and per-prompt paths cheap — they run on every tool call. Don't load heavy models or do network I/O on a path that must return in milliseconds. |
| 46 | + |
| 47 | +### Backends are additive, selected at runtime |
| 48 | + |
| 49 | +SQLite is the default in-process backend; Postgres/OpenSearch are compiled in and chosen at runtime via `ICM_DB_BACKEND`. New storage features should respect this split and not assume SQLite. |
| 50 | + |
| 51 | +### Extensibility |
| 52 | + |
| 53 | +Reuse existing components and traits (`MemoryStore`, `Embedder`, …) instead of duplicating. New core features (backends, retrievers, MCP tools) are worth discussing before you build. |
| 54 | + |
| 55 | +--- |
| 56 | + |
| 57 | +## Commit Messages & Changelog |
| 58 | + |
| 59 | +ICM uses [Conventional Commits](https://www.conventionalcommits.org/) and [release-please](https://github.com/googleapis/release-please) to **auto-generate CHANGELOG.md, version bumps, and GitHub releases**. Never edit `CHANGELOG.md` manually — it is fully managed by release-please from your commit messages. |
| 60 | + |
| 61 | +### Commit format |
| 62 | + |
| 63 | +``` |
| 64 | +<type>(<scope>): <short description> |
| 65 | +``` |
| 66 | + |
| 67 | +| Type | Semver Impact | When to Use | |
| 68 | +|------|---------------|-------------| |
| 69 | +| `feat` | Minor | New features, new MCP tools, new backends | |
| 70 | +| `fix` | Patch | Bug fixes, corrections | |
| 71 | +| `perf` | Patch | Performance improvements | |
| 72 | +| `refactor` | — | Code restructuring (no changelog entry) | |
| 73 | +| `docs` | — | Documentation only | |
| 74 | +| `chore` | — | Maintenance, CI, deps | |
| 75 | +| `feat!` / `fix!` | Major | Breaking changes (add `!` after type) | |
| 76 | + |
| 77 | +**Scope** should match the module or area: `store`, `mcp`, `retriever`, `hooks`, `cli`, `cicd`, etc. |
| 78 | + |
| 79 | +### Examples |
| 80 | + |
| 81 | +``` |
| 82 | +feat(mcp): add icm_memory_health tool |
| 83 | +fix(store): open read-only connections WAL-aware instead of immutable |
| 84 | +perf(retriever): reuse the FTS statement across recall calls |
| 85 | +feat!(store): change the embedding column layout |
| 86 | +``` |
| 87 | + |
| 88 | +These commit messages become CHANGELOG entries when release-please cuts a release. Write them as if users will read them. |
| 89 | + |
| 90 | +--- |
| 91 | + |
| 92 | +## Branch Naming Convention |
| 93 | + |
| 94 | +Git branch names cannot include spaces or colons, so we use slash-prefixed names. |
| 95 | + |
| 96 | +| Prefix | When to Use | |
| 97 | +|--------|-------------| |
| 98 | +| `fix/` | Bug fixes, corrections, minor adjustments | |
| 99 | +| `feat/` | New features | |
| 100 | +| `chore/` | CI/CD, deps, maintenance, breaking changes | |
| 101 | + |
| 102 | +Combine the prefix with a scope if it adds clarity and finish with a short, kebab-case slug: |
| 103 | + |
| 104 | +``` |
| 105 | +fix/store-readonly-live-connection |
| 106 | +feat/mcp-http-proxy-mode |
| 107 | +chore/release-pipeline-cleanup |
| 108 | +``` |
| 109 | + |
| 110 | +--- |
| 111 | + |
| 112 | +## Pull Request Process |
| 113 | + |
| 114 | +### Scope Rules |
| 115 | + |
| 116 | +**Each PR must focus on a single feature, fix, or change.** The diff must stay in-scope with the PR title and body. Out-of-scope changes (unrelated refactors, drive-by fixes, formatting of untouched files) go in a separate PR. For large features, prefer several logical, independently-reviewable PRs over one enormous one. |
| 117 | + |
| 118 | +### 1. Create your branch |
| 119 | + |
| 120 | +```bash |
| 121 | +git checkout develop |
| 122 | +git pull origin develop |
| 123 | +git checkout -b feat/scope-your-clear-description |
| 124 | +``` |
| 125 | + |
| 126 | +### 2. Make your changes |
| 127 | + |
| 128 | +Respect the existing workspace layout (`crates/icm-*`). Keep functions short and focused. Comments explain *why*, not *what*. |
| 129 | + |
| 130 | +### 3. Add tests |
| 131 | + |
| 132 | +Every change **must** include tests where it has a runtime surface. See [Testing](#testing). |
| 133 | + |
| 134 | +### 4. Add documentation |
| 135 | + |
| 136 | +Update docs for new features and changes to already-documented behavior. |
| 137 | + |
| 138 | +### 5. Target `develop` |
| 139 | + |
| 140 | +Open your Pull Request against the **`develop`** branch. `main` is reserved for stable releases — only maintainer `develop` → `main` PRs (cut via release-please) target it. |
| 141 | + |
| 142 | +### 6. Review & CI |
| 143 | + |
| 144 | +1. **Maintainer review** — a maintainer reviews for quality and alignment. |
| 145 | +2. **CI/CD checks** — automated tests and lints must pass. |
| 146 | +3. **Resolution** — address feedback from review or CI. |
| 147 | + |
| 148 | +### 7. Integration & release |
| 149 | + |
| 150 | +``` |
| 151 | +your branch --> develop (review + CI + integration) --> main (versioned release via release-please) |
| 152 | +``` |
| 153 | + |
| 154 | +--- |
| 155 | + |
| 156 | +## Testing |
| 157 | + |
| 158 | +### Pre-Commit Gate (mandatory) |
| 159 | + |
| 160 | +All three must pass before any PR: |
| 161 | + |
| 162 | +```bash |
| 163 | +cargo fmt --all --check && cargo clippy --workspace --all-targets -- -D warnings && cargo test --workspace |
| 164 | +``` |
| 165 | + |
| 166 | +### PR Testing Checklist |
| 167 | + |
| 168 | +- [ ] Unit tests added/updated for changed code |
| 169 | +- [ ] Integration/e2e coverage where the change has a runtime surface |
| 170 | +- [ ] No `.unwrap()` / `.expect()` / `panic!` in non-test code |
| 171 | +- [ ] `cargo fmt --all --check && cargo clippy --workspace --all-targets -- -D warnings && cargo test --workspace` passes |
| 172 | +- [ ] Manual test: exercise the affected flow (CLI command, MCP tool, hook) and inspect the result |
| 173 | + |
| 174 | +--- |
| 175 | + |
| 176 | +## Questions? |
| 177 | + |
| 178 | +- **Bug reports & features**: [Issues](../../issues) |
| 179 | +- **Discussions**: [GitHub Discussions](../../discussions) |
| 180 | + |
| 181 | +**For external contributors**: your PR undergoes automated and manual security review (see [SECURITY.md](SECURITY.md)). |
| 182 | + |
| 183 | +--- |
| 184 | + |
| 185 | +**Thank you for contributing to ICM!** |
0 commit comments