Skip to main content

Module cron

Module cron 

Source
Expand description

HTTP handlers for jobs (docs/specs/SPEC_JOBS_AND_TEMPLATES_2026_10_24.md §5.1) and the persistent cron scheduler under them.

Routes (all auth-gated via X-AuthKey), under /agentmux/jobs, and the same under /agentmux/cron, kept as aliases for one release: POST /agentmux/jobs — create a job: a job definition (jobVersion 1), or the cron shape the Schedule tool sends DELETE /agentmux/jobs/:id — delete a job GET /agentmux/jobs — list all jobs, each with its last run PATCH /agentmux/jobs/:id — pause / resume, or edit its definition GET /agentmux/jobs/:id/runs — a job’s runs, newest first POST /agentmux/jobs/:id/run — run it now (a manual run) POST /agentmux/jobs/runs/:run_id/report — a run’s own verdict

The run routes are the run ledger’s (§3.2, §3.3 MuxAPI). Who may do what is §7: Who.

Structs§

CronCreateRequest
CronJobView
CronReportRequest
CronRunsQuery
CronSummary
Swarm-pane row shape for one cron job (SPEC_SWARM_LONG_RUNNING_PROCESS_ ROWS_2026_07_20 Phase 2) — CronJobView plus the created_by agent’s resolved block_id, so the frontend can group it under that agent’s row the same way ShellSummary does for the Shell bucket.

Enums§

Who 🔒
Who is asking, for the rules of §7. The operator is the app’s own client, which carries no agent token (Caller::Unattributed).

Constants§

CONTAINER_HOST_JOB 🔒
What a container agent is told for a job whose runs start things on the host (§7): the only jobs it can’t have, as it can’t start or run anything there. It says why and what to do instead.
FIXED_FIELDS 🔒
A job’s fields an edit can’t change: srv sets them.
REPORT_LABEL_MAX 🔒
REPORT_LINKS_MAX 🔒
The most links one report keeps, and the longest url and label.
REPORT_URL_MAX 🔒
RUNS_MAX 🔒
The most runs one history call returns.
SPAWN_FROM_THE_APP 🔒
What a spawn job asks of anyone who isn’t the app’s own controls: it starts agents that spend until someone stops them.

Functions§

bad_request 🔒
create_job 🔒
Create a job from a definition or the cron shape. origin.from_host: the operator’s decision, from the host route (handle_host_jobs) or the app’s own proven window (jobs.save): the only way to create a job that starts workers, to raise a cap, or to confirm a job on a provider that reports no cost. A definition that names a template is made from it (jobs::from_template).
forbidden 🔒
handle_cron_create 🔒
handle_cron_delete 🔒
handle_cron_list 🔒
handle_cron_patch 🔒
PATCH: {"action": "pause" | "resume"}, or an edit: definition fields (§5.1) laid over the job’s definition, which is then read as a create’s is. The 15-minute minimum applies only when the edit sets the trigger or the action, so a job kept as it was isn’t refused for a rule newer than it.
handle_cron_report 🔒
handle_cron_run_now 🔒
handle_cron_runs 🔒
handle_host_jobs 🔒
POST /api/v1/host/jobs: what the operator decides in the Jobs tab that starts agents, relayed by the host with its own token. action is create (definition: a job definition, a spawn job included), update (id, fields: an edit, which may raise the job’s caps) or run_now (id). confirm_no_cost: true confirms a job whose agent’s provider reports no cost (§5.3).
inject_here_following_runs 🔒
Deliver on this instance (jekt_files::inject_here). A delivery another instance forwarded here whose request_id is a run another channel fired is followed here, before the answer goes back (#1988).
job_for_change 🔒
The store and the job, or the response refusing the change: no store, no such job, or a caller may_change_job refuses.
jobs_store 🔒
Where jobs are (db_jobs): the shared store, beside the db_cron_jobs it replaced, or the work store of a task dev build, which keeps its own (crate::registry::work_store). Every job read and write goes through here, so the store can move in one place.
jobs_store_or_503 🔒
jobs_store, or the answer when there is none.
ledger_or_503 🔒
ledger_store 🔒
Where the run ledger is (db_job_runs): the identity store, or the work store of a task dev build, which keeps its own (crate::registry::work_store).
legacy_definition 🔒
The definition the cron shape describes: a cron trigger in tz and a message action to the target.
may_act_on 🔒
Whether caller may act on job (Run now): the operator (the app’s own client, which carries no agent token) or the agent that created or owns it (jobs spec §7). By UID when the job recorded one, else by the creator’s name against the caller’s agent slug.
may_change_job 🔒
Whether caller may pause, resume or delete job. An agent (a request carrying its token) may change only a job it created or owns, or one aimed at it; everyone else, the UI included, may change any job. Unattributed requests can’t be refused: at the same-user boundary one that omits its token looks like the UI (caller.rs). This stops an agent changing another agent’s job by mistake, not a determined one. A job with no recorded creator UID (created before identity M4c-1, or unattributed) is open to any caller. Editing the definition is narrower: may_edit_job.
may_define 🔒
Whether who may define a job like def (§7): the operator any job; an agent, container or not, a message or task job it owns; a native agent a Drone job too, which a container agent can’t have as its runs start on the host. A spawn job needs the operator’s approval once (the spawn consent rule, made at creation since its runs are unattended), which has no flow yet, so an agent can’t create one. current_owner is the job’s owner on an edit.
may_edit_job 🔒
Whether caller may edit job’s definition: the operator, or the agent that created or owns it (§7). The agent a job messages may pause it, not rewrite it. A job with no creator (the operator’s, or one from before creators were recorded) is the operator’s to edit.
next_fire 🔒
The job’s next fire (its trigger’s next slot, in its time zone) as an ISO-8601 UTC string; None when disabled, when its trigger has no next slot, or when it doesn’t read.
patch_job 🔒
handle_cron_patch’s work. origin.from_host: the operator’s edit, from the host route or the app’s own proven window, which may raise caps, confirm a job on a provider that reports no cost, and change a spawn job.
publish_cron_changed 🔒
report_links 🔒
The links a report keeps: https URLs, given as strings or as {label, url}, within the length bounds, at most five. Anything else is dropped: the ledger shows them to other agents and the UI.
run_job_now 🔒
Run job now and say how it went.
runnable_yet 🔒
What this build can’t run yet, though the definition is valid. Refused rather than stored and silently ignored: max_turns is a flag at the CLI’s launch, which a message to a running agent can’t set.
set_enabled 🔒
Pause or resume job id.
starts_on_the_host 🔒
Whether a job of this action_kind is one a container agent can’t run now or have scheduled: a spawn or Drone job starts things on the host.
target_of 🔒
A message’s to as the job’s target (name, uid): a UID names that agent; anything else is kept as a name, never resolved here (identity spec §5.4: the job then fires by name, counted).
to_summary 🔒
to_view 🔒
who 🔒
work_store 🔒
Where tasks are filed (the work queue and its cards): the identity store, or the work store of a task dev build, which keeps its own.
writer_of 🔒
Who stands behind a definition this request writes, as the request proves it: the app’s own window, an agent by its token, or no one (a caller nothing identified, which the rest of this file treats as the operator but cannot prove is). A scheduled fire of the job is proven only as far as this goes (CronJob::fire_proof).

Type Aliases§

Answer 🔒