Files
streamline/drizzle/0002_flaky_sprite.sql
T
2026-11-16 17:26:44 -08:00

108 lines
2.8 KiB
SQL

CREATE TABLE "kb_claims" (
"id" text PRIMARY KEY NOT NULL,
"kind" text NOT NULL,
"platform" text,
"scope_key" text NOT NULL,
"scope_label" text,
"subject_key" text NOT NULL,
"statement" text NOT NULL,
"payload" text,
"status" text DEFAULT 'active' NOT NULL,
"confidence" double precision DEFAULT 0.5 NOT NULL,
"support_count" bigint DEFAULT 0 NOT NULL,
"refute_count" bigint DEFAULT 0 NOT NULL,
"first_seen_at" bigint NOT NULL,
"last_validated_at" bigint,
"last_refuted_at" bigint,
"supersedes_id" text,
"version" bigint DEFAULT 1 NOT NULL,
"source" text DEFAULT 'distilled' NOT NULL,
"created_by" text,
"updated_at" bigint NOT NULL,
"embedding" text
);
--> statement-breakpoint
CREATE TABLE "kb_distill_runs" (
"id" text PRIMARY KEY NOT NULL,
"target_kind" text NOT NULL,
"target_id" text NOT NULL,
"target_title" text,
"trigger" text NOT NULL,
"priority" text DEFAULT 'normal' NOT NULL,
"status" text DEFAULT 'running' NOT NULL,
"prompt_id" text,
"prompt_name" text,
"model" text,
"node_id" text,
"raw_output" text,
"proposed_count" bigint DEFAULT 0 NOT NULL,
"applied_count" bigint DEFAULT 0 NOT NULL,
"error" text,
"duration_ms" bigint,
"created_by" text,
"created_at" bigint NOT NULL,
"finished_at" bigint
);
--> statement-breakpoint
CREATE TABLE "kb_evidence" (
"id" text PRIMARY KEY NOT NULL,
"claim_id" text NOT NULL,
"target_kind" text NOT NULL,
"target_id" text NOT NULL,
"round" bigint,
"node_id" text,
"polarity" text NOT NULL,
"outcome" text,
"weight" double precision DEFAULT 1 NOT NULL,
"excerpt" text,
"evidence_ref" text,
"distill_run_id" text,
"ts" bigint NOT NULL
);
--> statement-breakpoint
CREATE TABLE "kb_injections" (
"id" text PRIMARY KEY NOT NULL,
"target_kind" text NOT NULL,
"target_id" text NOT NULL,
"stage" text NOT NULL,
"claim_ids" text NOT NULL,
"outcome" text,
"evaluated_at" bigint,
"ts" bigint NOT NULL
);
--> statement-breakpoint
CREATE TABLE "kb_proposals" (
"id" text PRIMARY KEY NOT NULL,
"distill_run_id" text,
"op" text NOT NULL,
"target_claim_id" text,
"payload" text NOT NULL,
"rationale" text,
"status" text DEFAULT 'pending' NOT NULL,
"decided_by" text,
"decided_at" bigint,
"decision_note" text,
"created_at" bigint NOT NULL
);
--> statement-breakpoint
CREATE TABLE "spec_delta_events" (
"id" text PRIMARY KEY NOT NULL,
"target_kind" text NOT NULL,
"target_id" text NOT NULL,
"node_id" text,
"round" bigint NOT NULL,
"source" text NOT NULL,
"op" text NOT NULL,
"section" text,
"original" text,
"actual" text,
"reason" text,
"evidence" text,
"kind" text,
"confidence" text,
"ts" bigint NOT NULL,
"ingested_at" bigint NOT NULL,
"distilled_at" bigint
);
--> statement-breakpoint
ALTER TABLE "kb_evidence" ADD CONSTRAINT "kb_evidence_claim_id_kb_claims_id_fk" FOREIGN KEY ("claim_id") REFERENCES "public"."kb_claims"("id") ON DELETE cascade ON UPDATE no action;