-- A model's proposal for a mission's PHASES, and whether a human accepted it. -- -- The sibling of `mission_team_proposals` (0070), and deliberately the same -- shape: propose, review, approve, apply. That one lets a model size the team; -- this one lets a model decide what the work actually IS — the phases, their -- order, and what each must satisfy. -- -- What it replaces: five hand-written recipes in `templates/workflows/*.toml`, -- one of which every mission picks wholesale. A recipe is a fixed answer to -- "what phases does this kind of mission have", written before anyone saw the -- mission — which is the "do it this way: 1, 2, 3" over-specification that -- makes a capable model follow a worse plan than it would have chosen. The -- recipes stay: they remain the default for a mission nobody proposes a plan -- for, and the fallback when a proposal is refused. -- -- `status` matches 0070 exactly, including the partial unique index: two -- approved plans would be two answers to "what is this mission", and the phase -- table holds one. CREATE TABLE IF NOT EXISTS mission_plan_proposals ( id UUID PRIMARY KEY, mission_id UUID NOT NULL REFERENCES missions (id) ON DELETE CASCADE, workspace_id UUID NOT NULL, -- {"phases": [{kind, task, done_when?, done_when_check?, allow_empty?}, ...]} -- Order is the array's own order; a model that also emits `order_idx` would -- give two sources for one fact. plan JSONB NOT NULL, author_model TEXT NOT NULL, status TEXT NOT NULL DEFAULT 'proposed' CHECK (status IN ('proposed', 'approved', 'rejected')), note TEXT, created_at TIMESTAMPTZ NOT NULL DEFAULT now(), decided_at TIMESTAMPTZ, decided_by UUID ); CREATE INDEX IF NOT EXISTS mission_plan_proposals_mission_idx ON mission_plan_proposals (mission_id, created_at DESC); CREATE UNIQUE INDEX IF NOT EXISTS mission_plan_proposals_one_approved ON mission_plan_proposals (mission_id) WHERE status = 'approved';