Pick any line to see why it is the way it is: the commit, the pull request and issue it came from, and what the agent was thinking.
| Work service in Rust, with RFC 3339 timestamps | 1 | //! Rows as they come out of D1, and their conversion to contract types. |
| 2 | ||
| 3 | use g1t_contracts::User; | |
| 4 | use g1t_contracts::repos::RepoPath; | |
| 5 | use g1t_contracts::work::{ | |
| Agents as a team: lifecycle, merge queue, billing and a new shell | 6 | CheckStatus, Comment, CommentKind, Issue, IssueReason, Pull, PullStatus, Runtime, SessionEntry, |
| Acceptance checks in sandboxes, line comments and review verdicts | 7 | SessionEntryKind, State, Verdict, |
| Work service in Rust, with RFC 3339 timestamps | 8 | }; |
| 9 | use serde::Deserialize; | |
| 10 | ||
| Agents as a team: lifecycle, merge queue, billing and a new shell | 11 | pub(crate) fn user(id: String, username: String) -> User { |
| Issues and pull requests replace intents and attempts | 12 | User { |
| 13 | id, | |
| 14 | username, | |
| 15 | ..User::default() | |
| 16 | } | |
| 17 | } | |
| 18 | ||
| Work service in Rust, with RFC 3339 timestamps | 19 | #[derive(Deserialize)] |
| Issues and pull requests replace intents and attempts | 20 | pub struct IssueRow { |
| Work service in Rust, with RFC 3339 timestamps | 21 | pub id: String, |
| 22 | pub repo_id: String, | |
| 23 | pub number: u32, | |
| 24 | pub title: String, | |
| Issues and pull requests replace intents and attempts | 25 | pub body: String, |
| 26 | /// JSON array of label names. | |
| 27 | pub labels: String, | |
| 28 | pub state: State, | |
| 29 | pub reason: Option<IssueReason>, | |
| 30 | pub resolved_by: Option<u32>, | |
| Work service in Rust, with RFC 3339 timestamps | 31 | pub author_id: String, |
| 32 | pub author_name: String, | |
| 33 | pub created_at: String, | |
| Issues and pull requests replace intents and attempts | 34 | pub updated_at: String, |
| 35 | pub closed_at: Option<String>, | |
| 36 | pub pull_count: u32, | |
| 37 | pub comment_count: u32, | |
| Agents as a team: lifecycle, merge queue, billing and a new shell | 38 | /// JSON array of usernames. |
| 39 | pub assignees: String, | |
| 40 | /// JSON array of issue numbers. | |
| 41 | pub blocked_by: String, | |
| 42 | /// JSON of who queued it for a g1t agent, if anyone has. | |
| 43 | pub queued_by: Option<String>, | |
| 44 | pub agent: Option<String>, | |
| Work service in Rust, with RFC 3339 timestamps | 45 | } |
| 46 | ||
| Issues and pull requests replace intents and attempts | 47 | impl From<IssueRow> for Issue { |
| 48 | fn from(row: IssueRow) -> Self { | |
| 49 | Issue { | |
| Work service in Rust, with RFC 3339 timestamps | 50 | id: row.id, |
| 51 | repo_id: row.repo_id, | |
| 52 | number: row.number, | |
| 53 | title: row.title, | |
| Issues and pull requests replace intents and attempts | 54 | body: row.body, |
| 55 | labels: serde_json::from_str(&row.labels).unwrap_or_default(), | |
| 56 | state: row.state, | |
| 57 | reason: row.reason, | |
| 58 | resolved_by: row.resolved_by, | |
| 59 | author: user(row.author_id, row.author_name), | |
| Work service in Rust, with RFC 3339 timestamps | 60 | created_at: row.created_at, |
| Issues and pull requests replace intents and attempts | 61 | updated_at: row.updated_at, |
| 62 | closed_at: row.closed_at, | |
| 63 | pull_count: row.pull_count, | |
| 64 | comment_count: row.comment_count, | |
| Agents as a team: lifecycle, merge queue, billing and a new shell | 65 | assignees: serde_json::from_str(&row.assignees).unwrap_or_default(), |
| 66 | blocked_by: serde_json::from_str(&row.blocked_by).unwrap_or_default(), | |
| 67 | queued: row.queued_by.is_some(), | |
| 68 | agent: row.agent, | |
| Work service in Rust, with RFC 3339 timestamps | 69 | } |
| 70 | } | |
| 71 | } | |
| 72 | ||
| Agents as a team: lifecycle, merge queue, billing and a new shell | 73 | /// The remembered assessment of a pull request, read beside its row. |
| Work service in Rust, with RFC 3339 timestamps | 74 | #[derive(Deserialize)] |
| Agents as a team: lifecycle, merge queue, billing and a new shell | 75 | pub struct Snapshot { |
| 76 | pub stage: Option<g1t_contracts::work::Stage>, | |
| 77 | pub stage_detail: Option<String>, | |
| 78 | #[serde(default)] | |
| 79 | pub revisions: u32, | |
| 80 | /// Whether g1t is seeing it through at all. | |
| 81 | #[serde(default)] | |
| 82 | pub managed: u32, | |
| 83 | } | |
| 84 | ||
| Thirteen MCP tools and classic token scopes; agents rate their confidence and can be put on an issue in one step | 85 | /// A pull request's columns, with its confidence (confidence.rs) beside |
| 86 | /// them: what every read of a [`PullRow`] selects. | |
| 87 | pub const PULL_COLUMNS: &str = | |
| 88 | "pulls.*, (SELECT detail FROM pull_confidence WHERE pull_confidence.pull_id = pulls.id) AS confidence"; | |
| 89 | ||
| Agents as a team: lifecycle, merge queue, billing and a new shell | 90 | #[derive(Deserialize)] |
| Issues and pull requests replace intents and attempts | 91 | pub struct PullRow { |
| Work service in Rust, with RFC 3339 timestamps | 92 | pub id: String, |
| 93 | pub repo_id: String, | |
| 94 | pub number: u32, | |
| Issues and pull requests replace intents and attempts | 95 | pub issue_number: Option<u32>, |
| 96 | pub title: String, | |
| 97 | pub body: Option<String>, | |
| Work service in Rust, with RFC 3339 timestamps | 98 | pub agent: String, |
| Issues and pull requests replace intents and attempts | 99 | pub runtime: Runtime, |
| 100 | pub status: PullStatus, | |
| Pull requests from branches | 101 | pub fork_repo_id: Option<String>, |
| 102 | pub fork_namespace: Option<String>, | |
| 103 | pub fork_name: Option<String>, | |
| 104 | pub source_branch: Option<String>, | |
| Work service in Rust, with RFC 3339 timestamps | 105 | pub head_commit: Option<String>, |
| Issues and pull requests replace intents and attempts | 106 | pub merge_base: Option<String>, |
| 107 | pub merged_by: Option<String>, | |
| 108 | pub merged_at: Option<String>, | |
| 109 | pub superseded_by: Option<u32>, | |
| Acceptance checks in sandboxes, line comments and review verdicts | 110 | pub check_status: Option<CheckStatus>, |
| Agents as a team: lifecycle, merge queue, billing and a new shell | 111 | /// JSON array of changed files; `None` until first worked out. |
| 112 | pub files: Option<String>, | |
| 113 | /// JSON arrays of usernames. | |
| 114 | pub assignees: String, | |
| 115 | pub reviewers: String, | |
| Issues and pull requests replace intents and attempts | 116 | pub author_id: String, |
| 117 | pub author_name: String, | |
| Work service in Rust, with RFC 3339 timestamps | 118 | pub created_at: String, |
| 119 | pub updated_at: String, | |
| Thirteen MCP tools and classic token scopes; agents rate their confidence and can be put on an issue in one step | 120 | /// JSON of its confidence, once worked out. |
| 121 | #[serde(default)] | |
| 122 | pub confidence: Option<String>, | |
| Work service in Rust, with RFC 3339 timestamps | 123 | } |
| 124 | ||
| Issues and pull requests replace intents and attempts | 125 | impl From<PullRow> for Pull { |
| 126 | fn from(row: PullRow) -> Self { | |
| 127 | Pull { | |
| Work service in Rust, with RFC 3339 timestamps | 128 | id: row.id, |
| 129 | repo_id: row.repo_id, | |
| 130 | number: row.number, | |
| Issues and pull requests replace intents and attempts | 131 | issue: row.issue_number, |
| 132 | title: row.title, | |
| 133 | body: row.body, | |
| Work service in Rust, with RFC 3339 timestamps | 134 | agent: row.agent, |
| 135 | runtime: row.runtime, | |
| 136 | status: row.status, | |
| Pull requests from branches | 137 | fork: row |
| 138 | .fork_namespace | |
| 139 | .zip(row.fork_name) | |
| 140 | .map(|(namespace, name)| RepoPath { namespace, name }), | |
| Work service in Rust, with RFC 3339 timestamps | 141 | fork_repo_id: row.fork_repo_id, |
| Pull requests from branches | 142 | branch: row.source_branch, |
| Work service in Rust, with RFC 3339 timestamps | 143 | head_commit: row.head_commit, |
| Issues and pull requests replace intents and attempts | 144 | merge_base: row.merge_base, |
| 145 | merged_by: row.merged_by, | |
| 146 | merged_at: row.merged_at, | |
| 147 | superseded_by: row.superseded_by, | |
| Acceptance checks in sandboxes, line comments and review verdicts | 148 | check_status: row.check_status, |
| Agents as a team: lifecycle, merge queue, billing and a new shell | 149 | files: row |
| 150 | .files | |
| 151 | .as_deref() | |
| 152 | .and_then(|files| serde_json::from_str(files).ok()) | |
| 153 | .unwrap_or_default(), | |
| 154 | assignees: serde_json::from_str(&row.assignees).unwrap_or_default(), | |
| 155 | reviewers: serde_json::from_str(&row.reviewers).unwrap_or_default(), | |
| Issues and pull requests replace intents and attempts | 156 | author: user(row.author_id, row.author_name), |
| Work service in Rust, with RFC 3339 timestamps | 157 | created_at: row.created_at, |
| 158 | updated_at: row.updated_at, | |
| Thirteen MCP tools and classic token scopes; agents rate their confidence and can be put on an issue in one step | 159 | confidence: row |
| 160 | .confidence | |
| 161 | .as_deref() | |
| 162 | .and_then(|detail| serde_json::from_str(detail).ok()), | |
| Work service in Rust, with RFC 3339 timestamps | 163 | } |
| 164 | } | |
| 165 | } | |
| 166 | ||
| 167 | #[derive(Deserialize)] | |
| Issues and pull requests replace intents and attempts | 168 | pub struct CommentRow { |
| 169 | pub id: String, | |
| Agents as a team: lifecycle, merge queue, billing and a new shell | 170 | pub kind: CommentKind, |
| Issues and pull requests replace intents and attempts | 171 | pub author_id: String, |
| 172 | pub author_name: String, | |
| 173 | pub body: String, | |
| Acceptance checks in sandboxes, line comments and review verdicts | 174 | pub path: Option<String>, |
| 175 | pub line: Option<u32>, | |
| 176 | pub verdict: Option<Verdict>, | |
| Issues and pull requests replace intents and attempts | 177 | pub created_at: String, |
| 178 | } | |
| 179 | ||
| 180 | impl From<CommentRow> for Comment { | |
| 181 | fn from(row: CommentRow) -> Self { | |
| 182 | Comment { | |
| 183 | id: row.id, | |
| Agents as a team: lifecycle, merge queue, billing and a new shell | 184 | kind: row.kind, |
| Issues and pull requests replace intents and attempts | 185 | author: user(row.author_id, row.author_name), |
| 186 | body: row.body, | |
| Acceptance checks in sandboxes, line comments and review verdicts | 187 | path: row.path, |
| 188 | line: row.line, | |
| 189 | verdict: row.verdict, | |
| Issues and pull requests replace intents and attempts | 190 | created_at: row.created_at, |
| 191 | } | |
| 192 | } | |
| 193 | } | |
| 194 | ||
| 195 | #[derive(Deserialize)] | |
| Work service in Rust, with RFC 3339 timestamps | 196 | pub struct SessionRow { |
| 197 | pub seq: u32, | |
| 198 | pub kind: SessionEntryKind, | |
| 199 | pub text: String, | |
| 200 | pub tool: Option<String>, | |
| 201 | pub commit: Option<String>, | |
| 202 | pub at: String, | |
| 203 | } | |
| 204 | ||
| 205 | impl From<SessionRow> for SessionEntry { | |
| 206 | fn from(row: SessionRow) -> Self { | |
| 207 | SessionEntry { | |
| 208 | seq: row.seq, | |
| 209 | kind: row.kind, | |
| 210 | text: row.text, | |
| 211 | tool: row.tool, | |
| 212 | commit: row.commit, | |
| 213 | at: row.at, | |
| 214 | } | |
| 215 | } | |
| 216 | } | |
| Issues and pull requests replace intents and attempts | 217 | |
| Acceptance checks in sandboxes, line comments and review verdicts | 218 | /// A pull request whose head a push moved. |
| 219 | #[derive(Deserialize)] | |
| 220 | pub struct MovedRow { | |
| 221 | pub id: String, | |
| 222 | pub repo_id: String, | |
| 223 | pub number: u32, | |
| 224 | pub issue_number: Option<u32>, | |
| 225 | pub status: PullStatus, | |
| 226 | } | |
| 227 | ||
| Issues and pull requests replace intents and attempts | 228 | /// A single number selected as `n`. |
| 229 | #[derive(Deserialize)] | |
| 230 | pub struct NumberRow { | |
| 231 | pub n: u32, | |
| 232 | } | |
| 233 | ||
| 234 | /// A single string selected as `value`. | |
| 235 | #[derive(Deserialize)] | |
| 236 | pub struct ValueRow { | |
| 237 | pub value: String, | |
| 238 | } |