@chernabog/sdk 0.11.1 → 0.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/src/phases.ts ADDED
@@ -0,0 +1,264 @@
1
+ // The phases an item reaches between runs, by kind of item, and what the
2
+ // catalogue declares of them: the phases each source reads and each block
3
+ // records (docs/run-progress/handoffs.md, questions 1 and 8). A phase is
4
+ // written by one flow and read by another, so these declarations are what the
5
+ // check across a repo's flows goes by (Compose.phaseGaps).
6
+ //
7
+ // Unlike labels, a repo can't rename these: no person reads or applies them.
8
+ // A team's own phases are strings it chooses, recorded with progress.advance.
9
+
10
+ import {
11
+ activity,
12
+ Claims,
13
+ CurrentNode,
14
+ type NodeAt,
15
+ Phase as CorePhase,
16
+ type PhaseRecord,
17
+ PhaseWriter,
18
+ Progress,
19
+ ProgressError,
20
+ Run,
21
+ type WorkItem,
22
+ } from "@chernabog/core";
23
+ import * as Arr from "effect/Array";
24
+ import * as Context from "effect/Context";
25
+ import * as Effect from "effect/Effect";
26
+ import * as Option from "effect/Option";
27
+ import * as Schema from "effect/Schema";
28
+
29
+ // What a phase is kept for. These are the names claim refs already use.
30
+ export type ItemKind = "issue" | "pull-request" | "epic";
31
+
32
+ export const ITEM_KINDS: ReadonlyArray<ItemKind> = ["issue", "pull-request", "epic"];
33
+
34
+ export const PHASES = {
35
+ issue: {
36
+ handedOff: "handed-off",
37
+ askedQuestions: "asked-questions",
38
+ awaitingReady: "awaiting-ready",
39
+ proposed: "proposed",
40
+ becameEpic: "became-epic",
41
+ },
42
+ pullRequest: {
43
+ reviewAsked: "review-asked",
44
+ changesAsked: "changes-asked",
45
+ reviewAskedAgain: "review-asked-again",
46
+ approved: "approved",
47
+ mergeHeld: "merge-held",
48
+ readyForPerson: "ready-for-person",
49
+ draft: "draft",
50
+ watched: "watched",
51
+ },
52
+ epic: { waiting: "waiting", finished: "finished" },
53
+ } as const;
54
+
55
+ type PhasesOf<Kind extends keyof typeof PHASES> =
56
+ (typeof PHASES)[Kind][keyof (typeof PHASES)[Kind]];
57
+
58
+ // One of the SDK's phases.
59
+ export type Phase = PhasesOf<"issue"> | PhasesOf<"pullRequest"> | PhasesOf<"epic">;
60
+
61
+ // What a source reads of an item with no record yet.
62
+ export const NO_RECORD = "none";
63
+
64
+ // The SDK's phases of each kind of item.
65
+ export const phasesOf = (item: ItemKind): ReadonlyArray<string> =>
66
+ Object.values(
67
+ { issue: PHASES.issue, "pull-request": PHASES.pullRequest, epic: PHASES.epic }[item],
68
+ );
69
+
70
+ // The item a run on each subject works on, which a team's own
71
+ // progress.advance step records its phase on. Four subjects are one pull
72
+ // request, seen by different flows.
73
+ export const SUBJECT_ITEMS = {
74
+ issue: "issue",
75
+ spec: "issue",
76
+ "pull-request": "pull-request",
77
+ "changes-asked": "pull-request",
78
+ conflict: "pull-request",
79
+ merged: "pull-request",
80
+ epic: "epic",
81
+ } as const satisfies { readonly [subject: string]: ItemKind };
82
+
83
+ // One phase a block may record on its way out.
84
+ export type Recorded = {
85
+ readonly item: ItemKind;
86
+ readonly phase: Phase;
87
+ // Recorded only when the block comes to this outcome; left out: on any
88
+ // ending that goes on.
89
+ readonly on?: string;
90
+ };
91
+
92
+ // The phases whose items a source finds, or a wake finds parked runs by.
93
+ // NO_RECORD for an item with no record yet.
94
+ export type Reading = {
95
+ readonly item: ItemKind;
96
+ readonly phases: ReadonlyArray<Phase | typeof NO_RECORD>;
97
+ };
98
+
99
+ // A phase a source moves an item to from what it reads on GitHub, such as a
100
+ // person's review, each from the phases it moves on from (question 5).
101
+ export type Reconciling = {
102
+ readonly item: ItemKind;
103
+ readonly from: ReadonlyArray<Phase | typeof NO_RECORD>;
104
+ readonly to: Phase;
105
+ };
106
+
107
+ // What a source declares of phases.
108
+ export type SourceProgress = {
109
+ readonly reads: ReadonlyArray<Reading>;
110
+ readonly reconciles?: ReadonlyArray<Reconciling>;
111
+ };
112
+
113
+ // As a phase is written: lower-case words joined by hyphens.
114
+ export const PHASE_NAME = /^[a-z][a-z0-9]*(-[a-z0-9]+)*$/;
115
+
116
+ // Reading and recording an item's phase, through core's Progress port, for the
117
+ // blocks that own a handoff and the sources that read one. Both a document's
118
+ // blocks and a recipe's own code call these, so the two record and read alike.
119
+
120
+ // The item a phase is kept for, named as its claim is.
121
+ export const issueItem = (issue: number) => Claims.issue(issue);
122
+ export const pullRequestItem = (pullRequest: number) => Claims.pullRequest(pullRequest);
123
+
124
+ const asPhase = Schema.decodeSync(CorePhase);
125
+ const asWriter = Schema.decodeSync(PhaseWriter);
126
+
127
+ // The times a run's write reads the item again after another writer moved it.
128
+ const RECORD_TRIES = 3;
129
+
130
+ // Records that `item` has reached `to`, as the run: from whatever phase it
131
+ // holds now, and nothing when it is there already, so a source that
132
+ // reconciled the same fact first, or a replay, writes no second record. A
133
+ // handoff happens whatever the item held before it, so a lost race reads
134
+ // again and moves on from what it finds. Call it inside the activity that
135
+ // makes the handoff, so a replay of a finished one doesn't write again.
136
+ export const record = (item: string, to: string) =>
137
+ Effect.gen(function* () {
138
+ const progress = yield* Progress;
139
+ const run = yield* Run;
140
+ const phase = asPhase(to);
141
+ const by = asWriter(run.runId);
142
+
143
+ for (let tries = 1; ; tries++) {
144
+ const current = yield* progress.read(item);
145
+
146
+ if (Option.exists(current, (found) => found.phase === phase)) {
147
+ return;
148
+ }
149
+
150
+ const from = Option.map(current, (found) => found.phase);
151
+
152
+ const moved = yield* progress.advance(item, { from, to: phase, by }).pipe(
153
+ Effect.as(false),
154
+ Effect.catchTag("PhaseMoved", (lost) => {
155
+ if (tries < RECORD_TRIES) {
156
+ return Effect.succeed(true);
157
+ }
158
+
159
+ return Effect.fail(new ProgressError({ message: lost.message }));
160
+ }),
161
+ );
162
+
163
+ if (!moved) {
164
+ return;
165
+ }
166
+ }
167
+ });
168
+
169
+ // Every item's record, in one read, for a source that looks at every open item.
170
+ export const records = Progress.use((progress) => progress.readAll);
171
+
172
+ // The record of `item` among `all`, from records.
173
+ export const recordOf = (all: ReadonlyMap<string, PhaseRecord>, item: string) =>
174
+ Option.fromUndefinedOr(all.get(item));
175
+
176
+ // Whether `found` holds one of `phases`.
177
+ export const holds = (found: PhaseRecord, phases: ReadonlyArray<Phase>) =>
178
+ phases.some((phase) => phase === found.phase);
179
+
180
+ // Moves `item` from the record a source read, `found`, to `to`, from a fact
181
+ // on GitHub that no run was there to record, such as a person's review
182
+ // (docs/run-progress/handoffs.md, question 5). Outside a run, so `by` names
183
+ // the source. Returns the record the item holds afterwards: the one written,
184
+ // or, when another writer moved it first, the one it moved it to.
185
+ export const reconcile = (item: string, found: Option.Option<PhaseRecord>, to: Phase, by: string) =>
186
+ Progress.use((progress) =>
187
+ progress
188
+ .advance(item, {
189
+ from: Option.map(found, (held) => held.phase),
190
+ to: asPhase(to),
191
+ by: asWriter(by),
192
+ })
193
+ .pipe(
194
+ Effect.asSome,
195
+ Effect.catchTag("PhaseMoved", () => progress.read(item)),
196
+ ),
197
+ );
198
+
199
+ // A work item's key for the record an item holds: the item, its phase and
200
+ // the record's version shortened as a head SHA is, `pr-7-changes-asked-1a2b3c4`.
201
+ // A new record is new work, as a new head is to pr.conflicting.
202
+ export const keyFor = (item: string, found: PhaseRecord) =>
203
+ `${item}-${found.phase}-${found.version.slice(0, 7)}`;
204
+
205
+ const PullRequestWork = Schema.Struct({ pullRequest: Schema.Finite });
206
+ const IssueWork = Schema.Struct({ issue: Schema.Finite });
207
+
208
+ // The item a run on `subject` works on, from its work item: the pull request
209
+ // its data names, or the issue, or the epic, whose claim is `epic-N` though
210
+ // its work item is the issue's. None for one that names neither.
211
+ export const itemOfWork = (subject: string, work: WorkItem): Option.Option<string> =>
212
+ Option.flatMap(
213
+ Option.map(
214
+ Arr.findFirst(Object.entries(SUBJECT_ITEMS), ([name]) => name === subject),
215
+ ([, kind]): ItemKind => kind,
216
+ ),
217
+ (kind) => {
218
+ if (kind === "pull-request") {
219
+ return Option.map(Schema.decodeUnknownOption(PullRequestWork)(work.data), (found) =>
220
+ pullRequestItem(found.pullRequest),
221
+ );
222
+ }
223
+
224
+ return Option.map(Schema.decodeUnknownOption(IssueWork)(work.data), (found) => {
225
+ if (kind === "epic") {
226
+ return Claims.epic(found.issue);
227
+ }
228
+
229
+ return issueItem(found.issue);
230
+ });
231
+ },
232
+ );
233
+
234
+ // The item a document's run records a team's own phase on (progress.advance):
235
+ // its work item's, as its subject sees it, which Blocks.assemble provides.
236
+ // None outside a document's run.
237
+ export const RecordedOn = Context.Reference<Option.Option<string>>("@chernabog/sdk/RecordedOn", {
238
+ defaultValue: () => Option.none(),
239
+ });
240
+
241
+ // The step a progress.advance records in: named by its node in the plan,
242
+ // with its round and lane, so each step records once and a replay finds it
243
+ // recorded, rather than moving the item back.
244
+ const advanceStep = (phase: string, node: Option.Option<NodeAt>) =>
245
+ Option.match(node, {
246
+ onNone: () => `progress-${phase}`,
247
+ onSome: (at) =>
248
+ [
249
+ `progress-${at.id}`,
250
+ ...Option.toArray(Option.map(at.round, (round) => `${round}`)),
251
+ ...Option.toArray(at.lane),
252
+ ].join("-"),
253
+ });
254
+
255
+ // Records `phase` on the item the document's run works on (RecordedOn), as
256
+ // the run, in a step of its own; nothing outside a document's run.
257
+ export const advanceRun = (phase: string) =>
258
+ Effect.gen(function* () {
259
+ const step = advanceStep(phase, yield* CurrentNode);
260
+
261
+ for (const item of Option.toArray(yield* RecordedOn)) {
262
+ yield* activity(step, record(item, phase));
263
+ }
264
+ });
@@ -22,7 +22,9 @@ import {
22
22
  IssueNumber,
23
23
  ToPerson,
24
24
  } from "./block.ts";
