Files
ai-agent/backend/test_cron_lean.py
gabrielvidalandClaude Opus 5.5 5670313285 feat(cron): cron jobs leave the core for the cron-jobs plugin
Owner jobs and guests' own scheduled jobs are the cron-jobs live plugin's
(forms move-ai-agent-cron-jobs-into-a-plugin_u0wa6b,
cron-scheduled-in-the-cli-and-mcp_x4nk83). Gone: backend/cron/,
schemas/cron.py, /api/cron*, /api/me/cron*, the cron scheduler thread,
Settings → Cron and the guests' Tâches planifiées pages, `ai-agent cron`
(now a pointer), MCP run_cron_job / set_cron_job / browse cron, the
scheduled-jobs core skill, guestDefaults.cronLimits.

The core keeps thin contracts:
- runs.guest bridge (runs/guestjob.py): a guest's job run as that guest,
  confined by the core from their record; the plugin only names it.
- runs.start's cron stamp → meta.cron.
- delivery of a guest job's result (push, mail, mailHtml) off the stamp.
- « Discuter »: POST /api/cron-runs/discuss.
- runs.cron provider readers (plugins/cron_bridge.py): budget,
  auto-archive, agents catalog, the agents page's Schedule.
- core/cronexpr.py, agents/runconfig.py; context.write create for a new
  agent definition; ui.pages[].unless; setRoute keeps a Settings page
  under /settings/p/.
- carryover.cron_jobs: /data/cron-jobs.json → the plugin's jobs.json,
  cronLimits → limits.json, guests' qwen jobs → sonnet (PR #23's
  decision, superseded).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-28 17:57:41 +01:00

25 lines
808 B
Python

"""An agent file's (a cron job's) `lean:` frontmatter → the run config's lean spec (sidecar
launch.py "lean runs")."""
from agents import runconfig as cron_mod
def _cfg(fm: str) -> dict:
return cron_mod.run_config(f"---\n{fm}\n---\nThe job.\n")
def test_no_lean_key_is_a_normal_run():
assert _cfg("harness: claude\nmodel: sonnet")["lean"] is None
assert _cfg("lean: false")["lean"] is None
def test_lean_true_takes_the_defaults():
assert _cfg("lean: true")["lean"] == {}
def test_lean_mapping_keeps_the_valid_programs_and_tools():
cfg = _cfg("harness: pi\nlean:\n allow: [mail-recap, mail, 'rm -rf', 3]\n"
" tools: [Bash, Write, Agent]")
assert cfg["harness"] == "pi"
assert cfg["lean"] == {"allow": ["mail-recap", "mail"], "tools": ["Bash", "Write"]}