CREATE TABLE "sys"."activity_memory" ( "id" text PRIMARY KEY NOT NULL, "activity_id" text NOT NULL, "layer" text NOT NULL, "statement" text NOT NULL, "evidence" jsonb NOT NULL, "increment" jsonb, "created_at" timestamp with time zone DEFAULT now() NOT NULL, "pruned_at" timestamp with time zone, "active" boolean DEFAULT true NOT NULL ); --> statement-breakpoint CREATE TABLE "sys"."task_memory_seal" ( "task_id" text PRIMARY KEY NOT NULL, "sealed_at" timestamp with time zone NOT NULL ); --> statement-breakpoint CREATE TABLE "sys"."task_memory" ( "id" text PRIMARY KEY NOT NULL, "task_id" text NOT NULL, "seq" integer NOT NULL, "at" timestamp with time zone NOT NULL, "kind" text NOT NULL, "side" text NOT NULL, "title" text NOT NULL, "detail" jsonb, "stamp" jsonb NOT NULL, "governance" jsonb NOT NULL, "links_to" text, "event_ref" text ); --> statement-breakpoint CREATE TABLE "sys"."replay_tool" ( "key" text PRIMARY KEY NOT NULL, "call" jsonb NOT NULL, "result" jsonb NOT NULL, "recorded_at" timestamp with time zone DEFAULT now() NOT NULL ); --> statement-breakpoint CREATE TABLE "sys"."tool_allowlist" ( "activity_id" text NOT NULL, "tool" text NOT NULL, CONSTRAINT "tool_allowlist_activity_id_tool_pk" PRIMARY KEY("activity_id","tool") ); --> statement-breakpoint CREATE TABLE "sys"."tool" ( "name" text PRIMARY KEY NOT NULL, "version" text NOT NULL, "description" text NOT NULL, "input" jsonb NOT NULL, "output" jsonb NOT NULL, "effect" text NOT NULL, "errors" jsonb DEFAULT '[]'::jsonb NOT NULL, "idempotent" boolean DEFAULT false NOT NULL, "timeout_ms" integer DEFAULT 30000 NOT NULL, "retries" integer DEFAULT 1 NOT NULL, "connection_keys" jsonb DEFAULT '[]'::jsonb NOT NULL, "capabilities" jsonb, "pure" boolean DEFAULT false NOT NULL, "owner_activity_id" text, "connection_cipher" jsonb, "enabled" boolean DEFAULT true NOT NULL, "registered_at" timestamp with time zone DEFAULT now() NOT NULL ); --> statement-breakpoint CREATE INDEX "activity_memory_layer_idx" ON "sys"."activity_memory" USING btree ("activity_id","layer","created_at");--> statement-breakpoint CREATE UNIQUE INDEX "task_memory_seq_key" ON "sys"."task_memory" USING btree ("task_id","seq");--> statement-breakpoint CREATE INDEX "task_memory_task_idx" ON "sys"."task_memory" USING btree ("task_id","at");--> statement-breakpoint CREATE INDEX "tool_effect_idx" ON "sys"."tool" USING btree ("effect");--> statement-breakpoint CREATE INDEX "tool_owner_idx" ON "sys"."tool" USING btree ("owner_activity_id");