25
+ import * as Events from "./events.ts";
25
26
  import * as Implement from "./implement.ts";
27
+ import { PHASES } from "./phases.ts";
26
28
  import * as Plan from "./plan.ts";
27
29
  import * as Routing from "./routing.ts";
28
30
  import * as Settings from "./settings.ts";
@@ -85,19 +87,24 @@ export const specSubject = {
85
87
  };
86
88
 
87
89
  export const planSources = {
88
- "plan.queued": defineSource("plan.queued", "spec", () => ({
89
- trigger: Effect.gen(function* () {
90
- const queued = yield* (yield* GitHub).queuedIssuesLabelled(Plan.LABELS.plan);
90
+ "plan.queued": defineSource(
91
+ "plan.queued",
92
+ "spec",
93
+ () => ({
94
+ trigger: Effect.gen(function* () {
95
+ const queued = yield* (yield* GitHub).queuedIssuesLabelled(Plan.LABELS.plan);
91
96
 
92
- return yield* Effect.forEach(queued, (issue) =>
93
- Implement.routed(issue, Implement.issueItem(issue, Option.some(Plan.LABELS.plan))),
94
- );
95
- }).pipe(reportAs("trigger")),
96
- contributes: {
97
- settings: { ...Routing.Settings.fields, ...Settings.Board.fields },
98
- labels: Plan.flowLabels,
99
- },
100
- })),
97
+ return yield* Effect.forEach(queued, (issue) =>
98
+ Implement.routed(issue, Implement.issueItem(issue, Option.some(Plan.LABELS.plan))),
99
+ );
100
+ }).pipe(reportAs("trigger")),
101
+ contributes: {
102
+ settings: { ...Routing.Settings.fields, ...Settings.Board.fields },
103
+ labels: Plan.flowLabels,
104
+ },
105
+ }),
106
+ { events: [Events.issueLabelled] },
107
+ ),
101
108
  };
