From 3e57144b48a6e5fc9e58e7306f472102f5c664f3 Mon Sep 17 00:00:00 2001 From: tlongwell-block <109685178+tlongwell-block@users.noreply.github.com> Date: Fri, 26 Jun 2026 20:47:41 -0400 Subject: [PATCH] fix(relay-mt): clear clippy -D warnings introduced by tenant threading MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit CI Rust Lint + Windows Rust run `cargo clippy --workspace --all-targets -- -D warnings`; the community_id/tenant args pushed six fns to 8/7 and the new NIP-98 replay code tripped clamp/const-assert lints. Resolve at the bar, matching existing repo conventions: - 6x #[allow(clippy::too_many_arguments)] on the fns that gained a tenant/community arg (same convention already used across buzz-db/relay). - buzz-pubsub replay TTL: .max().min() -> .clamp() (floor 120 < ceiling 3600, cannot panic; behavior identical, incl. the u64::MAX clamp test). - buzz-auth replay const-drift tripwires: scoped #[allow(clippy::assertions_on_constants)] — the assert-on-constant IS the design (fails if someone drifts the TTL constants). Co-authored-by: Eva <011987e296fd5006292d2f930b574be47c7801048d1983c46c425d3c95f0cffd@sprout-oss.stage.blox.sqprod.co> Signed-off-by: tlongwell-block <109685178+tlongwell-block@users.noreply.github.com> --- crates/buzz-auth/src/nip98_replay.rs | 12 ++++++++++-- crates/buzz-db/src/archived_identities.rs | 1 + crates/buzz-db/src/channel.rs | 2 ++ crates/buzz-db/src/lib.rs | 2 ++ crates/buzz-pubsub/src/nip98_replay.rs | 4 +--- crates/buzz-relay/src/handlers/side_effects.rs | 1 + 6 files changed, 17 insertions(+), 5 deletions(-) diff --git a/crates/buzz-auth/src/nip98_replay.rs b/crates/buzz-auth/src/nip98_replay.rs index 0b91065c98..9910399d2e 100644 --- a/crates/buzz-auth/src/nip98_replay.rs +++ b/crates/buzz-auth/src/nip98_replay.rs @@ -192,7 +192,11 @@ mod tests { #[test] fn default_ttl_meets_gate_floor() { // §5 gate: TTL ≥ 120s. Drift this constant down and the gate breaks. - assert!(DEFAULT_REPLAY_TTL_SECS >= 120); + // Const-drift tripwire: the assertion is intentionally over a constant. + #[allow(clippy::assertions_on_constants)] + { + assert!(DEFAULT_REPLAY_TTL_SECS >= 120); + } } #[test] @@ -200,7 +204,11 @@ mod tests { // Sanity: any caller's clamped TTL must end up in [DEFAULT, MAX]. // If these ever cross, the impl can't satisfy both bounds and the // contract is broken. - assert!(DEFAULT_REPLAY_TTL_SECS < MAX_REPLAY_TTL_SECS); + // Const-drift tripwire: the assertion is intentionally over a constant. + #[allow(clippy::assertions_on_constants)] + { + assert!(DEFAULT_REPLAY_TTL_SECS < MAX_REPLAY_TTL_SECS); + } } #[test] diff --git a/crates/buzz-db/src/archived_identities.rs b/crates/buzz-db/src/archived_identities.rs index 728f8bd0a9..941c0fc735 100644 --- a/crates/buzz-db/src/archived_identities.rs +++ b/crates/buzz-db/src/archived_identities.rs @@ -46,6 +46,7 @@ pub async fn is_archived(pool: &PgPool, community_id: CommunityId, pubkey: &str) /// Returns `true` if the row was inserted, `false` if the identity was already /// archived in that community. Re-archiving is idempotent and does not mutate /// the existing row. +#[allow(clippy::too_many_arguments)] pub async fn archive( pool: &PgPool, community_id: CommunityId, diff --git a/crates/buzz-db/src/channel.rs b/crates/buzz-db/src/channel.rs index 8ffc5866fa..99f202b790 100644 --- a/crates/buzz-db/src/channel.rs +++ b/crates/buzz-db/src/channel.rs @@ -83,6 +83,7 @@ pub struct MemberRecord { } /// Creates a new channel, bootstraps the creator as owner, and returns the record. +#[allow(clippy::too_many_arguments)] pub async fn create_channel( pool: &PgPool, community_id: CommunityId, @@ -1388,6 +1389,7 @@ mod tests { id } + #[allow(clippy::too_many_arguments)] async fn create_test_channel( pool: &PgPool, community_id: Uuid, diff --git a/crates/buzz-db/src/lib.rs b/crates/buzz-db/src/lib.rs index d5325bb5f7..3f636928ad 100644 --- a/crates/buzz-db/src/lib.rs +++ b/crates/buzz-db/src/lib.rs @@ -463,6 +463,7 @@ impl Db { } /// Creates a new channel, bootstraps the creator as owner, and returns the record. + #[allow(clippy::too_many_arguments)] pub async fn create_channel( &self, community_id: CommunityId, @@ -1754,6 +1755,7 @@ impl Db { } /// Archives an identity in `community_id`. Returns `true` if inserted, `false` if already archived. + #[allow(clippy::too_many_arguments)] pub async fn archive( &self, community_id: CommunityId, diff --git a/crates/buzz-pubsub/src/nip98_replay.rs b/crates/buzz-pubsub/src/nip98_replay.rs index 264e935d55..79df78db11 100644 --- a/crates/buzz-pubsub/src/nip98_replay.rs +++ b/crates/buzz-pubsub/src/nip98_replay.rs @@ -44,9 +44,7 @@ impl Nip98ReplayGuard for RedisNip98ReplayGuard { // down to MAX_REPLAY_TTL_SECS (contract REQUIRES clamping) so a buggy // caller cannot send a Redis-incompatible `EX` arg or pin a slot for // implausibly long. - let ttl = ttl_secs - .max(DEFAULT_REPLAY_TTL_SECS) - .min(MAX_REPLAY_TTL_SECS); + let ttl = ttl_secs.clamp(DEFAULT_REPLAY_TTL_SECS, MAX_REPLAY_TTL_SECS); let mut conn = self.pool.get().await.map_err(|e| { // Structured field for ops; the user-facing AuthError stays a diff --git a/crates/buzz-relay/src/handlers/side_effects.rs b/crates/buzz-relay/src/handlers/side_effects.rs index ea5ee57cf6..3152112e1e 100644 --- a/crates/buzz-relay/src/handlers/side_effects.rs +++ b/crates/buzz-relay/src/handlers/side_effects.rs @@ -2718,6 +2718,7 @@ pub async fn publish_nipia_archived( } /// Publish a kind:8003 unarchived-identity delta event (NIP-IA). +#[allow(clippy::too_many_arguments)] pub async fn publish_nipia_unarchived( tenant: &TenantContext, state: &Arc,