refactor(cron): decompose run_job and _run_one_job_body into phase helpers
run_job 307 -> ~75: _prepare_job_prompt (pre-agent gates, wake gate, injection block), _CronRunScope (ContextVar/tool-cwd scope with paired enter/exit), _reload_dotenv_and_publish_ delivery_target, _resolve_cron_agent_setup -> _CronAgentSetup (same gate order), _construct_cron_ agent, _FireAudit. _run_one_job_body 338 -> 170: _FireOwnership (fence + ownership check), _RunDelivery + _save_compose_deliver, _finish_interrupted_run, _finish_completed_run, _deliver_crash_failure. Source-inspection test repointed to _finish_interrupted_run.
This commit is contained in:
+536
-430
File diff suppressed because it is too large
Load Diff
@@ -251,10 +251,12 @@ class TestDeliveryErrorIsRecordedWhenTheNoticeCannotBeSent:
|
||||
|
||||
import cron.scheduler as sched
|
||||
|
||||
src = inspect.getsource(sched._run_one_job_body)
|
||||
body_src = inspect.getsource(sched._run_one_job_body)
|
||||
src = inspect.getsource(sched._finish_interrupted_run)
|
||||
assert 'update_job(job["id"], {"last_delivery_error": delivery_error})' in src, (
|
||||
"interrupted runs must still persist the delivery failure"
|
||||
)
|
||||
# The recovery branch hangs off the interrupted-flag short-circuit,
|
||||
# not off a second mark_job_run call.
|
||||
assert "if interrupted:" in src and "if delivery_error:" in src
|
||||
assert "_consume_interrupted_flag(" in body_src and "_finish_interrupted_run(" in body_src
|
||||
assert "if delivery_error:" in src and "mark_job_run(" not in src
|
||||
|
||||
Reference in New Issue
Block a user