102
109
 
103
110
  // What every plan block suits: each reads or writes the spec's plan, whose
@@ -198,7 +205,12 @@ export const planBlocks = {
198
205
  mustRoute: ["approved", "changes"],
199
206
  exhaustive: true,
200
207
  waits: true,
201
- contributes: { wakes: Plan.answers.pipe(reportAs("trigger")) },
208
+ records: [{ item: "issue", phase: PHASES.issue.proposed }],
209
+ contributes: {
210
+ wakes: Plan.answers.pipe(reportAs("trigger")),
211
+ wakeEvents: [Events.commentCreated],
212
+ wakeReads: [{ item: "issue", phases: [PHASES.issue.proposed] }],
213
+ },
202
214
  }),
203
215
 
204
216
  "plan.changesAsked": defineBlock({
@@ -268,6 +280,7 @@ export const planBlocks = {
268
280
  failures: { NeedsHuman: "person", Skip: "skip", StepFailed: "person" },
269
281
  outcomes: {},
270
282
  mustRoute: [],
283
+ records: [{ item: "issue", phase: PHASES.issue.becameEpic }],
271
284
  contributes: {},
272
285
  }),
273
286
 
@@ -38,6 +38,8 @@ import {
38
38
  PullRequestNumber,
39
39
  ToPerson,
40
40
  } from "./block.ts";
41
+ import * as Events from "./events.ts";
42
+ import { PHASES } from "./phases.ts";
41
43
  import * as PullRequest from "./pull-request.ts";
42
44
  import * as Settings from "./settings.ts";
43
45
 
@@ -513,6 +515,7 @@ export const postMergeBlocks = {
513
515
  failures: { NeedsHuman: "told", Skip: "skip", StepFailed: "fail" },
514
516
  outcomes: {},
515
517
  mustRoute: [],
518
+ records: [{ item: "pull-request", phase: PHASES.pullRequest.watched }],
516
519
  contributes: {},
517
520
  }),
