Skip to content

Bug report: subagent-watchdog has systemic ownership, liveness, process-tree, monitor lifecycle, recovery/supersession,  #218

Description

@stgmt

Report

Bug report: subagent-watchdog has systemic ownership, liveness, process-tree, monitor lifecycle, recovery/supersession, and acknowledgement defects.

Context/evidence from a long authorized lm-saas OpenRouter-agent run:

  • The watchdog correctly prevented false completion and detected a real detached rollout after TaskStop.
  • However, live agents with empty .output files were repeatedly classified stale even while SendMessage, tool calls, progress journals, heartbeats, and child processes showed activity.
  • TaskStop reported success while descendant heartbeat-run/sync_rollout/PowerShell/WSL processes remained alive and continued mutating a checkout.
  • Failed API/context tasks kept blocking after replacement workers independently completed and verified the work.
  • Ownerless tail -F monitors accumulated as stale background IDs after their agents terminated.
  • Watchdog surfaced background IDs that TaskStop could not resolve because Agent, Bash, and Monitor IDs use incompatible registries.
  • Terminal task-notifications did not reconcile the watchdog registry; manual ack remained necessary.
  • The suggested manual Node ack command failed under Windows/Git Bash quoting and relative-path resolution before an absolute POSIX-style invocation worked.
  • Identical findings were emitted repeatedly without state-hash deduplication (many repeated SubagentStop inspections saying no process/no lock/clean checkout).
  • Recovery agents themselves created new tasks, monitors, journals, context growth, and additional watchdog alerts.
  • Command-line substring process scans matched their own diagnostic commands.
  • Repo-owned P0 tombstones, released writer locks, free leases, and absence of processes were ignored by the platform watchdog.
  • running but silent, failed and untrusted, stop-partial, orphan monitor, and recovered/superseded all produced effectively the same inspect/resume/stop guidance.

Root design gap:
Agent task <-> OS process tree <-> Monitor <-> worktree <-> run-id <-> progress journal <-> replacement/recovery task are not represented as one ownership graph.

P0 requested fixes:

  1. Launch every Agent in an OS process group / Windows Job Object. TaskStop is successful only when ownerAlive=false, descendantsAlive=0, writersAlive=0; otherwise status=stop-partial.
  2. Owner-bind every Monitor (ownerTaskId, ownerRunId, autoStopOnOwnerTerminal).
  3. Unified typed work registry and StopBackgroundWork API for agent/shell/monitor IDs.
  4. Aggregate liveness from tool activity, SendMessage, progress journal pulse, heartbeat, run-state, and process group; output-file mtime only as fallback.
  5. Automatic terminal reconciliation from task-notification: failed-uninspected -> failed-inspected/recovered/superseded.
  6. Supersession graph: failed task A can be closed by verified recovery B + gate evidence C.
  7. Deduplicate findings by (taskId, stateVersion, findingHash).
  8. Built-in WatchdogAck tool or stable CLI wrapper; no generated long Node command.
  9. Repo P0 adapter: matching tombstone + no processes + no writer lock/lease => terminal-clean.
  10. Structured process identity (owner token/environment), excluding current PID/ancestors; no command-line substring grep.
  11. Read-only InspectBackgroundTask reconciler so routine inspection does not spawn another Agent.
  12. Distinct verdict/action states: live-running(wait), silent-running(inspect), stop-partial(kill descendants), failed-uninspected(inspect result), failed-superseded(auto-close), monitor-orphaned(auto-stop), terminal-clean(no block).

P1:

  • UI showing task, PID tree, worktree, run-id, monitor, writer lock and lease.
  • Recovery capsule instead of full transcript.
  • Automatic postmortem metrics: productive time, watchdog recovery time, false-stale count, orphan-monitor count, context overflows, detached-process count.
  • Progress notifications only on phase start, newly verified blocker, terminal result.

Required regression tests:

  1. Active Agent, output=0, SendMessage activity => not stale.
  2. Active Agent with journal pulse => not stale.
  3. Agent stopped while child PowerShell/WSL remains => stop-partial.
  4. Owner terminal automatically stops Monitor.
  5. Failed Agent + verified replacement => old task recovered-superseded.
  6. Same finding hash emits once.
  7. Unified stop accepts Monitor ID.
  8. Terminal task notification updates registry automatically.
  9. Process inspection cannot match itself.
  10. Matching P0 tombstone + no process/locks => terminal-clean.
  11. API failure => failed-uninspected, never running.
  12. Ack works from PowerShell, Git Bash, and WSL.
  13. Job Object terminates detached WSL descendants.
  14. Context-overflow replacement does not inherit old monitors.
  15. Recovery terminal-clean does not create a new watchdog alert.

Severity: P0. The gate is valuable and must not be weakened; it needs ownership/process/recovery semantics so safety does not produce alert storms and context-overflow feedback loops.

Environment

  • Reported with dev-pomogator

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions