Reakce na 5. 9.: ujetý AI bot lil 11dílný Gemini 429 dump na #meshcore
(99 ze 100 posledních zpráv kanálu) a naše repeatery ho poslušně šířily.
Vrstva A — FairnessLimiter (port Beanowovy větve beanow/wp-repeat,
upstream návrh meshcore-dev/MeshCore#1502): token buckety nad
FORWARDOVANÝM provozem, klíčované 1B identifikátory v plaintextu
(channel hash / src hash / pubkey[0]). Nový virtual
Mesh::takeForwardingRateLimit() jako poslední podmínka všech čtyř
forward rozhodnutí. DIRECT se nelimituje. Odchylky od originálu: bez
RTC závislosti (logy přes MESH_DEBUG_PRINTLN), bounds guardy na
payload_len. Kill switch: `fairness on|off` (persistovaný pref).
Vrstva B — ChannelFilter: repeater se znalostí PSK (committed
[channel_filter] — klíče hashtag kanálů jsou SHA256(jméno)[:16],
tedy veřejné z konstrukce; derivace ověřená na 0xEF z éteru)
dešifruje GRP_TXT a zprávy odesílatelů z runtime deny listu
odmítne přeposlat (markDoNotRetransmit, stejný mechanismus jako
ANON větev). CLI `filter add|del|list|clear`, seznam v NodePrefs.
Jméno je spoofovatelné — je to zadržení ujetého bota, ne security;
příjem a rxlog/pktfeed (CoreScope) nedotčené. Fork-only, upstream
by to nevzal (privacy/no-censorship, viz diskuze u #169).
ChannelBot refactor: registr kanálů + parse sdílené v ChannelCommon.h
(bot = botOnChannelText), čisté helpery v ChanListUtil.h kvůli native
testům. Nové testy test_fairness_limiter + test_chan_list (native i
ASAN, 164/164 zelených).
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
BOT_FRAG_LEN was 72, chosen against the longest command name rather than the
longest answer, and it held only because !link had never been asked from
further than two hops away. An 11-hop request wanted 88 chars, so the reply
was cut at 71 -- and it cut off exactly the SNR and RSSI the command exists to
report: "... 209f:34fa:ed9c, SNR 4.0 ".
Two changes, because the size alone would not be enough:
* 100 bytes, sized against the real worst case. botFormatPath() caps the
path at 62 chars (21 hops at 1 B, 12 at 2 B, 9 at 3 B all land just under
BOT_PATH_STR_LEN) and the numbers in front add 36, so 98 + NUL.
* the path goes LAST. It is the only unbounded part of the reply -- and the
SENDER picks the hash width, so this node does not even control how long
it gets. With it at the tail, an overrun eats hops instead of eating the
link budget, and a partial path is still useful where a missing SNR is not.
Both bot envs (Xiao_x1_bot, Xiao_x3_obs) build.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Reported symptom: "!link arrived only on the second try". Cause was the throttle
itself -- one global 10 s window per channel, so a second person asking inside it
got silence. That reads as a broken bot rather than "wait ten seconds", and it
happened twice while testing.
Now each sender has its own window, keyed on the "<name>: " prefix, over an
8-slot LRU. Spoofable by design and that is fine: this is politeness throttling,
and a channel message carries no identity beyond that prefix anyway.
The airtime guarantee that the global window used to provide is kept explicitly
as BOT_MIN_GAP_MS (2.5 s floor between any two replies, whoever asked), so N
senders can no longer produce N simultaneous transmissions. Without that, going
per-sender would have quietly traded politeness for responsiveness.
`bot` now reports both numbers plus a throttled counter, so a suppressed reply is
visible instead of looking like a dead node.
Bench-verified on the discriminating case, which is the whole point: sender A
asking twice in 3.5 s gets one answer, while sender B asking INSIDE A's window
gets answered -- 3/3.
Note on how that was measured, because it bit me: reading the console counter
costs ~2.4 s (the CDC needs a settle delay), so a probe pair with a counter read
between them is ~15 s apart and the 10 s window has legitimately expired. The
first run of this test "failed" for exactly that reason. Read counters only
before and after a pair, never inside it.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Correcting how I split the two bots. I gave !path to the Solo node and kept only
analyzer trivia here, which gets the direction backwards.
When you drive away with the handheld and ask "what link do I have home?", the
handheld's own !path is useless: it describes packets the handheld RECEIVED,
i.e. the reverse leg. Only a fixed node at home can answer the forward one,
because it is the thing your packet actually arrived at. So !path belongs here,
and !link joins it: hops + path + SNR + RSSI in one reply, so the question is one
command and not two while driving.
No duplicate answers in that scenario: when the question comes FROM the handheld,
the handheld is the sender and does not answer its own message, so only this node
replies. Two answers only appear when a third node asks -- which is exactly what
my earlier test did, which is why I mistook it for a general problem.
Second reason to answer from here, found while reading the Solo tree: a Solo
node's own bot reply is INVISIBLE in the phone app. tryBotReplyChannel() echoes
only to the local screen under #ifdef DISPLAY_CLASS
(MeshCore-solo/examples/companion_radio/MyMeshBot.h:220), and the only path into
a connected client is onChannelMessageRecv(), which runs for RECEIVED packets
only. A reply from a different node arrives over the air, so the app shows it
like any other message. Answering from here therefore fixes the "I cannot see
what my node said" confusion for free, with no change to the Solo firmware.
Verified live on #tth-test: !link -> "0 hop direct, SNR 13.2 dB, RSSI -43 dBm",
reply counter 2 -> 3.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
#tth-test already had a bot: tracker (Solo firmware), which also puts "Ping" on
the channel by itself. Measured consequence of running a second bot there with
no coordination, over a few minutes: the counter went 2 -> 9, i.e. seven of the
replies went to tracker rather than to a person, and because the cooldown is one
per channel, a human question then landed in a closed window. One of four probes
got no answer for exactly that reason.
Worth stating because it corrects an earlier guess of mine: that miss was NOT an
RF problem. Replies arrive DIRECT (0 hops) at SNR +13.5..14.25 dB, and SF7
demodulates down to about -7.5 dB, so at 2 dBm there is ~20 dB of margin. More
TX power would have bought nothing; the fix was arbitration, not watts.
Two build-time knobs, both defaulting to today's behaviour:
BOT_IGNORE_SENDERS comma-separated node names, dropped before trigger and
command matching. Verified live: `ignored` incremented on
a real tracker message.
BOT_COMMANDS whitelist of !commands this node answers, "" = all.
Matching for both is EXACT and case-insensitive, deliberately unlike
botTriggerMatches()' substring search -- a substring ignore list would let a node
called "TTH" silence "tracker", and a substring whitelist would let "path" enable
"!pathx".
Adds !noise (noise floor), which is in the same spirit as !snr and !heard: things
a companion bot cannot answer at all because it has no analyzer.
`bot` now also reports the whitelist, the ignore list and an ignored counter, so
the arbitration is inspectable from the console instead of inferred.
Deployed split: x3 answers only !snr/!heard/!noise and has NO bare-word trigger,
so it never speaks into ordinary traffic; !path/!ping stay with tracker. Verified
live -- !path drew exactly one answer, from tracker.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
The #tth-test bot needed a host process (slidge) plus a dedicated serial
companion node. Putting it in the firmware removes both: the observer node
answers by itself, and the serial console stays free for the CoreScope feed.
Not a port of the Solo bot. That one lives in examples/companion_radio on a
branch 610 commits diverged from ours, and it can only be configured from an
on-device BotScreen -- a XIAO has no display or buttons, so it would compile
and never arm. What made a local implementation cheap is that mesh::Mesh
already exposes everything:
* Mesh::onRecvPacket() calls searchChannelsByHash() + onGroupDataRecv() and
THEN routeRecvPacket() (Mesh.cpp:236-249), so reading a channel is
independent of forwarding it. Both hooks are no-op virtuals, which is the
only reason a repeater is normally deaf to channel traffic.
* allowPacketForward() gates only RECEIVED packets, so a node with
`repeat off` can still originate a reply. That is the point here: the
observer sits metres from another repeater and must never forward, but it
does have to answer.
* createGroupDatagram() is in mesh::Mesh and sendFloodScoped() is a plain
alias for sendFlood(), so none of the chat/contact machinery is needed.
Written against the mesh::Mesh API only, so it drops into
examples/simple_room_server unchanged if we ever want it there.
Commands are the ones only an analyzer can answer: !path (per-hop hashes at
the packet's own hash width, not a hardcoded 1 byte -- one node here runs 3),
!snr from the frame that carried the request, !heard from the registry.
Two guards, because this node's replies are its only transmissions:
anti-loop compares the sender prefix against _prefs.node_name (the runtime
name, so it holds even when stored prefs override the build-time one), and a
cooldown caps the reply rate. Both are needed: the cooldown alone would only
slow a ping-pong down, not stop it.
The channel key comes in as hex via -D BOT_CHANNEL_PSK, which is the form
`meshcore-cli get_channel <n>` prints -- no base64 round trip and no
base64.hpp dependency in this build. Hash derivation matches
BaseChatMesh::addChannel(); cross-checked against a live node, whose
128-bit key hashes to the same channel_hash the node reports.
All of it compiles out without BOT_CHANNEL_PSK. Costs 2.4 KB flash and 48 B
RAM over the plain analyzer build.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>