Add a staff audit feed for notable service actions

A [log] channel now receives a one-line announcement of each notable
state change a service command makes — registrations, drops, vhosts,
suspensions, akicks, access and founder changes, bot and oper host-config
changes — naming the actor (by nick, plus account when it differs) and
what changed. The feed reads the typed event log directly: dispatch marks
the log before running a command and diffs it after, so each announcement
is exactly that command's footprint, sourced from the services server so
it reaches the channel without a pseudo-client having to be present.

Private and cosmetic events are deliberately never surfaced: memo bodies,
password/verifier material, greets, auto-join, personal and channel
cosmetic settings. Omitting [log] disables the feed.
This commit is contained in:
Jean Chevronnet 2026-07-13 23:48:23 +00:00
parent 34892dbba7
commit 698d604954
No known key found for this signature in database
5 changed files with 184 additions and 0 deletions

View file

@ -683,6 +683,13 @@ impl EventLog {
self.outbound = Some(tx);
}
// The events appended at or after `mark`, cloned. Used by the audit feed to
// see exactly what a just-run command changed (the log only ever grows during
// a command, so `[mark..]` is that command's footprint).
fn events_from(&self, mark: usize) -> Vec<Event> {
self.entries.get(mark..).into_iter().flatten().map(|e| e.event.clone()).collect()
}
// Our version vector: highest seq applied per origin.
fn version_vector(&self) -> HashMap<String, u64> {
self.versions.clone()
@ -951,6 +958,16 @@ impl Db {
self.log.set_outbound(tx);
}
/// The number of entries in the log, a mark to later diff against.
pub fn log_len(&self) -> usize {
self.log.len()
}
/// The events appended since `mark` (a value from an earlier [`log_len`]).
pub fn events_since(&self, mark: usize) -> Vec<Event> {
self.log.events_from(mark)
}
/// Our version vector, advertised to peers so they can send what we lack.
pub fn version_vector(&self) -> HashMap<String, u64> {
self.log.version_vector()