feat(repeater): fairness grid viditelnost + runtime cap/refill tuning

Bez gridu jsme slepí — `fairness` čítač říkal KOLIK, ne CO. A capy byly
build konstanty, takže zvolnit telemetrii šlo jen reflashem.

FairnessLimiter:
- per-bucket deny čítače (uint16, group/sender/advert mapy) + formatGrid:
  vypíše nejrušnější buckety po kategoriích jako `<pfx>=<count>`, busiest
  first. Bucket prefix se křížově dohledá v observeru/CoreScope na jméno.
- runtime settery capů (setGroupCap/…; 0 = build default).

MyMesh + NodePrefs (persistováno přes savePrefs):
- prefs fair_{g,s,a}cap + fair_{g,s,a}rf_s (0 = build default), aplikují se
  v begin() a refill scheduling je z nich (fairGroupRefillMs atd.).
- CLI `fairness grid`, `fairness cap <g> <s> <a>`, `fairness refill <g> <s>
  <a>` (sekundy); bare `fairness` teď hlásí i capy a refilly.

Bench (x1, 5. 9.): `fairness cap 2 2 2` → burst 6 zpráv na #test →
grid `group(cap 2): 19=5` (bucket 0x19 = #test hash 0xD9 & 0x1F, sedí);
cap 0/refill 0 vrací defaulty. Testy test_fairness_limiter rozšířeny
o cap tuning + grid (native i ASAN, 66/66 zelených).

Telemetrie chodí FLOOD jen do naučení cesty — direct část se nelimituje
vůbec (FAIRNESS_ALLOW_DIRECT), takže zvolnění se týká jen flood telemetrie.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
tthandClaude Fable 5 committed 2026-09-05 23:39:04 +02:00
1 parent 04838e8492
commit 141a1c8069
6 files changed
+231 -27

No files matched your search

+12 -2
View File
@@ -319,8 +319,18 @@ class MyMesh : public mesh::Mesh, public CommonCLICallbacks {
bool botPeerAllowed(const char* name);
bool botHandleCommand(const char* command, char* reply);
#endif
// CUSTOM (TeTeHacko): `fairness [on|off]` CLI. Defined in MyMesh.cpp.
bool fairnessHandleCommand(const char* command, char* reply);
// CUSTOM (TeTeHacko): `fairness [on|off|grid|cap ...|refill ...]` CLI. Defined in MyMesh.cpp.
bool fairnessHandleCommand(const char* command, char* reply, int reply_max);
// Refill interval in ms: persisted pref (seconds) if set, else the build default.
uint32_t fairGroupRefillMs() const {
return _prefs.fair_group_refill_s ? (uint32_t)_prefs.fair_group_refill_s * 1000 : FAIRNESS_GROUP_REFILL_MS;
}
uint32_t fairSenderRefillMs() const {
return _prefs.fair_sender_refill_s ? (uint32_t)_prefs.fair_sender_refill_s * 1000 : FAIRNESS_SENDER_NORMAL_REFILL_MS;
}
uint32_t fairAdvertRefillMs() const {
return _prefs.fair_advert_refill_s ? (uint32_t)_prefs.fair_advert_refill_s * 1000 : FAIRNESS_SENDER_LOW_REFILL_MS;
}
uint8_t handleLoginReq(const mesh::Identity& sender, const uint8_t* secret, uint32_t sender_timestamp, const uint8_t* data, bool is_flood);
uint8_t handleAnonRegionsReq(const mesh::Identity& sender, uint32_t sender_timestamp, const uint8_t* data);
uint8_t handleAnonOwnerReq(const mesh::Identity& sender, uint32_t sender_timestamp, const uint8_t* data);