-- Outbound message queue: the real effect of the gated email.send tool. -- Rows land here ONLY after human approval (ยง15); the delivery transport -- (SMTP / Slack / etc.) drains the queue in P4. CREATE TABLE outbox ( id UUID PRIMARY KEY, workspace_id UUID NOT NULL REFERENCES workspaces (id), agent_id UUID NOT NULL REFERENCES agents (id), recipient TEXT NOT NULL, subject TEXT NOT NULL, body TEXT NOT NULL, status TEXT NOT NULL DEFAULT 'queued' CHECK (status IN ('queued', 'sent', 'failed')), created_at TIMESTAMPTZ NOT NULL DEFAULT now() ); CREATE INDEX outbox_workspace_idx ON outbox (workspace_id, created_at DESC);