Skip to content
Source
Sign inSign up
pingdotgg/t3code
Open History to see the last commit

PullRequestProvider.ts

673 lines28.0 KB

1import * as Effect from "effect/Effect";
2import * as Schema from "effect/Schema";
3import type {
4 PullRequestStackMembership,
5 PullRequestAction,
6 PullRequestStackHead,
7 PullRequestActor,
8 PullRequestBaseComparison,
9 PullRequestCapabilities,
10 PullRequestChecksState,
11 PullRequestCheck,
12 PullRequestChecks,
13 PullRequestComment,
14 PullRequestFileViewed,
15 PullRequestCommit,
16 PullRequestInvolvement,
17 PullRequestLabel,
18 PullRequestListFilters,
19 PullRequestListState,
20 PullRequestMergeCapabilities,
21 PullRequestMergeMethod,
22 PullRequestMergeability,
23 PullRequestOmittedFileStat,
24 PullRequestReaction,
25 PullRequestReactionContent,
26 PullRequestReviewCommentDraft,
27 PullRequestReviewDecision,
28 PullRequestReviewThread,
29 PullRequestThreadCommentsResult,
30 PullRequestReviewVerdict,
31 PullRequestReviewerCandidateList,
32 PullRequestReviewerKind,
33 PullRequestLabelCandidateList,
34 PullRequestState,
35 PullRequestPreview,
36 PullRequestUpdateMethod,
37 PullRequestViewerPermissions,
38 SourceControlProviderKind,
39} from "@t3tools/contracts";
40import { SourceControlProviderKind as SourceControlProviderKindSchema } from "@t3tools/contracts";
41​
42/**
43 * The one failure shape every provider reports, so the service can decide what a failure means
44 * without knowing which CLI or API produced it.
45 *
46 * `reason` is the part the service acts on: a missing or unauthenticated tool disables the
47 * provider for the whole workspace, a rate limit pauses its host, and anything else is specific
48 * to the request.
49 */
50export class PullRequestProviderError extends Schema.TaggedError<PullRequestProviderError>()(
51 "PullRequestProviderError",
52 {
53 provider: SourceControlProviderKindSchema,
54 operation: Schema.String,
55 reason: Schema.Literals(["missing-tool", "unauthenticated", "rate-limited", "failed"]),
56 detail: Schema.String,
57 retryAt: Schema.optional(Schema.Number),
58 cause: Schema.optional(Schema.Defect()),
59 },
60) {
61 override get message(): string {
62 return `${this.provider} failed in ${this.operation}: ${this.detail}`;
63 }
65​
66export interface PullRequestProviderFailure {
67 readonly reason: PullRequestProviderError["reason"];
68 readonly retryAt?: number | undefined;
70​
71/** A change request as the provider sees it, before the service attaches project context. */
72export interface ProviderChangeRequest {
73 readonly stack?: PullRequestStackMembership;
74 readonly number: number;
75 readonly title: string;
76 readonly url: string;
77 readonly author: PullRequestActor | null;
78 readonly headBranch: string;
79 readonly headRepositoryNameWithOwner?: string | null;
80 readonly baseBranch: string;
81 readonly state: PullRequestState;
82 readonly isDraft: boolean;
83 readonly mergeability: PullRequestMergeability;
84 readonly additions: number;
85 readonly deletions: number;
86 readonly createdAt: string;
87 readonly closedAt?: string | null;
88 readonly mergedAt?: string | null;
89 readonly updatedAt: string;
90 /** Accounts with a review requested. Team-level requests are excluded by each provider. */
91 readonly reviewRequestLogins: ReadonlyArray<string>;
92 readonly labels: ReadonlyArray<PullRequestLabel>;
93 /** Absent from a host that does not summarise its reviews, which is every host but GitHub. */
94 readonly reviewDecision?: PullRequestReviewDecision | null | undefined;
95 /** Absent from a host that reports no check rollup on its listings. */
96 readonly checksState?: PullRequestChecksState | null | undefined;
98​
99/** The fields needed to keep a linked thread's pull request status live. */
100export interface ProviderChangeRequestSummary {
101 readonly number: number;
102 readonly title: string;
103 readonly url: string;
104 readonly headBranch: string;
105 readonly baseBranch: string;
106 readonly state: PullRequestState;
107 /** Present when the host says an open pull request is still a draft. */
108 readonly isDraft?: boolean;
109 readonly closedAt?: string | null;
110 readonly mergedAt?: string | null;
111 readonly updatedAt: string;
112 /** Overview fields, present where the host's single read returns them at no extra cost. */
113 readonly author?: PullRequestActor | null | undefined;
114 readonly additions?: number | undefined;
115 readonly deletions?: number | undefined;
116 readonly changedFiles?: number | undefined;
117 readonly reviewDecision?: PullRequestReviewDecision | null | undefined;
118 readonly checksState?: PullRequestChecksState | null | undefined;
119 readonly mergeability?: PullRequestMergeability | undefined;
120 /**
121 * The host-native stack the pull request sits in, from the same read. Null when the host says
122 * it is in none; absent when the read did not ask.
123 */
124 readonly stack?: PullRequestStackMembership | null | undefined;
126​
127/** One layer of a host-native stack, bottom to top order is the array's. */
128export interface ProviderChangeRequestStackLayer {
129 readonly title?: string;
130 readonly isDraft?: boolean;
131 readonly headSha?: string;
132 readonly number: number;
133 readonly headBranch: string;
134 readonly state: PullRequestState;
136​
137/**
138 * A host-native stack: an ordered set of change requests the host itself merges and retargets as
139 * a unit. Only GitHub offers one today; the neutral shape lets the sync reactor and the UI stay
140 * ignorant of which host said so.
141 */
142export interface ProviderChangeRequestStack {
143 readonly id: string;
144 readonly number: number;
145 readonly url: string;
146 readonly base: string;
147 readonly layers: ReadonlyArray<ProviderChangeRequestStackLayer>;
149​
150export interface ProviderChangeRequestPage {
151 readonly items: ReadonlyArray<ProviderChangeRequest>;
152 /** True when the host has more rows than the page size asked for. */
153 readonly truncated: boolean;
154 /**
155 * Optional count-based cursor advance. Most hosts advance by the rows delivered after local
156 * de-duplication; an offset-paged host may need to count malformed raw rows it consumed too.
157 */
158 readonly cursorAdvance?: number;
159 /**
160 * This page can be carried on from, so the service may hand the caller a cursor for it. False
161 * where the host answered in an order a cursor means nothing in, which leaves a larger `limit`
162 * as the only way to the rest — what every listing did before there were cursors.
163 */
164 readonly continues: boolean;
166​
167/**
168 * Where a repository's next slice starts, as the provider that has to ask for it needs it. Built
169 * by the service out of the slice it just handed over, so the boundary that decides whether a row
170 * arrives twice or not at all is decided in one place rather than in four.
171 */
172export interface ProviderListCursor {
173 /**
174 * The instant of the oldest row already handed over, checked against a timestamp's shape before
175 * it gets here because it goes into a host's own filter. Asked for inclusively: several rows
176 * share one instant often enough — a bot that touches eight change requests writes one timestamp
177 * on all eight — and asking for strictly older would lose whichever of them the slice ended
178 * before. The service drops the ones it has already sent.
179 */
180 readonly updatedBefore: string;
181 /**
182 * How many provider rows this repository has consumed so far, for a host that carries on by
183 * counting rather than by date. Usually this is the number handed over; malformed raw rows may
184 * count too when the provider reports a `cursorAdvance`.
185 */
186 readonly delivered: number;
188​
189/** One repository's row inside an answer that spans several of them. */
190export interface ProviderBatchedChangeRequest extends ProviderChangeRequest {
191 /** Provider-native identity, exactly as it was asked for, so the caller can file the row. */
192 readonly repository: string;
194​
195/**
196 * One slice of a host read across several repositories at once, newest update first across all
197 * of them. There is no per-repository page here because the host was asked one question: the
198 * caller splits the rows by `repository` and works out where each of them carries on from the
199 * oldest row in the slice, which every repository the slice covers is now read up to.
200 */
201export interface ProviderBatchedChangeRequestPage {
202 readonly items: ReadonlyArray<ProviderBatchedChangeRequest>;
203 /** True when the host has more rows than the slice asked for, for any of the repositories. */
204 readonly truncated: boolean;
206​
207/** The line counts for one change request, which a listing may leave for a second read. */
208export interface ProviderChangeRequestStat {
209 readonly repository: string;
210 readonly number: number;
211 readonly additions: number;
212 readonly deletions: number;
214​
215export interface ProviderChangeRequestDetail extends ProviderChangeRequest {
216 readonly body: string;
217 readonly changedFiles: number;
218 readonly mergedAt: string | null;
219 readonly closedAt: string | null;
220 readonly reviewers: ReadonlyArray<PullRequestActor>;
221 readonly checks: ReadonlyArray<PullRequestCheck>;
222 readonly mergeCapabilities: PullRequestMergeCapabilities;
223 readonly viewerPermissions: PullRequestViewerPermissions;
224 /** Absent from a host that cannot compare the branch with its base, which is most of them. */
225 readonly baseComparison?: PullRequestBaseComparison;
226 readonly behindBy?: number;
227 /** Absent from a host that does not report whether it is armed to merge this on its own. */
228 readonly autoMergeEnabled?: boolean;
229 /** The strategy stored with an armed auto-merge, where the host reports it. */
230 readonly autoMergeMethod?: PullRequestMergeMethod;
231 /** Workflow runs on this head commit that still need a maintainer's approval. */
232 readonly workflowApprovalsRequired?: number;
234​
235/** The conversation-shaped half of a detail, loaded after the core can already render. */
236export interface ProviderChangeRequestActivity {
237 /** An optional richer actor, e.g. after GitHub's GraphQL read supplies an avatar. */
238 readonly author?: PullRequestActor | null;
239 /** Optional because most hosts already report their reviewer list in the core detail. */
240 readonly reviewers?: ReadonlyArray<PullRequestActor>;
241 readonly comments: ReadonlyArray<PullRequestComment>;
242 /**
243 * The host's own count of the conversation, which a bounded read can fall short of. A host
244 * that reports no count of its own answers with what it handed over, which is the same number
245 * once the read went to the end.
246 */
247 readonly commentCount: number;
248 readonly commentsTruncated: boolean;
249 readonly reviewThreads: ReadonlyArray<PullRequestReviewThread>;
250 readonly commits: ReadonlyArray<PullRequestCommit>;
251 /** The change request's own reactions, from a host that has them. */
252 readonly reactions?: ReadonlyArray<PullRequestReaction>;
254​
255export interface ProviderDiffSlice {
256 readonly patch: string;
257 /** Something in this slice could not be shown, as opposed to there being more slices. */
258 readonly truncated: boolean;
259 readonly nextCursor: string | null;
260 /** The host's own counts for the files whose hunks it withheld from this slice. */
261 readonly omittedFileStats?: ReadonlyArray<PullRequestOmittedFileStat>;
263​
264export interface ProviderDiffFileContents {
265 readonly oldContents: string;
266 readonly newContents: string;
268​
269export interface ProviderFilesViewed {
270 readonly files: ReadonlyArray<PullRequestFileViewed>;
271 /** The host has more files than were read, so the ones missing here are not "unviewed". */
272 readonly truncated: boolean;
274​
275/**
276 * What version each of the asked-for files is at, on the change request's head. Opaque strings,
277 * compared only against one another, where the empty string is the answer for a file the change
278 * request deletes rather than a gap. A path is absent only where the read could not say, so a
279 * provider converts its host's own absences on the way here.
280 *
281 * The whole path a version travels, and the three senses of null along it, are in
282 * `docs/internals/pull-request-file-revisions.md`.
283 */
284export interface ProviderFileRevisions {
285 readonly revisions: ReadonlyMap<string, string>;
286 /**
287 * Whether these are every file the change request carries rather than only the paths asked
288 * about. A host with no per-file version reads the whole change to answer for one file, and
289 * saying so is what keeps the next tick, naming a path nothing asked about before, from making
290 * it read the whole change again. False for a read cut short, which cannot speak past the cut.
291 */
292 readonly complete?: boolean;
294​
295export interface ProviderRepositoryRef {
296 readonly cwd: string;
297 /** Provider-native repository identity, e.g. `owner/repo` or `group/subgroup/project`. */
298 readonly repository: string;
299 /**
300 * The host it lives on, which `repository` deliberately leaves out — the same `owner/repo`
301 * exists on github.com and on a GitHub Enterprise install, and only the caller knows which
302 * one a project's remote points at.
303 */
304 readonly host: string;
306​
307/**
308 * One host's change requests. Implementations own their own tool and JSON shapes and hand back
309 * the neutral types above; anything a host cannot do is declared in `capabilities` rather than
310 * failing at call time.
311 */
312export interface PullRequestProviderApi {
313 readonly withVerifiedCredential?: <A, E, R>(
314 input: { readonly cwd: string; readonly host: string },
315 use: (identity: {
316 readonly accountId: string;
317 readonly viewer: string;
318 readonly credentialFingerprint: string;
319 }) => Effect.Effect<A, E, R>,
320 ) => Effect.Effect<A, E | PullRequestProviderError, R>;
321 readonly getRoutingIdentity?: (input: {
322 readonly cwd: string;
323 readonly host: string;
324 }) => Effect.Effect<
325 { readonly accountId: string; readonly viewer: string },
326 PullRequestProviderError
327 >;
328 readonly kind: SourceControlProviderKind;
329 readonly capabilities: PullRequestCapabilities;
330​
331 /** The signed-in account, which is what involvement filtering compares against. */
332 readonly getViewer: (input: {
333 readonly cwd: string;
334 readonly host?: string;
335 }) => Effect.Effect<string, PullRequestProviderError>;
336​
337 readonly listChangeRequests: (
338 input: ProviderRepositoryRef & {
339 readonly state: PullRequestListState;
340 readonly involvement: PullRequestInvolvement;
341 readonly viewer: string;
342 readonly limit: number;
343 /**
344 * Free text to narrow the listing by, as the host understands it. A host with no text
345 * filter of its own ignores it and answers with the page it would have answered with
346 * anyway — the caller narrows what it gets, so an unfiltered page is a wider answer
347 * rather than a wrong one.
348 */
349 readonly query?: string | undefined;
350 /**
351 * Where to carry on from, rather than reading this repository from its newest row. Absent
352 * asks for the first slice, which is every listing that has not been continued.
353 */
354 readonly cursor?: ProviderListCursor | undefined;
355 /**
356 * Further narrowings, which a host applies as far as it can and ignores the rest of —
357 * an unnarrowed page is a wider answer rather than a wrong one, and the caller narrows
358 * what it gets for the fields a row carries.
359 */
360 readonly filters?: PullRequestListFilters | undefined;
361 },
362 ) => Effect.Effect<ProviderChangeRequestPage, PullRequestProviderError>;
363​
364 /**
365 * The same listing for a whole host in one request, for a host that has a search across
366 * repositories. Optional: three of the four hosts here have no such API, and breaking the port
367 * for them to spare GitHub a fan-out would be paying for the fix with everyone else's clarity.
368 * The caller falls back to `listChangeRequests` per repository where this is absent, and where
369 * it fails.
370 *
371 * `limit` is the whole slice rather than a size per repository, because that is the shape of
372 * the answer: the newest `limit` rows across every repository named, which is exactly the rows
373 * a page ordered by update shows.
374 *
375 * `cursor` is one boundary for all of them, so a caller with repositories standing at different
376 * boundaries asks in groups rather than in one call.
377 */
378 readonly listChangeRequestsAcross?: (input: {
379 /** Any checkout on the host, which is what the tool is run in. */
380 readonly cwd: string;
381 readonly host: string;
382 readonly repositories: ReadonlyArray<string>;
383 readonly state: PullRequestListState;
384 readonly involvement: PullRequestInvolvement;
385 readonly viewer: string;
386 readonly limit: number;
387 readonly query?: string | undefined;
388 readonly cursor?: ProviderListCursor | undefined;
389 readonly filters?: PullRequestListFilters | undefined;
390 }) => Effect.Effect<ProviderBatchedChangeRequestPage, PullRequestProviderError>;
391​
392 /**
393 * The line counts for rows a listing has already handed over. Only implemented by a provider
394 * whose listing leaves them out — for everyone else the numbers arrived with the row, and the
395 * caller has nothing to ask for.
396 */
397 readonly listChangeRequestStats?: (input: {
398 readonly cwd: string;
399 readonly host: string;
400 readonly changeRequests: ReadonlyArray<{
401 readonly repository: string;
402 readonly number: number;
403 }>;
404 }) => Effect.Effect<ReadonlyArray<ProviderChangeRequestStat>, PullRequestProviderError>;
405​
406 readonly getChangeRequestChecks?: (
407 input: ProviderRepositoryRef & { readonly number: number },
408 ) => Effect.Effect<PullRequestChecks, PullRequestProviderError>;
409​
410 readonly getChangeRequest: (
411 input: ProviderRepositoryRef & { readonly number: number },
412 ) => Effect.Effect<ProviderChangeRequestDetail, PullRequestProviderError>;
413​
414 /** Hosts without a narrow read use their existing detail response for hover cards. */
415 readonly getChangeRequestPreview?: (
416 input: ProviderRepositoryRef & { readonly number: number },
417 ) => Effect.Effect<
418 Omit<PullRequestPreview, "projectId" | "repository">,
419 PullRequestProviderError
420 >;
421​
422 /**
423 * The cheap live fields used by linked threads. Optional because a provider without a narrow
424 * endpoint can fall back to its full detail read at the service boundary.
425 */
426 readonly getChangeRequestSummary?: (
427 input: ProviderRepositoryRef & { readonly number: number },
428 ) => Effect.Effect<ProviderChangeRequestSummary, PullRequestProviderError>;
429​
430 /**
431 * The host-native stack a change request belongs to, or null when it is not stacked. Optional
432 * because most hosts have no such object; the service derives chains from base branches there.
433 */
434 readonly getChangeRequestStack?: (
435 input: ProviderRepositoryRef & { readonly includeDetails?: boolean; readonly number: number },
436 ) => Effect.Effect<ProviderChangeRequestStack | null, PullRequestProviderError>;
437​
438 /** Comments, line threads, and commits, kept off the critical path for the core detail. */
439 readonly getChangeRequestActivity: (
440 input: ProviderRepositoryRef & { readonly number: number },
441 ) => Effect.Effect<ProviderChangeRequestActivity, PullRequestProviderError>;
442​
443 /** One explicit page after a reader asks to continue an unfinished review thread. */
444 readonly getReviewThreadComments?: (
445 input: ProviderRepositoryRef & {
446 readonly number: number;
447 readonly threadId: string;
448 readonly cursor: string;
449 },
450 ) => Effect.Effect<PullRequestThreadCommentsResult, PullRequestProviderError>;
451​
452 /**
453 * The same answer `getChangeRequest` carries, on its own. Asked before anything is written, so
454 * a request that reached the server without going past the page is refused by what the host
455 * says rather than by what the client claimed — and asked freshly, because access granted or
456 * taken away since the page loaded is exactly the case this guards.
457 *
458 * Implementations read the cheapest thing that answers it, which for a host with nothing to say
459 * is no request at all.
460 */
461 readonly getViewerPermissions: (
462 input: ProviderRepositoryRef & {
463 readonly number: number;
464 /** Skip branch comparison when checking permission for an unrelated operation. */
465 readonly includeUpdateBranch?: boolean;
466 },
467 ) => Effect.Effect<PullRequestViewerPermissions, PullRequestProviderError>;
468​
469 /**
470 * One slice of the patch. Only called when `capabilities.diff` is true. A provider that can
471 * serve the whole diff at once answers with `nextCursor: null` and is done; one that pages
472 * hands back whatever it needs to find the next slice.
473 */
474 readonly getDiff: (
475 input: ProviderRepositoryRef & {
476 readonly number: number;
477 readonly cursor?: string | undefined;
478 /** One commit's own changes, rather than everything the change request carries. */
479 readonly commit?: string | undefined;
480 },
481 ) => Effect.Effect<ProviderDiffSlice, PullRequestProviderError>;
482​
483 /**
484 * Full files at the exact revisions the host used for its patch. Optional where the provider
485 * exposes no diff at all; the service refuses expansion there just as it refuses the patch.
486 */
487 readonly getDiffFileContents?: (
488 input: ProviderRepositoryRef & {
489 readonly number: number;
490 readonly commit?: string | undefined;
491 readonly changeType: "change" | "rename-pure" | "rename-changed" | "new" | "deleted";
492 readonly oldPath: string;
493 readonly newPath: string;
494 },
495 ) => Effect.Effect<ProviderDiffFileContents, PullRequestProviderError>;
496​
497 /**
498 * Which files the reader has already cleared. Only called when `capabilities.viewedFiles` is
499 * `"host"`, and read apart from the patch: this moves with every press rather than every push.
500 */
501 readonly getFilesViewed?: (
502 input: ProviderRepositoryRef & { readonly number: number },
503 ) => Effect.Effect<ProviderFilesViewed, PullRequestProviderError>;
504​
505 /**
506 * Clears files, or puts them back. Only called when `capabilities.viewedFiles` is `"host"`.
507 * A host with no bulk form is still owed one round trip for the batch rather than one per file,
508 * since the point of gathering presses is that the host is asked once.
509 */
510 readonly setFilesViewed?: (
511 input: ProviderRepositoryRef & {
512 readonly number: number;
513 readonly files: ReadonlyArray<{ readonly path: string; readonly viewed: boolean }>;
514 },
515 ) => Effect.Effect<void, PullRequestProviderError>;
516​
517 /**
518 * What version the head has of each of these files. Required of a host whose
519 * `capabilities.viewedFiles` is `"environment"`, and unused by one that keeps the marks itself:
520 * the marks live here, but only the host can say whether what a reader cleared last week is
521 * still what is in front of them. Asked for the marked paths alone, so the cost follows how
522 * much of the change request has been read rather than how large it is.
523 */
524 readonly getFileRevisions?: (
525 input: ProviderRepositoryRef & {
526 readonly number: number;
527 readonly paths: ReadonlyArray<string>;
528 },
529 ) => Effect.Effect<ProviderFileRevisions, PullRequestProviderError>;
530​
531 readonly runAction: (
532 input: ProviderRepositoryRef & {
533 readonly number: number;
534 readonly action: PullRequestAction;
535 readonly stackNumber?: number;
536 readonly expectedStackHeads?: ReadonlyArray<PullRequestStackHead>;
537 /** Meaningful for `merge` and `enable-auto-merge`; absent takes the host's own default. */
538 readonly mergeMethod?: PullRequestMergeMethod;
539 /** Only meaningful for `update-branch`; absent takes the host's own default. */
540 readonly updateMethod?: PullRequestUpdateMethod;
541 },
542 ) => Effect.Effect<void, PullRequestProviderError>;
543​
544 /**
545 * Rewrites the change request's own words. Only called when `capabilities.edit.changeRequest`
546 * is true, and never with both fields absent — the caller refuses that before it gets here,
547 * because a host asked to change nothing answers differently on each of them.
548 */
549 readonly updateChangeRequest?: (
550 input: ProviderRepositoryRef & {
551 readonly number: number;
552 readonly title?: string | undefined;
553 readonly body?: string | undefined;
554 },
555 ) => Effect.Effect<void, PullRequestProviderError>;
556​
557 readonly comment: (
558 input: ProviderRepositoryRef & { readonly number: number; readonly body: string },
559 ) => Effect.Effect<void, PullRequestProviderError>;
560​
561 /**
562 * Rewrites a remark somebody already posted. Only called when `capabilities.edit.comment` is
563 * true, with an id exactly as the conversation carried it.
564 *
565 * Whether this remark is the reader's to rewrite is the host's own answer: no read here can
566 * settle it, since access can be taken away between the conversation being read and the
567 * rewrite being sent, and a host refuses a stranger's remark with a sentence saying so.
568 */
569 readonly updateComment?: (
570 input: ProviderRepositoryRef & {
571 readonly number: number;
572 readonly commentId: string;
573 readonly kind: "issue-comment" | "review-comment";
574 readonly body: string;
575 },
576 ) => Effect.Effect<void, PullRequestProviderError>;
577​
578 /**
579 * Sends a whole review at once. Only called for a verdict the host declared in
580 * `capabilities.review.verdicts`, and with line comments only where it declared
581 * `inlineComment`.
582 */
583 readonly submitReview: (
584 input: ProviderRepositoryRef & {
585 readonly number: number;
586 readonly verdict: PullRequestReviewVerdict;
587 readonly body: string;
588 readonly comments: ReadonlyArray<PullRequestReviewCommentDraft>;
589 },
590 ) => Effect.Effect<void, PullRequestProviderError>;
591​
592 /**
593 * The people this viewer may ask for a review, with whoever has already been asked marked as
594 * such. Only called when `capabilities.reviewers.listCandidates` is true.
595 *
596 * The author is left out by each provider rather than by the caller, because only the provider
597 * knows how the host spells the same person in a candidate list and on a pull request.
598 */
599 readonly listReviewerCandidates: (
600 input: ProviderRepositoryRef & { readonly number: number },
601 ) => Effect.Effect<PullRequestReviewerCandidateList, PullRequestProviderError>;
602​
603 /**
604 * Asks for a review, or takes the request back. Only called when
605 * `capabilities.reviewers.request` is true.
606 *
607 * One call for both directions, because that is what every host does with them: GitHub posts and
608 * deletes the same collection, and GitLab and Bitbucket write the whole reviewer set either way.
609 * Asking again somebody who has already reviewed is a request like any other — which is how a
610 * re-request is made.
611 */
612 readonly setReviewerRequest: (
613 input: ProviderRepositoryRef & {
614 readonly number: number;
615 readonly reviewers: ReadonlyArray<{
616 readonly id: string;
617 readonly kind: PullRequestReviewerKind;
618 }>;
619 readonly requested: boolean;
620 },
621 ) => Effect.Effect<void, PullRequestProviderError>;
622​
623 /**
624 * The repository's labels, with the ones already on the change request marked. Present with
625 * `setLabels` only where `capabilities.labels` is true; the service refuses both without it.
626 */
627 readonly listLabelCandidates?: (
628 input: ProviderRepositoryRef & { readonly number: number },
629 ) => Effect.Effect<PullRequestLabelCandidateList, PullRequestProviderError>;
630​
631 /** Puts labels on the change request, or takes them off. One call for both directions. */
632 readonly setLabels?: (
633 input: ProviderRepositoryRef & {
634 readonly number: number;
635 readonly labels: ReadonlyArray<string>;
636 readonly applied: boolean;
637 },
638 ) => Effect.Effect<void, PullRequestProviderError>;
639​
640 /** Only called when `capabilities.review.reply` is true. */
641 readonly replyToThread: (
642 input: ProviderRepositoryRef & {
643 readonly number: number;
644 readonly threadId: string;
645 readonly body: string;
646 },
647 ) => Effect.Effect<void, PullRequestProviderError>;
648​
649 /**
650 * Adds a reaction, or takes it back. Only called when `capabilities.reactions` is true.
651 *
652 * `subjectId` is a remark's id as the conversation carried it; absent means the change request
653 * itself, whose reactions sit on its description. Whatever a host needs to address either of
654 * them is worked out here, because the id a conversation travels with is the one the reader has.
655 */
656 readonly setReaction: (
657 input: ProviderRepositoryRef & {
658 readonly number: number;
659 readonly subjectId?: string | undefined;
660 readonly content: PullRequestReactionContent;
661 readonly reacted: boolean;
662 },
663 ) => Effect.Effect<void, PullRequestProviderError>;
664​
665 /** Only called when `capabilities.review.resolve` is true. */
666 readonly setThreadResolution: (
667 input: ProviderRepositoryRef & {
668 readonly number: number;
669 readonly threadId: string;
670 readonly resolved: boolean;
671 },
672 ) => Effect.Effect<void, PullRequestProviderError>;