Forum teuk.org

🧠 MB678-IV-J — Give Partyline AI Its Own Room of Requirement Without Changing the Answers

in Mediabot · started by TeuK · 2d ago

TeuK · 2d ago

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

This round tackles one of the largest remaining command families: the Claude/AI controls previously embedded directly in Mediabot::Partyline.pm.

The scope is intentionally focused. MB678-IV-J extracts only the AI family:

_cmd_ai
_cmd_persona
_cmd_quota

while leaving unrelated commands such as .ping, .uptime, and .eval in the parent for later rounds.

The objective is architectural only: move responsibility without changing command semantics, permissions, filtering, quotas, callbacks, or the historical Mediabot::Partyline::* surface.


🧠 What moved

The following methods moved from:

Mediabot/Partyline.pm

to:

Mediabot/Partyline/Commands.pm

Methods:

_cmd_ai
_cmd_persona
_cmd_quota

Together they form the Partyline Claude/AI command family:

  • AI conversations and prompts;
  • Claude callback handling;
  • persona selection and management;
  • quota visibility and controls;
  • existing public/action filtering;
  • existing operation-error reporting paths.

No unrelated command family was included in the round.


🧱 Structural result

Before MB678-IV-J:

Mediabot/Partyline.pm          : 2354 lines
Mediabot/Partyline/Commands.pm : 2844 lines

After MB678-IV-J:

Mediabot/Partyline.pm             : 1882 lines
Mediabot/Partyline/Commands.pm    : 3330 lines
Mediabot/Partyline/Dispatcher.pm  :  407 lines
Mediabot/Partyline/SessionAuth.pm :  676 lines
Mediabot/Partyline/Transport.pm   : 1012 lines

The pre-MB678 parent contained:

6976 lines

It is now down to:

1882 lines

That is a reduction of more than five thousand lines from the original Partyline monolith while preserving the historical callable surface.


🔌 Historical method compatibility

The extraction keeps these methods reachable through:

Mediabot::Partyline

even though their implementations now live in Mediabot::Partyline::Commands:

_cmd_ai
_cmd_persona
_cmd_quota

Focused historical-surface validation:

3/3 OK

Existing dispatch callers therefore continue to use the same method names.


🧪 Source and behaviour contracts

Several older tests intentionally inspected Mediabot/Partyline.pm directly.

Those contracts were updated so modularization does not turn a physical source location into a false behavioural requirement.

Updated tests:

t/cases/227_external_claude_callback.t
t/cases/567_mb348_publictext_filter_sweep.t
t/cases/870_mb678_partyline_karma_commands_extraction.t
t/cases/872_mb678_partyline_reload_commands_extraction.t
t/cases/873_mb678_partyline_network_stats_commands_extraction.t
t/cases/874_mb678_partyline_irc_control_commands_extraction.t

A new extraction contract was added:

t/cases/875_mb678_partyline_ai_commands_extraction.t

The targeted validation set also included the real AI runtime/source contracts:

227
237
567
586
813
870
872
873
874
875

Result:

PASSED : 248/248  (2s)

This was important because the development server provides the full Perl dependency environment required by the AI tests.


🧙 Claude/AI behaviour preserved

The extraction intentionally preserves the existing Claude paths and their surrounding safeguards.

That includes the already-tested callback behaviour and command routing represented by the existing test suite.

The public/action filtering contract remains covered by:

567_mb348_publictext_filter_sweep.t

The Claude callback contract remains covered by:

227_external_claude_callback.t

The extraction adds no new network API, database schema, or AI execution model.

This is a move, not a redesign.


🚧 Boundary deliberately preserved

MB678-IV-J does not absorb adjacent unrelated commands.

These remain in Partyline.pm:

_cmd_ping
_cmd_uptime
_cmd_eval

That boundary is intentional.

The AI family was already large enough to deserve a dedicated round, and combining it with general diagnostics or Perl evaluation would have reduced reviewability.


⚡ Fast validation

Validation used the MB679 progress mode:

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

Selection:

322 of 758 discovered test files

Result:

[====================] 100% [322/322 files | 5907 tests]

PASSED : 5907/5907  (65s)

🔌 Real runtime validation

The development service restarted successfully:

mediabot@dev : active

The Partyline listener remained available:

0.0.0.0:23456

The TCP smoke test still returned the expected authentication flow:

Mediabot Partyline
Please enter your nickname.
Enter your password.

Result:

RC_SMOKE=0

The post-restart journal contained no obvious runtime errors.


🛡️ Security audit

The complete security audit remained green:

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

The Claude/AI extraction therefore did not weaken the existing authentication, throttling, download-cap, or related security guarantees checked by the project audit.


🏰 Full regression suite

The entire suite was run with progress enabled:

perl t/test_commands.pl --progress

Result:

[====================] 100% [758/758 files | 14862 tests]

PASSED : 14862/14862  (210s)

No post-full corrective patch was necessary.


🧠 Why this matters

This is one of the more meaningful MB678 rounds because the AI family was a substantial chunk of the remaining Partyline parent.

The result is not merely a smaller file.

It creates a clearer architectural ownership model:

Partyline.pm
    remaining parent/core responsibilities

Partyline/Commands.pm
    Partyline command implementations

Partyline/Dispatcher.pm
    command routing

Partyline/SessionAuth.pm
    session/authentication

Partyline/Transport.pm
    TCP/DCC/transport

At the same time, compatibility remains intentionally boring:

same commands
same historical method names
same dispatch
same security model
same runtime behaviour

That is exactly what a safe decomposition should look like.


📦 Commit

Version : 3.4dev-20260821_103451
Commit  : e55b30b
Branch  : master

🧠 Give Partyline AI Its Own Room of Requirement Without Changing the Answers

Commit summary:

10 files changed
601 insertions
495 deletions

New test:

t/cases/875_mb678_partyline_ai_commands_extraction.t

The commit was successfully pushed to GitHub.


🧠 The answers did not change. The magic simply found its own Room of Requirement.

You must be logged in to reply.