Skip to content

Commit 5980257

Browse files
chore: remove obvious/redundant inline comments across all crates
Strip ~160 inline comments that restate what self-evident code does without explaining WHY. No code or functionality changes. Kept: doc comments, section separators, safety/security notes, WHY explanations, edge case warnings, non-obvious behavior notes, TODO/FIXME markers, and test scenario descriptions. 34 files changed across 12 crates.
1 parent cd3b45f commit 5980257

34 files changed

Lines changed: 2 additions & 167 deletions

File tree

crates/sprout-audit/src/service.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,6 @@ impl AuditService {
7575
.catch_unwind()
7676
.await;
7777

78-
// Always release the lock before returning the connection to the pool.
7978
let _ = sqlx::query("DO RELEASE_LOCK(?)")
8079
.bind(AUDIT_LOCK_NAME)
8180
.execute(&mut *conn)

crates/sprout-auth/src/nip42.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ fn normalize_relay_url(raw: &str) -> String {
2727
let _ = parsed.set_host(Some("127.0.0.1"));
2828
}
2929
}
30-
// Remove trailing slash from the path component.
3130
let path = parsed.path().trim_end_matches('/').to_string();
3231
parsed.set_path(&path);
3332
parsed.to_string()

crates/sprout-auth/src/okta.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,6 @@ impl JwksCache {
204204
ttl_secs: u64,
205205
client: &reqwest::Client,
206206
) -> Result<CachedJwks, AuthError> {
207-
// Fast path: read lock, return if fresh.
208207
{
209208
let guard = self.inner.read().await;
210209
if let Some(cached) = guard.as_ref() {
@@ -244,7 +243,6 @@ impl JwksCache {
244243
fetched_at: Instant::now(),
245244
};
246245

247-
// Re-acquire write lock to store the result.
248246
// Final re-check: another thread may have stored a fresh entry while
249247
// we were fetching. If so, discard our result and return theirs.
250248
let mut guard = self.inner.write().await;

crates/sprout-core/src/filter.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -91,21 +91,18 @@ mod tests {
9191
let past = Timestamp::from(now_ts.as_u64() - 3600);
9292
let future = Timestamp::from(now_ts.as_u64() + 3600);
9393

94-
// kind
9594
assert!(filters_match(&[Filter::new().kind(Kind::TextNote)], &ev));
9695
assert!(!filters_match(
9796
&[Filter::new().kind(Kind::ContactList)],
9897
&ev
9998
));
10099

101-
// author
102100
assert!(filters_match(&[Filter::new().author(pubkey)], &ev));
103101
assert!(!filters_match(
104102
&[Filter::new().author(Keys::generate().public_key())],
105103
&ev
106104
));
107105

108-
// compound AND
109106
assert!(filters_match(
110107
&[Filter::new().kind(Kind::TextNote).author(pubkey)],
111108
&ev
@@ -115,7 +112,6 @@ mod tests {
115112
&ev
116113
));
117114

118-
// since / until
119115
assert!(filters_match(&[Filter::new().since(past)], &ev));
120116
assert!(!filters_match(&[Filter::new().since(future)], &ev));
121117
assert!(filters_match(&[Filter::new().until(future)], &ev));

crates/sprout-db/src/channel.rs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -204,9 +204,6 @@ pub async fn create_channel(
204204
let id = Uuid::new_v4();
205205
let id_bytes = id.as_bytes().as_slice().to_vec();
206206

207-
// Use a transaction so the INSERT + SELECT are atomic. Without this, a concurrent
208-
// reader could see the channel between the insert and the fetch, or the channel
209-
// could be modified before we read it back.
210207
let mut tx = pool.begin().await?;
211208

212209
sqlx::query(
@@ -329,9 +326,6 @@ pub async fn add_member(
329326

330327
let channel_id_bytes = channel_id.as_bytes().as_slice().to_vec();
331328

332-
// Begin transaction: all role checks and the INSERT run atomically.
333-
// This prevents a TOCTOU race where the inviter is removed between the
334-
// role check and the INSERT.
335329
let mut tx = pool.begin().await?;
336330

337331
let channel = get_channel_tx(&mut tx, channel_id).await?;
@@ -514,7 +508,6 @@ pub async fn get_members(pool: &MySqlPool, channel_id: Uuid) -> Result<Vec<Membe
514508
///
515509
/// Includes channels where the pubkey is an active member AND all open channels.
516510
/// Open channels must be included in REQ filter resolution.
517-
/// Returns IDs of all channels accessible to the given pubkey.
518511
pub async fn get_accessible_channel_ids(pool: &MySqlPool, pubkey: &[u8]) -> Result<Vec<Uuid>> {
519512
let rows = sqlx::query(
520513
r#"

crates/sprout-db/src/feed.rs

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -72,12 +72,10 @@ pub async fn query_mentions(
7272
.push_bind(serde_json::json!([["p", pubkey_hex]]).to_string())
7373
.push(", '$')");
7474

75-
// Kinds: stream messages, stream replies, forum posts, forum comments
7675
qb.push(format!(
7776
" AND kind IN ({KIND_STREAM_MESSAGE}, {KIND_STREAM_MESSAGE_V2}, {KIND_FORUM_POST}, {KIND_FORUM_COMMENT})"
7877
));
7978

80-
// Channel access filter
8179
if !accessible_channel_ids.is_empty() {
8280
qb.push(" AND channel_id IN (");
8381
let mut sep = qb.separated(", ");
@@ -130,16 +128,12 @@ pub async fn query_needs_action(
130128
" AND kind IN ({KIND_WORKFLOW_APPROVAL_REQUESTED}, {KIND_STREAM_REMINDER})"
131129
));
132130

133-
// Tag filter: must be tagged to this user.
134131
// Wrap in outer array so MySQL checks for exact sub-array membership — see
135132
// query_mentions for a full explanation of the JSON_CONTAINS semantics.
136133
qb.push(" AND JSON_CONTAINS(tags, ")
137134
.push_bind(serde_json::json!([["p", pubkey_hex]]).to_string())
138135
.push(", '$')");
139136

140-
// Access control: only return events from channels the user can access.
141-
// Identical pattern to query_mentions — prevents leaking events from
142-
// channels the user has been removed from.
143137
if !accessible_channel_ids.is_empty() {
144138
qb.push(" AND channel_id IN (");
145139
let mut sep = qb.separated(", ");
@@ -183,8 +177,6 @@ pub async fn query_activity(
183177
FROM events WHERE 1=1",
184178
);
185179

186-
// Stream messages, forum posts, agent job events.
187-
// KIND_JOB_REQUEST = agent job requested, KIND_JOB_PROGRESS = in-flight progress update, KIND_JOB_RESULT = completed result.
188180
qb.push(format!(
189181
" AND kind IN ({KIND_STREAM_MESSAGE}, {KIND_STREAM_MESSAGE_V2}, {KIND_FORUM_POST}, {KIND_JOB_REQUEST}, {KIND_JOB_PROGRESS}, {KIND_JOB_RESULT})"
190182
));
@@ -233,7 +225,6 @@ mod tests {
233225

234226
#[test]
235227
fn pubkey_hex_encoding_32_byte_key() {
236-
// Simulate a full 32-byte Nostr pubkey.
237228
let pubkey_bytes: Vec<u8> = (0u8..32).collect();
238229
let hex = hex::encode(&pubkey_bytes);
239230
assert_eq!(hex.len(), 64);
@@ -308,8 +299,6 @@ mod tests {
308299
use sprout_core::kind::{
309300
KIND_FORUM_COMMENT, KIND_FORUM_POST, KIND_STREAM_MESSAGE, KIND_STREAM_MESSAGE_V2,
310301
};
311-
// query_mentions filters for: KIND_STREAM_MESSAGE, KIND_STREAM_MESSAGE_V2,
312-
// KIND_FORUM_POST, KIND_FORUM_COMMENT
313302
let mention_kinds: &[u32] = &[
314303
KIND_STREAM_MESSAGE,
315304
KIND_STREAM_MESSAGE_V2,
@@ -338,7 +327,6 @@ mod tests {
338327
#[test]
339328
fn needs_action_query_includes_approval_and_reminder_kinds() {
340329
use sprout_core::kind::{KIND_STREAM_REMINDER, KIND_WORKFLOW_APPROVAL_REQUESTED};
341-
// query_needs_action filters for: KIND_WORKFLOW_APPROVAL_REQUESTED, KIND_STREAM_REMINDER
342330
let needs_action_kinds: &[u32] = &[KIND_WORKFLOW_APPROVAL_REQUESTED, KIND_STREAM_REMINDER];
343331

344332
assert!(
@@ -357,8 +345,6 @@ mod tests {
357345
KIND_FORUM_POST, KIND_JOB_PROGRESS, KIND_JOB_REQUEST, KIND_JOB_RESULT,
358346
KIND_STREAM_MESSAGE, KIND_STREAM_MESSAGE_V2,
359347
};
360-
// query_activity filters for: KIND_STREAM_MESSAGE, KIND_STREAM_MESSAGE_V2,
361-
// KIND_FORUM_POST, KIND_JOB_REQUEST, KIND_JOB_PROGRESS, KIND_JOB_RESULT
362348
let activity_kinds: &[u32] = &[
363349
KIND_STREAM_MESSAGE,
364350
KIND_STREAM_MESSAGE_V2,
@@ -423,7 +409,6 @@ mod tests {
423409
KIND_STREAM_MESSAGE, KIND_STREAM_MESSAGE_V2, KIND_STREAM_REMINDER,
424410
KIND_WORKFLOW_APPROVAL_REQUESTED,
425411
};
426-
// The two queries serve different purposes — their kind sets should not overlap.
427412
let needs_action_kinds: &[u32] = &[KIND_WORKFLOW_APPROVAL_REQUESTED, KIND_STREAM_REMINDER];
428413
let activity_kinds: &[u32] = &[
429414
KIND_STREAM_MESSAGE,

crates/sprout-db/src/lib.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -804,7 +804,6 @@ mod tests {
804804
assert_eq!(channel.description, Some("desc".to_string()));
805805
assert!(db.is_member(channel.id, &owner).await.unwrap());
806806

807-
// Add member via owner invite
808807
db.add_member(
809808
channel.id,
810809
&member,
@@ -818,7 +817,6 @@ mod tests {
818817
let members = db.get_members(channel.id).await.expect("get members");
819818
assert_eq!(members.len(), 2);
820819

821-
// Owner removes member
822820
db.remove_member(channel.id, &member, &owner)
823821
.await
824822
.expect("remove");
@@ -919,17 +917,14 @@ mod tests {
919917
.await
920918
.expect("add rando");
921919

922-
// Rando cannot remove member
923920
let result = db.remove_member(channel.id, &member, &rando).await;
924921
assert!(matches!(result, Err(DbError::AccessDenied(_))));
925922

926-
// Owner can remove member
927923
db.remove_member(channel.id, &member, &owner)
928924
.await
929925
.expect("owner removes");
930926
assert!(!db.is_member(channel.id, &member).await.unwrap());
931927

932-
// Member can remove themselves
933928
db.remove_member(channel.id, &rando, &rando)
934929
.await
935930
.expect("self-remove");

crates/sprout-db/src/workflow.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -940,14 +940,12 @@ mod tests {
940940
let mut cloned = record.clone();
941941
cloned.name = "Cloned".to_owned();
942942

943-
// Original is unchanged.
944943
assert_eq!(record.name, "Original");
945944
assert_eq!(cloned.name, "Cloned");
946945
}
947946

948947
#[test]
949948
fn workflow_record_status_variants() {
950-
// Verify all WorkflowStatus variants can be stored in the struct.
951949
let now = Utc::now();
952950
for status in &[
953951
WorkflowStatus::Active,
@@ -1093,7 +1091,6 @@ mod tests {
10931091
created_at: now,
10941092
};
10951093

1096-
// Trace is a JSON array with 2 entries.
10971094
assert!(record.execution_trace.is_array());
10981095
assert_eq!(record.execution_trace.as_array().unwrap().len(), 2);
10991096
}

crates/sprout-huddle/src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,6 @@ mod tests {
139139
HuddleService::create_room_name(id),
140140
"sprout-550e8400-e29b-41d4-a716-446655440000"
141141
);
142-
// Deterministic
143142
assert_eq!(
144143
HuddleService::create_room_name(id),
145144
HuddleService::create_room_name(id)

crates/sprout-huddle/src/webhook.rs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -186,15 +186,12 @@ mod tests {
186186

187187
#[test]
188188
fn test_webhook_event_variants() {
189-
// room_started
190189
let ev = signed_parse(r#"{"event":"room_started","room":{"name":"r1"}}"#).unwrap();
191190
assert_eq!(ev, WebhookEvent::RoomStarted { room: "r1".into() });
192191

193-
// room_finished
194192
let ev = signed_parse(r#"{"event":"room_finished","room":{"name":"r1"}}"#).unwrap();
195193
assert_eq!(ev, WebhookEvent::RoomFinished { room: "r1".into() });
196194

197-
// participant_joined
198195
let ev = signed_parse(
199196
r#"{"event":"participant_joined","room":{"name":"r1"},"participant":{"identity":"alice"}}"#,
200197
)
@@ -207,7 +204,6 @@ mod tests {
207204
}
208205
);
209206

210-
// participant_left
211207
let ev = signed_parse(
212208
r#"{"event":"participant_left","room":{"name":"r1"},"participant":{"identity":"alice"}}"#,
213209
)
@@ -220,7 +216,6 @@ mod tests {
220216
}
221217
);
222218

223-
// track_published — audio (default)
224219
let ev = signed_parse(
225220
r#"{"event":"track_published","room":{"name":"r1"},"participant":{"identity":"alice"},"track":{"type":"audio"}}"#,
226221
)
@@ -234,7 +229,6 @@ mod tests {
234229
}
235230
);
236231

237-
// track_published — video
238232
let ev = signed_parse(
239233
r#"{"event":"track_published","room":{"name":"r1"},"participant":{"identity":"alice"},"track":{"type":"video"}}"#,
240234
)
@@ -248,7 +242,6 @@ mod tests {
248242
}
249243
);
250244

251-
// track_published — screen_share
252245
let ev = signed_parse(
253246
r#"{"event":"track_published","room":{"name":"r1"},"participant":{"identity":"alice"},"track":{"type":"screen_share"}}"#,
254247
)

0 commit comments

Comments
 (0)