Forum teuk.org

🏰 MB670 β€” Move the Social Chronicles Into Their Own Hogwarts Wing

in Mediabot Β· started by TeuK Β· 4d ago

TeuK Β· 4d ago

Version: 3.4dev-20260819_131425
Commit: c0eda2d

Mediabot’s social and history features have grown steadily over the last several releases.

That was good for the bot.

It was becoming much less good for one file:

Mediabot/UserCommands.pm

Before MB670, that module had reached:

13,746 lines

MB670 starts fixing that architectural pressure without changing the public command surface.

The goal was not to redesign the commands.

The goal was to give them a proper home.


🏰 A new Social / History module

MB670 introduces:

Mediabot/SocialHistory.pm

The following command families now live there:

profil
dashboard
mood
leaderboard
chronos
recap
onthisday
memory
milestone
awards
yearbook

After the extraction:

Mediabot/UserCommands.pm : 11,065 lines
Mediabot/SocialHistory.pm:  2,831 lines

So UserCommands.pm immediately loses almost 2,700 lines of social/history implementation.


πŸͺ„ No public command regression

This refactor deliberately keeps the historical API surface intact.

Existing symbols such as:

Mediabot::UserCommands::mbProfil_ctx
Mediabot::UserCommands::mbMemory_ctx
Mediabot::UserCommands::mbAwards_ctx
Mediabot::UserCommands::mbYearbook_ctx

remain available.

The public dispatch also stays unchanged.

That means existing command routing, help, callers and compatibility assumptions do not suddenly have to learn a new namespace.

The implementation moves.

The public contract does not.


🧩 Two-step extraction

MB670 was intentionally split into two internal passes.

The first moved:

memory
awards
yearbook

That reduced UserCommands.pm from:

13,746

to:

13,091 lines

The second pass moved the rest of the targeted block:

profil
dashboard
mood
leaderboard
chronos
recap
onthisday
milestone

Final result:

UserCommands : 11,065 lines
SocialHistory:  2,831 lines

This avoided a single blind multi-thousand-line move.


πŸ§ͺ First focused validation

The first extraction passed:

PASSED : 772/772
RC=0

The complete MB670 focused regression then passed:

PASSED : 1566/1566
RC=0
Runtime: 15s

Coverage included dispatch integrity, archive/history helpers, profile, recap, mood, OnThisDay, milestone, Community Footprint, Memory, Awards, Yearbook and module structure.


🧹 The tests had to learn where the code lives

A refactor like this exposed an important class of old tests.

Several tests were not checking behavior.

They were checking things like:

"this exact implementation must physically exist in UserCommands.pm"

That assumption stopped being true after MB670.

The application was still correct.

The tests were looking in the wrong file.

Examples included tests for:

public/action filters
factoid/channel predicates
OnThisDay sargable date ranges
leaderboard layout
dashboard formatting
achievement presentation APIs
profile hidden-achievement counts
Community Footprint identity resolution

Those structural tests were updated to follow the real owner of the implementation:

Mediabot/SocialHistory.pm

instead of assuming everything belongs in UserCommands.pm.


πŸ”Ž 7 false failures in the focused round

The second extraction initially reported seven failures.

They came from three stale test assumptions:

567 : public/action filters counted only in UserCommands.pm
694 : test source switched entirely to SocialHistory.pm,
      even though factoid handlers still live in UserCommands.pm
852 : Perl delete() was mistaken for a DELETE SQL statement

No application code needed changing.

After correcting those test guards:

PASSED : 113/113

and then:

PASSED : 1566/1566

⚑ Fast lane

The first fast run exposed one more stale structural assertion:

811_mb628_precommit_runtime_test_coherence.t

The test still expected the OnThisDay sargable range to exist inside UserCommands.pm.

It now lives in SocialHistory.pm.

Again:

application code changed: NO

Targeted correction:

PASSED : 9/9

Then the full fast lane:

PASSED : 5194/5194
RC=0
Runtime: 171s

🎭 Real IRC smoke test

The refactor was also validated on the development bot with real IRC commands.

The following commands all responded correctly:

m profile
m profil
m memory
m awards 7d
m yearbook 2026
m recap

Examples included:

πŸ† #radiocapsule Awards β€” last 7 days

and:

πŸ“– #radiocapsule Yearbook β€” 2026 Β· year to date

as well as the enriched profile and channel-memory paths.

That confirmed the new module was not merely compiling β€” the real command dispatch still worked after restart.


πŸ“Ό A pre-existing mojibake was spotted

During the m memory smoke test, an old message appeared as:

mΓƒΒͺme

The MB670 extraction was checked against the pre-refactor snapshot.

The relevant _memory_lines implementation was unchanged character-for-character.

So the mojibake was not introduced by this refactor.

It remains separate technical debt rather than being mixed into MB670.


πŸ§ͺ First complete-suite checkpoint

Because MB670 moves thousands of lines and touches many structural tests, a complete test suite was run before commit.

The first full run reported:

FAILED : 35/13953

Those 35 failures were concentrated in only seven test files:

650 : 1
793 : 2
810 : 10
812 : 18
826 : 2
840 : 1
851 : 1

Every one of them had the same architectural cause:

the test still inspected UserCommands.pm
after the implementation had moved to SocialHistory.pm

No application-code correction was required.


🧹 Closing all 35 full-suite failures

The seven affected tests were updated to follow the new implementation ownership.

The exact failing set was then replayed:

PASSED : 204/204
RC=0

The correction explicitly left:

Mediabot/UserCommands.pm
Mediabot/SocialHistory.pm

unchanged.

So the failed full suite led to test-maintenance fixes, not emergency runtime changes.


βœ… Final complete-suite certification

The complete Mediabot suite was then run again.

Final result:

PASSED : 13953/13953
RC=0
Runtime: 769s

That is the certification result for MB670.


🧱 Architectural boundary

The README now makes the ownership explicit.

New work for:

profil
dashboard
mood
leaderboard
chronos
recap
onthisday
memory
milestone
awards
yearbook

belongs in:

Mediabot::SocialHistory

and should not make UserCommands.pm grow again.

The old namespace remains available for compatibility.


πŸ”’ Operational scope

MB670 introduces:

no database schema change
no migration
no configuration change
no service change
no systemd change

This is an architectural refactor only.


πŸ“¦ Commit scope

The final commit contains:

42 files changed
3192 insertions
2904 deletions

including the new files:

Mediabot/SocialHistory.pm
t/cases/852_mb670_social_history_extraction.t

and the automatically updated VERSION.


✨ Commit

c0eda2d
🏰 Move the Social Chronicles Into Their Own Hogwarts Wing

Version:

3.4dev-20260819_131425

🧭 What MB670 changes for future work

This round adds almost no visible feature to Mediabot.

That is precisely why it matters.

Before MB670:

new social feature
    ↓
more code in UserCommands.pm
    ↓
harder review
    ↓
higher regression risk

After MB670:

social/history work
    ↓
Mediabot::SocialHistory
    ↓
smaller ownership boundary
    ↓
faster review and safer evolution

The castle did not gain another spell today.

It gained a new wing so the next spells have somewhere sane to live. 🏰✨

You must be logged in to reply.