Skip to main content

Module background_task_pid

Module background_task_pid 

Source
Expand description

Files a background task’s pid in db_background_tasks from srv itself (docs/specs/SPEC_BACKGROUND_TASK_STRUCTURED_FEED_AND_SWARM_OWNERSHIP_2026_09_27.md §5, first bullet; docs/specs/SPEC_BACKGROUND_TASK_PID_CAPTURE_2026_08_20.md).

agentmux-bashwrap publishes a pid chunk when the command it runs starts. Only an open agent pane used to read it, and relayed it to srv: with the pane closed or parked the row never got its pid, and the liveness sweep (background_task_sweep) had nothing to check it by. The chunk is on the broker whether or not a pane is open, so srv reads it there.

The pid usually beats its row: bashwrap publishes it at its own start, and the row is made when the CLI’s task feed (in the stdout reader, which needs no pane) or the pane’s docknodestatus first sees the call run in the background. A pid that finds no row waits in the process-wide pen (PendingBackgroundPids), and whoever makes the row applies it (apply_stashed).

Functions§

apply_stashed
The row tool_id now exists: give it the pid that came before it, if one did. Blocking: a store write.
file_pid
Record pid on the row tool_id, or keep it in the pen until that row exists. Tells the pane to re-read when broker is given. Blocking: a store write.
install
Start listening. Called once, with the app’s broker and store.