flagon-io/g1t

public

Where people and agents ship software together. The open-source git platform for the whole job: issues, agents, checks and deploys to the edge.

g1t/services/work/migrations/0015_agent_runs_and_memory.sql

65 lines2,215 bytesCodeBlame
1-- Every sandbox g1t starts for an agent (and for checks and the merge
2-- queue): what it works on, step by step, what it cost and how it ended.
3CREATE TABLE agent_runs (
4 id TEXT PRIMARY KEY,
5 -- The workspace's slug, for the fleet across its projects.
6 workspace TEXT NOT NULL,
7 repo_id TEXT NOT NULL,
8 -- "<owner>/<name>" when it started, for showing it.
9 repo TEXT NOT NULL,
10 number INTEGER,
11 pull_id TEXT,
12 title TEXT,
13 -- implement, revise, review, answer, update, plan, checks, queue, mergecheck
14 kind TEXT NOT NULL,
15 agent TEXT NOT NULL,
16 model TEXT,
17 -- queued, running, succeeded, failed, stopped
18 status TEXT NOT NULL,
19 step TEXT,
20 -- JSON array of { at, text }, the latest 200.
21 steps TEXT NOT NULL DEFAULT '[]',
22 step_count INTEGER NOT NULL DEFAULT 0,
23 cost_usd REAL,
24 turns INTEGER,
25 -- The sandbox's name, which stopping it needs.
26 sandbox TEXT NOT NULL,
27 token_hash TEXT NOT NULL,
28 started_by TEXT,
29 error TEXT,
30 created_at TEXT NOT NULL,
31 started_at TEXT,
32 finished_at TEXT,
33 updated_at TEXT NOT NULL
34);
35CREATE INDEX agent_runs_by_repo ON agent_runs (repo_id, created_at);
36CREATE INDEX agent_runs_by_workspace ON agent_runs (workspace, created_at);
37CREATE INDEX agent_runs_by_pull ON agent_runs (pull_id, created_at);
38CREATE INDEX agent_runs_active ON agent_runs (status, created_at);
39
40-- What agents and people learned that the next agent should know: about a
41-- project (scope_key is its repository's id) or about the whole workspace
42-- (scope_key is the workspace's slug).
43CREATE TABLE memories (
44 id TEXT PRIMARY KEY,
45 scope TEXT NOT NULL,
46 scope_key TEXT NOT NULL,
47 workspace TEXT NOT NULL,
48 -- For a project's memory: "<owner>/<name>", for showing it.
49 repo TEXT,
50 text TEXT NOT NULL,
51 -- fact, convention, decision, gotcha
52 kind TEXT NOT NULL,
53 -- person, agent or run
54 source_kind TEXT NOT NULL,
55 source_run TEXT,
56 source_repo TEXT,
57 source_number INTEGER,
58 created_by TEXT NOT NULL,
59 pinned INTEGER NOT NULL DEFAULT 0,
60 created_at TEXT NOT NULL,
61 updated_at TEXT NOT NULL,
62 last_used_at TEXT
63);
64CREATE INDEX memories_by_scope ON memories (scope, scope_key, pinned, last_used_at);
65CREATE INDEX memories_by_workspace ON memories (workspace);