mirror of
https://github.com/block/buzz.git
synced 2026-11-24 02:02:07 +00:00
## Summary NIP-AR clients can store community-scoped artifacts and subscribe to live changes for one exact artifact type. Community and channel artifacts share revision and retry semantics and use separate identity scopes. Community owners and admins can choose whether a type accepts edits from all admitted members or only administrators. This PR combines the protocol from #9638 with the relay implementation. [Protocol](0b8949f5e2/docs/nips/NIP-AR.md (community-scoped-artifacts-proposed-extension)) - Kind `45010` binds community writes to a signed tenant UUID. Explicit community filters select signed HTTP reads and WebSocket sync. NIP-11 advertises capability after the schema transition. - Kind `9034` sets per-type policy using compare-and-set. The relay commits the policy update and audit entry together. Readers fetch the current policy and its revision through the explicit policy view. - Kind `9005` redacts a community revision. Relay peers send tenant-scoped change metadata and re-read the authorized head for delivery. This reuses the existing snapshot, bounded buffering, and resync semantics. ## Rollout Migration `0097` expands storage and retains the existing channel write key. Deploy compatible serving backends, deletion executors and operator tools with community scope disabled. Then run the guarded key transition and enable the capability. The resulting rollback floor is the first compatible relay version. [Rollout guide](0b8949f5e2/docs/community-artifact-rollout.md) ## Why each change belongs in the relay or protocol | Change | Necessity | Minimality | | --- | --- | --- | | NIP-AR community scope | The current protocol gives every artifact a home channel and defines channel-based access. Clients need a shared contract for community identity, admission, reads and moderation to interoperate. [NIP-AR.md:9](493cb4cc13/docs/nips/NIP-AR.md (L9)) [NIP-AR.md:65](493cb4cc13/docs/nips/NIP-AR.md (L65)) | An optional version-1 section reuses the artifact envelope version and revision operations. The channel sections state where their existing rules apply. [NIP-AR.md:242](0b8949f5e2/docs/nips/NIP-AR.md (L242)) | | Signed community revisions | The validator requires an `h` tag, and the write path stores an event and mentions for that channel. A client-defined tag cannot establish a different audience on the relay. [artifact.rs:122](493cb4cc13/crates/buzz-core/src/artifact.rs (L122)) [artifact.rs:196](493cb4cc13/crates/buzz-db/src/store/artifact.rs (L196)) | The existing event kind accepts a mutually exclusive, signed community UUID. HTTP and WebSocket bind it to the resolved tenant at ingest and reuse the revision authentication checks. [community_artifact.rs:120](0b8949f5e2/crates/buzz-relay/src/handlers/community_artifact.rs (L120)) [community_artifact.rs:174](0b8949f5e2/crates/buzz-relay/src/handlers/community_artifact.rs (L174)) | | Scoped heads and revisions | The database key places every artifact in one identity space per community. Only the relay can advance an accepted head atomically across clients. [artifact_heads.sql:2](493cb4cc13/schema/tables/public/artifact_heads.sql (L2)) [artifact.rs:187](493cb4cc13/crates/buzz-db/src/store/artifact.rs (L187)) | The head and revision ledger gain a scope discriminator. Community revisions keep their signed payload in the ledger and reuse the compare-and-set, replay and tombstone rules. [community_artifact.rs:350](0b8949f5e2/crates/buzz-db/src/store/community_artifact.rs (L350)) | | Community admission | Channel reads check channel visibility and membership. A client can filter its own view but cannot enforce admission for other readers or synchronize delivery with a revocation. [artifact_query.rs:65](493cb4cc13/crates/buzz-db/src/store/artifact_query.rs (L65)) | Explicit community reads and writes share an admission check against current membership, verified delegation and bans. Administrative authority requires a direct role. [community_artifact.rs:36](0b8949f5e2/crates/buzz-db/src/store/community_artifact.rs (L36)) | | Per-type write policy | The administrative scope dispatch has no artifact-policy command. A client preference cannot enforce an edit rule against another client or a concurrent write. [ingest.rs:650](493cb4cc13/crates/buzz-relay/src/handlers/ingest.rs (L650)) | One signed admin command sets policy for one exact type using compare-and-set. A bounded map on the existing community row records the policy and revision. A shared lock orders policy changes with writes, and the existing audit chain commits in the same transaction. [community_artifact.rs:183](0b8949f5e2/crates/buzz-db/src/store/community_artifact.rs (L183)) [community_artifact.rs:365](0b8949f5e2/crates/buzz-db/src/store/community_artifact.rs (L365)) [community_artifact.rs:189](0b8949f5e2/crates/buzz-relay/src/handlers/community_artifact.rs (L189)) | | Signed HTTP reads | The artifact endpoint dispatches to the channel store. It cannot return a community head, its history or the authoritative write policy. [artifact.rs:70](493cb4cc13/crates/buzz-relay/src/api/artifact.rs (L70)) [artifact_query.rs:65](493cb4cc13/crates/buzz-db/src/store/artifact_query.rs (L65)) | One scope selector on the existing signed endpoint extends the current, history and head views and adds an exact-type policy lookup. Counts and HTTP incremental tokens stay channel-only. [artifact.rs:73](0b8949f5e2/crates/buzz-relay/src/api/artifact.rs (L73)) [artifact_sync.rs:154](0b8949f5e2/crates/buzz-relay/src/api/artifact_sync.rs (L154)) | | Community WebSocket sync | The relay requires channel IDs and confirms live interest on those channels. A client cannot register community interest through the existing filter. [artifact_sync.rs:51](493cb4cc13/crates/buzz-core/src/artifact_sync.rs (L51)) [artifact_sync.rs:440](493cb4cc13/crates/buzz-relay/src/handlers/artifact_sync.rs (L440)) | One exact type selects the community set. The relay reuses subscription ownership, snapshot paging, bounded buffering, EOSE and resync, with a current admission check before delivery. [artifact_sync.rs:683](0b8949f5e2/crates/buzz-relay/src/handlers/artifact_sync.rs (L683)) [artifact_sync.rs:755](0b8949f5e2/crates/buzz-relay/src/handlers/artifact_sync.rs (L755)) [artifact_sync.rs:934](0b8949f5e2/crates/buzz-relay/src/handlers/artifact_sync.rs (L934)) | | Cross-node delivery | Redis routes channel and ordinary global events. A connected client cannot coordinate when peers reread an authorized head. [topic.rs:15](493cb4cc13/crates/buzz-pubsub/src/topic.rs (L15)) | One tenant-scoped topic carries the identity, exact type and change cause. Each relay filters its own subscriptions and rereads the authorized head or signals resync. [artifact_sync.rs:211](0b8949f5e2/crates/buzz-relay/src/handlers/artifact_sync.rs (L211)) [artifact_sync.rs:1039](0b8949f5e2/crates/buzz-relay/src/handlers/artifact_sync.rs (L1039)) | | Ordinary event audience | Generic queries and search apply event-store rules. A client cannot enforce who else receives a response from those paths, including on a relay with community writes disabled. [event.rs:785](493cb4cc13/crates/buzz-db/src/store/event.rs (L785)) [query.rs:329](493cb4cc13/crates/buzz-search/src/query.rs (L329)) | Community payloads stay in the ledger. Ordinary reads and fan-out enforce the channel boundary, including for rows from older paths. Explicit artifact views enforce community admission. [event.rs:7267](0b8949f5e2/crates/buzz-db/src/store/event.rs (L7267)) [event.rs:153](0b8949f5e2/crates/buzz-relay/src/handlers/event.rs (L153)) | | Community redaction | The moderation path requires a channel in `h`. A client delete cannot apply relay moderation to a stored community revision. [side_effects.rs:671](493cb4cc13/crates/buzz-relay/src/handlers/side_effects.rs (L671)) | The existing moderation kind gains one community-scoped target form for direct owners and admins. Redaction preserves the accepted revision ID and sends affected syncs through the existing resync path. [community_artifact.rs:214](0b8949f5e2/crates/buzz-relay/src/handlers/community_artifact.rs (L214)) [community_artifact.rs:609](0b8949f5e2/crates/buzz-db/src/store/community_artifact.rs (L609)) | | Community purge | The deletion executor retains the community row as a tombstone. Client-side removal cannot clear authoritative policy on that row or prove it was erased. [deletion.rs:2448](493cb4cc13/crates/buzz-db/src/store/deletion.rs (L2448)) [deletion.rs:3488](493cb4cc13/crates/buzz-db/src/store/deletion.rs (L3488)) | The existing purge covers both ledger tables. The tombstone transaction clears the policy map when the column exists, and the absence check verifies it. [deletion.rs:2451](0b8949f5e2/crates/buzz-db/src/store/deletion.rs (L2451)) [deletion.rs:3489](0b8949f5e2/crates/buzz-db/src/store/deletion.rs (L3489)) | | Schema rollout | Older writers use the existing two-column conflict target. Clients cannot preserve that write contract during a key change or attest which relay binaries are serving. [artifact.rs:196](493cb4cc13/crates/buzz-db/src/store/artifact.rs (L196)) | Migration 0097 adds columns and indexes without a backfill and preserves the old key. A separate guarded SQL operation installs the scoped key after the compatible fleet is in place. The rollout guide documents the sequence and rollback boundary. [0097_community_artifact_expand.sql:7](0b8949f5e2/migrations/0097_community_artifact_expand.sql (L7)) [community-artifact-contract.sql:13](0b8949f5e2/scripts/maintenance/community-artifact-contract.sql (L13)) [community-artifact-rollout.md:38](0b8949f5e2/docs/community-artifact-rollout.md (L38)) | | NIP-11 and enablement | The baseline artifact descriptor supplies neither the tenant UUID nor a signal that the scoped schema is active. Clients cannot infer activation across mixed-version deployments. [nip11.rs:478](493cb4cc13/crates/buzz-relay/src/nip11.rs (L478)) | One optional discovery object advertises the version, canonical tenant UUID and policy limit. The handlers and NIP-11 share the configuration and schema-readiness gate. [nip11.rs:482](0b8949f5e2/crates/buzz-relay/src/nip11.rs (L482)) [community_artifact.rs:51](0b8949f5e2/crates/buzz-relay/src/handlers/community_artifact.rs (L51)) | ## Size Measured with `git diff` from `493cb4cc1` to `0b8949f5e`. Dedicated test files and changed lines inside Rust `#[cfg(test)]` items count as tests. Each side of a mixed hunk is classified against its own revision. | | Added | Removed | | --- | ---: | ---: | | Production, including schema and rollout SQL | 2,249 | 117 | | Tests | 1,897 | 53 | | Docs | 180 | 8 | | Standalone runtime probe | 397 | 0 | | **Total** | **4,723** | **178** | The total includes `crates/buzz-relay/examples/community_artifact_probe.rs`. The production and test rows exclude it. The probe supports manual mixed-version and feature-disabled checks against a running relay. ## Validation Validated at `0b8949f5e29f5ccf51ec5e2d487f09e2f49bffeb` against `493cb4cc1369ff9fdb44ae6c50f18c66d1fb6474`. - The signed HTTP and WebSocket workflow exercised the old and new channel writers on the expanded schema, the guarded key transition, community snapshot and live sync, policy compare-and-set and replay, tenant binding, scope isolation, and redaction followed by resync. Restarting the relay with community scope disabled after the transition withheld capability advertisement and preserved channel artifact operations. - The normal `buzz-db` suite passed 268 tests, including doctests. All 860 `buzz-db` PostgreSQL tests passed, including the wide `#e` read regression from #9591. - The full eight-package PostgreSQL run passed 1,695 of 1,696 tests. `handlers::ingest::postgres_tests::reaction_and_deletion_h_must_name_the_target_channel` failed while setting up its private-channel fixture. The same fixture failed on the protocol base `27a4c8a86e9e9795bfaf5fe59f35164a6389a9ed`. - The hosted PostgreSQL run at `686b8445` passed 1,698 of 1,699 tests. The same test was the sole failure on the PR and on `main` at `493cb4cc13`. In both runs, fixture setup returned `restricted: not a channel member` while storing the private target. #9640 fixes the fixture by invalidating the author's membership cache after creating the private channel. Its PostgreSQL run passes the test. [PR run 44325182932](https://github.com/block/buzz/actions/runs/44325182932/job/134884438543) · [Main run 44254013047](https://github.com/block/buzz/actions/runs/44254013047/job/134638066441) · [Fix #9640](https://github.com/block/buzz/pull/9640) · [Passing test on #9640](https://github.com/block/buzz/actions/runs/44248427229/job/134618695910) - `just test-unit` and `just test` passed on Linux in separate runs. The commands recorded 6,611 and 7,243 passing test executions, respectively, with overlap between the suites. These runs passed the CLI socket ownership tests and push-gateway fixture that failed during the earlier parallel hook run. Both Tauri Clippy configurations and 3,560 Tauri test executions also passed at this commit. - `just ci` passed Rust formatting, workspace Clippy, and desktop, Tauri, and web checks. It stopped at mobile formatting after the Linux environment failed to resolve `pub.dev` for the Flutter dependencies. ## End-user test The PR author’s agent ran the app and plugin end to end on Linux against a local relay built at `0b8949f5e`. The final browser rerun passed all 15 steps plus the public default-channel case. The native desktop run passed all seven steps it covered. - A group saved by the owner appeared in a member’s open Settings without a reload. - Changing the write policy to owners and admins made the member’s editor read-only. The relay refused a signed write by that member and preserved the current record. - The audit log identified the policy revision as the accepted kind-`9034` event ID. The policy change back to everyone used that ID as `prev`. - A second relay with community artifacts disabled advertised no community scope, and the app withheld shared group actions. [End-user test evidence](https://github.com/block/buzz-app/pull/3838#end-user-test-agentsmd-step-3) Supersedes #9646. The reviewed commit is now on an upstream branch. --------- Signed-off-by: Krish Ray <kray@block.xyz> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: Codex <codex@openai.com>
516 lines
28 KiB
Plaintext
516 lines
28 KiB
Plaintext
# =============================================================================
|
||
# Buzz Backend — Local Development Environment
|
||
# =============================================================================
|
||
# Copy this file to .env and adjust as needed:
|
||
# cp .env.example .env
|
||
#
|
||
# All defaults here work with `docker compose up` out of the box.
|
||
#
|
||
# Service ports (defaults):
|
||
# Postgres → localhost:5432
|
||
# Redis → localhost:6379
|
||
# Typesense → localhost:8108
|
||
# Adminer → localhost:8082 (DB browser UI)
|
||
#
|
||
# Note: If port 8082 conflicts, change the adminer port in docker-compose.yml
|
||
# =============================================================================
|
||
|
||
# -----------------------------------------------------------------------------
|
||
# Database (Postgres 17)
|
||
# -----------------------------------------------------------------------------
|
||
DATABASE_URL=postgres://buzz:buzz_dev@localhost:5432/buzz
|
||
# Optional read-replica URL; unset/blank keeps all reads on the writer.
|
||
# READ_DATABASE_URL=postgres://buzz:buzz_dev@localhost:5433/buzz
|
||
PGHOST=localhost
|
||
PGPORT=5432
|
||
PGUSER=buzz
|
||
PGPASSWORD=buzz_dev
|
||
PGDATABASE=buzz
|
||
|
||
# -----------------------------------------------------------------------------
|
||
# Redis 7
|
||
# -----------------------------------------------------------------------------
|
||
REDIS_URL=redis://localhost:6379
|
||
# Max connections in each of the relay's Postgres pools — writer and, when
|
||
# READ_DATABASE_URL is set, reader (default 50).
|
||
# BUZZ_DB_POOL_SIZE=50
|
||
# Read-only partition catalog audit interval, clamped to 60s..24h (default 900s).
|
||
# BUZZ_PARTITION_AUDIT_INTERVAL_SECS=900
|
||
# Emergency kill switch for all automatic partition DDL, including catch-all
|
||
# advancement; audits remain enabled.
|
||
# BUZZ_PARTITION_MANAGER_CREATE_ENABLED=true
|
||
# Which workflow runs may direct agents: any (default) or owner (owner-only
|
||
# agent mentions). See docs/operator-workflow-agent-mentions.md.
|
||
# BUZZ_WORKFLOW_AGENT_MENTIONS=owner
|
||
# Replace an empty partition catch-all with six months of dedicated monthlies,
|
||
# at startup and on every audit interval (default true). Has no effect while the
|
||
# kill switch above is off.
|
||
# BUZZ_PARTITION_MANAGER_ADVANCE_ENABLED=true
|
||
|
||
# Writer-session Postgres timeouts for buzz-db-backed pools and the relay audit
|
||
# pool, all in milliseconds; 0 disables the lock and idle timeouts. The
|
||
# separately deployed push gateway owns its own database and session policy
|
||
# and does not consume these knobs.
|
||
# lock_timeout: fail a statement that waits this long on any lock instead of
|
||
# parking behind a wedged holder (default 5000).
|
||
# BUZZ_DB_LOCK_TIMEOUT_MS=5000
|
||
# idle_in_transaction_session_timeout: reap sessions idle inside an open
|
||
# transaction — bounds how long a wedged client can hold locks (default 60000).
|
||
# BUZZ_DB_IDLE_TXN_TIMEOUT_MS=60000
|
||
# statement_timeout: cap any single statement's runtime (default 120000). A
|
||
# session cannot disable it: 0 or anything above 300000 installs 300000 (5
|
||
# minutes) and logs a warning at startup. Migrations, schema destruction, and
|
||
# community-deletion inventory and purge transactions lift it for themselves.
|
||
# Generic event reads (REQ history, /query, /count) and read-replica sessions
|
||
# are further capped at 20s. Warning: a pathologically low value (e.g. 1) also
|
||
# times out connection setup and can prevent any DB connection from
|
||
# establishing.
|
||
# BUZZ_DB_STATEMENT_TIMEOUT_MS=120000
|
||
|
||
# -----------------------------------------------------------------------------
|
||
# Typesense (search)
|
||
# -----------------------------------------------------------------------------
|
||
TYPESENSE_API_KEY=buzz_dev_key
|
||
TYPESENSE_URL=http://localhost:8108
|
||
|
||
# -----------------------------------------------------------------------------
|
||
# Relay (WebSocket server)
|
||
# -----------------------------------------------------------------------------
|
||
# Bind address for the relay (host:port)
|
||
BUZZ_BIND_ADDR=0.0.0.0:3000
|
||
# Public WebSocket URL — used in NIP-42 auth challenges
|
||
RELAY_URL=ws://localhost:3000
|
||
# Stable relay signing key (required). `just bootstrap` generates a random key in
|
||
# the gitignored .env file. Preserve that value across restarts and backups.
|
||
# BUZZ_RELAY_PRIVATE_KEY=<32-byte hex private key>
|
||
# Optional: path to the web UI dist directory. When set, the relay serves
|
||
# the web frontend at / for browser requests. Leave unset for local dev
|
||
# (use `just web` for Vite HMR instead).
|
||
# BUZZ_WEB_DIR=./web/dist
|
||
|
||
# NIP-PL mobile push is an explicit deployment opt-in. A gateway URL alone
|
||
# never enables it. When enabled, the exact HTTP(S) delivery URL is required.
|
||
# Rollback requires replacing every enabled writer/worker process. Inspect and
|
||
# explicitly decide retained queue disposition before re-enabling (see docs/push-gateway-deployment.md).
|
||
BUZZ_PUSH_ENABLED=false
|
||
BUZZ_PUSH_GATEWAY_DELIVERY_URL=https://push.buzz.xyz/v1/deliveries/apns
|
||
|
||
# Push gateway (buzz-push-gateway) Android settings, optional. They belong to the
|
||
# gateway process, not the relay, and are supplied together or not at all. Example
|
||
# values only; see docs/push-gateway-deployment.md.
|
||
# BUZZ_PUSH_ANDROID_PACKAGE_NAME=com.example.buzz
|
||
# BUZZ_PUSH_ANDROID_SIGNING_CERT_DIGESTS=<64-hex-char SHA-256 of the app signing certificate>[,...]
|
||
# BUZZ_PUSH_FCM_PROJECT_ID=example-project
|
||
# BUZZ_PUSH_FCM_SERVICE_ACCOUNT_PATH=/etc/buzz-push/fcm-service-account.json
|
||
# Optional Android attestation settings. Boot keys are SHA-256 digests of verified
|
||
# boot keys accepted with a self-signed boot state; empty accepts stock Android only.
|
||
# BUZZ_PUSH_ANDROID_BOOT_KEY_DIGESTS=<64-hex-char digest>[,...]
|
||
# BUZZ_PUSH_ANDROID_ATTESTATION_ROOTS_PATH=/etc/buzz-push/attestation-roots.pem
|
||
# BUZZ_PUSH_ANDROID_REVOCATION_GRACE_SECONDS=604800
|
||
# BUZZ_PUSH_SIGNED_CALL_WINDOW_SECONDS=60
|
||
# BUZZ_PUSH_SIGNED_CALL_MAX_CALLS=30
|
||
|
||
# -----------------------------------------------------------------------------
|
||
# Admin Dashboard (private moderation surface)
|
||
# -----------------------------------------------------------------------------
|
||
# Host name that serves the moderation dashboard and its /api/admin/v1
|
||
# endpoints. Leave unset to keep the admin surface absent.
|
||
# BUZZ_ADMIN_HOST=admin.localhost:3000
|
||
#
|
||
# Authentication mode. Accepted values: nip98 (default), disabled.
|
||
# Any other value is a startup error. Token authentication was removed:
|
||
# BUZZ_ADMIN_TOKEN is ignored with a startup warning — remove it from the environment.
|
||
# BUZZ_ADMIN_AUTH=nip98
|
||
#
|
||
# Option A — BUZZ_ADMIN_AUTH=nip98 (Nostr pubkey-based auth, default):
|
||
# NIP-98 HTTP Auth. Each request must carry an Authorization: Nostr header
|
||
# with a signed kind-27235 event. Authorized principals are resolved from:
|
||
# 1. RELAY_OPERATOR_PUBKEYS — comma-separated 64-char hex pubkeys (config Operators).
|
||
# 2. RELAY_OWNER_PUBKEY — implicit Operator fallback when RELAY_OPERATOR_PUBKEYS is unset.
|
||
# 3. relay_operators table — DB-managed Operator/Moderator roster.
|
||
# The dashboard requires a NIP-07 browser extension.
|
||
# Setting RELAY_OPERATOR_PUBKEYS for the admin console does NOT require
|
||
# RELAY_OPERATOR_API_ORIGIN; that origin is only for community provisioning
|
||
# (see below). When BUZZ_ADMIN_HOST is set, the relay advertises the admin
|
||
# origin in its NIP-11 document (`admin_api` field) so clients can auto-discover
|
||
# the console without manual URL entry.
|
||
# RELAY_OPERATOR_PUBKEYS=<64-char hex pubkey>[,<64-char hex pubkey>...]
|
||
|
||
# Serve multiple communities (default true; strict boolean). With false, only
|
||
# the normalized RELAY_URL host (including a nondefault port) serves ordinary
|
||
# HTTP/WebSocket traffic. New operator creation is disabled; canonical startup
|
||
# bootstrap and authenticated admin/operator cleanup of existing extras remain
|
||
# available. Existing rows and background cleanup workers are retained.
|
||
# Restart every serving revision when changing this setting. Requires a supporting
|
||
# image: old images ignore unknown vars; rollback can reopen serving/creation.
|
||
# BUZZ_MULTI_COMMUNITY_RELAY=true
|
||
#
|
||
# Option B — BUZZ_ADMIN_AUTH=disabled (read-only, no authentication):
|
||
# Anyone who can reach the relay can read, in every community: reports (with
|
||
# reporter notes and reported message content, deleted included), feedback and
|
||
# attachments, bans and timeouts with reasons, the community directory, member
|
||
# search and profiles (not staff status), and any stored message by ID.
|
||
# Writes and staffing are refused.
|
||
# Only people allowed to see all of that should be able to reach it. The admin
|
||
# API is on the relay's main listener and its hostname check uses the caller's
|
||
# Host header, so the whole relay port must be private, not just the admin
|
||
# hostname. The relay logs a WARN on every startup.
|
||
# `just admin` defaults to this mode for local review.
|
||
#
|
||
# Directory holding the built dashboard assets (`pnpm -C admin-web build`).
|
||
# BUZZ_ADMIN_WEB_DIR=./admin-web/dist
|
||
#
|
||
# Canonical origin (http(s)://host[:port], no path) that community-provisioning
|
||
# NIP-98 requests are verified against. Required only to USE the provisioning
|
||
# endpoints (POST /operator/communities) — not for the admin console. When
|
||
# RELAY_OPERATOR_PUBKEYS is set but this is unset, the relay boots with a WARN
|
||
# and provisioning requests fail closed until it is set.
|
||
# RELAY_OPERATOR_API_ORIGIN=http://127.0.0.1:3000
|
||
|
||
# Deployment-global operator-listener routes. Each configured Nostr identity
|
||
# may register target pubkeys and receives mention notifications at its URL.
|
||
# URLs may use HTTP or HTTPS. Use HTTP only for operator-controlled internal
|
||
# connections: NIP-98 signs requests but does not encrypt them, and
|
||
# notifications carry full message content.
|
||
# Format: pubkey:deliveryUrl;pubkey:deliveryUrl
|
||
# BUZZ_OPERATOR_LISTENER_TIMEOUT_MS=5000
|
||
# BUZZ_OPERATOR_LISTENERS=<64-char hex pubkey>:https://listener.example/mentions
|
||
|
||
# Optional endpoint that receives each new per-community storage snapshot
|
||
# written by `buzz-admin storage-snapshot`, in NIP-98 relay-signed POST batches
|
||
# shaped like kgoose's storage-usage record request. One relay pod checks for a
|
||
# new snapshot every 5 minutes. Receivers must treat a repeated community and
|
||
# measured_at as already recorded.
|
||
# BUZZ_STORAGE_USAGE_URL=https://kgoose.example/cash-app/goose/v1/buzz/storage-usage/record
|
||
|
||
# Optional relay-owned KLIPY key. When set, NIP-11 advertises GIF search and
|
||
# authenticated desktop clients use this relay as the metadata/search proxy.
|
||
# Keep the real value in your deployment's secret manager; never commit it.
|
||
# BUZZ_KLIPY_API_KEY=
|
||
|
||
# Shared Redis-backed admission limits. Defaults shown below; each value must
|
||
# be a positive integer.
|
||
# BUZZ_RATE_LIMIT_HUMAN_MESSAGES_PER_MIN=60
|
||
# BUZZ_RATE_LIMIT_GIF_SEARCHES_PER_MIN=30
|
||
# BUZZ_RATE_LIMIT_HUMAN_API_CALLS_PER_MIN=300
|
||
# BUZZ_RATE_LIMIT_HUMAN_WS_EVENTS_PER_SEC=10
|
||
# BUZZ_RATE_LIMIT_AGENT_STANDARD_MESSAGES_PER_MIN=120
|
||
# BUZZ_RATE_LIMIT_AGENT_STANDARD_API_CALLS_PER_MIN=600
|
||
# BUZZ_RATE_LIMIT_AGENT_ELEVATED_MESSAGES_PER_MIN=300
|
||
# BUZZ_RATE_LIMIT_AGENT_PLATFORM_MESSAGES_PER_MIN=600
|
||
|
||
# -----------------------------------------------------------------------------
|
||
# Git (NIP-34 bare repositories)
|
||
# -----------------------------------------------------------------------------
|
||
# Root directory for ephemeral Git workspaces and the disposable pack cache.
|
||
# Default: ./repos (relative to CWD).
|
||
# BUZZ_GIT_REPO_PATH=./repos
|
||
# BUZZ_GIT_MAX_PACK_BYTES=524288000
|
||
# BUZZ_GIT_MAX_REPO_BYTES=1048576000
|
||
# Process-local immutable pack/index cache. Zero disables retention.
|
||
# BUZZ_GIT_PACK_CACHE_PATH=./repos/.pack-cache
|
||
# BUZZ_GIT_PACK_CACHE_MAX_BYTES=5368709120
|
||
# BUZZ_GIT_PACK_CACHE_MAX_CONCURRENT_POPULATIONS=2
|
||
|
||
# Channel media revocation: off (default), shadow, enforce. Restart to change.
|
||
# Apply migration 0086 first; see docs/operator-private-media.md.
|
||
BUZZ_MEDIA_READ_MODE=off
|
||
|
||
# -----------------------------------------------------------------------------
|
||
# S3-Compatible Object Storage (media + Git/CAS)
|
||
# -----------------------------------------------------------------------------
|
||
# The local MinIO container is reachable from host processes at localhost:9000.
|
||
# Path style keeps the bucket in the URL path and is required by this local DNS
|
||
# setup. Use `virtual` only when the provider requires bucket-as-subdomain URLs.
|
||
BUZZ_S3_ENDPOINT=http://localhost:9000
|
||
BUZZ_S3_ACCESS_KEY=buzz_dev
|
||
BUZZ_S3_SECRET_KEY=buzz_dev_secret
|
||
BUZZ_S3_BUCKET=buzz-media
|
||
BUZZ_S3_REGION=us-east-1
|
||
BUZZ_S3_ADDRESSING_STYLE=path
|
||
|
||
# -----------------------------------------------------------------------------
|
||
# Media Upload Admission
|
||
# -----------------------------------------------------------------------------
|
||
# Bound image/video parser and storage work admitted by one relay process.
|
||
# BUZZ_MEDIA_MAX_CONCURRENT_UPLOADS=8
|
||
# BUZZ_MEDIA_MAX_CONCURRENT_UPLOADS_PER_PUBKEY=2
|
||
# BUZZ_MEDIA_UPLOADS_PER_MINUTE=30
|
||
# GET/HEAD /media/* always require Blossom t=get auth and relay membership.
|
||
# BUZZ_REQUIRE_MEDIA_GET_AUTH and BUZZ_REQUIRE_MEDIA_READ_AUTH are no longer
|
||
# read; setting either (including to false) changes nothing and the relay warns
|
||
# about it at startup.
|
||
|
||
# -----------------------------------------------------------------------------
|
||
# Ephemeral Channels (TTL testing)
|
||
# -----------------------------------------------------------------------------
|
||
# Override the TTL for all ephemeral channels (in seconds). When set, any
|
||
# channel created with a TTL tag will use this value instead of the
|
||
# client-provided one. Unset to use the client-provided TTL.
|
||
# BUZZ_EPHEMERAL_TTL_OVERRIDE=60
|
||
|
||
# How often the reaper checks for expired ephemeral channels (default: 60s).
|
||
# BUZZ_REAPER_INTERVAL_SECS=5
|
||
|
||
# -----------------------------------------------------------------------------
|
||
# Logging / Tracing
|
||
# -----------------------------------------------------------------------------
|
||
RUST_LOG=buzz_relay=debug,buzz_datastore=info,buzz_db=debug,buzz_auth=debug,buzz_pubsub=debug,tower_http=debug
|
||
# Optional OpenTelemetry-only target filter. This is deliberately independent
|
||
# from RUST_LOG so log verbosity changes cannot break trace parentage.
|
||
# BUZZ_OTEL_FILTER=buzz_relay=info,buzz_relay::access=off,buzz_datastore=info
|
||
#
|
||
# Access log: the relay writes JSON lines for security-relevant actions under
|
||
# the `buzz_relay::access` target, with an `event` field of `http`, `auth`,
|
||
# `req`, `count`, `sync`, or `close`. `http` is one line per HTTP request, written
|
||
# by one layer when the response is ready (not proof the body was delivered):
|
||
# `route` is the matched route template (never the raw path), with the response
|
||
# `status` and `time_to_response_ms` on every line. It carries the login
|
||
# (`method`, `pubkey`, `pubkey_verified`) and `outcome` (`success`, `denied`,
|
||
# `failed`, `challenged`, or `undecided` when the route recorded no decision; a
|
||
# refusal is final). `/query` and `/count` add the filter summary and
|
||
# `result_count`; `/events` adds `accepted`, `kind`, `event_id` and a fixed
|
||
# `reject_reason` code; invite and admin attachment routes add their own fields
|
||
# (`invite_id`, `expires_at`, `max_uses`, `joined`, `feedback_id`,
|
||
# `attachment_sha256`). Invite codes, tokens and Blossom read hashes are never
|
||
# logged. An attachment read with admin auth disabled logs
|
||
# `method=network_trusted` and no key. A request dropped before its response
|
||
# logs `request=aborted` with no `status`.
|
||
# Every matched route is logged except `/` (non-upgrade), `/info`,
|
||
# `/.well-known/nostr.json`, `/health`, `/_liveness` and `/_readiness`.
|
||
# Requests matching no route log only at status 400 and above, as
|
||
# `route="<unmatched>"`, except that the SPA and static files the relay
|
||
# serves when enabled (web assets, invite landing pages, git web pages, the
|
||
# admin bundle) log nothing at any status, including 404. Successful WebSocket
|
||
# upgrades log no `http` line.
|
||
# `auth` is one line per WebSocket login, written when it succeeds or is
|
||
# refused; every root WebSocket `auth` line carries the TCP `peer_addr`.
|
||
# `req` / `count` / `sync` is one line per WebSocket read (a NIP-AR sync
|
||
# subscription is a `sync` read), with the same filter summary
|
||
# (search text is never logged, only `search: true`). A `sync` line is written
|
||
# when its initial set completes, not when live delivery ends: its summary is
|
||
# the registered live filter (kinds and channels, never artifact predicates)
|
||
# and `events_queued` counts the initial set. `buzz_ws_reads_total` counts
|
||
# parsed reads by `type` (`req`, `count`, `sync`). The summary lists up to
|
||
# 10 kinds, channel ids, authors and `p` values each; `kind_count`,
|
||
# `channel_count`, `author_count` and `p_count` appear only when the list is
|
||
# `*` or shows fewer values than the filters held. `close` is the
|
||
# connection's one line: duration, totals, the login's `pubkey`, `method` and
|
||
# `pubkey_verified`, and `reads_suppressed` / `auth_suppressed` for repeated
|
||
# refusals past the first 16. It is written however the connection ends, with
|
||
# `refused` (`not_admitted`, `connection_limit`) when the relay refused it
|
||
# before serving it. Refusals that arrive after `close` has been written log
|
||
# their own lines.
|
||
# Successful lines and git's credential-less first request
|
||
# (`outcome=challenged`) are INFO; refusals, error statuses and aborted
|
||
# requests are WARN. A successful `/query` or `/count` that returned nothing
|
||
# (`result_count=0`) is DEBUG, since polling clients make most of them. A
|
||
# WebSocket read is WARN only when it ends in `error`;
|
||
# refused and `aborted` reads stay INFO, since `aborted` means the read ended
|
||
# before completing: the client closed the connection or sent CLOSE, a same-ID
|
||
# REQ replaced it, or the session was cancelled, all of which are routine. Turn it down with
|
||
# `buzz_relay::access=warn` (keeps refusals, errors and aborted HTTP requests,
|
||
# and of WebSocket reads only `error` outcomes) or `buzz_relay::access=off` in
|
||
# RUST_LOG.
|
||
# It is off in the OTel export by default so lines are not shipped twice.
|
||
# Removed or renamed: `NIP-42 auth successful/failed`, `WebSocket connection
|
||
# established/closed` and the `event=connect` line (folded into `close`), `HTTP
|
||
# bridge request` (folded into the bridge's `http` line), `Event ingested via
|
||
# pipeline` (the WebSocket `Event ingested` line and the `/events` line carry
|
||
# its fields), `relay invite minted`, `relay member added via invite` and `admin
|
||
# feedback attachment read` (folded into the route's `http` line), the `addr`
|
||
# field, now `peer_addr`, and the JSON `span` field (`spans` already ends with
|
||
# the current span; a line logged under an explicit parent span loses that
|
||
# parent's fields). Git subprocess stderr moved from WARN to DEBUG because hook
|
||
# output can contain message text.
|
||
|
||
# Request header holding the real client IP, logged as `client_ip` on `http`,
|
||
# `auth`, `close` and connection-limit lines next to `peer_addr` (optional,
|
||
# case-insensitive; unset or empty turns it off). A list value logs its
|
||
# rightmost entry; a value that isn't an IP address is not logged. Set it only
|
||
# when every request reaches the relay through a proxy that overwrites this
|
||
# header (for example `cf-connecting-ip` behind Cloudflare or `x-real-ip`
|
||
# behind nginx); otherwise clients can forge it.
|
||
# BUZZ_CLIENT_IP_HEADER=x-real-ip
|
||
|
||
# OTLP tracing endpoint (optional — leave unset to disable)
|
||
# OTEL_EXPORTER_OTLP_ENDPOINT=http://localhost:4317
|
||
|
||
# -----------------------------------------------------------------------------
|
||
# ACP (Agent Communication Protocol — buzz-acp harness)
|
||
# -----------------------------------------------------------------------------
|
||
# The ACP harness bridges Buzz events to AI agents. Each env var below maps
|
||
# to a CLI flag of the same name (lowercase, hyphens → underscores). All values
|
||
# are optional unless noted; defaults are shown in comments.
|
||
#
|
||
# Quick start:
|
||
# BUZZ_PRIVATE_KEY=<hex> BUZZ_RELAY_URL=ws://localhost:3000 buzz-acp
|
||
|
||
# ── Identity & auth ──────────────────────────────────────────────────────────
|
||
# Nostr private key (hex or bech32). REQUIRED — identifies the agent on the relay.
|
||
# BUZZ_PRIVATE_KEY=<32-byte hex or nsec1… private key>
|
||
|
||
# Relay WebSocket URL the harness connects to.
|
||
# Note: the relay itself uses RELAY_URL (above); this is the ACP harness's
|
||
# connection target — they happen to point at the same place in local dev.
|
||
# BUZZ_RELAY_URL=ws://localhost:3000
|
||
|
||
# ── Agent subprocess ─────────────────────────────────────────────────────────
|
||
# Binary to spawn as the AI agent (e.g. "goose", "codex-acp", "claude-code").
|
||
# BUZZ_ACP_AGENT_COMMAND=goose
|
||
|
||
# Comma-separated arguments passed to the agent binary.
|
||
# Goose default: "acp". Codex/Claude default: "" (empty).
|
||
# BUZZ_ACP_AGENT_ARGS=acp
|
||
|
||
# Binary for an optional MCP server sidecar (e.g. buzz-dev-mcp for buzz-agent).
|
||
# BUZZ_ACP_MCP_COMMAND=
|
||
|
||
# Number of parallel agent subprocesses (1–32).
|
||
# BUZZ_ACP_AGENTS=1
|
||
|
||
# Desired LLM model ID. Applied to every new ACP session.
|
||
# Use `buzz-acp models` to discover available model IDs.
|
||
# BUZZ_ACP_MODEL=
|
||
|
||
# Optional Databricks model-picker visibility filter. Discovery-only; this does
|
||
# not grant inference access. Comma-separated full-string * / ? patterns are
|
||
# OR-matched against raw workspace endpoint and Unity Catalog model-service IDs.
|
||
# Unset or blank shows every catalog entry. A nonblank value with no usable patterns is invalid.
|
||
# DATABRICKS_MODEL_FILTER=databricks-*,data_tools.goose.*
|
||
|
||
# ── Timeouts & sessions ──────────────────────────────────────────────────────
|
||
# Max seconds per agent turn before timeout (default 320 = ~5 min).
|
||
# BUZZ_ACP_TURN_TIMEOUT=320
|
||
|
||
# Max turns per session before proactive rotation. 0 = disabled (rotate only
|
||
# on MaxTokens / MaxTurnRequests). Recommended: 50 for long-running agents.
|
||
# BUZZ_ACP_MAX_TURNS_PER_SESSION=0
|
||
|
||
# ── Prompts ──────────────────────────────────────────────────────────────────
|
||
# System prompt injected into every agent session (inline text).
|
||
# BUZZ_ACP_SYSTEM_PROMPT=
|
||
|
||
# Path to a file containing the system prompt (mutually exclusive with above).
|
||
# BUZZ_ACP_SYSTEM_PROMPT_FILE=
|
||
|
||
# Message sent to the agent immediately after session creation.
|
||
# BUZZ_ACP_INITIAL_MESSAGE=
|
||
|
||
# ── Heartbeat ────────────────────────────────────────────────────────────────
|
||
# Seconds between heartbeat prompts. 0 = disabled. Must be 0 or ≥10.
|
||
# Recommended: 60 for long-running agents to prevent idle session timeouts.
|
||
# BUZZ_ACP_HEARTBEAT_INTERVAL=0
|
||
|
||
# Heartbeat prompt text (inline). Mutually exclusive with file variant.
|
||
# BUZZ_ACP_HEARTBEAT_PROMPT=
|
||
|
||
# Path to a file containing the heartbeat prompt.
|
||
# BUZZ_ACP_HEARTBEAT_PROMPT_FILE=
|
||
|
||
# ── Desktop development ──────────────────────────────────────────────────────
|
||
# DEV-only: replay first-run onboarding and the Welcome Team kickoff on each
|
||
# app launch while keeping the current identity and relay data.
|
||
# VITE_BUZZ_FORCE_FRESH_ONBOARDING=true
|
||
|
||
# Protected internal builds only: selects the module graph that contains the
|
||
# default-off Bestie experiment. Official OSS builds must leave this unset.
|
||
# VITE_BUZZ_BESTIE=1
|
||
|
||
# ── Subscription & filtering ─────────────────────────────────────────────────
|
||
# Subscribe mode: "mentions" (default), "all", or "config" (rule-based).
|
||
# BUZZ_ACP_SUBSCRIBE=mentions
|
||
|
||
# Comma-separated event kind numbers to subscribe to (overrides mode defaults).
|
||
# BUZZ_ACP_KINDS=
|
||
|
||
# Comma-separated channel UUIDs to limit subscription scope.
|
||
# BUZZ_ACP_CHANNELS=
|
||
|
||
# Set to true to disable the @-mention filter in mentions mode.
|
||
# BUZZ_ACP_NO_MENTION_FILTER=false
|
||
|
||
# Path to TOML config file for rule-based subscriptions (config mode).
|
||
# BUZZ_ACP_CONFIG=./buzz-acp.toml
|
||
|
||
# ── Dedup & self-ignore ──────────────────────────────────────────────────────
|
||
# How to handle duplicate events: "queue" (default) or "drop".
|
||
# BUZZ_ACP_DEDUP=queue
|
||
|
||
# Set to true to process the agent's own messages (default: ignore self).
|
||
# BUZZ_ACP_NO_IGNORE_SELF=false
|
||
|
||
# ── Session scoping ──────────────────────────────────────────────────────────
|
||
# How ACP provider sessions are scoped in channels: "channel" (default) or
|
||
# "thread". "channel" keeps one provider session per channel (legacy). "thread"
|
||
# gives each canonical channel thread its own isolated provider session; direct
|
||
# messages stay conversation-scoped either way. Ships as "channel" so thread
|
||
# scoping can be canaried and rolled back without code changes.
|
||
# BUZZ_ACP_SESSION_POLICY=channel
|
||
|
||
# ── Context ──────────────────────────────────────────────────────────────────
|
||
# Max context messages fetched for thread replies and DMs (0–100). 0 = disabled.
|
||
# BUZZ_ACP_CONTEXT_MESSAGE_LIMIT=12
|
||
|
||
# ── Presence & typing ────────────────────────────────────────────────────────
|
||
# Set to true to disable automatic online/offline presence status.
|
||
# BUZZ_ACP_NO_PRESENCE=false
|
||
|
||
# Set to true to disable typing indicators while the agent is processing.
|
||
# BUZZ_ACP_NO_TYPING=false
|
||
|
||
# ── Advanced tuning ──────────────────────────────────────────────────────────
|
||
# Event channel buffer capacity (WebSocket → harness). Increase for
|
||
# high-throughput agents. Minimum 1.
|
||
# BUZZ_ACP_EVENT_BUFFER=256
|
||
|
||
# ── Legacy aliases ───────────────────────────────────────────────────────────
|
||
# These are accepted for backward compatibility but the canonical names above
|
||
# are preferred:
|
||
# BUZZ_ACP_PRIVATE_KEY → BUZZ_PRIVATE_KEY
|
||
|
||
# Optional relay join policy. Markdown is served by the relay so every join
|
||
# surface can present the same documents. Each document and the independent age
|
||
# attestation are optional; configuring any one enables policy acceptance.
|
||
# BUZZ_TERMS_OF_SERVICE_MARKDOWN="# Terms of Service\n\nFull terms here."
|
||
# BUZZ_PRIVACY_POLICY_MARKDOWN="# Privacy Policy\n\nFull policy here."
|
||
# BUZZ_AGE_ATTESTATION_REQUIRED=true
|
||
|
||
# ── NIP-FI database community source ─────────────────────────────────────────
|
||
# Where NIP-FI communities come from: "env" (BUZZ_NIP_FI_COMMUNITIES, default)
|
||
# or "database" (bindings created by provisioning; needs
|
||
# BUZZ_NIP_FI_PROVISION_BINDING and must not be combined with
|
||
# BUZZ_NIP_FI_COMMUNITIES). See docs/operator-nip-fi-bindings.md.
|
||
# BUZZ_NIP_FI_COMMUNITY_SOURCE=env
|
||
# Most community-issuer rows one snapshot may hold (1..=10000000).
|
||
# BUZZ_NIP_FI_SNAPSHOT_MAX_ROWS=1000000
|
||
# Snapshot load timeout in ms; must be under the 30s refresh interval.
|
||
# BUZZ_NIP_FI_SNAPSHOT_REFRESH_TIMEOUT_MS=10000
|
||
# Hosts whose "not found" is cached for 5s (1..=1000000).
|
||
# BUZZ_NIP_FI_RESOLVER_NEGATIVE_CACHE_MAX=100000
|
||
# Concurrent live lookups; clamped below the database pool size.
|
||
# BUZZ_NIP_FI_RESOLVER_MAX_INFLIGHT=8
|
||
|
||
# Optional absolute legacy-v1 invite cutoff, UTC RFC3339 whole seconds.
|
||
# Unset preserves natural token expiry; never changes v2 invitations.
|
||
# BUZZ_INVITE_V1_INVALID_AFTER=2026-12-01T00:00:00Z
|
||
|
||
# Optional NIP-FI historical verified profiles (disabled by default): issuer JSON
|
||
# entries may set public_profile=true, public_issuer_label="Example Corp", and
|
||
# verified_at_refresh_seconds=3600 (integer 0..86400). Requires a stable relay
|
||
# key and NIP-FI enforcement. Profiles are historical records and are never
|
||
# retracted.
|
||
|
||
# Permit community FI policy enables and disables only after the whole fleet
|
||
# supports policy management. A closed gate preserves receipt recovery/status.
|
||
BUZZ_NIP_FI_CHANGES=false
|
||
|
||
# NIP-CL compact membership discovery. Deploy fleet-wide dark before enabling.
|
||
BUZZ_MEMBERSHIP_SNAPSHOT_ENABLED=false
|
||
# Independent listed-open public membership lookup; also deploy disabled.
|
||
BUZZ_MEMBERSHIP_PUBLIC_ENABLED=false
|
||
|
||
# Enable community NIP-AR only after the separate operator contract.
|
||
# See docs/community-artifact-rollout.md.
|
||
BUZZ_COMMUNITY_ARTIFACTS_ENABLED=false
|