42b0fbe1ab
Componente runtime/ che cabla core+clients+state+safety in un engine autonomo notify-only: nessuna conferma manuale, ordini combo piazzati direttamente quando le regole passano. 311 test pass, copertura totale 94%, runtime/ 90%, mypy strict pulito, ruff clean. Moduli: - runtime/alert_manager.py: escalation tree LOW/MEDIUM/HIGH/CRITICAL → audit + Telegram + kill switch. - runtime/dependencies.py: build_runtime() costruisce RuntimeContext con tutti i client MCP, repository, audit log, kill switch, alert manager. - runtime/entry_cycle.py: flusso settimanale (snapshot parallelo spot/dvol/funding/macro/holdings/equity → validate_entry → compute_bias → options_chain → select_strikes → liquidity_gate → sizing_engine → combo_builder.build → place_combo_order → notify_position_opened). - runtime/monitor_cycle.py: loop 12h con dvol_history per il return_4h, exit_decision.evaluate, close auto-execute. - runtime/health_check.py: probe parallelo MCP + SQLite + environment match; 3 strikes consecutivi → kill switch HIGH. - runtime/recovery.py: riconciliazione SQLite vs broker all'avvio; mismatch → kill switch CRITICAL. - runtime/scheduler.py: AsyncIOScheduler builder con cron entry (lun 14:00), monitor (02/14), health (5min). - runtime/orchestrator.py: façade boot() + run_entry/monitor/health + install_scheduler + run_forever, con env check vs strategy. CLI: - start: avvia engine bloccante (asyncio.run + scheduler). - dry-run --cycle entry|monitor|health: esegue un singolo ciclo per debug/test in produzione. - stop: documenta lo shutdown via SIGTERM al container. Documentazione: - docs/06-operational-flow.md riscritto per il modello notify-only auto-execute (no conferma manuale, no memory, no brain-bridge). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
28 lines
857 B
Python
28 lines
857 B
Python
"""Tests for the APScheduler bootstrap helper."""
|
|
|
|
from __future__ import annotations
|
|
|
|
import pytest
|
|
|
|
from cerbero_bite.runtime.scheduler import JobSpec, build_scheduler
|
|
|
|
|
|
async def _noop() -> None:
|
|
return None
|
|
|
|
|
|
def test_build_scheduler_registers_all_jobs() -> None:
|
|
specs = [
|
|
JobSpec(name="entry", cron="0 14 * * MON", coro_factory=_noop),
|
|
JobSpec(name="monitor", cron="0 2,14 * * *", coro_factory=_noop),
|
|
JobSpec(name="health", cron="*/5 * * * *", coro_factory=_noop),
|
|
]
|
|
sched = build_scheduler(specs)
|
|
job_ids = {j.id for j in sched.get_jobs()}
|
|
assert job_ids == {"entry", "monitor", "health"}
|
|
|
|
|
|
def test_build_scheduler_rejects_malformed_cron() -> None:
|
|
with pytest.raises(ValueError, match="cron must have 5 fields"):
|
|
build_scheduler([JobSpec(name="x", cron="0 14 * *", coro_factory=_noop)])
|