518
521
 
@@ -724,63 +727,74 @@ export const postMergeBlocks = {
724
727
  export const postMergeSources = {
725
728
  // Pull requests this persona wrote that merged into the base branch in the
726
729
  // last day, among the 30 closed most lately, and that no run has watched yet.
727
- "pr.mergedRecently": defineSource("pr.mergedRecently", "merged", () => ({
728
- trigger: Effect.gen(function* () {
729
- const github = yield* GitHub;
730
- const repo = yield* Repo;
731
- const base = yield* Settings.base;
732
- const me = yield* github.login;
733
- const now = yield* DateTime.now;
734
- const items: Array<WorkItem> = [];
735
-
736
- const closed = yield* github
737
- .request(
738
- "GET",
739
- `/repos/${repo.slug}/pulls?state=closed&sort=updated&direction=desc&per_page=30`,
740
- Option.none(),
741
- )
742
- .pipe(Effect.flatMap(decodeIn(ClosedPulls, "trigger")));
743
-
744
- for (const pull of closed) {
745
- if (
746
- !sameLogin(pull.user.login, me) ||
747
- pull.base.ref !== base ||
748
- Option.isNone(pull.merge_commit_sha) ||
749
- !Option.exists(pull.merged_at, (at) => isRecent(at, now))
750
- ) {
751
- continue;
752
- }
753
-
754
- const comments = yield* github.trustedComments(pull.number);
755
-
756
- if (comments.some((comment) => Option.isSome(watchedMarker.read(comment.body)))) {
757
- continue;
758
- }
759
-
760
- const issue = closedIssue(
761
- Option.getOrElse(pull.body, () => ""),
762
- pull.head.ref,
763
- );
764
-
765
- items.push({
766
- key: `merged-${pull.number}`,
767
- title: pull.title,
768
- url: pull.html_url,
769
- data: {
770
- pullRequest: pull.number,
771
- url: pull.html_url,
730
+ "pr.mergedRecently": defineSource(
731
+ "pr.mergedRecently",
732
+ "merged",
733
+ () => ({
734
+ trigger: Effect.gen(function* () {
735
+ const github = yield* GitHub;
736
+ const repo = yield* Repo;
737
+ const base = yield* Settings.base;
738
+ const me = yield* github.login;
739
+ const now = yield* DateTime.now;
740
+ const items: Array<WorkItem> = [];
741
+
742
+ const closed = yield* github
743
+ .request(
744
+ "GET",
745
+ `/repos/${repo.slug}/pulls?state=closed&sort=updated&direction=desc&per_page=30`,
746
+ Option.none(),
747
+ )
748
+ .pipe(Effect.flatMap(decodeIn(ClosedPulls, "trigger")));
749
+
750
+ for (const pull of closed) {
751
+ if (
752
+ !sameLogin(pull.user.login, me) ||
753
+ pull.base.ref !== base ||
754
+ Option.isNone(pull.merge_commit_sha) ||
755
+ !Option.exists(pull.merged_at, (at) => isRecent(at, now))
756
+ ) {
757
+ continue;
758
+ }
759
+
760
+ const comments = yield* github.trustedComments(pull.number);
761
+
762
+ if (comments.some((comment) => Option.isSome(watchedMarker.read(comment.body)))) {
763
+ continue;
764
+ }
765
+
766
+ const issue = closedIssue(
767
+ Option.getOrElse(pull.body, () => ""),
768
+ pull.head.ref,
769
+ );
770
+
771
+ items.push({
772
+ key: `merged-${pull.number}`,
772
773
  title: pull.title,
773
- mergeSha: pull.merge_commit_sha.value,
774
- baseRef: pull.base.ref,
775
- ...Option.match(issue, { onNone: () => ({}), onSome: (number) => ({ issue: number }) }),
776
- },
777
- });
778
- }
774
+ url: pull.html_url,
775
+ data: {
776
+ pullRequest: pull.number,
777
+ url: pull.html_url,
778
+ title: pull.title,
779
+ mergeSha: pull.merge_commit_sha.value,
780
+ baseRef: pull.base.ref,
781
+ ...Option.match(issue, {
782
+ onNone: () => ({}),
783
+ onSome: (number) => ({ issue: number }),
784
+ }),
785
+ },
786
+ });
787
+ }
779
788
 
780
- return items;
781
- }).pipe(reportAs("trigger")),
782
- contributes: { settings: Settings.Base.fields, ownWork: true },
783
- })),
789
+ return items;
790
+ }).pipe(reportAs("trigger")),
791
+ contributes: { settings: Settings.Base.fields, ownWork: true },
792
+ }),
793
+ {
794
+ reads: [{ item: "pull-request", phases: [PHASES.pullRequest.watched] }],
795
+ events: [Events.pullRequestClosed],
796
+ },
797
+ ),
784
798
  };
785
799
 
786
800
  // A pull request this persona wrote, merged into the base branch. A run only
@@ -40,6 +40,7 @@ import * as DurableDeferred from "effect/workflow/DurableDeferred";
40
40
 
41
41
  import * as Ci from "./ci.ts";
42
42
  import { commentStep } from "./comment.ts";
43
+ import * as Phases from "./phases.ts";
43
44
  import * as Settings from "./settings.ts";
44
45
 
45
46
  // Marks the pull request as this run's: its claim ref, and a comment for people to read.
@@ -631,6 +632,10 @@ export const holdWhileBaseRed = (pullRequest: number, attempt = 1) =>
631
632
  pullRequest,
632
633
  `Holding the merge: CI is failing on \`${base}\`. It merges once CI there is green again. ${holdMarker.write({ runId: run.runId, key: run.item.key })}`,
633
634
  );
