botserv: op assigned bots on join; statserv: persist counters across restart
Some checks failed
CI / check (push) Failing after 3m48s

Problem 1: an assigned bot joined via IJOIN with no status mode, so it had no
+o. Join it with the 4-param IJOIN form (ts 1, mode o) so it's opped, matching
Anope's default bot modes (+o), and exempt bots from SECUREOPS/RESTRICTED so the
op is never stripped.

Problem 2: the shared stat counters lived only in memory, so a restart wiped
them. Snapshot them to the log (StatsSet event, folded into NetData + compaction)
periodically and on shutdown, and reseed the live registry from the log at
startup. Live gauges (online counts) stay re-derived, not stored.
This commit is contained in:
Jean Chevronnet 2026-07-16 17:32:20 +00:00
parent fd455922a5
commit 8a9b6a37ca
No known key found for this signature in database
10 changed files with 85 additions and 10 deletions

View file

@ -525,6 +525,22 @@
assert_eq!(db.jupes(), vec![("rogue.example".to_string(), sid, "abuse".to_string())], "the jupe replays from the log");
}
// StatServ / Stats-API counters are snapshotted to the log, so they survive a
// restart instead of resetting to zero.
#[test]
fn stat_counters_survive_a_restart() {
let p = tmp("statspersist");
let counters: std::collections::BTreeMap<String, u64> =
[("chanserv.register".to_string(), 7u64), ("nickserv.identify".to_string(), 42u64)].into_iter().collect();
{
let mut db = Db::open(&p, "N1");
db.persist_stats(&counters).unwrap();
assert_eq!(db.persisted_stats(), counters, "stored while live");
}
let db = Db::open(&p, "N1");
assert_eq!(db.persisted_stats(), counters, "counters replay from the log after a restart");
}
// Fold parity: the live state after a broad sequence of writes must equal the
// state rebuilt by replaying the same log — every event's manual live mutation
// has to match its `apply()` arm, or a restart silently changes the data.