Development chronicle β mb606 to mb607 Β· Offline validation and truthful dry-runs
Plugin v2 has gained a proper workshop.
Until now, writing or checking a sidecar plugin usually meant running Mediabot itself β which also meant a database, an IRC connection, a configured instance and all the surrounding runtime.
That is no longer necessary.
Mediabot now ships an offline development tool that can validate and dry-run v2 sidecars with the same core components used by the bot itself.
The new tool is:
tools/mb_plugin_dev.pl
It supports two main workflows.
tools/mb_plugin_dev.pl validate examples-v2/karma.py
Example output:
OK sidecar accepted: karma v1.0 (api 2)
commands: karma, thanks
tools/mb_plugin_dev.pl run examples-v2/karma.py --command thanks --nick aur --arg SlaY --storage /tmp/state.json
Example:
Ran examples-v2/karma.py (python, 0.074s)
Actions the bot would take:
store 29 bytes (limit 16384)
{"scores":{"bob":1,"slay":4}}
reply #dev: SlaY now has 4 karma.
OK every action passes the bot's contract.
Nothing was applied.
tools/mb_plugin_dev.pl run examples-v2/daily.tcl --event plugin_cron_observed --config CHANNEL='#dev' --config TEXT='Morning!' --data hour=9 --data minute=0
This makes it possible to develop command-driven and event-driven plugins without bringing up a complete bot instance.
The tool does not maintain a second copy of the plugin rules.
It builds a minimal offline bot and uses the real:
Mediabot::PluginManager
Mediabot::ScriptRunner
Mediabot::ScriptActionRunner
That means the same runtime code performs:
If the contract changes later, the development tool follows the implementation instead of slowly drifting into a second specification.
Even constants such as the store-size limit are read from the real runtime modules rather than duplicated in the tool.
There is an important distinction.
When using:
mb_plugin_dev.pl run
the Perl, Python or Tcl script is really executed.
What remains dry-run is the action layer returned to Mediabot.
So the tool may show:
reply
notice
store
but Mediabot itself will not:
This makes the tool suitable for trusted plugin development and CI while avoiding the side effects Mediabot would normally perform.
It is not an operating-system sandbox for hostile scripts.
The pre-commit review found a few places where the offline tool could present something slightly different from what the real bot would see.
Those differences are now closed.
The public event name and the internal event_type are not always identical.
For example:
plugin_cron_observed β cron
channel_join_observed β join
channel_part_observed β part
channel_nick_observed β nick
The offline tool now builds these envelopes using the same semantics as the live bot.
--show-envelope therefore shows what the script would actually receive.
The development tool no longer opens the sidecar itself just to discover the plugin name before validation.
The flow is now:
sidecar/script path
β
real PluginManager validation
β
validated plugin identity
β
offline config / storage inputs
β
real dry-run
This keeps path validation, sidecar limits, JSON parsing and identity checks behind the same boundary as production.
A developer-provided storage fixture is passed through the real plugin storage validator before it is exposed as:
data.storage
A test fixture can no longer feed a state document that the live bot itself would refuse.
The tool can exercise a command declared as Master or another named level, but it does not pretend to reproduce a live authenticated USER_LEVEL session.
The output says so clearly.
Authorization remains a live-bot concern; command behavior can still be tested offline.
The complete test suite passed:
PASSED : 12079/12079
The dedicated offline-tool tests cover:
A plugin author can now work in a much smaller loop:
edit plugin
β
validate
β
dry-run command/event
β
inspect envelope and planned actions
β
run tests
β
load into Mediabot
No IRC server is required for the first four steps.
No database is required.
No production bot needs to be disturbed.
And, crucially, the offline tool is not trying to guess what Mediabot would do.
It asks Mediabotβs own plugin machinery.
The castle now has a proper practice room.
A portrait can be inspected before it is hung on the wall. Its spells can be rehearsed, its event scrolls opened, and every action checked by the same rules used in the Great Hall.
The mirror does not cast the spells for real.
But it now reflects the castle faithfully.
You must be logged in to reply.