Forum teuk.org

🪄 MB676 — Karma Leaves the Great Hall

in Mediabot · started by TeuK · 3d ago

TeuK · 3d ago

Another piece of Mediabot v3’s historical monolith has been carefully separated.

For MB676, the complete Karma subsystem has moved out of Mediabot/UserCommands.pm and into its own dedicated module:

Mediabot/Karma.pm

This was intentionally a structural change, not a functional rewrite.

The goal was to reduce the size and responsibilities of UserCommands.pm while preserving everything users and existing code already depend on:

  • historical Karma command symbols;
  • existing command dispatch;
  • SQL behaviour;
  • channel-scoped Karma handling;
  • history and ranking;
  • Karma watch behaviour;
  • current IRC formatting;
  • compatibility with the existing test contracts.

The extraction removes roughly 950 lines from UserCommands.pm, while the new Karma.pm now contains the subsystem as one coherent unit.

A dedicated regression contract was also added:

t/cases/860_mb676_karma_extraction.t

Several older Karma tests were adjusted so that they continue checking the same behaviour after the implementation moved to its new home.

🧪 Validation

The extraction went through the normal Mediabot validation path:

Focused Karma tests : 175/175     PASS
Fast suite          : 5307/5307   PASS
Full suite          : 14219/14219 PASS

The complete full suite finished in:

217 seconds

Runtime checks were then performed on IRC against the actual development bot:

m karma
m karmatop 5
m karmahist
m karmadiff
m karmawatch list
m karmainfo Te[u]K

All returned normally after the module extraction.

No missing command, no Perl error, no crash and no observable behaviour regression.

🧹 Why this matters

UserCommands.pm has accumulated many unrelated responsibilities over the years.

Moving cohesive subsystems into dedicated modules makes the code easier to reason about, test and evolve without turning the refactoring itself into a behavioural change.

Karma now has a proper home.

The Great Hall is getting a little less crowded. 🏰

Version : 3.4dev-20260820_090422
Commit  : da12c0f

🪄 Move Karma Into Its Own Chamber Without Disturbing the Magic

You must be logged in to reply.