CREATE TABLE "sys"."flow_state" ( "task_id" text PRIMARY KEY NOT NULL, "model" jsonb NOT NULL, "position" jsonb NOT NULL, "updated_at" timestamp with time zone DEFAULT now() NOT NULL ); --> statement-breakpoint CREATE TABLE "sys"."loop_state" ( "task_id" text PRIMARY KEY NOT NULL, "model" jsonb NOT NULL, "parsed" jsonb NOT NULL, "runtime" jsonb NOT NULL, "updated_at" timestamp with time zone DEFAULT now() NOT NULL ); --> statement-breakpoint CREATE TABLE "sys"."task" ( "id" text PRIMARY KEY NOT NULL, "activity_id" text NOT NULL, "paradigm" text NOT NULL, "workflow_id" text, "node_id" text, "owner_id" text NOT NULL, "title" text NOT NULL, "runtime" text DEFAULT 'running' NOT NULL, "terminal" text, "reason" text, "envelope" jsonb NOT NULL, "caps" jsonb NOT NULL, "used_steps" integer DEFAULT 0 NOT NULL, "used_tokens" integer DEFAULT 0 NOT NULL, "used_active_ms" integer DEFAULT 0 NOT NULL, "used_human_calls" integer DEFAULT 0 NOT NULL, "last_progress_at" timestamp with time zone, "started_at" timestamp with time zone DEFAULT now() NOT NULL, "finished_at" timestamp with time zone ); --> statement-breakpoint CREATE INDEX "task_owner_idx" ON "sys"."task" USING btree ("owner_id","runtime");--> statement-breakpoint CREATE INDEX "task_workflow_idx" ON "sys"."task" USING btree ("workflow_id");--> statement-breakpoint CREATE INDEX "task_terminal_idx" ON "sys"."task" USING btree ("terminal");