Skip to main content

Module jobs

Module jobs 

Source
Expand description

Jobs: things that run by themselves, and the one run ledger under them (docs/specs/SPEC_JOBS_AND_TEMPLATES_2026_10_24.md §3).

RunLedger writes db_job_runs rows (storage::job_runs) for cron fires and Drone runs, follows a delivered fire’s turn to its end (follower), and on startup closes the runs a restart interrupted. After each change it nudges incidents, which opens one incident per failing job (§3.4). Cron fires are never held for a stopped agent: an undelivered fire is missed, or, under catch-up latest, the job’s one pending fire (§3.2, §5.2), which the scheduler delivers when the agent is back.

Modules§

admission
Letting a run start under its job’s policy (docs/specs/SPEC_JOBS_AND_TEMPLATES_2026_10_24.md §5.1 “Policy”): overlap, concurrency groups and the global limit when it wants to start, the timeout while it runs, and the retry of an infrastructure failure when it ends. The decisions are policy.rs; this reads who is running from the ledger and writes the rows.
app_events
App events: something inside AgentMux happened, and a job on the app_event source starts a run (docs/specs/SPEC_DRONE_REAL_WORLD_JOBS_2026_11_11.md §3.2, §3.2.1).
cap_alert
The alert for a job’s first cap skip of the day (docs/specs/ SPEC_JOBS_AND_TEMPLATES_2026_10_24.md §5.3): one note to the owning leader and one notification to the operator. No Kanban task: a skip is the cap doing its work, not a failure. The job isn’t paused and its runs resume the next day.
caps
Spending caps for job runs (docs/specs/SPEC_JOBS_AND_TEMPLATES_2026_10_24.md §5.3): the defaults Settings → Jobs holds, the figures a job’s policy.caps may lower, and the rules that decide, from the spend the ledger found, whether a run may start. Pure: reservation.rs reads the ledger and acts on the answer.
cloud_events
Cloud jobs report in: the signed run event (docs/specs/SPEC_JOBS_AND_TEMPLATES_2026_10_24.md §4.1, §4.2).
cloud_hub
Where cloud job events enter this AgentMux (docs/specs/SPEC_JOBS_AND_TEMPLATES_2026_10_24.md §4.2).
definition
The job definition (docs/specs/SPEC_JOBS_AND_TEMPLATES_2026_10_24.md §5.1): a trigger, an action, a policy and an owner, as JSON. Published as schema/agentmux-job.v1.schema.json; definition_tests.rs pins the two together.
expect
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.
file_watch
File watch: a path in a workspace changed, and a job on the file_watch source starts a run (docs/specs/SPEC_DRONE_REAL_WORLD_JOBS_2026_11_11.md §3.2).
follower
The turn follower: a delivered run follows its pane’s agentturn events (blockcontroller::health::TurnLedger) to the end of the turn it started or joined, and takes that turn’s cost, output tokens and steps (spec §3.2).
from_template
A job made from a template, and a template’s update diff (docs/specs/SPEC_JOBS_AND_TEMPLATES_2026_10_24.md §5.4).
incidents
When a job’s run fails: one incident per job, not one per run (docs/specs/SPEC_JOBS_AND_TEMPLATES_2026_10_24.md §3.4).
paused
The slots a paused job lets pass: each is counted into one collapsed skipped (paused) row (docs/specs/SPEC_JOBS_AND_TEMPLATES_2026_10_24.md §3.3, Pause / Resume). A paused job has no scheduler task, so a minute timer here walks the paused jobs’ slots since its last look. Pause all’s skips are the scheduler’s own (CronScheduler::fire): those jobs still have their task.
policy
What a job’s policy decides about a run before it starts, and what to do when it failed (docs/specs/SPEC_JOBS_AND_TEMPLATES_2026_10_24.md §5.1 “Policy”). Pure: the ledger gathers who is running and acts on the answer (admission.rs).
poll
A job on the poll source asks AgentMux’s own state a question every so often and starts one run for each item that is new in the answer (docs/specs/SPEC_DRONE_REAL_WORLD_JOBS_2026_11_11.md §3.2). Polling spends no agent tokens: the question is one of the App query’s, answered by srv.
remote
A run delivered to an agent in another channel (#1988, spec §3.2).
reporters
The cloud reporters the operator pinned (docs/specs/SPEC_JOBS_AND_TEMPLATES_2026_10_24.md §4.2).
reservation
Spending caps at work (docs/specs/SPEC_JOBS_AND_TEMPLATES_2026_10_24.md §5.3): the reservation before a run starts, the stop when a run reaches its own cap, and the skips a cap makes. The rules are caps.rs; this reads the spend from the ledger and writes the rows.
verdict
What a run concluded for the Jobs tab: whether it failed, and whether its job is failing (docs/specs/SPEC_JOBS_AND_TEMPLATES_2026_10_24.md §3.4), and the state a job is in (§3.3).
watchdog
The watchdog for cloud jobs (docs/specs/SPEC_JOBS_AND_TEMPLATES_2026_10_24.md §4.4).
webhook_local
A job on the webhook_local source starts a run when a script on this computer POSTs to http://127.0.0.1:<port>/agentmux/hook/<job id> with the job’s secret (docs/specs/SPEC_DRONE_REAL_WORLD_JOBS_2026_11_11.md §3.2; the route is server::hook_handlers).

Structs§

RunLedger
The run ledger, shared by the cron scheduler, the Drone handlers and the Schedule routes.

Enums§

Begin
What inserting a cron slot’s row answered.

Constants§

BY_EVENT
triggered_by for an event’s run is this, then : and the source (event:app_event).
BY_OPERATOR
BY_SCHEDULER
triggered_by for runs the scheduler starts, and for the operator.
CATCH_UP_LATEST
CATCH_UP_SKIP
A cron job’s catch-up policy (§5.2): what an undelivered fire leaves.
DRONE_STATUS_INTERRUPTED
The status a Drone run left running by a restart gets in db_drone_runs (§3.2). An open string there, like every other status.
FLAG_PAUSED_ALL
The identity-store switch Pause all sets (§3.3): while it is on, every scheduled fire is a collapsed skipped (paused_all) row and Run now is refused. Only the operator turns it on or off.
OVERLAP_REFUSAL
What a Run now gets while the job’s previous run is still going and its policy overlap is skip.
PAUSED_ALL_REFUSAL
What a Run now gets while Pause all is on.
SOURCE_CLOUD
SOURCE_CRON
Job kinds in job_source (§3.1).
SOURCE_DRONE
TRIGGER_CATCH_UP
TRIGGER_EVENT
TRIGGER_MANUAL
TRIGGER_RETRY
TRIGGER_SCHEDULE
Run triggers in trigger (§3.1).

Functions§

brief_line
The line a fire’s prompt ends with: the run id, and how to report (§3.2). A late fire (a catch-up, a pending fire delivered when its agent came back) also says which slot it was for and when it started, so the agent can tell its work is late. Plain text: srv rewrites [AgentMux] markers in anything forwarded.
drone_cost
The summed cost_usd of a Drone run’s blocks: only Agent blocks report one, in their output (drone/executor/blocks/agent.rs). Known only when at least one block reported a cost.
missed_slots
Missed slots of a job’s schedule after base_ms and before now_ms: the newest, and the earlier ones as (first, count). The newest is the schedule’s last slot before now, found directly, so it is right after any downtime; only the count of earlier ones stops at cap, so a one-minute job off for a year costs bounded work.
next_slot_after
The job’s next fire time after slot_ms: when a pending fire for that slot expires (§5.2). None for a job whose trigger has no later slot or doesn’t read.
pending_wake
Woken whenever an agent registers (reactive::registered), so a pending fire reaches its agent as soon as it is back.
registered_in_another_channel
Whether the agent with uid is registered by another channel’s AgentMux on this computer and that process is alive: the cross-channel tier the inject path forwards to (Tier 2b, the host-global shared registry). A pending fire whose agent lives there is delivered through it, rather than expiring here unseen.

Type Aliases§

BlockHook
Something done to a pane, by its block id: interrupting its turn, stopping a worker.