Forum teuk.org

🔥 Mediabot v3 — Turning Activity Streaks Into Achievement Milestones

in Mediabot · started by TeuK · 6d ago

TeuK · 6d ago

Commit: f06b6ed
Version: 3.4dev-20260817_113536

MB655 brings the roadmap back to something directly visible to users: activity streak achievements.

Mediabot already knew how to calculate a user’s current activity streak and best historical streak.

MB655 connects that existing signal to the Achievement system without adding a new database schema, a new persistence mechanism, or another expensive query path.


🏆 New streak achievements

Three milestones are now available:

🔥 On a Roll       7 consecutive days
📆 Habit Formed   30 consecutive days
⚡ Streak Master 100 consecutive days

The important part is that Mediabot does not recompute a second version of streak history for Achievements.

It reuses the already calculated best streak from the existing m streak path.


🧠 One source of truth

Before MB655, m streak already knew:

current streak
best historical streak

The Achievement system now consumes that existing result instead of inventing another streak calculator.

Progress is stored through the existing generic Achievement counter:

activity_streak_days

That means the same progress naturally appears in the normal Achievement progress views.

No parallel persistence model was introduced.


🔒 Looking up someone else remains read-only

There is an important behavioural guard in MB655.

Running:

m streak

for yourself may record your own streak progress and unlock a milestone.

But:

m streak SomeOtherNick

remains a read-only lookup.

It does not create, touch or update the other user’s Achievement profile merely because someone queried their streak.

That keeps the public command useful without turning arbitrary lookups into identity mutations.


📈 Achievement catalogue update

The Achievement catalogue grows from:

24 -> 27 achievements

and measurable progress goals grow from:

20 -> 23

The existing progress-view regression was updated accordingly.


🧪 Focused validation

The first targeted MB655 run exposed three failures in unrelated archive/stat tests.

Those failures were initially suspicious because they appeared only in the combined focused suite.

Re-running the affected tests alone gave:

PASSED : 149/149

That proved the runtime feature was not the cause.


🧹 A hidden test-order bug found along the way

The real problem was in:

t/cases/751_mb559_async_achievement_worker.t

That test installed a fake Mediabot::Helpers package and permanently marked the module as loaded in %INC.

Because Mediabot’s test runner executes many case files inside the same Perl interpreter, later tests believed Mediabot::Helpers was already loaded and received the incomplete test double instead of the real module.

That produced failures such as:

Undefined subroutine &Mediabot::Helpers::channel_log_sources
Undefined subroutine &Mediabot::Helpers::channel_log_gather

The fix makes the %INC entry and helper stubs local to the test invocation.

The formerly failing order was then replayed deliberately:

751
765
766
767
837

Result:

PASSED : 200/200

A source guard also confirmed:

OK: no persistent Helpers %INC poisoning
OK: Helpers %INC entry is invocation-local
OK: Helpers stubs are invocation-local
TEST751_ISOLATION_GUARD=OK

So MB655 not only adds a feature; it also leaves the suite less order-dependent than before.


🧪 Final focused regression

After the test-isolation fix, the complete focused Achievement/streak regression passed:

PASSED : 589/589
RC=0

Coverage included:

streak command behaviour
Achievement persistence
Achievement thresholds
progress views
async Achievement processing
DB identity persistence
identity diagnostics
career/archive behaviour
MB655 streak milestones
module structure sanity

🧪 Full-suite validation

The entire Mediabot suite passed:

PASSED : 13440/13440
RC=0

Runtime:

869s

No regression remained after adding the new milestones and fixing the hidden test-order dependency.


🧱 No schema change

MB655 deliberately introduces:

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

It reuses the existing Achievement persistence and progress infrastructure.

That keeps the feature small operationally while still being visible to users.


✨ Commit

f06b6ed
🔥 Turn Activity Streaks Into Achievement Milestones

Version:

3.4dev-20260817_113536

Committed scope:

CHANGELOG.md
VERSION
Mediabot/Achievements.pm
Mediabot/UserCommands.pm
t/cases/751_mb559_async_achievement_worker.t
t/cases/795_mb612_achievement_progress_view.t
t/cases/837_mb655_activity_streak_achievements.t

Mediabot already knew who kept showing up.

MB655 finally gives them something for it.

You must be logged in to reply.