mirror of
https://github.com/block/buzz.git
synced 2026-11-01 06:51:17 +00:00
Add `crates/buzz-relay/src/conformance/` module:
- `Tracer` re-export, `NoopTracer` (production), `JsonlTracer` (test/CI).
- `EmitGuard::arm(tracer, state, kind) → (guard, counting_tracer)`:
RAII coverage breach. The guard wraps the original tracer in a
counting layer; production callers transparently use that wrapper.
If no emit reaches the wrapper before the guard drops, the guard
emits a synthetic `ImplBug` step on the underlying tracer — the
checker treats that as CoverageBreach. The wrapper design means
production paths never need to "disarm" or pass anything around;
a future new exit that forgets to emit will be caught
automatically.
- `state_for_request(tenant, actor)`: builds AbstractState. Pulls
community + host directly from server-resolved TenantContext.
- `claimed_community_from_event`: reads the event's h tag for the
trace's `claimed_community` field — recorded SEPARATELY from
`resolved_community` so M2 (claim≠resolved) and M8 (host/channel
disagreement) bite at the checker.
- `sanitized_reason_for(&IngestError) → SanitizedReason`: 1:1 map
of IngestError variants (Rejected/AuthFailed/Internal) onto the
closed SanitizedReason alphabet (Invalid/Restricted/ServerError).
Adding a fourth IngestError variant breaks this match — CI catches
it before it ships.
Emitter wiring in `crates/buzz-relay/src/handlers/ingest.rs`:
- `ingest_event` is now a thin wrapper: arms EmitGuard, calls
`ingest_event_inner`, and on Err maps to SanitizedError. All 36
early-Err returns and 6 Ok returns in the inner fn are covered
by this single outer mapping.
- At `check_channel_membership` call site (line 1401): emits
`AuthCheck { channel, claimed_community, verdict }` with
Allow on Ok, Deny on Err. The verdict basis is `tenant.community()`
server-resolved — confirmed at ingest.rs:424's `is_member_cached`
call signature (not event-derived).
- At each `dispatch_persistent_event` call site (lines 1908, 2014):
emits `WriteInsert` (channel + was_inserted=true), `WriteDuplicate`
(channel + was_inserted=false), or `WriteInsertGlobal` (no channel).
This is the entire write side of the ingest seam.
`crates/buzz-relay/src/handlers/event.rs` `dispatch_persistent_event`:
- No emit added. Documented why inline: the spec has no separate
fan-out action — acceptance is recorded at ingest's WriteInsert;
fan-out surfaces as ReadMessageRows on the subscriber side (the
read seam in req.rs, lands in the held-back additive diff).
AppState carries `tracer: Arc<dyn buzz_conformance::Tracer>`,
defaulting to NoopTracer (zero cost). Test contexts overwrite this
field with a JsonlTracer after construction.
Verify:
- cargo check -p buzz-relay green
- cargo test -p buzz-relay --lib: 378/378 (no regressions)
- cargo test -p buzz-conformance: 9/9 (checker still bites all four
failure modes)
Co-authored-by: Tyler Longwell <tlongwell@block.xyz>
Signed-off-by: Tyler Longwell <tlongwell@block.xyz>
76 lines
2.9 KiB
TOML
76 lines
2.9 KiB
TOML
[package]
|
|
name = "buzz-relay"
|
|
default-run = "buzz-relay"
|
|
# Independent version: buzz-relay ships as a pinnable artifact
|
|
# (ghcr.io/block/buzz), released on its own cadence via `just release-relay`.
|
|
# It does NOT inherit the workspace version.
|
|
version = "0.1.1"
|
|
edition.workspace = true
|
|
rust-version.workspace = true
|
|
license.workspace = true
|
|
repository.workspace = true
|
|
description = "WebSocket relay server for the Buzz communications platform"
|
|
|
|
[[bin]]
|
|
name = "buzz-relay"
|
|
path = "src/main.rs"
|
|
|
|
[dependencies]
|
|
buzz-core = { workspace = true }
|
|
buzz-conformance = { workspace = true }
|
|
buzz-db = { workspace = true }
|
|
buzz-auth = { workspace = true }
|
|
buzz-pubsub = { workspace = true }
|
|
buzz-audit = { workspace = true }
|
|
buzz-search = { workspace = true }
|
|
axum = { workspace = true }
|
|
tokio = { workspace = true }
|
|
# `io` (ReaderStream) is needed to stream git subprocess stdout straight into
|
|
# the HTTP response body — see api::git::transport read-path streaming. The
|
|
# workspace default only enables rt+codec.
|
|
tokio-util = { workspace = true, features = ["io"] }
|
|
tower = { workspace = true }
|
|
tower-http = { workspace = true }
|
|
nostr = { workspace = true }
|
|
serde = { workspace = true }
|
|
serde_json = { workspace = true }
|
|
tracing = { workspace = true }
|
|
tracing-subscriber = { workspace = true }
|
|
thiserror = { workspace = true }
|
|
anyhow = { workspace = true }
|
|
uuid = { workspace = true }
|
|
chrono = { workspace = true }
|
|
dashmap = { workspace = true }
|
|
futures-util = { workspace = true }
|
|
deadpool-redis = { workspace = true }
|
|
redis = { workspace = true }
|
|
sqlx = { workspace = true }
|
|
base64 = "0.22"
|
|
buzz-sdk = { workspace = true }
|
|
buzz-workflow = { workspace = true, features = ["reqwest"] }
|
|
buzz-media = { workspace = true }
|
|
s3 = { version = "0.37", package = "rust-s3", default-features = false, features = ["tokio-rustls-tls", "fail-on-err", "tags"] }
|
|
tempfile = "3"
|
|
bytes = "1"
|
|
infer = "0.19"
|
|
serde_yaml = { workspace = true }
|
|
sha2 = { workspace = true }
|
|
hmac = { workspace = true }
|
|
subtle = { workspace = true }
|
|
rand = { workspace = true }
|
|
hex = { workspace = true }
|
|
url = { workspace = true }
|
|
moka = { workspace = true }
|
|
metrics = { workspace = true }
|
|
metrics-exporter-prometheus = { workspace = true }
|
|
|
|
[features]
|
|
dev = ["buzz-auth/dev"]
|
|
|
|
[dev-dependencies]
|
|
mesh-llm-sdk = { git = "https://github.com/Mesh-LLM/mesh-llm.git", rev = "ebc3ab4c4b5f4a45d5bc942c66c18583800c3f82", package = "mesh-llm-sdk", default-features = false, features = ["client", "serving"] }
|
|
mesh-llm-host-runtime = { git = "https://github.com/Mesh-LLM/mesh-llm.git", rev = "ebc3ab4c4b5f4a45d5bc942c66c18583800c3f82", package = "mesh-llm-host-runtime", default-features = false, features = ["dynamic-native-runtime"] }
|
|
buzz-core = { workspace = true, features = ["test-utils"] }
|
|
buzz-auth = { workspace = true, features = ["dev"] }
|
|
reqwest = { workspace = true }
|