-- Planner round outcomes, independent of task completion. A failed planning -- round keeps the unmet goal and survives a restart without an infinite loop: -- db/planner_progress.go counts failed cycles on unchanged input and moves the -- task to needs_attention after MaxPlanningFailures. -- -- This DDL used to run from schema.sql on every boot. A database that already -- ran that version has the table, possibly with the earlier state constraint -- (without 'retrying'); the constraint is replaced once here. -- -- Numbered 0021, after 0020 on main: migrations are append-only and applied in -- version order, so this file must land after every lower-numbered one. CREATE TABLE IF NOT EXISTS planner_progress ( exploration_id BIGINT PRIMARY KEY REFERENCES explorations(id) ON DELETE CASCADE, state TEXT NOT NULL CHECK(state IN ('active','waiting','stalled','needs_attention','retrying')), reason TEXT NOT NULL, fingerprint TEXT NOT NULL, failures INTEGER NOT NULL DEFAULT 0, next_check_at TIMESTAMPTZ, updated_at TIMESTAMPTZ NOT NULL DEFAULT now() ); ALTER TABLE planner_progress DROP CONSTRAINT IF EXISTS planner_progress_state_check; ALTER TABLE planner_progress ADD CONSTRAINT planner_progress_state_check CHECK(state IN ('active','waiting','stalled','needs_attention','retrying'));