feat(MAT-174): Add cron job scheduler and executors

Cron package that syncs jobs from matrixhost portal API, schedules execution
with timezone-aware timing, and posts results to Matrix rooms. Includes
Brave Search, reminder, and browser scrape (placeholder) executors with
formatter. 31 pytest tests.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Christian Gick
2026-03-16 09:31:19 +02:00
parent 21b8a4efb1
commit 4d8ea44b3d
15 changed files with 1009 additions and 0 deletions

28
cron/executor.py Normal file
View File

@@ -0,0 +1,28 @@
"""Dispatch cron jobs to the correct executor by job_type."""
import logging
from .brave_search import execute_brave_search
from .browser_executor import execute_browser_scrape
from .reminder import execute_reminder
logger = logging.getLogger(__name__)
EXECUTORS = {
"brave_search": execute_brave_search,
"browser_scrape": execute_browser_scrape,
"reminder": execute_reminder,
}
async def execute_job(job: dict, send_text, matrix_client) -> dict:
"""Execute a cron job and return a result dict for reporting."""
job_type = job["jobType"]
executor = EXECUTORS.get(job_type)
if not executor:
msg = f"Unknown job type: {job_type}"
logger.error(msg)
return {"status": "error", "error": msg}
return await executor(job=job, send_text=send_text, matrix_client=matrix_client)