Forum teuk.org

🧭 MB678-IV-I — Give Partyline IRC Control Its Own Command Deck Without Changing the Course

in Mediabot · started by TeuK · 2d ago

TeuK · 2d ago

MB678 continues the progressive decomposition of Mediabot’s Partyline subsystem.

This round extracts the compact IRC control and lifecycle command family from the historical Mediabot::Partyline parent while deliberately leaving unrelated operator commands and the much larger AI family untouched.

The goal remains the same: reduce the monolith without changing protocol, permissions, command behaviour, or the historical Mediabot::Partyline::* method surface.


🧭 What moved

MB678-IV-I moves six methods from:

Mediabot/Partyline.pm

into:

Mediabot/Partyline/Commands.pm

Methods moved:

_cmd_join
_cmd_part
_cmd_nick
_cmd_raw
_cmd_rehash
_cmd_restart

Together they form a coherent IRC control/lifecycle family:

  • join a channel;
  • part a channel;
  • change the IRC nickname;
  • send an Owner-authorized raw IRC command;
  • rehash runtime state;
  • restart the IRC connection in-process.

The following remain intentionally in Partyline.pm for later rounds:

_cmd_say
_cmd_who
_cmd_eval
_cmd_ai

🧱 Structural result

Before MB678-IV-I:

Mediabot/Partyline.pm          : 2506 lines
Mediabot/Partyline/Commands.pm : 2674 lines

After MB678-IV-I:

Mediabot/Partyline.pm             : 2354 lines
Mediabot/Partyline/Commands.pm    : 2844 lines
Mediabot/Partyline/Dispatcher.pm  :  407 lines
Mediabot/Partyline/SessionAuth.pm :  676 lines
Mediabot/Partyline/Transport.pm   : 1012 lines

The original pre-MB678 Partyline.pm contained:

6976 lines

It is now down to:

2354 lines

The reduction is increasingly significant, but each round remains intentionally narrow and independently validated.


🔐 Existing IRC control semantics preserved

The extraction keeps the existing behaviour and privilege boundaries.

.join

Preserved:

  • normal joinChannel($chan, $key) path;
  • optional channel key;
  • channel-key redaction in logs.

The source-contract test:

t/cases/346_join_channel_key_redacted.t

was adapted so it can locate _cmd_join after modularization.

The key itself is still passed to IRC while logs continue to display only:

key: [redacted]

.part

Preserved:

  • normal IRC part request;
  • existing "Partyline requested part" reason;
  • nicklist timer cleanup.

.nick

Preserved:

  • nickname format validation;
  • existing change_nick() path.

.raw

Preserved:

  • Owner-only authorization;
  • CR/LF stripping before data reaches the IRC socket.

.rehash

Preserved:

  • Master-or-Owner authorization;
  • existing runtime-state rehash path.

.restart

Preserved:

  • Owner-only authorization;
  • Partyline restart broadcast;
  • existing in-process IRC restart mechanism.

No command syntax or permission model changed.


🧪 Extraction contract

A new structural/behaviour contract was added:

t/cases/874_mb678_partyline_irc_control_commands_extraction.t

It verifies that all six implementations moved exactly once into Commands.pm, while their historical methods remain reachable through Mediabot::Partyline.

It also protects key behavioural invariants for:

.join
.part
.nick
.raw
.rehash
.restart

and explicitly confirms that IV-I does not broaden into:

_cmd_ai
_cmd_say
_cmd_who

Focused validation:

346
873
874

Result:

PASSED : 75/75

Historical surface validation:

_cmd_join
_cmd_part
_cmd_nick
_cmd_raw
_cmd_rehash
_cmd_restart

Result:

6/6 available through Mediabot::Partyline

⚡ Fast validation

The MB679 progress mode was used directly:

perl t/test_commands.pl --fast --progress

Selection:

321 of 757 discovered test files

Result:

[====================] 100% [321/321 files | 5875 tests]

PASSED : 5875/5875  (65s)

🔌 Runtime validation

The development instance restarted successfully:

mediabot@dev : active

The Partyline listener remained available on:

0.0.0.0:23456

A real TCP smoke test returned:

Mediabot Partyline
Please enter your nickname.
Enter your password.

Result:

RC_SMOKE=0

The journal showed no obvious runtime errors after restart.


🛡️ Security audit

The security audit remained completely green:

RC_AUDIT=0
Verdict: GO — all 11 security invariants hold.

In particular, the extraction did not weaken authentication, command authorization, or existing transport protections.


🏰 Full regression suite

The complete suite was executed with progress enabled:

perl t/test_commands.pl --progress

Result:

[====================] 100% [757/757 files | 14830 tests]

PASSED : 14830/14830  (210s)

No follow-up source-contract repair was required.


🧠 Why this matters

The six commands extracted here all operate directly on the IRC connection or its lifecycle.

Keeping them together gives Commands.pm a clearer responsibility boundary while reducing the amount of operational logic still embedded in the Partyline parent.

The subsystem now has distinct areas for:

  • transport;
  • session/authentication;
  • dispatch;
  • plugin commands;
  • operator/session commands;
  • scheduler and operational commands;
  • channel/network visibility;
  • reminders and seen-history;
  • Karma;
  • configuration reload;
  • network statistics;
  • IRC control and lifecycle commands.

Most importantly, the refactoring keeps following the same rule:

Move responsibility.
Preserve behaviour.
Validate every boundary.

📦 Commit

Version : 3.4dev-20260821_100903
Commit  : fad3dd3
Branch  : master

🧭 Give Partyline IRC Control Its Own Command Deck Without Changing the Course

Commit summary:

5 files changed
276 insertions
161 deletions

New test:

t/cases/874_mb678_partyline_irc_control_commands_extraction.t

The commit was successfully pushed to GitHub.


🧭 The helm moved to its own deck. The ship kept exactly the same course.

You must be logged in to reply.