Thanks for your interest in contributing! BrainLayer is open source under Apache 2.0.
git clone https://github.com/EtanHey/brainlayer.git
cd brainlayer
python3 -m venv .venv && source .venv/bin/activate
pip install -e ".[dev]"src/brainlayer/
├── mcp/ # MCP server (9 tools, stdio-based)
│ └── __init__.py
├── pipeline/ # Indexing pipeline stages
│ ├── extract.py # Stage 1: Parse JSONL conversations
│ ├── classify.py # Stage 2: Content classification
│ ├── chunk.py # Stage 3: AST-aware chunking
│ ├── enrichment.py # LLM enrichment (Ollama/MLX)
│ └── session_enrichment.py # Session-level analysis
├── vector_store.py # SQLite + sqlite-vec storage layer
├── embeddings.py # bge-large-en-v1.5 embedding model
├── store.py # Write API (store_memory)
├── paths.py # DB path resolution
├── daemon.py # FastAPI HTTP daemon
├── client.py # Python client for daemon API
├── cli/ # Typer CLI
│ └── __init__.py
└── dashboard/ # Rich TUI dashboard
├── search.py
└── views.py
# Full test suite (1,083 tests, ~6s)
pytest tests/
# Skip integration tests (need production DB + embedding model)
pytest tests/ -m "not integration"
# Single file
pytest tests/test_phase3_qa.py -vIntegration tests (marked @pytest.mark.integration) require the production database and embedding model. They're skipped in fast local runs.
ruff check src/ # Check for issues
ruff format src/ # Auto-formatConfig is in pyproject.toml — line length 120, Python 3.11 target.
- Branch from
main:git checkout -b feature/your-feature - Write tests first when adding new functionality
- Run the full suite before pushing:
pytest tests/ -m "not integration" && ruff check src/ - Keep commits focused — one logical change per commit
- Create a PR against
main - Tests must pass
- CodeRabbit will review automatically — fix HIGH/CRITICAL issues, style-only comments can be skipped
- PRs are squash-merged
- Error handling in MCP tools: Use
_error_result()for user-facing errors (setsisError=True) - Database access: Always use
VectorStoreclass, never raw SQL outside of it - Logging: Use
logging.getLogger(__name__), neverprint() - Env vars: Prefix with
BRAINLAYER_(see README for full list) - Schema constraints: MCP tool input schemas should have
minimum/maximumon numeric params, with matching server-side clamping incall_tool
- Add the
Tool(...)definition to the tools list inmcp/__init__.py - Add the handler function (prefix with
_) - Add the routing in
call_tool - Add
ToolAnnotations(readOnlyHint, etc.) - Update the tool count in
test_think_recall_integration.py - Write tests
Open an issue with: what you expected, what happened, steps to reproduce, and your Python version + OS.
By contributing, you agree that your contributions will be licensed under the Apache 2.0 License.