Repository navigation
Add a line per run to User:ParamBot/ReportHistory - #1
Conversation
Live and report-only runs now add a row to the top of a report history page, like ZackBotPy's User:ZackBot/DepReport: when the run started and ended, its mode, what it did and how it ended. A run aborted because someone changed User:ParamBot/Run says so, with when and by whom. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XRKwUh3dhUxq1hCdk3gfq1
|
Thanks for this. The idea is good, the code is in the house style, and the tests cover every way a run can end. Three things to fix before I merge. Each one below says what's wrong, where it is, and what I'd like instead, so it can be worked on without any other context. Already settled, so please don't change these:
1. Narrow the change to the fake wiki in
|
- tests/fakes.py: FakeWiki.page() again returns a throwaway FakePage for
a missing title; the page joins the wiki only when it's saved, as a
created page does on a real wiki.
- history.py: drop its own duration(); rows use messages.duration, the
same words as the report ("14 minutes").
- The intro (messages.history_intro, history.py's docstring, the
Documentation) now says which runs get a line: every run, except runs
that didn't start because the Run page was off.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XRKwUh3dhUxq1hCdk3gfq1
Summary
After every live or report-only run, ParamBot now adds one line to the top of User:ParamBot/ReportHistory. It works like ZackBotPy's
User:ZackBot/DepReport(deprecbot/wikireport.py).User:ParamBot/Reportis replaced on every run and only shows the latest one. The history page keeps one row per run, newest first:The Result column says how the run ended:
finishedfinished early: <why>(max_edits, max_hours, or the BRFA trial limit)error: <message>(a crash, or a save error that every edit would hit, such as being blocked)stopped: <message>(any other stop after the run had started, such as the trial count failing to save)aborted: [[User:ParamBot/Run]] was changed at <time> by [[User:X|X]], so the run stopped: …This is for a run that someone switches off part way through by editing the Run page. The time and editor come from the Run page's newest revision. If they can't be read, the line just says the page was changed.When the report page was saved, the row ends with a permalink to that revision of the report.
Example of the page:
Changes
New:
parambot/history.pyhistory_row()builds one row. Its duration usesmessages.duration, so it's in the same words as the report's top line ("14 minutes").updated_page()puts the row at the top of the table, below a marker comment. Anything above the marker, such as the intro, can be edited by hand and is kept. A missing or placeholder page is started afresh. Only the newest 200 rows are kept (about 50 days at four runs a day).parambot/bot.pyRunPageOff(StopRun)exception, raised by_check_run_page, so a Run-page switch-off can be told apart from other stops. Existingexcept StopRuncode still catches it._write_history(). It runs after the report is written on every path out ofrun(): finished, finished early,StopRun,CannotEditand crashes. It only runs once the pre-flight checks have passed, and only for runs that save the report (live and report-only). It never raises: if the save fails, the failure is logged and the run carries on._switched_off_result(), which reads when the Run page was changed and by whom, for the abort line._end_early(), which records why a run stopped early (max_edits, max_hours, trial limit) for the history line. Those notes still go on the report too._check_history_page()in pre-flight. The history page must be a subpage ofUser:<bot>, and must not be one of the bot's other pages or a rules page._check_may_save()now lets a report-only run save the history page as well as the report page. Both must still be in the bot's own userspace._save_report_page()remembers the saved revision, so the history row can link to it.Behaviour change on Run-page stops. Until now, after a Run-page switch-off the bot made no more wiki edits at all. It now makes exactly one: the history line in its own userspace, explaining the abort. The report page, the trial log and all articles are still left alone. A run that the Run page stops before it starts adds no line, so a switched-off bot doesn't add four "not running" lines a day.
Settings / CLI / options
Options.history_pagedefaults toUser:<bot>/ReportHistoryand is listed inother_pages(). So the report page can never replace the history page, and the trial log check excludes it too.[pages] historysetting (settings.py,deploy/parambot.example.toml) and a--history-pageoption forrun(cli.py).nocreate). That is safe because it must be in the bot's own userspace.parambot/wiki.pyWiki.last_change(title):(timestamp, user)of a page's newest revision, orNoneif the page doesn't exist.parambot/messages.pyhistory_intro,history_summary,history_elsewhereandrun_page_changed. The intro says which runs get a line: every run, except runs that didn't start because the Run page was off.report_only_refused_savenow names both pages a report-only run may edit.Docs
README.md: new step 7 in "How a run works", the emergency-stop exception, the--history-pageand[pages] historyoptions, and the project layout.docs/operators.md: the page table and the description of each run.docs/documentation.mediawiki: the page table, a new "The report history" section, and the protection table.Tests
tests/test_history.py: row format, starting a fresh page, newest-first order with hand edits kept, trimming toMAX_ROWS, and that a row's duration is in the report's words.tests/test_bot.py, 17 new whole-run tests:CannotEditand other stopstests/test_wiki.py:last_change.tests/fakes.py:FakeWiki.last_change. A missing page still comes back as a throwawayFakePage, but it knows its wiki (wiki=), and joinsFakeWiki.pagesonly when it's saved, as a created page does on the real wiki. So every otherFakeWikimethod sees the same pages as before.pytest(686 passed),ruff check .and coverage (97%, threshold 95%) all pass.mypyreports the same 15 errors before and after this change, all about missingmwparserfromhellstubs in the local environment.Not changed
docs/header.mediawikidoesn't link the new page, on purpose.nocreate. Before deploying, either create User:ParamBot/ReportHistory by hand or give the bot password the page-creation grant.