CREATE TABLE "sys"."chat_card" ( "id" text PRIMARY KEY NOT NULL, "task_id" text NOT NULL, "recipient_id" text NOT NULL, "kind" text NOT NULL, "payload" jsonb NOT NULL, "at" timestamp with time zone NOT NULL, "superseded_by" text, "rejected_reason" text ); --> statement-breakpoint CREATE TABLE "sys"."work_order" ( "id" text PRIMARY KEY NOT NULL, "task_id" text NOT NULL, "recipient_id" text NOT NULL, "mode" text NOT NULL, "title" text NOT NULL, "payload" jsonb NOT NULL, "at" timestamp with time zone NOT NULL, "done" jsonb ); --> statement-breakpoint CREATE TABLE "sys"."action_intent" ( "id" text PRIMARY KEY NOT NULL, "task_id" text NOT NULL, "tool" text NOT NULL, "input" jsonb NOT NULL, "idempotency_key" text NOT NULL, "state" text DEFAULT 'drafted' NOT NULL, "label" text NOT NULL, "detail" text, "error" text, "created_at" timestamp with time zone DEFAULT now() NOT NULL ); --> statement-breakpoint CREATE INDEX "chat_card_task_idx" ON "sys"."chat_card" USING btree ("task_id","at");--> statement-breakpoint CREATE INDEX "chat_card_recipient_idx" ON "sys"."chat_card" USING btree ("recipient_id");--> statement-breakpoint CREATE INDEX "work_order_task_idx" ON "sys"."work_order" USING btree ("task_id","at");--> statement-breakpoint CREATE INDEX "work_order_recipient_idx" ON "sys"."work_order" USING btree ("recipient_id");--> statement-breakpoint CREATE INDEX "action_intent_task_idx" ON "sys"."action_intent" USING btree ("task_id","state");