635
+ yield* activity(
636
+ `merge-held-pr-${pullRequest}-${named}`,
637
+ Phases.record(Phases.pullRequestItem(pullRequest), Phases.PHASES.pullRequest.mergeHeld),
638
+ );
634
639
 
635
640
  if ((yield* parkOnBase(pullRequest, named, base, left)) !== BASE_GREEN) {
636
641
  return yield* stayedRed;
@@ -791,6 +796,10 @@ export const readyForPerson = (pullRequest: number, message: string) =>
791
796
  const label = yield* Settings.readyForPerson;
792
797
  yield* github.addLabel(pullRequest, label);
793
798
  yield* github.comment(pullRequest, message);
799
+ yield* Phases.record(
800
+ Phases.pullRequestItem(pullRequest),
801
+ Phases.PHASES.pullRequest.readyForPerson,
802
+ );
794
803
 
795
804
  return `#${pullRequest}: labelled ${label}; ${message}`;
796
805
  }),
@@ -7,6 +7,8 @@ import * as Effect from "effect/Effect";
7
7
  import * as Option from "effect/Option";
8
8
 
9
9
  import { Approved, defineBlock, defineSource, type PullRequestNumber } from "./block.ts";
10
+ import * as Events from "./events.ts";
11
+ import { NO_RECORD, PHASES } from "./phases.ts";
10
12
  import * as PullRequest from "./pull-request.ts";
