Add ChanFix: recover opless channels from op-time scores

The engine samples live op state on a short cadence, scoring op-time per
identity (account, else host) on the network view — a net +1 per pass
while opped, -1 while idle, so trusted regulars rise and stale ops fade.
ChanFix (operator-only) reads those scores: SCORES <#chan> shows the
standings, CHANFIX <#chan> reops the present regulars scoring above a
share of the top score, once the channel is opless enough and has real
history. It defers to ChanServ — a registered channel is refused. Opt-in.

C++ note: the original persists scores to the services DB and runs its own
timers; here scoring rides the existing periodic loop and lives on the
ephemeral network view, so it's node-local and rebuilds itself.
This commit is contained in:
Jean Chevronnet 2026-07-14 04:33:48 +00:00
parent 09be99785e
commit 06227e73da
No known key found for this signature in database
8 changed files with 260 additions and 1 deletions

View file

@ -25,6 +25,7 @@ use fedserv_diceserv::DiceServ;
use fedserv_infoserv::InfoServ;
use fedserv_reportserv::ReportServ;
use fedserv_groupserv::GroupServ;
use fedserv_chanfix::ChanFix;
use fedserv_example::ExampleServ;
use fedserv_inspircd::InspIrcd;
use fedserv_nickserv::NickServ;
@ -113,6 +114,11 @@ async fn main() -> Result<()> {
uid: format!("{}AAAAAL", cfg.server.sid),
}));
}
if enabled("chanfix") {
services.push(Box::new(ChanFix {
uid: format!("{}AAAAAM", cfg.server.sid),
}));
}
if enabled("example") {
services.push(Box::new(ExampleServ {
uid: format!("{}AAAAAC", cfg.server.sid),
@ -176,6 +182,17 @@ async fn main() -> Result<()> {
});
}
// ChanFix scores op-time on a shorter cadence so the fix has fresh data.
if enabled("chanfix") {
let engine = engine.clone();
tokio::spawn(async move {
loop {
tokio::time::sleep(std::time::Duration::from_secs(300)).await;
engine.lock().await.chanfix_tick();
}
});
}
let addr = format!("{}:{}", cfg.uplink.host, cfg.uplink.port);
tracing::info!(server = %cfg.server.name, %addr, "linking to uplink");
link::run(proto, engine, &addr, irc_rx, cfg.email.clone()).await