Skip to main content

Module incidents

Module incidents 

Source
Expand description

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).

After each change to a job’s runs the ledger nudges Incidents, and a sweep looks at every job every SWEEP_MS. The keeper walks the job’s decisive runs in the order they ended, from where it last stopped (its cursor, storage::job_incidents), judging each with the Jobs tab’s own rule (verdict::run_failed):

  • A failure with no incident open opens one, files a Kanban task for the job’s owning leader (kind: job-failure, no review), sends that leader an [AgentMux] note and the operator one notification (NotifyKind::JobFailed).
  • Another failure while it is open is counted, and adds a line to the task’s history (fewer as a streak grows, worth_a_line), and nothing else.
  • The next success recovers it: the task gets a “recovered” line and stays open for its owner (§10, decision 6); the notification is taken down.
  • A task its owner finished or cancelled while the job still failed ends the incident; the job’s next failure opens a new one, and the next success still takes its notification down.
  • A late report that changes a run’s outcome moves the cursor back to it (job_run_report), so it is judged again: a success reported failed reopens the incident it recovered, or opens one.

Only the instance that has the cron job (its shared store lists it) moves an incident: the owner is resolved from the job, and the notification is on that instance. Another channel that followed a run (#1988) only says the job changed. Skips (paused, Pause all) are never decisive, so they neither fail nor recover a job; a cap skip has its own once-a-day alert (cap_alert.rs), and a run stopped at its cap (over_budget) is a failure like any other. Cron jobs only: a Drone graph is run by hand, from a pane that shows its failure already.

Structs§

Incidents
The incident keeper: one per instance, beside the run ledger.
Leader
Who an incident’s alerts go to (§3.4): the owning leader, resolved when the incident opens. None when no agent resolves: the operator alone is told, and the task waits in the backlog for anyone.

Enums§

Step
What one decisive run did to the job’s incident.

Constants§

FILED_BY
PASS_MAX
The most runs one look at a job walks; the rest wait for the next.
SWEEP_MS
How often every job is looked at even without a nudge: a run another channel closed, or reported, reaches the owner this way at the latest.
TASK_KIND
The task’s kind, and who files it (created_by, filed_by, the history’s actor).

Functions§

failure_words
How the run failed, in a few words of AgentMux’s own (never the run’s summary): for titles, notes and the notification.
note_text
The [AgentMux] note to the owning leader (§3.4). The job’s name is quoted: an agent named it.
notify_body
The notification’s body: fixed text and the reason, never the summary.
notify_key
The notification’s group: one per job.
owning_leader
The owning leader of job (§3.4): its owner (the cron job’s creator), that owner’s lead when it has a seat with one or is a spawned worker, else the owner itself. None when the job has no owner, or none resolves.
task_body
The task’s body: the failing run’s state, reason, infrastructure and outcome, its summary (the agent’s words, as data), its links, and where the job’s history is.
task_title
The task’s title: the job’s name and how it failed.
worth_a_line
Whether the countth failure in a row gets a line in the task’s history: the first five, then 10, 20, 50, 100, 200, 500… A job failing every minute would otherwise write 1,440 lines a day; the incident keeps the exact count, and the Jobs tab every run.