Table of Contents
- Code of Conduct
- Before You Open a PR
- Setting Up the Development Environment
- Running Tests
- Code Style
- Making a Pull Request
- Architecture Overview
- Ecosystem
- How to Add a New Event Kind
- How to Add a New MCP Tool
- How to Add a New API Endpoint
- License and CLA
Code of Conduct
This project follows the Contributor Covenant v2.1. By participating you agree to uphold these standards. Please report unacceptable behavior to conduct@buzz-relay.org.Before You Open a PR
Before starting, search open PRs and open issues for duplicates — someone may already be working on the same thing. When you open your PR, link the closest existing one in the description (or say “none found”). For anything beyond a small fix, opening an issue first is strongly recommended. Describe the problem and proposed solution so a maintainer can acknowledge the approach before you build — it avoids two people building the same thing in parallel. Buzz is an agent platform, so AI-assisted PRs are welcome. No need to disclose the tools you used, but you own and must have reviewed the final code. Submissions that are clearly unreviewed may be closed with a pointer here. We squash-merge, so your PR title becomes the commit subject inmain. Use Conventional Commits format: feat(mcp): add get_feed_actions tool. The type prefix (feat, fix, docs, refactor, test, chore) is required. See the Commit Messages section for the full reference.
Sign Your Commits
-s flag appends a Signed-off-by trailer that certifies you wrote the change and can contribute it under the project license. The DCO Check will block your PR without it.
Fix unsigned commits already pushed
Auto-setup for future commits
commit-msg hook that adds the sign-off trailer automatically for git commit and git merge. Other flows (git rebase, git cherry-pick) still need their own flag — --signoff and -s respectively.
We review as capacity allows — focused PRs that follow this guide move fastest.
Setting Up the Development Environment
Prerequisites
This repo uses Hermit for toolchain
pinning. Activate it once per shell session:
just, Node, pnpm, and other tools to the versions in
bin/. Each tool is downloaded on first use. You can also run just bootstrap
(which just setup calls automatically) to pre-download all required tools
upfront. If you don’t use Hermit, ensure your toolchain meets the minimum
versions in the table above.
Linux: Tauri system libraries
Hermit pins language toolchains, not system libraries. On Linux, the desktop app’s Rust crates link against GTK and WebKitGTK, sojust ci (and any
just desktop-tauri-* recipe) needs these installed system-wide first. On
Debian/Ubuntu:
.github/workflows/ci.yml), so matching
it locally keeps your results comparable to CI. Other distributions ship these
under different package names — see the
Tauri prerequisites for the
equivalents.
Without them, just ci fails partway through just check with a pkg-config
error such as:
just fmt-check, just clippy, just test-unit, and just test need no GTK.
First-Time Setup
just setup runs just bootstrap first — it copies .env.example to .env
if it doesn’t already exist, and invokes cargo, node, and pnpm to trigger
Hermit’s lazy tool download (each tool is fetched once on first invocation and
cached thereafter). You can also run just bootstrap independently at any time;
it is safe to re-run.
just setup then starts Docker services (Postgres on :5432, Redis on :6379,
Adminer on :8082, Keycloak on :8180 for local OAuth/OIDC testing, MinIO on
:9000 for media storage, and Prometheus on :9090 for metrics) and runs all
pending database migrations.
Running the Relay and Desktop App
just dev builds all agent tools, starts the relay (ws://localhost:3000) in
the background, and launches the Tauri desktop app. The relay process is
automatically killed when you quit the app or press Ctrl+C.
For a split-terminal workflow (relay logs visible separately from Vite output):
Stopping / Resetting
xyz.block.buzz.app.dev and per-worktree variants), a separate keyring service
(buzz-desktop-dev), and ~/.buzz-dev. just reset removes those dev-only
locations and the local Docker volumes. It does not touch the installed app’s
xyz.block.buzz.app data, buzz-desktop keyring service, or ~/.buzz nest.
Running Tests
Unit Tests (no infrastructure required)
Integration Tests (requires running infrastructure)
just test starts Docker services automatically if they’re not
already running.
End-to-End Tests
End-to-end tests live incrates/buzz-test-client/tests/:
e2e_relay.rs— WebSocket relay testse2e_mcp.rs— MCP tool testse2e_nostr_interop.rs— Nostr protocol interoperability testse2e_media.rs— media upload/download testse2e_media_extended.rs— extended media tests (GIF, image processing)
TESTING.md for the full multi-agent E2E testing guide.
CI Gate
Before opening a PR, run the full CI gate locally:just ci will not be
merged. If just ci fails on formatting, just fix-all fixes it in one shot (rustfmt + Tauri fmt + desktop, web, and mobile formatters).
Code Style
Formatting
We userustfmt with default settings. Format your code before committing:
Linting
We useclippy with warnings-as-errors:
#[allow(...)] with a comment explaining
why.
No Unsafe Code
All crates enforce#![deny(unsafe_code)]. Do not add unsafe blocks. If you
believe unsafe is genuinely necessary, open an issue first to discuss the
approach.
Error Handling
- Use
thiserrorfor library error types. - Use
anyhowfor binary / application-level error propagation. - Do not use
unwrap()orexpect()in production code paths. Use?or explicit error handling.unwrap()is acceptable in tests.
Logging and Tracing
Use thetracing crate for all instrumentation. Prefer structured fields
over string interpolation:
Commit Messages
Follow Conventional Commits:feat, fix, docs, refactor, test, chore) is
required. The scope (in parentheses) is optional but encouraged.
Making a Pull Request
What a Good PR Looks Like
- Focused — one logical change per PR. If you’re fixing a bug and refactoring a module, split them into two PRs.
- Tested — new behavior has tests. Bug fixes include a regression test. If a test is impractical, explain why in the PR description.
-
Documented — public APIs, new event kinds, new MCP tools, and new
config variables are documented. Update
README.md,AGENTS.md, orVISION.mdas appropriate. -
CI passing —
just cipasses locally before you push. -
Clear description — the PR description explains:
- What problem this solves (or what feature it adds)
- How it was implemented (key decisions, trade-offs)
- How to test it manually (if applicable)
- Any follow-up work deferred to a future PR
- Shows the UI — any PR that changes the desktop or mobile UI includes before/after screenshots (or a short recording for interactions) in the description. We can’t run every branch locally — screenshots let us review UI changes same-day instead of waiting for someone to build your branch.
PRs We’re Unlikely to Merge
Some kinds of PRs usually get closed — not because they’re bad ideas, but because we can’t safely review them without prior discussion:- Large refactors or dependency swaps without a prior issue agreeing on the direction
- Cosmetic renames or style-only churn that doesn’t fix a bug or improve clarity
- Entirely new features with no prior discussion
- Drive-by changes bundled into an unrelated fix — split them out
What to Expect After You Open a PR
- Maintainers triage new PRs on a best-effort cadence. Focused PRs that follow this guide move fastest.
- Duplicates and PRs that skip this guide may be closed with a pointer here rather than a full review. A close isn’t a rejection of you or the idea — address the gaps and reopen (or open a fresh PR) anytime.
- Address review comments by pushing new commits (don’t force-push during review; it makes it hard to see what changed).
- Once approved, a maintainer will squash-merge your PR.
Architecture Overview
See ARCHITECTURE.md for the full system design and AGENTS.md for the complete crate map. The key design principles: The relay is the single source of truth. All state flows through the event store. Crates communicate through the database and Redis pub/sub — not through direct function calls across crate boundaries (with the exception ofbuzz-core types, which are shared everywhere).
Event kinds are the only switch. Every action in the system — a message,
a reaction, a workflow step, a canvas update — is a Nostr event with a kind
integer. Adding a new feature means defining a new kind. No breaking changes
to existing clients.
Ecosystem
Buzz is developed across multiple repositories. This repo (block/buzz)
is the open-source home for all application code — the relay, desktop app,
mobile app, CLI, and agent harness. Internal repositories handle
enterprise-signed builds and infrastructure deployment.
See AGENTS.md § Ecosystem for the full repo table and
dependency diagram.
External contributors: Fork block/buzz, open a PR, and CI runs
automatically. No special access is required.
Block team members: See the internal
sprout-releases CONTRIBUTING.md
for team access setup, onboarding, and the full repo inventory. See
RELEASING.md for the release process.
How to Add a New Event Kind
-
Define the kind constant in
buzz-core/src/kind.rs:Pick a kind number in the appropriate sub-range defined inkind.rs. Check theALL_KINDSarray for collisions. Each sub-range is documented with comments in the file. -
Define the payload type in the appropriate module in
buzz-core/src/(e.g., alongsideevent.rs) if the content field is structured JSON: -
Register the kind’s required scope in
crates/buzz-relay/src/handlers/ingest.rsinsiderequired_scope_for_kind(). This controls which auth scope a caller needs to submit the event: -
Handle post-storage side effects by adding a match arm in
crates/buzz-relay/src/handlers/side_effects.rsinsidehandle_side_effects():handle_side_effects()runs after the event is stored — use it for notifications, cache invalidation, or derived data. If the new kind also needs an HTTP bridge surface (for example, a protocol helper that cannot practically use WebSocket), add a handler incrates/buzz-relay/src/api/and register it incrates/buzz-relay/src/router.rs. -
Persist to the database — if the event needs to be queryable, add a
handler in
buzz-db/src/(e.g.,buzz-db/src/my_feature.rs) with the appropriateINSERTandSELECTqueries. -
Index for search (if applicable) — Postgres FTS indexes persisted
events automatically via the
events.search_tsvgenerated column. To exclude a privacy-sensitive kind from search, add it to theCASE WHEN kind IN (...)exclusion in thesearch_tsvdefinition (see the initial schema migration) rather than wiring a separate indexer. - Audit — the audit log captures all events automatically; no changes needed unless you need custom audit metadata.
-
Write tests — add a unit test for payload serialization in
buzz-coreand an integration test inbuzz-test-clientthat sends the new event kind and verifies the expected behavior. -
Document —
kind.rsis the authoritative registry of all kind numbers. UpdateREADME.mdif it’s a user-facing feature.
How to Add a New API Endpoint
Prefer a signed Nostr event and the existing WebSocket/POST /events ingest
path over adding endpoint-specific JSON APIs. The relay intentionally exposes
only a narrow HTTP surface: NIP-11/NIP-05 metadata, /events, /query,
/count, /hooks/{id}, Blossom media, git smart HTTP, git policy hooks, and
health probes.
If an HTTP endpoint is still necessary:
-
Define the handler in the appropriate module under
crates/buzz-relay/src/api/. Resolve the request tenant before any auth or data lookup, use NIP-98 when the endpoint accepts user credentials, and keep community scoping explicit. -
Register the route in
crates/buzz-relay/src/router.rsusing the narrowest path possible. Do not add new/api/*compatibility routes unless the product decision explicitly calls for one. -
Add database queries in
buzz-db/src/only when the endpoint cannot be expressed through the existing event query paths. -
Handle errors using the
api_error(),internal_error(), andnot_found()helpers inbuzz-relay/src/api/mod.rs. Return(StatusCode, Json<Value>)tuples. -
Write tests with the
buzz-test-clientharness incrates/buzz-test-client/tests/, covering auth, community scoping, and the relevant success path. -
Document any public endpoint in
ARCHITECTURE.mdand user-facing docs.
License and CLA
Buzz is licensed under the Apache License, Version 2.0. See LICENSE for the full text. By submitting a pull request, you agree that your contribution is licensed under the Apache 2.0 license and that you have the right to submit it. If your employer has rights to intellectual property you create, you may need their sign-off. When in doubt, check with your legal team.Thank you for contributing to Buzz. Every bug report, documentation fix, and code contribution makes the project better for everyone. 🐝