Skip to main content

Module direct

Module direct 

Source
Expand description

Runs started by hand are tasks.

magi run and magi review used to mint a run no task knew about: no detail page, no attempt history, invisible to duplicate detection, and an orphan the moment anything cleaned up after it. They now file a task first, through the queue like magi task add, and then either hand it to a live loop or execute it here through the daemon’s own attempt (crate::daemon::run_claimed). There is no second dispatcher in this module: it decides who runs the task and watches it, nothing more.

  • A live loop in another process (a fresh daemon.json heartbeat, see crate::daemon::foreign_loop) gets the task as urgent, runs it in its own urgent slot, and the caller follows it. The caller never claims or executes it: two processes must not drive one task.
  • Otherwise the caller claims the task before it is written, so a loop that starts mid-run finds the claim and leaves it alone, and executes it.

Structs§

Adopted
A run opened inside this process (the follow-up review of magi fix) and the task that owns it. See adopt.
Filing
What to file. Everything magi run / magi review take that changes what the run does rides on the task, so a loop that executes it behaves the same as this process would have.
Followed
How a followed task ended up.

Enums§

Filed
Who will execute a filed task.

Functions§

adopt
Give a run this process is about to execute an owning task. A parent task that exists just gains the run in runs; with none, a task is filed and claimed for the duration, and Adopted::finish settles it as the daemon would. A no-op (None) when no magi home is pinned.
config_for
The config a task’s run is built with: the task’s --config layer, then its overrides and solo. What the loop’s attempt does, for the dry run.
file
File filing and decide who runs it. home is the magi home whose daemon.json is judged; own_pid is this process (a loop of our own is not “another” one). force_local (--dry-run) never hands over: a dry run spends no agent call and a loop would not honour that.
follow
Watch id until the loop that owns it is done with it, calling seen with each run id the first time it appears on the task, and progress with a line whenever the newest run’s status changes.