CodeIssuesDiscussionsWikiPull RequestsProjectsCommitsActionsReleasesContributorsPulse● GatesSecuritySettingsDeploymentsPipelineInsightsAgents✨ Explain✨ Ask AI✨ Workspace✨ Spec✨ Tests▓ Debt Map✨ NL Search🏛 Archaeology
Blame · Line-by-line history
0044_pr_risk_scores.sql
Each line is annotated with the commit that last touched it. Click any SHA to jump to that commit and see the surrounding change.
| 534f04a | 1 | -- Block M3 — AI pre-merge risk score. |
| 2 | -- | |
| 3 | -- Cache of computed PR risk scores keyed on (pull_request_id, commit_sha). | |
| 4 | -- The score formula is documented in src/lib/pr-risk.ts and runs over a | |
| 5 | -- transparent set of signals; the AI summary is the only LLM-produced | |
| 6 | -- field. Storing both fields lets us re-render the badge cheaply on every | |
| 7 | -- PR detail view, while still letting reviewers re-trigger recomputation | |
| 8 | -- when a new push arrives. | |
| 9 | -- | |
| 10 | -- Strictly additive: no existing tables touched. | |
| 11 | ||
| 12 | CREATE TABLE IF NOT EXISTS "pr_risk_scores" ( | |
| 13 | "id" uuid PRIMARY KEY DEFAULT gen_random_uuid(), | |
| 14 | "pull_request_id" uuid NOT NULL REFERENCES "pull_requests"("id") ON DELETE CASCADE, | |
| 15 | "commit_sha" text NOT NULL, | |
| 16 | "score" integer NOT NULL, | |
| 17 | "band" text NOT NULL, | |
| 18 | "signals" jsonb NOT NULL, | |
| 19 | "ai_summary" text, | |
| 20 | "generated_at" timestamptz NOT NULL DEFAULT now(), | |
| 21 | UNIQUE ("pull_request_id", "commit_sha") | |
| 22 | ); | |
| 23 | ||
| 24 | CREATE INDEX IF NOT EXISTS "pr_risk_scores_pr_idx" ON "pr_risk_scores" ("pull_request_id"); |