Skip to main content

Module monitor

Module monitor 

Source
Expand description

Background monitor daemon.

Spawns a detached child process that owns the coding agent: it launches the agent, captures its stdout and exit code into .devflow/, and — when the agent exits — runs devflow advance to advance the stage machine.

Owning the agent is the key fix over a CLI-scoped capture thread: because the monitor outlives devflow start, the agent’s stdout keeps flowing into the capture file and its exit code is still reaped after the CLI exits.

This is the core automation primitive — no cron, no scheduler, no agent cooperation needed.

Structs§

CloseRule
IdleTimeoutSetting
A resolved idle timeout together with how it was arrived at.

Enums§

IdleTimeoutResolution
How parse_idle_timeout_secs arrived at the timeout now in force.
MonitorError
Errors produced by monitor operations.
MonitorLaunch
Which supervision shape spawn_monitor should launch.

Constants§

DEFAULT_IDLE_TIMEOUT_SECS
Idle-timeout default in seconds (D-02): the measured constraint-8 floor.
IDLE_TIMEOUT_ENV
The environment variable that raises the idle timeout above its floor.
IDLE_TIMEOUT_FLOOR_SECS
The floor an idle timeout can never be configured below (D-02/D-04, 31-02).
MAX_IDLE_EXTENSIONS_WITH_TASKS_OPEN
How many consecutive idle windows the monitor will wait through while a background task is known to be outstanding, before treating the silence as a hang after all.

Functions§

idle_timeout_setting
The thin environment wrapper over parse_idle_timeout_secs.
parse_idle_timeout_secs
Resolve a raw idle-timeout override into the value actually in force.
run_pipe_owning_monitor
Supervise a stream-json child, owning both of its pipes, until the close rule is satisfied and the child exits. Returns the child’s exit code, which is also written to the phase exit file.
spawn_monitor
Spawn a background monitor that owns the agent for the given workflow state.
user_turn_line
The single place the stdin wire shape is constructed: one line of JSON carrying the initial user turn for a --input-format stream-json child.
wait_for_agent_pid
Poll for the agent PID that the monitor records, for up to ~1 second.