Harden Nostr mesh discovery - #268
Conversation
michaelneale
left a comment
There was a problem hiding this comment.
Review
Good change — validates Nostr listings before joining and falls back through candidates instead of committing to a single token. The validation, typed errors, and tests are solid.
Issues
-
run_autojoin loop inconsistency. The PR adds candidate fallback (try #2 if #1 fails) injoin_mesh_for_mcpand the client--autopath inrun(), but therun_autojoin loop (~line 1340) only got the better error message — not the full fallback-through-candidates behavior. All three join paths should be consistent. -
discovered_mesh()test helper uses raw"published-token"which would failvalidate_listing. Fine for the current unit tests but a latent footgun — should usevalid_invite_token()like the scoring tests do. -
client_count > max_clients * 8heuristic is undocumented. Why 8x? Andmax_clients: 0skips the check entirely, so a listing withmax_clients: 0, client_count: 999999passes validation — could that game scoring? -
No test for the actual fallback behavior — tests confirm
queue_auto_join_candidatespopulates the list, but nothing tests that when candidate #1 has a bad token, candidate #2 is actually tried. -
valid_invite_tokentakes an unused_label: &strparam — can just bevalid_invite_token().
|
I think can close this one now? |
Summary
Clients now recover when Nostr discovery returns malformed mesh listings or bad invite tokens instead of failing the whole auto-join flow.
What Changed
Root Cause
Nostr listing content was being treated as trustworthy enough to defer validation until join time. A malformed
invite_tokencould survive discovery, get selected as a candidate, and then fail with a JSON parse error or force the client into a bad fallback path.Impact
Validation
cargo fmt --all -- mesh-llm/src/network/nostr.rs mesh-llm/src/mesh/mod.rs mesh-llm/src/mesh/tests.rs mesh-llm/src/runtime/mod.rs mesh-llm/src/runtime/discovery.rs/Users/jdumay/.local/bin/mesh-llm client --auto --port 19337 --console 13131just buildis in progress to restore local UI assets for full repo validationcargo check -p mesh-llmwas previously blocked becausemesh-llm/ui/distwas missing in this worktree