g1t/crates/contracts/src/events.rs
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.
| Events service in Rust, with RFC 3339 times and accurate push events | 1 | //! Events published on the bus, and the events service that carries them. |
| 2 | //! Mirrors `packages/contracts/src/events.ts`. | |
| Rust repos service with shipping; pull requests kept in the model | 3 | |
| 4 | use serde::Serialize; | |
| 5 | ||
| 6 | /// What a publisher supplies; the bus fills in the id and time. | |
| 7 | #[derive(Debug, Serialize)] | |
| 8 | #[serde(rename_all = "camelCase")] | |
| 9 | pub struct NewEvent<T: Serialize> { | |
| 10 | #[serde(rename = "type")] | |
| 11 | pub kind: &'static str, | |
| 12 | /// The service that published it. | |
| 13 | pub source: &'static str, | |
| 14 | /// The repo the event concerns. | |
| 15 | pub repo_id: Option<String>, | |
| 16 | /// The user or agent that caused it, if any. | |
| 17 | pub actor: Option<String>, | |
| 18 | pub data: T, | |
| 19 | } | |
| 20 | ||
| 21 | #[derive(Debug, Serialize)] | |
| 22 | #[serde(rename_all = "camelCase")] | |
| 23 | pub struct RepoCreated { | |
| 24 | pub repo_id: String, | |
| 25 | pub namespace: String, | |
| 26 | pub name: String, | |
| 27 | pub is_private: bool, | |
| 28 | } | |
| 29 | ||
| 30 | #[derive(Debug, Serialize)] | |
| 31 | #[serde(rename_all = "camelCase")] | |
| 32 | pub struct RepoForked { | |
| 33 | pub repo_id: String, | |
| 34 | pub source_repo_id: String, | |
| Issues and pull requests replace intents and attempts | 35 | pub pull_id: String, |
| Rust repos service with shipping; pull requests kept in the model | 36 | } |
| 37 | ||
| Events service in Rust, with RFC 3339 times and accurate push events | 38 | /// One branch moved by a push. `after` is the commit it points to now. |
| Rust repos service with shipping; pull requests kept in the model | 39 | #[derive(Debug, Serialize)] |
| 40 | #[serde(rename_all = "camelCase")] | |
| 41 | pub struct GitPush { | |
| 42 | pub repo_id: String, | |
| Events service in Rust, with RFC 3339 times and accurate push events | 43 | /// The full ref, such as `refs/heads/main`. |
| Rust repos service with shipping; pull requests kept in the model | 44 | #[serde(rename = "ref")] |
| 45 | pub git_ref: String, | |
| 46 | pub after: String, | |
| Events service in Rust, with RFC 3339 times and accurate push events | 47 | /// Whether the ref is the repository's default branch. |
| 48 | pub default_branch: bool, | |
| Rust repos service with shipping; pull requests kept in the model | 49 | } |
| Work service in Rust, with RFC 3339 timestamps | 50 | |
| Agents as a team: lifecycle, merge queue, billing and a new shell | 51 | /// The payload of `issue.opened`, `issue.updated`, `issue.assigned`, |
| 52 | /// `issue.closed` and `issue.reopened`; each uses the fields that apply to it. | |
| Issues and pull requests replace intents and attempts | 53 | #[derive(Debug, Default, Serialize)] |
| Work service in Rust, with RFC 3339 timestamps | 54 | #[serde(rename_all = "camelCase")] |
| Issues and pull requests replace intents and attempts | 55 | pub struct IssueEvent { |
| 56 | pub issue_id: String, | |
| Work service in Rust, with RFC 3339 timestamps | 57 | pub repo_id: String, |
| 58 | pub number: u32, | |
| Issues and pull requests replace intents and attempts | 59 | #[serde(skip_serializing_if = "Option::is_none")] |
| 60 | pub title: Option<String>, | |
| 61 | /// On close: `completed` or `not_planned`. | |
| 62 | #[serde(skip_serializing_if = "Option::is_none")] | |
| 63 | pub reason: Option<&'static str>, | |
| 64 | /// On close: the number of the pull request whose merge closed it. | |
| 65 | #[serde(skip_serializing_if = "Option::is_none")] | |
| 66 | pub resolved_by: Option<u32>, | |
| Agents as a team: lifecycle, merge queue, billing and a new shell | 67 | /// On `issue.assigned`: the people it is now assigned to. |
| 68 | #[serde(skip_serializing_if = "Option::is_none")] | |
| 69 | pub assignees: Option<Vec<String>>, | |
| Work service in Rust, with RFC 3339 timestamps | 70 | } |
| 71 | ||
| Acceptance checks in sandboxes, line comments and review verdicts | 72 | /// The payload of `pull.opened`, `pull.ready`, `pull.updated` (its head |
| 73 | /// moved), `pull.closed` and `pull.merged`; each uses the fields that apply to it. | |
| Work service in Rust, with RFC 3339 timestamps | 74 | #[derive(Debug, Default, Serialize)] |
| 75 | #[serde(rename_all = "camelCase")] | |
| Issues and pull requests replace intents and attempts | 76 | pub struct PullEvent { |
| 77 | pub pull_id: String, | |
| Work service in Rust, with RFC 3339 timestamps | 78 | pub repo_id: String, |
| Issues and pull requests replace intents and attempts | 79 | pub number: u32, |
| 80 | /// The number of the issue it is for. | |
| 81 | #[serde(skip_serializing_if = "Option::is_none")] | |
| 82 | pub issue: Option<u32>, | |
| Work service in Rust, with RFC 3339 timestamps | 83 | #[serde(skip_serializing_if = "Option::is_none")] |
| 84 | pub agent: Option<String>, | |
| Issues and pull requests replace intents and attempts | 85 | /// On merge: the commit the branch now points to. |
| Work service in Rust, with RFC 3339 timestamps | 86 | #[serde(skip_serializing_if = "Option::is_none")] |
| Issues and pull requests replace intents and attempts | 87 | pub commit: Option<String>, |
| 88 | /// On close: the pull request that was merged instead. | |
| Work service in Rust, with RFC 3339 timestamps | 89 | #[serde(skip_serializing_if = "Option::is_none")] |
| Issues and pull requests replace intents and attempts | 90 | pub superseded_by: Option<u32>, |
| Work service in Rust, with RFC 3339 timestamps | 91 | } |
| 92 | ||
| Acceptance checks in sandboxes, line comments and review verdicts | 93 | /// `checks.completed`: a run of an issue's acceptance checks against a pull |
| 94 | /// request finished. | |
| 95 | #[derive(Debug, Serialize)] | |
| 96 | #[serde(rename_all = "camelCase")] | |
| 97 | pub struct ChecksEvent { | |
| 98 | pub pull_id: String, | |
| 99 | pub repo_id: String, | |
| 100 | pub number: u32, | |
| 101 | /// `passed`, `failed` or `errored`. | |
| 102 | pub status: &'static str, | |
| 103 | /// The commit that was checked. | |
| 104 | pub commit: String, | |
| 105 | } | |
| 106 | ||
| Agents as a team: lifecycle, merge queue, billing and a new shell | 107 | /// `review.completed`: a g1t agent finished reviewing a pull request, or |
| 108 | /// could not. | |
| 109 | #[derive(Debug, Serialize)] | |
| 110 | #[serde(rename_all = "camelCase")] | |
| 111 | pub struct ReviewEvent { | |
| 112 | pub pull_id: String, | |
| 113 | pub repo_id: String, | |
| 114 | pub number: u32, | |
| 115 | /// `approve` or `request_changes`; absent when no review was written. | |
| 116 | #[serde(skip_serializing_if = "Option::is_none")] | |
| 117 | pub verdict: Option<&'static str>, | |
| 118 | } | |
| 119 | ||
| Issues and pull requests replace intents and attempts | 120 | /// `comment.created`. `number` is the issue or pull request commented on. |
| Work service in Rust, with RFC 3339 timestamps | 121 | #[derive(Debug, Serialize)] |
| 122 | #[serde(rename_all = "camelCase")] | |
| Issues and pull requests replace intents and attempts | 123 | pub struct CommentCreated { |
| 124 | pub comment_id: String, | |
| 125 | pub repo_id: String, | |
| 126 | pub number: u32, | |
| Agents as a team: lifecycle, merge queue, billing and a new shell | 127 | /// Set when the comment is on a pull request. |
| 128 | #[serde(skip_serializing_if = "Option::is_none")] | |
| 129 | pub pull_id: Option<String>, | |
| 130 | /// Set when the comment is a review: approve or request changes. | |
| 131 | #[serde(skip_serializing_if = "Option::is_none")] | |
| 132 | pub verdict: Option<crate::work::Verdict>, | |
| Issues and pull requests replace intents and attempts | 133 | } |
| 134 | ||
| 135 | #[derive(Debug, Serialize)] | |
| 136 | #[serde(rename_all = "camelCase")] | |
| Work service in Rust, with RFC 3339 timestamps | 137 | pub struct SessionAppended { |
| Issues and pull requests replace intents and attempts | 138 | pub pull_id: String, |
| 139 | pub repo_id: String, | |
| 140 | pub number: u32, | |
| Work service in Rust, with RFC 3339 timestamps | 141 | pub count: u32, |
| 142 | } | |
| 143 | ||
| Events service in Rust, with RFC 3339 times and accurate push events | 144 | /// An event as stored in the log and delivered to subscribers. `data` is |
| 145 | /// left as JSON; each reader decodes the types it cares about. | |
| 146 | #[derive(Clone, Debug, Serialize, serde::Deserialize)] | |
| 147 | #[serde(rename_all = "camelCase")] | |
| 148 | pub struct Event { | |
| 149 | /// Sorts by the time the event was published. | |
| 150 | pub id: String, | |
| 151 | #[serde(rename = "type")] | |
| 152 | pub kind: String, | |
| 153 | /// The service that published it. | |
| 154 | pub source: String, | |
| 155 | /// RFC 3339. | |
| 156 | pub time: String, | |
| 157 | /// The repo the event concerns. | |
| 158 | pub repo_id: Option<String>, | |
| 159 | /// The user or agent that caused it, if any. | |
| 160 | pub actor: Option<String>, | |
| 161 | pub data: serde_json::Value, | |
| 162 | } | |
| 163 | ||
| 164 | /// `publish`, as a publisher sends it. Returns nothing. | |
| 165 | #[derive(Debug, Serialize)] | |
| 166 | pub struct Publish<T: Serialize> { | |
| 167 | pub events: Vec<NewEvent<T>>, | |
| 168 | } | |
| 169 | ||
| 170 | /// `publish`, as the events service reads it. | |
| 171 | #[derive(Debug, serde::Deserialize)] | |
| 172 | pub struct PublishArgs { | |
| 173 | pub events: Vec<Published>, | |
| 174 | } | |
| 175 | ||
| 176 | /// A [`NewEvent`] of any type, as received. | |
| Work service in Rust, with RFC 3339 timestamps | 177 | #[derive(Debug, serde::Deserialize)] |
| 178 | #[serde(rename_all = "camelCase")] | |
| Events service in Rust, with RFC 3339 times and accurate push events | 179 | pub struct Published { |
| Work service in Rust, with RFC 3339 timestamps | 180 | #[serde(rename = "type")] |
| 181 | pub kind: String, | |
| Events service in Rust, with RFC 3339 times and accurate push events | 182 | pub source: String, |
| 183 | #[serde(default)] | |
| Work service in Rust, with RFC 3339 timestamps | 184 | pub repo_id: Option<String>, |
| Events service in Rust, with RFC 3339 times and accurate push events | 185 | #[serde(default)] |
| 186 | pub actor: Option<String>, | |
| Work service in Rust, with RFC 3339 timestamps | 187 | pub data: serde_json::Value, |
| 188 | } | |
| Events service in Rust, with RFC 3339 times and accurate push events | 189 | |
| 190 | /// `list`: events from the log, newest first. Returns `Vec<Event>`. | |
| 191 | #[derive(Debug, Default, Serialize, serde::Deserialize)] | |
| 192 | #[serde(rename_all = "camelCase")] | |
| 193 | pub struct ListArgs { | |
| 194 | #[serde(default)] | |
| 195 | pub repo_id: Option<String>, | |
| 196 | /// Only these types; all types when empty. | |
| 197 | #[serde(default)] | |
| 198 | pub types: Vec<String>, | |
| 199 | /// Only events older than this event id. | |
| 200 | #[serde(default)] | |
| 201 | pub before: Option<String>, | |
| 202 | #[serde(default)] | |
| 203 | pub limit: Option<u32>, | |
| 204 | } | |
| Agents as a team: lifecycle, merge queue, billing and a new shell | 205 | |
| 206 | /// `queue.changed`: a repository's merge queue gained, lost or settled an | |
| 207 | /// entry, so the next batch may be ready to test. | |
| 208 | #[derive(Debug, Serialize)] | |
| 209 | #[serde(rename_all = "camelCase")] | |
| 210 | pub struct QueueChanged { | |
| 211 | pub repo_id: String, | |
| 212 | } |