Skip to main content

Module background_task_sweep

Module background_task_sweep 

Source
Expand description

Ends the db_background_tasks rows that nothing is left to end (docs/specs/SPEC_BACKGROUND_TASK_STRUCTURED_FEED_AND_SWARM_OWNERSHIP_2026_09_27.md §5, the liveness sweep; docs/retro/retro-agent-pane-progress-flicker-and-orphaned-background-tasks-2026-09-30.md §5, fixes 4 and 5).

A row ends from the CLI’s own task feed (background_task_feed) or from the renderer’s <task-notification>. Neither speaks when the CLI dies mid-task, or drops a task without ending it from a feed that no longer holds a record of it (a row older than this srv). Two cases remain, and a pass over the still-running rows settles both:

  • A row with a pid whose process is gone. The pid is checked against the row’s start, so a pid the OS has since given to another program does not keep it alive (pid_alive_since). A task that really still runs keeps its pid, so a long task dev stays.
  • A row with no pid that nothing has seen for ORPHAN_AFTER_MS. It can’t be checked; it only has the CLI’s word, and the word stopped. The dock reads such a row as unknown after two hours; this ends it after a day.

Both end as stopped and only while still running (background_task_end_if_running), so a real outcome that arrives during the pass stands. Pids here are the host’s: a container pane’s pid, from its own pid namespace, is filed apart (container_tool_chunk) and checked inside its container (background_task_container_sweep).

Constants§

ORPHAN_AFTER_MS
A running row with no pid is ended when it was last seen this long ago.

Functions§

start
Starts the sweep: a first pass soon after srv starts, then every [EVERY]. containers checks a container pane’s rows inside its container (background_task_container_sweep); with none, they are left to the restart path and the day’s wait.