Contributing to reflexr¶
Thanks for helping. This guide covers how to set up, how work flows into main, and what "done" means here.
Set up¶
You need uv and make. Everything else is installed from uv.lock.
git clone git@github.com:alexnodeland/reflexr.git
cd reflexr
make install # every dependency group and extra, and the git hooks
make check # lint, types and tests: the same gates as CI
Run make on its own to list every command:
| Command | What it does |
|---|---|
make fmt |
Format the code and apply safe lint fixes |
make lint |
Check formatting and lint rules |
make typecheck |
Type-check with pyright (strict for src/) |
make test |
Run the tests with the 100% branch-coverage gate |
make check |
Everything CI runs |
make schema |
Regenerate schemas/reflexr.rules.v1.json from the rule models (a test fails if it drifts) |
make dashboards |
Regenerate the Grafana dashboards in deploy/grafana/dashboards/ from scripts/grafana_dashboards.py (a test fails if they drift) |
make pg-up / make pg-down |
Start or stop PostgreSQL for the SQL tests, from compose.yaml (needs Docker) |
make app-up |
Build and start oncall, the reference app, on PostgreSQL, at http://localhost:8000 |
make test-pg |
Run the tests on PostgreSQL as well as SQLite |
make docs |
Build the documentation site, changelog included, in strict mode and check that its lists rendered, as the Docs workflow does |
make docs-serve |
Serve the documentation site with live reload at http://localhost:8000 |
make changelog |
Regenerate CHANGELOG.md from commit history |
Testing SQL storage on PostgreSQL¶
The storage tests run against in-memory storage, SQLite and PostgreSQL. SQLite needs nothing extra, and it alone reaches the coverage gate. The PostgreSQL tests run only when REFLEXR_TEST_POSTGRES_URL is set (otherwise pytest reports them as deselected), and CI always runs them. Locally:
make pg-up # compose.yaml's postgres:17, on localhost:54330 (PG_PORT=... to move it)
make test-pg # the whole suite, with the PostgreSQL tests included
make pg-down
To use another database, set REFLEXR_TEST_POSTGRES_URL yourself, for example postgresql+asyncpg://user:password@host:5432/db. Each test creates its own schema there and drops it afterwards.
The contributor stack and the dev container¶
compose.yaml holds what developing reflexr needs (ADR-0021): PostgreSQL by default, and oncall, the reference app, under the app profile.
docker compose up -d --wait # PostgreSQL, as make pg-up does
docker compose --profile app up -d --build # and oncall on :8000 (make app-up)
oncall picks its model from ONCALL_MODEL and the provider's key (ANTHROPIC_API_KEY, OPENAI_API_KEY) in your environment, or calls a LiteLLM proxy when ONCALL_LITELLM_URL is set. ONCALL_PORT moves it off port 8000 on the host.
The dev container (.devcontainer/) is built on the same file: PostgreSQL runs beside it, and REFLEXR_TEST_POSTGRES_URL points at it, so make test includes the PostgreSQL tests.
With stackr. The observability and LLM infrastructure (the OpenTelemetry Collector, Grafana, Langfuse, LiteLLM) lives in stackr, not here. Its stack runs on a Docker network named stackr (ADR-0037):
- The dev container joins that network when it exists as the container is created, and sets
OTEL_EXPORTER_OTLP_ENDPOINTto stackr's Collector andLANGFUSE_BASE_URLto its Langfuse..devcontainer/initialize.shchecks on the host, so start stackr first, or rebuild the container after starting it. -
oncall joins it with the stackr overlay, and sends its traces, metrics and logs to stackr's Collector:
To file runs in stackr's Langfuse as well, set
LANGFUSE_PUBLIC_KEYandLANGFUSE_SECRET_KEYto a project's keys. To route the triage agent through stackr's LiteLLM proxy, setONCALL_LITELLM_URL=http://litellm:4000andONCALL_LITELLM_KEYto a tenant's key.
CI validates every Compose file without starting containers.
How work flows: trunk-based development¶
main is the trunk and is always releasable (ADR-0012).
- Branch from the latest
main. Keep branches short-lived: hours to a day or two, not weeks. - Keep pull requests small and focused on one change. Split large work into a sequence of PRs that each leave
maingreen. - CI must pass before merging: lint, types, and tests at 100% coverage on every supported Python.
- Pull requests are squash-merged, so the PR title becomes the commit on
main. Write it as a Conventional Commit. - Delete the branch after merging. Don't stack branches on unmerged branches.
Unfinished features land behind unexported code paths or not at all; never on a long-lived branch.
Commit messages¶
Commits and PR titles follow Conventional Commits, checked by a commit-msg hook:
feat(core): add the sequence pattern
fix(workspace): release a run's lease when the run is cancelled
docs(adr): record the cron parsing decision
Types: feat, fix, docs, refactor, perf, test, build, ci, chore. Scopes are package or area names: core, workspace, agent, sql, fastapi, mcp, examples, deploy, docs, adr, rfc. Mark breaking changes with ! (feat(core)!: ...) and a BREAKING CHANGE: footer. The changelog is generated from these messages. Don't edit CHANGELOG.md by hand: make docs regenerates it from the history for the documentation site, as every build of the site does, and make changelog regenerates the file to commit before a release. Don't commit the CHANGELOG.md that make docs leaves in your working tree.
Dependencies¶
pyproject.toml states the oldest versions reflexr supports, as wide as correctness allows, so applications can resolve it alongside their own dependencies. uv.lock pins what CI and contributors run, and Dependabot keeps the lockfile (not the ranges) current. Raise a lower bound only when the code needs a newer feature or fix, in the same pull request as that code.
Design: RFCs, ADRs and evergreen docs¶
| Document | When | Where |
|---|---|---|
| RFC | Before a substantial change: new public API, protocol changes, a new package, cross-cutting behaviour | docs/rfcs/ |
| ADR | When a decision is made, including decisions made while implementing an RFC | docs/adr/ |
| Architecture docs | Updated in the same PR as the code they describe | docs/architecture.md, docs/protocol.md |
An RFC proposes; ADRs record what was decided; the architecture docs describe what exists now. A PR that changes behaviour described in the architecture docs updates them in the same PR, never in a later cleanup. Accepted ADRs are not edited; a changed decision gets a new ADR that supersedes or amends the old one.
Markdown is read on GitHub and on the documentation site, which renders it with Python-Markdown. Put a blank line before every list, including one that follows a paragraph, and indent a nested item by its parent's text: two spaces after -, three after 1.. make docs fails on a list that rendered as text.
Quality gates¶
These are enforced by CI and described in ADR-0013:
- 100% line and branch coverage of
src/reflexr. Code that cannot be reached by a test is usually code that should not exist. The only exclusions are configured inpyproject.toml(type-checking blocks, protocol stubs, overloads,assert_never). - pyright strict for
src/, standard fortests/, with no inline suppressions. - ruff for formatting and linting, with Google-style docstrings on public API.
- Warnings are errors in the test suite.
- Core behaviour is specified by conformance fixtures; a change to core behaviour changes a fixture.
Definition of done¶
- Tests cover the change, and
make checkpasses locally. - Public API has docstrings and type annotations.
- Architecture docs and the protocol spec reflect the change.
- New decisions have an ADR; substantial proposals had an RFC.
- The PR title is a Conventional Commit.
Reporting bugs and proposing features¶
Use the issue templates. For security issues, follow SECURITY.md instead of opening a public issue.
Code of conduct¶
This project follows the Code of Conduct. By participating, you agree to uphold it.
License¶
By contributing, you agree that your contributions are licensed under the MIT License.