11
13
  import * as Review from "./review.ts";
12
14
  import * as Routing from "./routing.ts";
@@ -161,6 +163,10 @@ export const reReviewBlocks = {
161
163
  },
162
164
  mustRoute: ["approve", "changes"],
163
165
  exhaustive: true,
166
+ records: [
167
+ { item: "pull-request", phase: PHASES.pullRequest.changesAsked, on: "changes" },
168
+ { item: "pull-request", phase: PHASES.pullRequest.approved, on: "approve" },
169
+ ],
164
170
  contributes: { settings: { ...Settings.Reviewers.fields, ...Settings.Rules.fields } },
165
171
  }),
166
172
 
@@ -204,31 +210,45 @@ export const reReviewBlocks = {
204
210
  failures: { NeedsHuman: "told", Skip: "skip", StepFailed: "fail" },
205
211
  outcomes: {},
206
212
  mustRoute: [],
213
+ records: [{ item: "pull-request", phase: PHASES.pullRequest.readyForPerson }],
207
214
  contributes: { namedLabels: [Settings.readyForPersonLabel] },
208
215
  }),
209
216
  };
210
217
 
211
218
  export const reReviewSources = {
212
- // Pull requests that ask this persona again after it reviewed them, one item
213
- // per request, unless a person has them (auto:needs-human): asking again
214
- // during a dispute doesn't restart the loop. Each item's key carries the
215
- // review it asks for, `pr-7-review-2`, so each request is a run of its own.
216
- "review.requestedAgain": defineSource("review.requestedAgain", "pull-request", () => ({
217
- trigger: Effect.gen(function* () {
218
- const labelNames = yield* Settings.labels;
219
-
220
- return yield* Effect.forEach(
221
- (yield* Review.reviewRequests).filter(
222
- ({ pull, reviewed }) => reviewed > 0 && !pull.labels.includes(labelNames.needsHuman),
223
- ),
224
- ({ pull, reviewed }) =>
225
- Review.routed(pull, Review.reviewItem(pull, `pr-${pull.number}-review-${reviewed + 1}`)),
226
- );
227
- }).pipe(reportAs("trigger")),
228
- contributes: {
229
- settings: Routing.Settings.fields,
230
- doctor: [Review.reviewerCheck],
231
- ownWork: true,
219
+ // Pull requests whose record says a review is asked again of this persona,
220
+ // one item per request, unless a person has them (auto:needs-human): asking
221
+ // again during a dispute doesn't restart the loop. Each item's key carries
222
+ // the record it reads, so each request is a run of its own. A request that
223
+ // finds the record at changes asked or approved, such as a person asking
224
+ // after a fix of their own, moves it on first (Review.requestedAgain).
225
+ "review.requestedAgain": defineSource(
226
+ "review.requestedAgain",
227
+ "pull-request",
228
+ () => ({
229
+ trigger: Review.requestedAgain.pipe(reportAs("trigger")),
230
+ contributes: {
231
+ settings: Routing.Settings.fields,
232
+ doctor: [Review.reviewerCheck],
233
+ ownWork: true,
234
+ },
235
+ }),
236
+ {
237
+ reads: [{ item: "pull-request", phases: [PHASES.pullRequest.reviewAskedAgain, NO_RECORD] }],
238
+ reconciles: [
239
+ {
240
+ item: "pull-request",
241
+ from: [
242
+ PHASES.pullRequest.reviewAsked,
243
+ PHASES.pullRequest.changesAsked,
244
+ PHASES.pullRequest.approved,
245
+ PHASES.pullRequest.draft,
246
+ PHASES.pullRequest.readyForPerson,
247
+ ],
248
+ to: PHASES.pullRequest.reviewAskedAgain,
249
+ },
250
+ ],
251
+ events: [Events.reviewRequestedAgain],
232
252
  },
233
- })),
253
+ ),
234
254
  };