Repository navigation
fix(scheduling): keep a flow's recurring schedule when adding a delayed run - #3894
Conversation
…ed run flows run --timestamp and datamachine/schedule-flow with a numeric timestamp rewrote scheduling_config to one_time, and JobCompleteHandler then reverted it to manual, silently dropping every_N/cron schedules. For flows with a recurring or cron schedule, enqueue an extra datamachine_run_flow_once action at T without touching scheduling_config or the flow routine. Manual flows keep the one_time -> manual behavior. Fixes #3884
Homeboy Results —
|
Homeboy Results —
|
Homeboy Results —
|
Fixes #3884
Problem
wp datamachine flows run <id> --timestamp=<T>, anddatamachine/schedule-flowwith a numeric timestamp, replaced the flow'sscheduling_configwithone_time. After the run,JobCompleteHandlerreverted it tomanual, so any recurring or cron schedule was silently lost. On production, flow 4 (EC Agent Progress Ping,every_3_days) sat onmanualfor 10 days after an operator ran one delayed verification run.Fix
ScheduleFlowAbility::scheduleOneTime(): if the flow already has a recurring or cron interval, it enqueues one extradatamachine_run_flow_onceaction at T through the newFlowRoutines::enqueue_one_time(). It does not callsync(), soscheduling_config, the flow routine, and its pending wake are untouched. A log line records that the schedule was preserved.action_idis now returned for real instead ofnull.one_time, thenmanualafter the run.FlowRoutines::enqueue_one_time()returns aWP_Errorif Action Scheduler is missing or the enqueue fails, so a failed enqueue is never reported as success.schedule_one_time()now uses this method too.--timestampCLI docblock.Design note: if someone edits the schedule later (
sync()on a recurring interval), any pending extra one-off for that flow is still cancelled bycancel_one_time(). A schedule edit resets the flow's queued runs; nothing else touches the extra run.Tests
plugins/data-machine/tests/delayed-flow-preserves-schedule-smoke.php, run withphpagainst the real ability, scheduling adapter, and completion handler:every_3_daysandcronflows: the delayed run keeps the config identical, the action is queued at T on the engine bridge hook, and after completion the config and routine action are still unchanged.manualand empty-config flows:one_time, thenmanualafter the run (existing behavior).schedule_failedand leaves the recurring config alone.Provenance
Written by a Homeboy Cook (
agent-task-d48af8b6-d1aa-4251-9f7b-ed775b160274, Lab, Pi). The scoped task gate (diff scope,php -l, regression smoke) passed on Lab and again locally. The default component gate (gate-2) failed in exactly the same way on the unmodified baseline. Homeboy classified that asaccepted_inherited_failure, and promotion went ahead on the task gate with operator authorization. Homeboy could not publish the PR because of homeboy#17190 (monorepo matches multiple component configurations), so the verified candidate was committed and this PR opened by hand outside Homeboy.🤖 AI-generated (Extra Chill Bot via Homeboy Cook); reviewed against the code before opening.