pr_01m47d24b0e6n91zwymwxg0vpx/crates/contracts/src/work.rs

1,402 lines46,168 bytesCodeBlame
1//! The work service: issues, pull requests, comments and sessions.
2//!
3//! Each `*Args` struct is the argument of the method of the same name,
4//! served at `POST /rpc/<method>`.
5//!
6//! Issues and pull requests share one sequence of numbers per repository,
7//! so `#12` names exactly one of them.
8
9use serde::{Deserialize, Serialize};
10
11use crate::repos::{CompareArgs, RepoPath};
12use crate::{User, Viewer};
13
14/// Labels every repository starts with. Any other label comes into being
15/// the first time it is put on an issue.
16pub const DEFAULT_LABELS: [&str; 5] = ["bug", "feature", "docs", "chore", "question"];
17
18/// `open` or `closed`: the filter on lists of issues and pull requests. An
19/// open pull request is a draft or one ready for review; a closed one was
20/// merged or closed without merging.
21#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)]
22#[serde(rename_all = "lowercase")]
23pub enum State {
24 Open,
25 Closed,
26}
27
28/// Why an issue was closed.
29#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)]
30#[serde(rename_all = "snake_case")]
31pub enum IssueReason {
32 /// The work was done. If a pull request did it, `resolved_by` names it.
33 Completed,
34 NotPlanned,
35}
36
37impl IssueReason {
38 pub fn as_str(self) -> &'static str {
39 match self {
40 IssueReason::Completed => "completed",
41 IssueReason::NotPlanned => "not_planned",
42 }
43 }
44}
45
46/// Something that should change in a repository: a bug, a feature, a
47/// question. Opened by a person, an agent or an integration. Pull requests
48/// are made against it; the one that is merged resolves it.
49#[derive(Clone, Debug, Serialize, Deserialize)]
50#[serde(rename_all = "camelCase")]
51pub struct Issue {
52 pub id: String,
53 pub repo_id: String,
54 /// Shown as `#12`.
55 pub number: u32,
56 pub title: String,
57 /// Markdown. Also what an agent is given to work from.
58 pub body: String,
59 pub labels: Vec<String>,
60 /// Commands that must pass for a pull request to be accepted.
61 pub checks: Vec<String>,
62 pub state: State,
63 /// Set when closed.
64 pub reason: Option<IssueReason>,
65 /// The number of the pull request whose merge closed this issue.
66 pub resolved_by: Option<u32>,
67 pub author: User,
68 /// RFC 3339.
69 pub created_at: String,
70 /// RFC 3339.
71 pub updated_at: String,
72 /// RFC 3339.
73 pub closed_at: Option<String>,
74 /// Pull requests made against this issue, in any state.
75 pub pull_count: u32,
76 pub comment_count: u32,
77 /// Usernames of the people it is assigned to.
78 #[serde(default)]
79 pub assignees: Vec<String>,
80 /// The numbers of the issues that have to be merged before this one is
81 /// worked on.
82 #[serde(default)]
83 pub blocked_by: Vec<u32>,
84 /// Whether a g1t agent takes it as soon as it can: at once, or when
85 /// what it is blocked by has merged.
86 #[serde(default)]
87 pub queued: bool,
88 /// The agent working on it now: the one behind its newest pull request
89 /// that is still in progress in a fork, such as `g1t-agent`.
90 #[serde(default)]
91 pub agent: Option<String>,
92}
93
94#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)]
95#[serde(rename_all = "lowercase")]
96pub enum PullStatus {
97 /// Still being worked on.
98 Draft,
99 /// Ready for review.
100 Open,
101 Merged,
102 /// Closed without merging.
103 Closed,
104}
105
106impl PullStatus {
107 pub fn as_str(self) -> &'static str {
108 match self {
109 PullStatus::Draft => "draft",
110 PullStatus::Open => "open",
111 PullStatus::Merged => "merged",
112 PullStatus::Closed => "closed",
113 }
114 }
115
116 /// Whether the pull request can still be changed or merged.
117 pub fn is_active(self) -> bool {
118 matches!(self, PullStatus::Draft | PullStatus::Open)
119 }
120}
121
122/// Where the agent runs: on g1t's sandboxes, or in someone's own session.
123#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)]
124#[serde(rename_all = "lowercase")]
125pub enum Runtime {
126 Hosted,
127 External,
128}
129
130/// A proposed change. It is made either in a fork created for it, which is
131/// how agents work, or on a branch pushed to the repository itself.
132#[derive(Clone, Debug, Serialize, Deserialize)]
133#[serde(rename_all = "camelCase")]
134pub struct Pull {
135 pub id: String,
136 pub repo_id: String,
137 /// Shown as `#12`.
138 pub number: u32,
139 /// The number of the issue this is for, if any.
140 pub issue: Option<u32>,
141 pub title: String,
142 /// Markdown: what changed and why. Set when marked ready.
143 pub body: Option<String>,
144 /// A label for the agent doing the work, e.g. `claude-code`.
145 pub agent: String,
146 pub runtime: Runtime,
147 pub status: PullStatus,
148 /// The fork holding the change, unless it is on a branch.
149 pub fork: Option<RepoPath>,
150 /// The fork's repository id.
151 pub fork_repo_id: Option<String>,
152 /// The branch of the repository holding the change, unless it is in a
153 /// fork.
154 pub branch: Option<String>,
155 pub head_commit: Option<String>,
156 /// For a merged pull request, what the branch pointed to before the
157 /// merge. Comparing against it shows what the pull request changed.
158 pub merge_base: Option<String>,
159 /// Username of whoever merged it.
160 pub merged_by: Option<String>,
161 /// RFC 3339.
162 pub merged_at: Option<String>,
163 /// Set on a pull request closed because another one for the same issue
164 /// was merged: that one's number.
165 pub superseded_by: Option<u32>,
166 /// Where the latest run of the issue's acceptance checks stands, if
167 /// there has been one against the current head.
168 pub check_status: Option<CheckStatus>,
169 /// The files it changes, as of its latest push.
170 #[serde(default)]
171 pub files: Vec<ChangedFile>,
172 /// Usernames of the people it is assigned to.
173 #[serde(default)]
174 pub assignees: Vec<String>,
175 /// Those whose review was asked for: usernames, and `g1t-agent` when a
176 /// g1t agent was asked.
177 #[serde(default)]
178 pub reviewers: Vec<String>,
179 pub author: User,
180 /// RFC 3339.
181 pub created_at: String,
182 /// RFC 3339.
183 pub updated_at: String,
184}
185
186/// One file a pull request changes, and by how much.
187#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
188pub struct ChangedFile {
189 pub path: String,
190 pub additions: u32,
191 pub deletions: u32,
192}
193
194/// Another pull request in progress that changes some of the same files.
195/// Two for the same issue are alternatives; two for different issues are
196/// heading for a conflict.
197#[derive(Clone, Debug, Serialize, Deserialize)]
198pub struct Overlap {
199 pub number: u32,
200 pub title: String,
201 /// The number of the issue the other pull request is for.
202 pub issue: Option<u32>,
203 /// The files both change.
204 pub paths: Vec<String>,
205}
206
207impl Pull {
208 /// What to ask the repos service to see what this pull request changes.
209 ///
210 /// A fork is compared as a whole. A branch is compared by name while
211 /// the pull request is open, and by the commit it was merged or closed
212 /// at afterwards, so later pushes to the branch do not change the record.
213 pub fn comparison(&self, viewer: &Viewer) -> CompareArgs {
214 let settled = matches!(self.status, PullStatus::Merged | PullStatus::Closed);
215 let (repo_id, head) = match &self.fork_repo_id {
216 Some(fork) => (fork.clone(), None),
217 None => (
218 self.repo_id.clone(),
219 self.head_commit
220 .clone()
221 .filter(|_| settled)
222 .or_else(|| self.branch.clone()),
223 ),
224 };
225 CompareArgs {
226 repo_id,
227 viewer: viewer.clone(),
228 base: self.merge_base.clone(),
229 head,
230 }
231 }
232}
233
234#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)]
235#[serde(rename_all = "lowercase")]
236pub enum CheckStatus {
237 /// Waiting for a sandbox.
238 Queued,
239 Running,
240 Passed,
241 Failed,
242 /// The checks could not be run at all.
243 Errored,
244}
245
246impl CheckStatus {
247 pub fn as_str(self) -> &'static str {
248 match self {
249 CheckStatus::Queued => "queued",
250 CheckStatus::Running => "running",
251 CheckStatus::Passed => "passed",
252 CheckStatus::Failed => "failed",
253 CheckStatus::Errored => "errored",
254 }
255 }
256}
257
258/// How one acceptance check went.
259#[derive(Clone, Debug, Serialize, Deserialize)]
260#[serde(rename_all = "camelCase")]
261pub struct CheckResult {
262 pub command: String,
263 pub passed: bool,
264 /// Absent when the command was stopped for taking too long.
265 #[serde(default)]
266 pub exit_code: Option<i32>,
267 /// What the command printed, standard output and error together. The
268 /// end of it, when there was a lot.
269 #[serde(default)]
270 pub output: String,
271 #[serde(default)]
272 pub duration_ms: u64,
273}
274
275/// One run of an issue's acceptance checks against a pull request's head,
276/// in a sandbox that holds nothing but that commit.
277#[derive(Clone, Debug, Serialize, Deserialize)]
278#[serde(rename_all = "camelCase")]
279pub struct CheckRun {
280 pub id: String,
281 /// The commit that was checked.
282 pub head_commit: String,
283 pub status: CheckStatus,
284 pub results: Vec<CheckResult>,
285 /// Why the checks could not be run, when `status` is `errored`.
286 pub error: Option<String>,
287 /// RFC 3339.
288 pub created_at: String,
289 /// RFC 3339.
290 pub finished_at: Option<String>,
291}
292
293/// A reviewer's decision on a pull request.
294#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)]
295#[serde(rename_all = "snake_case")]
296pub enum Verdict {
297 Approve,
298 RequestChanges,
299}
300
301impl Verdict {
302 pub fn as_str(self) -> &'static str {
303 match self {
304 Verdict::Approve => "approve",
305 Verdict::RequestChanges => "request_changes",
306 }
307 }
308}
309
310/// What an entry in a conversation is.
311#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Serialize, Deserialize)]
312#[serde(rename_all = "lowercase")]
313pub enum CommentKind {
314 /// Something a person or an agent wrote.
315 #[default]
316 Comment,
317 /// Something that happened: an assignment, a review asked for, a close.
318 Event,
319}
320
321/// A comment on an issue or a pull request. On a pull request it can sit
322/// on one line of the change, and it can carry a reviewer's verdict.
323#[derive(Clone, Debug, Serialize, Deserialize)]
324#[serde(rename_all = "camelCase")]
325pub struct Comment {
326 pub id: String,
327 /// Something a person wrote, or something that happened.
328 #[serde(default)]
329 pub kind: CommentKind,
330 pub author: User,
331 /// Markdown. For an event, what its author did, as the rest of a
332 /// sentence that starts with their name: "assigned ana".
333 pub body: String,
334 /// The file commented on, for a comment on a line.
335 pub path: Option<String>,
336 /// The line of that file, as numbered after the change.
337 pub line: Option<u32>,
338 pub verdict: Option<Verdict>,
339 /// RFC 3339.
340 pub created_at: String,
341}
342
343#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)]
344#[serde(rename_all = "snake_case")]
345pub enum SessionEntryKind {
346 Prompt,
347 Message,
348 ToolCall,
349 ToolResult,
350 Note,
351}
352
353/// One step of an agent's session: the "why" behind a pull request's commits.
354#[derive(Clone, Debug, Serialize, Deserialize)]
355pub struct SessionEntry {
356 pub seq: u32,
357 pub kind: SessionEntryKind,
358 pub text: String,
359 /// For tool calls and results.
360 pub tool: Option<String>,
361 /// The fork's head commit when this entry was recorded, if known.
362 pub commit: Option<String>,
363 /// RFC 3339.
364 pub at: String,
365}
366
367#[derive(Clone, Debug, Serialize, Deserialize)]
368pub struct NewSessionEntry {
369 pub kind: SessionEntryKind,
370 pub text: String,
371 #[serde(default)]
372 pub tool: Option<String>,
373 #[serde(default)]
374 pub commit: Option<String>,
375}
376
377#[derive(Clone, Debug, Serialize, Deserialize)]
378pub struct IssueDetail {
379 pub issue: Issue,
380 /// Every pull request made against it, oldest first.
381 pub pulls: Vec<Pull>,
382 pub comments: Vec<Comment>,
383}
384
385#[derive(Clone, Debug, Serialize, Deserialize)]
386pub struct PullDetail {
387 pub pull: Pull,
388 /// The issue it is for, if any.
389 pub issue: Option<Issue>,
390 pub comments: Vec<Comment>,
391 /// The latest run of the issue's acceptance checks.
392 pub checks: Option<CheckRun>,
393 /// Other pull requests in progress that change the same files.
394 #[serde(default)]
395 pub overlaps: Vec<Overlap>,
396 /// Whether the branch it would merge into has moved on without it, so
397 /// that it has to catch up before it can merge.
398 #[serde(default)]
399 pub behind: bool,
400 /// Whether a g1t agent is reviewing it right now.
401 #[serde(default)]
402 pub review_pending: bool,
403 /// Where it stands on its way to being merged, for a pull request g1t
404 /// is seeing through. Absent on anyone else's.
405 #[serde(default)]
406 pub lifecycle: Option<Lifecycle>,
407 /// A merge was asked for while it was behind: g1t is bringing it up to
408 /// date and will then land it.
409 #[serde(default)]
410 pub landing: bool,
411 /// Why g1t stopped working on it, if it did: a catch-up that could not
412 /// be completed, for example.
413 #[serde(default)]
414 pub stalled: Option<String>,
415 /// Messages people sent the agent while it worked, oldest first.
416 #[serde(default)]
417 pub messages: Vec<AgentMessage>,
418 /// What workflow runs said about its head commit, one per workflow.
419 #[serde(default)]
420 pub statuses: Vec<CommitStatus>,
421}
422
423/// What a workflow run (or another tool) says about a commit.
424#[derive(Clone, Debug, Serialize, Deserialize)]
425#[serde(rename_all = "camelCase")]
426pub struct CommitStatus {
427 /// What reported it, such as `CI / push`.
428 pub context: String,
429 /// `pending`, `success`, `failure` or `error`.
430 pub state: String,
431 pub description: Option<String>,
432 /// Where to see more, such as the run's page.
433 pub target_url: Option<String>,
434 pub updated_at: String,
435}
436
437/// `set_commit_status`: for services only. Returns `Outcome<bool>`.
438#[derive(Debug, Serialize, Deserialize)]
439#[serde(rename_all = "camelCase")]
440pub struct SetCommitStatusArgs {
441 pub repo_id: String,
442 pub sha: String,
443 pub context: String,
444 pub state: String,
445 #[serde(default)]
446 pub description: Option<String>,
447 #[serde(default)]
448 pub target_url: Option<String>,
449}
450
451/// A message a person sent an agent at work on a pull request. The agent
452/// receives it at its next step.
453#[derive(Clone, Debug, Serialize, Deserialize)]
454#[serde(rename_all = "camelCase")]
455pub struct AgentMessage {
456 pub id: String,
457 pub author: String,
458 pub body: String,
459 /// RFC 3339.
460 pub created_at: String,
461 /// RFC 3339. When the agent received it; null until then.
462 pub delivered_at: Option<String>,
463 /// `message` from a person, or from another pull request's agent a
464 /// `question`, a `handoff` of work, or the `answer` to one.
465 #[serde(default = "message_kind")]
466 pub kind: String,
467 /// The pull request whose agent sent it, when an agent did.
468 #[serde(default)]
469 pub from_number: Option<u32>,
470 /// The pull request it was sent to.
471 #[serde(default)]
472 pub to_number: u32,
473 /// For a question or handoff: the reply, once there is one.
474 #[serde(default)]
475 pub answer: Option<String>,
476 /// For a handoff: whether it was declined.
477 #[serde(default)]
478 pub declined: bool,
479 /// For the agent that sent it: what to expect, when the agent it asked
480 /// is not at work and will not answer soon.
481 #[serde(default, skip_serializing_if = "Option::is_none")]
482 pub hint: Option<String>,
483}
484
485fn message_kind() -> String {
486 "message".to_owned()
487}
488
489/// `message_agent`: sends the agent working on a pull request a message.
490/// The pull request's author and members of the workspace may. Returns
491/// `Outcome<AgentMessage>`.
492#[derive(Debug, Serialize, Deserialize)]
493pub struct MessageAgentArgs {
494 pub actor: User,
495 pub repo: RepoPath,
496 pub number: u32,
497 pub body: String,
498 /// For an agent: `question` or `handoff`; a person's is a `message`.
499 #[serde(default)]
500 pub kind: Option<String>,
501 /// For an agent: the pull request it is working on, which the reply
502 /// goes back to.
503 #[serde(default)]
504 pub from_number: Option<u32>,
505}
506
507/// `answer_message`: replies to a question or a handoff an agent received,
508/// accepting or declining a handoff. The reply reaches the asking agent at
509/// its next step. Returns `Outcome<AgentMessage>`, the message answered.
510#[derive(Debug, Serialize, Deserialize)]
511pub struct AnswerMessageArgs {
512 pub actor: User,
513 pub repo: RepoPath,
514 pub id: String,
515 pub body: String,
516 #[serde(default)]
517 pub decline: bool,
518}
519
520/// `take_messages`: the messages not yet delivered to the agent working on
521/// a pull request, marked delivered. Only g1t's agents may. Returns
522/// `Outcome<Vec<AgentMessage>>`.
523#[derive(Debug, Serialize, Deserialize)]
524pub struct TakeMessagesArgs {
525 pub actor: User,
526 pub repo: RepoPath,
527 pub number: u32,
528}
529
530/// A step on the way from an assigned issue to a pull request that is ready
531/// to merge. g1t takes each one without being asked.
532#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)]
533#[serde(rename_all = "snake_case")]
534pub enum Stage {
535 /// The agent is making the change.
536 Working,
537 /// The issue's acceptance checks are running against it.
538 Checking,
539 /// A g1t agent is reviewing it.
540 Reviewing,
541 /// The agent is addressing failed checks or a review.
542 Revising,
543 /// The agent is merging in the branch it would land on, which moved.
544 CatchingUp,
545 /// In the repository's merge queue, being tested with what is ahead of
546 /// it before it lands.
547 Queued,
548 /// Checks passed, reviewed and approved, up to date. A person merges.
549 Ready,
550 /// g1t has stopped and a person has to decide what happens next.
551 NeedsYou,
552}
553
554/// Where a pull request made by a g1t agent stands. See [`Stage`].
555#[derive(Clone, Debug, Serialize, Deserialize)]
556pub struct Lifecycle {
557 pub stage: Stage,
558 /// One sentence saying what is happening, or why it stopped.
559 pub detail: String,
560 /// How many times the agent has been sent back to revise it.
561 pub revisions: u32,
562}
563
564/// `advance`: works out the next step for a pull request g1t is seeing
565/// through and, if there is one to take now, claims it, so that it is
566/// taken once however many times this is called. Called by the runner
567/// service, which carries the step out. Returns `Advance`.
568#[derive(Debug, Serialize, Deserialize)]
569#[serde(rename_all = "camelCase")]
570pub struct AdvanceArgs {
571 pub pull_id: String,
572}
573
574#[derive(Debug, Serialize, Deserialize)]
575#[serde(tag = "action", rename_all = "snake_case")]
576pub enum Advance {
577 /// Nothing to do now: a step is under way, or it is a person's turn.
578 None,
579 /// Have a g1t agent review it.
580 Review { job: LifecycleJob },
581 /// Send the agent back to address `job.feedback`.
582 Revise { job: LifecycleJob },
583 /// Merge in the branch it would land on.
584 CatchUp { job: LifecycleJob },
585}
586
587/// What the runner needs to carry out a step of a pull request's lifecycle.
588#[derive(Debug, Serialize, Deserialize)]
589#[serde(rename_all = "camelCase")]
590pub struct LifecycleJob {
591 pub pull_id: String,
592 pub repo: RepoPath,
593 pub number: u32,
594 /// Who the pull request belongs to. Sandboxes act as them.
595 pub author: User,
596 /// The repository holding the change: its fork, or the repository
597 /// itself for one made on a branch.
598 pub source: RepoPath,
599 /// The branch of the source holding the change; its default branch
600 /// when absent.
601 #[serde(default)]
602 pub branch: Option<String>,
603 pub default_branch: String,
604 pub title: String,
605 pub description: String,
606 pub issue: Option<Issue>,
607 /// For a revision: the failed checks or the review to address.
608 pub feedback: String,
609 /// For a revision: which one this is, from 1.
610 pub round: u32,
611}
612
613/// How a repository wants its pull requests handled. A repository that has
614/// changed nothing has the defaults.
615#[derive(Clone, Debug, Serialize, Deserialize)]
616#[serde(rename_all = "camelCase", default)]
617pub struct RepoSettings {
618 /// Land a g1t agent's pull request without a person once it is ready:
619 /// checks passed and approved as the settings below require.
620 pub auto_merge: bool,
621 /// Refuse to merge a pull request that does not contain the default
622 /// branch's latest commits, so that what merges is what was checked.
623 /// When off, merging one that is behind brings it up to date first.
624 pub require_up_to_date: bool,
625 /// How many approving reviews a pull request needs before it may
626 /// merge. A reviewer who has since asked for changes blocks it.
627 pub required_approvals: u32,
628 /// Whether a g1t agent's approval counts towards `required_approvals`.
629 pub count_agent_approvals: bool,
630 /// Whether a member may merge although the acceptance checks did not
631 /// pass.
632 pub allow_ignoring_checks: bool,
633 /// Whether a g1t agent's pull request is reviewed by a second agent
634 /// without being asked.
635 pub agent_review: bool,
636 /// How many times a g1t agent is sent back to its pull request before
637 /// a person is asked instead.
638 pub max_revisions: u32,
639 /// Merge through a queue: pull requests are tested together with those
640 /// ahead of them, and only a combination that passed reaches the default
641 /// branch.
642 pub merge_queue: bool,
643 /// Username of the member who last changed the settings, if anyone has.
644 pub updated_by: Option<String>,
645 /// RFC 3339.
646 pub updated_at: Option<String>,
647}
648
649impl Default for RepoSettings {
650 fn default() -> Self {
651 RepoSettings {
652 auto_merge: false,
653 require_up_to_date: false,
654 required_approvals: 0,
655 count_agent_approvals: true,
656 allow_ignoring_checks: true,
657 agent_review: true,
658 max_revisions: 2,
659 merge_queue: false,
660 updated_by: None,
661 updated_at: None,
662 }
663 }
664}
665
666/// `update_settings`: replaces a repository's settings. Members of its
667/// workspace only. Returns `Outcome<RepoSettings>`. `get_settings` takes
668/// `ViewArgs` and returns the same.
669#[derive(Debug, Serialize, Deserialize)]
670pub struct UpdateSettingsArgs {
671 pub actor: User,
672 pub repo: RepoPath,
673 /// Who changed them and when are filled in by the service.
674 pub settings: RepoSettings,
675}
676
677/// `catch_up_job`: what the runner needs to bring a pull request up to date
678/// because a merge of it was asked for. Null if none was. Returns
679/// `Option<LifecycleJob>`.
680#[derive(Debug, Serialize, Deserialize)]
681#[serde(rename_all = "camelCase")]
682pub struct CatchUpJobArgs {
683 pub pull_id: String,
684}
685
686/// `stall`: records that a step could not be carried out, so that g1t
687/// stops and a person is asked. Returns `bool`.
688#[derive(Debug, Serialize, Deserialize)]
689#[serde(rename_all = "camelCase")]
690pub struct StallArgs {
691 pub pull_id: String,
692 pub reason: String,
693}
694
695/// `managed_pulls`: ids of the open pull requests g1t is seeing through,
696/// in one repository or in all of them. Returns `Vec<String>`.
697#[derive(Debug, Default, Serialize, Deserialize)]
698#[serde(rename_all = "camelCase")]
699pub struct ManagedPullsArgs {
700 #[serde(default)]
701 pub repo_id: Option<String>,
702}
703
704/// `open_issue`. Returns `Outcome<Issue>`.
705#[derive(Debug, Serialize, Deserialize)]
706pub struct OpenIssueArgs {
707 pub actor: User,
708 pub repo: RepoPath,
709 pub title: String,
710 #[serde(default)]
711 pub body: String,
712 #[serde(default)]
713 pub labels: Vec<String>,
714 #[serde(default)]
715 pub checks: Vec<String>,
716}
717
718/// `list_issues`, newest first. Returns `Outcome<Vec<Issue>>`.
719#[derive(Debug, Serialize, Deserialize)]
720pub struct ListIssuesArgs {
721 pub repo: RepoPath,
722 pub viewer: Viewer,
723 #[serde(default)]
724 pub state: Option<State>,
725 /// Only issues carrying this label.
726 #[serde(default)]
727 pub label: Option<String>,
728}
729
730/// `list_pulls`, newest first. Returns `Outcome<Vec<Pull>>`.
731#[derive(Debug, Serialize, Deserialize)]
732pub struct ListPullsArgs {
733 pub repo: RepoPath,
734 pub viewer: Viewer,
735 #[serde(default)]
736 pub state: Option<State>,
737}
738
739/// `get_issue` (`Outcome<IssueDetail>`), `get_pull` (`Outcome<PullDetail>`),
740/// `read_session` (`Outcome<Vec<SessionEntry>>`), `list_labels`
741/// (`Outcome<Vec<String>>`) and `counts` (`Outcome<Counts>`). The last two
742/// ignore `number`.
743#[derive(Debug, Serialize, Deserialize)]
744#[serde(rename_all = "camelCase")]
745pub struct ViewArgs {
746 pub repo: RepoPath,
747 #[serde(default)]
748 pub number: u32,
749 pub viewer: Viewer,
750 /// For `read_session`: only entries after this sequence number.
751 #[serde(default)]
752 pub after_seq: u32,
753}
754
755/// How many issues and pull requests are open on a repository.
756#[derive(Debug, Serialize, Deserialize)]
757pub struct Counts {
758 pub issues: u32,
759 pub pulls: u32,
760}
761
762/// `update_issue`: changes whichever fields are given. The author or a
763/// member of the workspace may. Returns `Outcome<Issue>`.
764#[derive(Debug, Serialize, Deserialize)]
765pub struct UpdateIssueArgs {
766 pub actor: User,
767 pub repo: RepoPath,
768 pub number: u32,
769 #[serde(default)]
770 pub title: Option<String>,
771 #[serde(default)]
772 pub body: Option<String>,
773 #[serde(default)]
774 pub labels: Option<Vec<String>>,
775 /// Usernames of the people it is assigned to; replaces the whole set.
776 /// Assigning it to the g1t agent is the runner's `run`, not this.
777 #[serde(default)]
778 pub assignees: Option<Vec<String>>,
779}
780
781/// `close_issue` and `reopen_issue`. Each returns `Outcome<Issue>`.
782#[derive(Debug, Serialize, Deserialize)]
783pub struct IssueActionArgs {
784 pub actor: User,
785 pub repo: RepoPath,
786 pub number: u32,
787 /// For `close_issue`; `completed` if left out.
788 #[serde(default)]
789 pub reason: Option<IssueReason>,
790}
791
792/// `add_comment`, on an issue or a pull request. On a pull request it may
793/// name a line of the change, and may carry a verdict; nobody can give a
794/// verdict on their own pull request. Returns `Outcome<Comment>`.
795#[derive(Debug, Serialize, Deserialize)]
796pub struct AddCommentArgs {
797 pub actor: User,
798 pub repo: RepoPath,
799 pub number: u32,
800 /// May be empty when approving.
801 #[serde(default)]
802 pub body: String,
803 #[serde(default)]
804 pub path: Option<String>,
805 #[serde(default)]
806 pub line: Option<u32>,
807 #[serde(default)]
808 pub verdict: Option<Verdict>,
809}
810
811/// `open_pull`. Without `branch`, forks the repo and returns a draft pull
812/// request to push to. With it, opens a pull request, ready for review,
813/// for a branch already pushed to the repo. Returns `Outcome<Pull>`.
814#[derive(Debug, Serialize, Deserialize)]
815pub struct OpenPullArgs {
816 pub actor: User,
817 pub repo: RepoPath,
818 /// The issue this is for.
819 #[serde(default)]
820 pub issue: Option<u32>,
821 /// Defaults to the issue's title; required without an issue.
822 #[serde(default)]
823 pub title: String,
824 /// What changed and why. Usually set later, when a draft is marked ready.
825 #[serde(default)]
826 pub body: String,
827 /// A branch of the repository that already holds the change.
828 #[serde(default)]
829 pub branch: Option<String>,
830 #[serde(default)]
831 pub agent: String,
832 pub runtime: Runtime,
833}
834
835/// `ready_pull`, `close_pull` and `merge_pull`. Each returns `Outcome<Pull>`.
836#[derive(Debug, Serialize, Deserialize)]
837#[serde(rename_all = "camelCase")]
838pub struct PullActionArgs {
839 pub actor: User,
840 pub repo: RepoPath,
841 pub number: u32,
842 /// For `ready_pull`: what changed and why.
843 #[serde(default)]
844 pub summary: String,
845 /// For `merge_pull`: leave the issue open and the other pull requests
846 /// for it untouched, because this one is only part of the work.
847 #[serde(default)]
848 pub keep_issue_open: bool,
849 /// For `merge_pull`: merge although the acceptance checks have not
850 /// passed.
851 #[serde(default)]
852 pub ignore_checks: bool,
853}
854
855/// Where a plan stands.
856#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)]
857#[serde(rename_all = "lowercase")]
858pub enum PlanStatus {
859 /// An agent is reading the repository and writing it.
860 Planning,
861 /// Written, and waiting for a person to read and apply it.
862 Ready,
863 /// It could not be written.
864 Failed,
865 /// Its issues have been opened.
866 Applied,
867}
868
869/// One issue a plan proposes.
870#[derive(Clone, Debug, Default, Serialize, Deserialize)]
871#[serde(rename_all = "camelCase", default)]
872pub struct PlannedIssue {
873 pub title: String,
874 /// Markdown: what to change, where, and why.
875 pub body: String,
876 pub labels: Vec<String>,
877 /// Commands that must pass once the change is made.
878 pub checks: Vec<String>,
879 /// The files it will most likely change.
880 pub files: Vec<String>,
881 /// The positions, counting from 1, of earlier issues in the plan that
882 /// have to be merged first. An agent writes this as `depends_on`.
883 #[serde(alias = "depends_on")]
884 pub depends_on: Vec<u32>,
885 /// Its number, once the plan has been applied and it was kept.
886 pub number: Option<u32>,
887}
888
889/// An outcome someone wrote, and the issues an agent proposes to get there.
890#[derive(Clone, Debug, Serialize, Deserialize)]
891#[serde(rename_all = "camelCase")]
892pub struct Plan {
893 pub id: String,
894 pub repo_id: String,
895 /// The outcome wanted, as written.
896 pub brief: String,
897 pub status: PlanStatus,
898 /// The agent's account of how it split the work.
899 pub summary: String,
900 pub issues: Vec<PlannedIssue>,
901 /// Why it could not be written, when `status` is `failed`.
902 pub error: Option<String>,
903 pub author: User,
904 /// RFC 3339.
905 pub created_at: String,
906 /// RFC 3339.
907 pub finished_at: Option<String>,
908 /// Once applied: where each issue it opened stands now, in plan order.
909 /// Filled in by `get_plan` only.
910 #[serde(default)]
911 pub progress: Vec<IssueProgress>,
912 /// Questions and handoffs between the agents on its pull requests,
913 /// newest first. Filled in by `get_plan` only.
914 #[serde(default)]
915 pub exchanges: Vec<AgentMessage>,
916}
917
918/// Where one issue of an applied plan stands.
919#[derive(Clone, Debug, Serialize, Deserialize)]
920#[serde(rename_all = "camelCase")]
921pub struct IssueProgress {
922 pub number: u32,
923 pub title: String,
924 /// `blocked` (waiting on issues it depends on), `waiting` (for an
925 /// agent), `open` (nobody on it), one of the lifecycle stages
926 /// (`working`, `checking`, `reviewing`, `revising`, `catching_up`,
927 /// `queued`, `ready`, `needs_you`), `landed` or `closed`.
928 pub state: String,
929 /// One sentence about where it stands.
930 pub detail: String,
931 /// The issues it is waiting on that are still open.
932 pub blocked_by: Vec<u32>,
933 /// The pull request carrying it, the newest if several.
934 pub pull: Option<u32>,
935 /// Who or what is working on it, e.g. `g1t-agent`.
936 pub agent: Option<String>,
937}
938
939/// `start_plan`: records an outcome to plan for. Members of the
940/// repository's workspace only. Called by the runner service, which starts
941/// the sandbox. Returns `Outcome<PlanJob>`.
942#[derive(Debug, Serialize, Deserialize)]
943pub struct StartPlanArgs {
944 pub actor: User,
945 pub repo: RepoPath,
946 pub brief: String,
947}
948
949/// What a sandbox needs to write a plan.
950#[derive(Debug, Serialize, Deserialize)]
951#[serde(rename_all = "camelCase")]
952pub struct PlanJob {
953 pub plan_id: String,
954 /// Lets the sandbox, and nothing else, report this plan.
955 pub token: String,
956 pub brief: String,
957 pub repo: RepoPath,
958}
959
960/// `report_plan`: the plan a sandbox's agent wrote, or why it could not
961/// write one. Returns `Outcome<bool>`.
962#[derive(Debug, Serialize, Deserialize)]
963#[serde(rename_all = "camelCase")]
964pub struct ReportPlanArgs {
965 pub plan_id: String,
966 pub token: String,
967 #[serde(default)]
968 pub summary: String,
969 #[serde(default)]
970 pub issues: Vec<PlannedIssue>,
971 #[serde(default)]
972 pub error: Option<String>,
973}
974
975/// `get_plan`. Members only. Returns `Outcome<Plan>`. `list_plans` takes
976/// `ViewArgs` and returns `Outcome<Vec<Plan>>`, newest first.
977#[derive(Debug, Serialize, Deserialize)]
978pub struct PlanArgs {
979 pub repo: RepoPath,
980 pub viewer: Viewer,
981 pub id: String,
982}
983
984/// `apply_plan`: opens a plan's issues, each blocked by the ones it depends
985/// on. Members only, and once. Returns `Outcome<Plan>`, its issues now
986/// carrying their numbers.
987#[derive(Debug, Serialize, Deserialize)]
988pub struct ApplyPlanArgs {
989 pub actor: User,
990 pub repo: RepoPath,
991 pub id: String,
992 /// Queue every issue for a g1t agent.
993 #[serde(default)]
994 pub assign: bool,
995 /// The positions, counting from 1, of the issues to open. All of them
996 /// when absent.
997 #[serde(default)]
998 pub keep: Option<Vec<u32>>,
999}
1000
1001/// `queue_issue`: asks for a g1t agent to take an issue as soon as it can,
1002/// or withdraws that. The author or a member may. Returns `Outcome<bool>`.
1003#[derive(Debug, Serialize, Deserialize)]
1004pub struct QueueIssueArgs {
1005 pub actor: User,
1006 pub repo: RepoPath,
1007 pub number: u32,
1008 pub queued: bool,
1009}
1010
1011/// `ready_issues`: issues waiting for a g1t agent that can be given one
1012/// now, in one repository or in all. Called by the runner service. Returns
1013/// `Vec<ReadyIssue>`.
1014#[derive(Debug, Default, Serialize, Deserialize)]
1015#[serde(rename_all = "camelCase")]
1016pub struct ReadyIssuesArgs {
1017 #[serde(default)]
1018 pub repo_id: Option<String>,
1019}
1020
1021#[derive(Debug, Serialize, Deserialize)]
1022pub struct ReadyIssue {
1023 pub repo: RepoPath,
1024 pub number: u32,
1025 /// Who queued it, on whose say-so the agent works.
1026 pub actor: User,
1027}
1028
1029/// `update_pull`: changes who a pull request is assigned to and whose
1030/// review is asked for. Each list given replaces the whole set. Whoever
1031/// opened it, or a member of the workspace, may. Returns `Outcome<Pull>`.
1032#[derive(Debug, Serialize, Deserialize)]
1033pub struct UpdatePullArgs {
1034 pub actor: User,
1035 pub repo: RepoPath,
1036 pub number: u32,
1037 #[serde(default)]
1038 pub assignees: Option<Vec<String>>,
1039 /// May include `g1t-agent`. Asking for its review does not by itself
1040 /// start one; the runner's `review` does.
1041 #[serde(default)]
1042 pub reviewers: Option<Vec<String>>,
1043}
1044
1045/// `start_checks`: begins a run of the acceptance checks for a pull request
1046/// that is ready for review. Called by the runner service, which starts the
1047/// sandbox. Returns `Outcome<CheckJob>`.
1048#[derive(Debug, Serialize, Deserialize)]
1049#[serde(rename_all = "camelCase")]
1050pub struct StartChecksArgs {
1051 pub pull_id: String,
1052}
1053
1054/// What a sandbox needs to carry out a check run.
1055#[derive(Debug, Serialize, Deserialize)]
1056#[serde(rename_all = "camelCase")]
1057pub struct CheckJob {
1058 pub run_id: String,
1059 /// Lets the sandbox, and nothing else, report this run's results.
1060 pub token: String,
1061 pub commands: Vec<String>,
1062 /// The repository holding the commit: the fork, or the repository itself.
1063 pub source: RepoPath,
1064 pub commit: String,
1065 /// Who opened the pull request, and so can read its source.
1066 pub author: User,
1067 /// Username of whoever wrote the checks: the issue's author.
1068 pub requested_by: String,
1069 pub repo: RepoPath,
1070 pub number: u32,
1071}
1072
1073/// `report_checks`: what a sandbox says about its run. With no results and
1074/// no error it has started. `skip` forgets the run, for one that will not
1075/// be carried out. Returns `Outcome<CheckRun>`.
1076#[derive(Debug, Serialize, Deserialize)]
1077#[serde(rename_all = "camelCase")]
1078pub struct ReportChecksArgs {
1079 pub run_id: String,
1080 pub token: String,
1081 #[serde(default)]
1082 pub results: Vec<CheckResult>,
1083 #[serde(default)]
1084 pub error: Option<String>,
1085 #[serde(default)]
1086 pub skip: bool,
1087}
1088
1089/// A pull request in progress, with where it lives.
1090#[derive(Debug, Serialize, Deserialize)]
1091pub struct ActivePull {
1092 pub pull: Pull,
1093 pub issue: Option<Issue>,
1094 /// Where it stands, for one g1t is seeing through.
1095 #[serde(default)]
1096 pub lifecycle: Option<Lifecycle>,
1097}
1098
1099/// `list_active_pulls`: drafts and open pull requests the viewer started,
1100/// most recently active first. Returns `Vec<ActivePull>`. Also
1101/// `list_assigned_issues`: open issues assigned to the viewer, most
1102/// recently changed first. Returns `Vec<Issue>`.
1103#[derive(Debug, Serialize, Deserialize)]
1104pub struct ViewerArgs {
1105 pub viewer: Viewer,
1106}
1107
1108/// `append_session`. Returns `Outcome<Appended>`.
1109#[derive(Debug, Serialize, Deserialize)]
1110pub struct AppendSessionArgs {
1111 pub actor: User,
1112 pub repo: RepoPath,
1113 pub number: u32,
1114 pub entries: Vec<NewSessionEntry>,
1115}
1116
1117#[derive(Debug, Serialize, Deserialize)]
1118pub struct Appended {
1119 pub count: u32,
1120}
1121
1122/// `start_review`: begins a review of a pull request by a g1t agent. Called
1123/// by the runner service, which starts the sandbox. Returns
1124/// `Outcome<ReviewJob>`.
1125#[derive(Debug, Serialize, Deserialize)]
1126#[serde(rename_all = "camelCase")]
1127pub struct StartReviewArgs {
1128 pub pull_id: String,
1129}
1130
1131/// What a sandbox needs to review a pull request.
1132#[derive(Debug, Serialize, Deserialize)]
1133#[serde(rename_all = "camelCase")]
1134pub struct ReviewJob {
1135 pub run_id: String,
1136 /// Lets the sandbox, and nothing else, report this review.
1137 pub token: String,
1138 /// The repository holding the commit: the fork, or the repository itself.
1139 pub source: RepoPath,
1140 pub commit: String,
1141 pub repo: RepoPath,
1142 pub default_branch: String,
1143 pub number: u32,
1144 pub title: String,
1145 pub description: String,
1146 /// The issue the pull request is for, which says what it should achieve.
1147 pub issue: Option<Issue>,
1148 /// Who opened the pull request, and so can read its source.
1149 pub author: User,
1150}
1151
1152/// A comment on one line, as a reviewing agent reports it.
1153#[derive(Debug, Serialize, Deserialize)]
1154pub struct ReviewComment {
1155 pub path: String,
1156 #[serde(default)]
1157 pub line: u32,
1158 pub body: String,
1159}
1160
1161/// `report_review`: the review a sandbox's agent wrote, or why it could not
1162/// write one. Returns `Outcome<bool>`.
1163#[derive(Debug, Serialize, Deserialize)]
1164#[serde(rename_all = "camelCase")]
1165pub struct ReportReviewArgs {
1166 pub run_id: String,
1167 pub token: String,
1168 #[serde(default)]
1169 pub verdict: Option<Verdict>,
1170 #[serde(default)]
1171 pub body: String,
1172 #[serde(default)]
1173 pub comments: Vec<ReviewComment>,
1174 /// The model that wrote it, by its public name.
1175 #[serde(default)]
1176 pub model: Option<String>,
1177 #[serde(default)]
1178 pub error: Option<String>,
1179}
1180
1181/// Lowercases, trims and de-duplicates labels, dropping empty ones.
1182/// Returns `None` if there are too many or one is too long.
1183pub fn normalize_labels(labels: &[String]) -> Option<Vec<String>> {
1184 const MAX_LABELS: usize = 10;
1185 const MAX_LABEL_CHARS: usize = 40;
1186 let mut normalized: Vec<String> = Vec::new();
1187 for label in labels {
1188 let label = label
1189 .split_whitespace()
1190 .collect::<Vec<_>>()
1191 .join(" ")
1192 .to_lowercase();
1193 if label.is_empty() || normalized.contains(&label) {
1194 continue;
1195 }
1196 if label.chars().count() > MAX_LABEL_CHARS {
1197 return None;
1198 }
1199 normalized.push(label);
1200 }
1201 (normalized.len() <= MAX_LABELS).then_some(normalized)
1202}
1203
1204#[cfg(test)]
1205mod tests {
1206 use super::normalize_labels;
1207
1208 fn labels(names: &[&str]) -> Vec<String> {
1209 names.iter().map(|name| (*name).to_owned()).collect()
1210 }
1211
1212 #[test]
1213 fn labels_are_lowercased_trimmed_and_unique() {
1214 assert_eq!(
1215 normalize_labels(&labels(&[" Bug ", "bug", "", "Good First Issue"])),
1216 Some(labels(&["bug", "good first issue"]))
1217 );
1218 }
1219
1220 #[test]
1221 fn too_long_or_too_many_labels_are_refused() {
1222 assert_eq!(normalize_labels(&["x".repeat(41)]), None);
1223 let many: Vec<String> = (0..11).map(|i| format!("label-{i}")).collect();
1224 assert_eq!(normalize_labels(&many), None);
1225 }
1226}
1227
1228
1229// --- Merge queue ----------------------------------------------------------
1230
1231/// Where a pull request in a merge queue stands.
1232#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)]
1233#[serde(rename_all = "snake_case")]
1234pub enum QueueState {
1235 /// Waiting for its turn to be tested.
1236 Waiting,
1237 /// Its combined state is being built and checked.
1238 Testing,
1239 /// Its combined state passed; it lands once everything ahead has.
1240 Passed,
1241 /// Its combined state failed, or would not merge. It left the queue.
1242 Failed,
1243 /// On the default branch.
1244 Landed,
1245 /// Taken out of the queue by a person, or closed.
1246 Removed,
1247}
1248
1249impl QueueState {
1250 pub fn as_str(self) -> &'static str {
1251 match self {
1252 QueueState::Waiting => "waiting",
1253 QueueState::Testing => "testing",
1254 QueueState::Passed => "passed",
1255 QueueState::Failed => "failed",
1256 QueueState::Landed => "landed",
1257 QueueState::Removed => "removed",
1258 }
1259 }
1260
1261 /// Still in the queue.
1262 pub fn is_active(self) -> bool {
1263 matches!(
1264 self,
1265 QueueState::Waiting | QueueState::Testing | QueueState::Passed
1266 )
1267 }
1268}
1269
1270/// One pull request's place in a merge queue.
1271#[derive(Clone, Debug, Serialize, Deserialize)]
1272#[serde(rename_all = "camelCase")]
1273pub struct QueueEntry {
1274 pub id: String,
1275 pub number: u32,
1276 pub title: String,
1277 /// Who or what made the pull request, e.g. `g1t-agent`.
1278 pub agent: String,
1279 pub state: QueueState,
1280 /// The pull requests merged ahead of it in the state being tested, in
1281 /// queue order. Empty when it was tested on the default branch alone.
1282 pub ahead: Vec<u32>,
1283 /// The default branch's commit the tested state was built on.
1284 pub base_commit: Option<String>,
1285 /// The tested state: the default branch with everything ahead and this.
1286 pub combined_commit: Option<String>,
1287 /// Why it failed: a merge conflict or what could not be run.
1288 pub error: Option<String>,
1289 /// The checks run against the tested state.
1290 pub results: Vec<CheckResult>,
1291 /// Username of whoever merged it into the queue: a person, or `g1t`.
1292 pub enqueued_by: String,
1293 /// RFC 3339.
1294 pub created_at: String,
1295 /// RFC 3339. When it landed or left.
1296 pub finished_at: Option<String>,
1297}
1298
1299/// A repository's merge queue: what is in it, in order, and what recently
1300/// left it.
1301#[derive(Clone, Debug, Serialize, Deserialize)]
1302#[serde(rename_all = "camelCase")]
1303pub struct QueueView {
1304 /// Whether the repository merges through the queue.
1305 pub enabled: bool,
1306 pub active: Vec<QueueEntry>,
1307 /// Newest first.
1308 pub recent: Vec<QueueEntry>,
1309}
1310
1311/// `queue`: a repository's merge queue. Returns `Outcome<QueueView>`.
1312#[derive(Debug, Serialize, Deserialize)]
1313pub struct QueueArgs {
1314 pub repo: RepoPath,
1315 pub viewer: Viewer,
1316}
1317
1318/// `queue_build`: the next batch to test for a repository, if nothing is
1319/// being tested now. Returns `Vec<QueueJob>`, one per entry, each testing
1320/// the default branch with that entry and everything ahead of it.
1321#[derive(Debug, Serialize, Deserialize)]
1322#[serde(rename_all = "camelCase")]
1323pub struct QueueBuildArgs {
1324 pub repo_id: String,
1325}
1326
1327/// One pull request in a state being tested: where its change is.
1328#[derive(Clone, Debug, Serialize, Deserialize)]
1329#[serde(rename_all = "camelCase")]
1330pub struct QueueStackItem {
1331 pub number: u32,
1332 pub title: String,
1333 /// The repository holding the change: its fork, or the repository.
1334 pub source: RepoPath,
1335 /// The branch of `source` holding it.
1336 pub branch: String,
1337 pub commit: String,
1338}
1339
1340/// What a sandbox needs to build and check one combined state.
1341#[derive(Clone, Debug, Serialize, Deserialize)]
1342#[serde(rename_all = "camelCase")]
1343pub struct QueueJob {
1344 pub entry_id: String,
1345 /// Lets the sandbox, and nothing else, report this state's result.
1346 pub token: String,
1347 pub repo: RepoPath,
1348 pub default_branch: String,
1349 /// The default branch's commit to build on.
1350 pub base_commit: String,
1351 /// Where to push the tested state, in the repository itself.
1352 pub branch: String,
1353 /// The pull requests to merge in, in order; the last is the entry.
1354 pub stack: Vec<QueueStackItem>,
1355 /// Every acceptance check of every pull request in the stack.
1356 pub checks: Vec<String>,
1357 /// The checks of issues already completed: the default branch's
1358 /// contract. One that fails on the base alone is not held against the
1359 /// entry.
1360 #[serde(default)]
1361 pub contract_checks: Vec<String>,
1362 /// Who the sandbox acts as: a member who can push the tested state.
1363 pub actor: User,
1364}
1365
1366/// `report_queue`: a sandbox's result for one combined state. Returns
1367/// `Outcome<QueueState>`.
1368#[derive(Debug, Serialize, Deserialize)]
1369#[serde(rename_all = "camelCase")]
1370pub struct ReportQueueArgs {
1371 pub entry_id: String,
1372 pub token: String,
1373 #[serde(default)]
1374 pub combined_commit: Option<String>,
1375 #[serde(default)]
1376 pub results: Vec<CheckResult>,
1377 /// Set when the state could not be built or checked.
1378 #[serde(default)]
1379 pub error: Option<String>,
1380 /// For a merge conflict: the pull request whose change it collided with.
1381 #[serde(default)]
1382 pub conflict_with: Option<u32>,
1383}
1384
1385
1386/// `locate_pull`: where a pull request lives, by its id, for a tool that
1387/// knows only the fork it is working in (`g1t.sh/pulls/<id>`). Returns
1388/// `Outcome<LocatedPull>`; not found for anyone who cannot see it.
1389#[derive(Debug, Serialize, Deserialize)]
1390pub struct LocatePullArgs {
1391 pub id: String,
1392 pub viewer: Viewer,
1393}
1394
1395#[derive(Clone, Debug, Serialize, Deserialize)]
1396#[serde(rename_all = "camelCase")]
1397pub struct LocatedPull {
1398 pub repo: RepoPath,
1399 pub number: u32,
1400 pub title: String,
1401 pub status: PullStatus,
1402}