Pre-launch — Gluecron is in final validation. Public signups and git hosting for non-owner users open after launch review.
CodeIssuesPull RequestsActionsSecurityInsightsSettings
✨ AI
More
Blame · Line-by-line history

0034_agent_runs.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.

0034_agent_runs.sqlBlame35 lines · 1 contributor
a6d8fd5Claude1-- Block K1 — Autonomous agent runtime + sandbox.
2--
3-- The substrate every other Block K agent (triage, fix, review_response,
4-- deploy_watcher, heal_bot) runs on top of. A single row records one
5-- invocation: its kind + trigger (what fired it), its status lifecycle
6-- (queued → running → succeeded/failed/killed/timeout), a short summary,
7-- a size-capped append-only log (256 KB), cost accounting (input/output
8-- tokens + cents), and optional error_message on failure.
9
10CREATE TABLE IF NOT EXISTS "agent_runs" (
11 "id" uuid PRIMARY KEY DEFAULT gen_random_uuid(),
12 "repository_id" uuid NOT NULL REFERENCES "repositories"("id") ON DELETE CASCADE,
13 "kind" text NOT NULL, -- 'triage' | 'fix' | 'review_response' | 'deploy_watcher' | 'heal_bot' | 'custom'
14 "trigger" text NOT NULL, -- 'issue.opened' | 'pr.opened' | 'pr.review_comment' | 'deploy.failed' | 'manual' | 'scheduled'
15 "trigger_ref" text, -- e.g. issue number, PR number, commit sha
16 "status" text NOT NULL DEFAULT 'queued', -- 'queued' | 'running' | 'succeeded' | 'failed' | 'killed' | 'timeout'
17 "summary" text,
18 "log" text NOT NULL DEFAULT '',
19 "cost_input_tokens" integer NOT NULL DEFAULT 0,
20 "cost_output_tokens" integer NOT NULL DEFAULT 0,
21 "cost_cents" integer NOT NULL DEFAULT 0,
22 "started_at" timestamp,
23 "finished_at" timestamp,
24 "created_at" timestamp NOT NULL DEFAULT now(),
25 "error_message" text
26);
27
28CREATE INDEX IF NOT EXISTS "agent_runs_repo_created_idx"
29 ON "agent_runs" ("repository_id", "created_at" DESC);
30
31CREATE INDEX IF NOT EXISTS "agent_runs_status_idx"
32 ON "agent_runs" ("status");
33
34CREATE INDEX IF NOT EXISTS "agent_runs_kind_status_idx"
35 ON "agent_runs" ("kind", "status");