Skip to main content

Module expect

Module expect 

Source
Expand description

A job on the expect source is a dead man’s switch: it starts a run when a job it watches has not had a good run lately (docs/specs/SPEC_DRONE_REAL_WORLD_JOBS_2026_11_11.md §3.2). Silence is the event: “the nightly report did not come” is the failure nobody sees, and this is how someone does.

The job’s filter says what is expected:

  • job required: the name or id of the job whose runs are looked at.
  • within_minutes required: 1 to 43200 (30 days). The watched job should have a good run that ended within this long ago.
  • every_minutes how often to look, 1 to 1440, default 5.

A good run is the newest run of the watched job that is a finished one whose outcome is ok or findings (it did its work). A run that failed, or ended with an unknown outcome, is not one. While a run of the watched job is still going, nothing fires: it may yet succeed in time.

When the last good run is older than within_minutes (or there is none, or no job has that name), the job’s run starts once for that gap: the event is keyed by the last good run, so a restart, or the next look, does not repeat it, and a good run followed by a new gap is a new event. The run reads {{trigger.expected}} (the watched job), {{trigger.within_minutes}}, {{trigger.last_ok_ms}} (null when there has never been one), {{trigger.job_found}} and {{trigger.last_seen}} (the newest run, if any).

(The ledger is asked for the last good run on its own, so a long bad stretch does not hide it.)

The local form checks this machine’s run ledger, so it cannot fire while the machine is off; the cloud form that can is a later phase.

Structs§

ExpectState
The expect poller’s memory: when each job looks next.

Constants§

DEFAULT_EVERY_MINUTES
MAX_WITHIN_MINUTES

Functions§

expect_due
Looks at the watched job of every expect job that is due and starts a run for each gap. Returns how many runs it started or queued. check answers the App query’s jobs.
validate_filter
An expect trigger’s filter: the job, how recent a good run must be, and how often to look.