-- 019_task_completion_nudges.up.sql
-- See plans/2026-07-11-task-completion-safety-net.md (fix 2+3): a
-- goal-bearing session (set_goal was called, so it's a real structured
-- task, not the trivial-Q&A case handled by the inline safety net) can
-- still stall without ever calling complete_task. completion_nudges tracks
-- how many times the idle sweep has already nudged a stalled session, so it
-- can tell "never nudged" (nudge it) from "nudged once already, still
-- stuck" (auto-close it) rather than nudging forever.

ALTER TABLE agent_sessions ADD COLUMN IF NOT EXISTS completion_nudges INT NOT NULL DEFAULT 0;
