@operad-io/dev 0.1.1 → 0.2.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/README.md +1 -1
- package/dev.schema.json +41 -28
- package/package.json +9 -6
- package/skills/setup/SKILL.md +57 -0
- package/src/access-grants.ts +59 -0
- package/src/actions.ts +70 -16
- package/src/announce.ts +128 -16
- package/src/chat.ts +512 -36
- package/src/check-host.ts +111 -0
- package/src/check-load.ts +67 -0
- package/src/check.ts +17 -12
- package/src/clock.ts +29 -0
- package/src/commands.ts +103 -34
- package/src/create-actions.ts +210 -0
- package/src/flaky.ts +45 -29
- package/src/flow-compiler.ts +155 -68
- package/src/followups.ts +20 -22
- package/src/gate.ts +192 -73
- package/src/git.ts +47 -0
- package/src/index.ts +46 -6
- package/src/integrate.ts +82 -42
- package/src/integration-queue.ts +23 -10
- package/src/lock.ts +101 -5
- package/src/mainclone.ts +3 -3
- package/src/model-error.ts +70 -0
- package/src/model.ts +48 -35
- package/src/notcode.ts +51 -15
- package/src/places.ts +2 -2
- package/src/prepare.ts +7 -2
- package/src/project-flows.ts +135 -4
- package/src/project-settings.ts +81 -0
- package/src/register-requests.ts +87 -0
- package/src/repository-key.ts +4 -0
- package/src/rerun.ts +23 -7
- package/src/retry.ts +2 -12
- package/src/rework.ts +8 -0
- package/src/schedule.ts +317 -86
- package/src/service.ts +116 -152
- package/src/settings.ts +305 -60
- package/src/standing.ts +23 -6
- package/src/step-edge.ts +22 -0
- package/src/steps.ts +469 -123
- package/src/throughput.ts +4 -21
- package/src/timeouts.ts +10 -2
- package/src/views.ts +147 -81
- package/src/waits.ts +59 -0
package/src/flow-compiler.ts
CHANGED
|
@@ -9,11 +9,14 @@ import { type FlowDefinition, type StepShape } from "@operad-io/engine";
|
|
|
9
9
|
import { createHash } from "node:crypto";
|
|
10
10
|
import type { CheckCommand } from "./settings.ts";
|
|
11
11
|
import { DEV_MAX_VISITS } from "./timeouts.ts";
|
|
12
|
-
import { WAIT_STEPS, waitChoices } from "./waits.ts";
|
|
12
|
+
import { WAIT_STEPS, WORK_QUESTION_CHOICES, WORK_QUESTION_LATE_CHOICES, waitChoiceInfo, waitChoices } from "./waits.ts";
|
|
13
13
|
|
|
14
|
-
/** The
|
|
14
|
+
/** The current names of the four stage kinds. */
|
|
15
|
+
export type StageKind = "code" | "test" | "review" | "human";
|
|
16
|
+
|
|
17
|
+
/** The code stage: the harness changes the task branch. `work` is its older name. */
|
|
15
18
|
export interface WorkStage {
|
|
16
|
-
readonly stage: "work";
|
|
19
|
+
readonly stage: "code" | "work";
|
|
17
20
|
/** The harness step; unset uses `worker`/the default pool from dev.json. */
|
|
18
21
|
readonly use?: string | undefined;
|
|
19
22
|
/** Arguments for the harness step; unset uses the worker's own. */
|
|
@@ -30,9 +33,9 @@ export interface WorkStage {
|
|
|
30
33
|
readonly beforeAttempt?: string | undefined;
|
|
31
34
|
}
|
|
32
35
|
|
|
33
|
-
/** The
|
|
36
|
+
/** The test stage: commands run in a gate checkout. `check` is its older name. */
|
|
34
37
|
export interface CheckStage {
|
|
35
|
-
readonly stage: "check";
|
|
38
|
+
readonly stage: "test" | "check";
|
|
36
39
|
/** The commands; unset uses `gate.commands` from dev.json. */
|
|
37
40
|
readonly commands?: readonly CheckCommand[] | undefined;
|
|
38
41
|
/** How often a failed line list runs again; unset uses `check.rerun`. */
|
|
@@ -70,8 +73,8 @@ export type DevFlows = Readonly<Record<string, DevFlowSpec>>;
|
|
|
70
73
|
|
|
71
74
|
/** The stages a repository with no `flows` gets: today's dev flow. */
|
|
72
75
|
export const DEFAULT_STAGES: readonly DevStage[] = [
|
|
73
|
-
{ stage: "
|
|
74
|
-
{ stage: "
|
|
76
|
+
{ stage: "code" },
|
|
77
|
+
{ stage: "test" },
|
|
75
78
|
{ stage: "review" },
|
|
76
79
|
{ stage: "human" },
|
|
77
80
|
];
|
|
@@ -81,8 +84,9 @@ export const DEFAULT_FLOW_NAME = "dev";
|
|
|
81
84
|
|
|
82
85
|
/**
|
|
83
86
|
* The registered name of a repository's own flow: the repository and flow make
|
|
84
|
-
* it readable, and the
|
|
85
|
-
* use the same flow name and a changed flow
|
|
87
|
+
* it readable, and the hash of the compiled graph makes it unique, so two
|
|
88
|
+
* repositories may use the same flow name, and a changed flow or a dev that
|
|
89
|
+
* compiles the same stages to other steps gets a new name instead of
|
|
86
90
|
* replacing a graph a running attempt still uses.
|
|
87
91
|
*/
|
|
88
92
|
export function flowNameFor(
|
|
@@ -92,8 +96,11 @@ export function flowNameFor(
|
|
|
92
96
|
): string {
|
|
93
97
|
const slug = (text: string): string =>
|
|
94
98
|
text.replace(/[^A-Za-z0-9_-]+/g, "_").replace(/^_+|_+$/g, "") || "flow";
|
|
99
|
+
const graph = compileDevFlow("", spec.stages, { gradingName: flow });
|
|
95
100
|
const hash = createHash("sha1")
|
|
96
|
-
.update(
|
|
101
|
+
.update(
|
|
102
|
+
JSON.stringify({ entry: graph.entry, maxVisits: graph.maxVisits, steps: graph.steps }),
|
|
103
|
+
)
|
|
97
104
|
.digest("hex")
|
|
98
105
|
.slice(0, 12);
|
|
99
106
|
return `dev/${slug(repository)}/${slug(flow)}/${hash}`;
|
|
@@ -121,6 +128,7 @@ function waitPerson(
|
|
|
121
128
|
choices: readonly string[],
|
|
122
129
|
next: Edge,
|
|
123
130
|
note?: string,
|
|
131
|
+
primary = true,
|
|
124
132
|
): StepShape {
|
|
125
133
|
return {
|
|
126
134
|
id,
|
|
@@ -128,6 +136,7 @@ function waitPerson(
|
|
|
128
136
|
params: {
|
|
129
137
|
prompt,
|
|
130
138
|
choices,
|
|
139
|
+
choiceInfo: waitChoiceInfo(choices, primary),
|
|
131
140
|
...(note === undefined ? {} : { note }),
|
|
132
141
|
},
|
|
133
142
|
replay: "safe",
|
|
@@ -135,6 +144,32 @@ function waitPerson(
|
|
|
135
144
|
};
|
|
136
145
|
}
|
|
137
146
|
|
|
147
|
+
/** The wait a worker's own question goes to, and the answer goes back to the same work step. */
|
|
148
|
+
function workQuestionWaitId(workId: string): string {
|
|
149
|
+
return workId === "work"
|
|
150
|
+
? WAIT_STEPS["work-question"]
|
|
151
|
+
: `${WAIT_STEPS["work-question"]}_${workId}`;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
function waitWorkerQuestion(id: string, workId: string): StepShape {
|
|
155
|
+
return {
|
|
156
|
+
id,
|
|
157
|
+
kind: "wait_person",
|
|
158
|
+
params: {
|
|
159
|
+
prompt: "The worker asked about a call.",
|
|
160
|
+
choices: [...WORK_QUESTION_CHOICES],
|
|
161
|
+
lateChoices: [...WORK_QUESTION_LATE_CHOICES],
|
|
162
|
+
},
|
|
163
|
+
replay: "safe",
|
|
164
|
+
next: {
|
|
165
|
+
allow_once: workId,
|
|
166
|
+
allow_always: workId,
|
|
167
|
+
reject_once: workId,
|
|
168
|
+
interrupted: "end_cancelled",
|
|
169
|
+
},
|
|
170
|
+
};
|
|
171
|
+
}
|
|
172
|
+
|
|
138
173
|
function end(id: string, status: "done" | "failed" | "cancelled"): StepShape {
|
|
139
174
|
return { id, kind: "end", params: { status }, replay: "safe" };
|
|
140
175
|
}
|
|
@@ -143,13 +178,27 @@ const END_FAILED = end("end_failed", "failed");
|
|
|
143
178
|
const END_CANCELLED = end("end_cancelled", "cancelled");
|
|
144
179
|
const END_DONE = end("end_done", "done");
|
|
145
180
|
|
|
146
|
-
/**
|
|
147
|
-
|
|
181
|
+
/**
|
|
182
|
+
* The edges of an announcement step: a stop, or the question it hands over,
|
|
183
|
+
* goes to `wait`.
|
|
184
|
+
*/
|
|
185
|
+
function announce(
|
|
186
|
+
id: string,
|
|
187
|
+
from: string,
|
|
188
|
+
result: string,
|
|
189
|
+
wait: string,
|
|
190
|
+
choices: readonly string[],
|
|
191
|
+
): StepShape {
|
|
148
192
|
return plugin(
|
|
149
193
|
id,
|
|
150
194
|
"dev/announce",
|
|
151
|
-
{ from, result },
|
|
152
|
-
{
|
|
195
|
+
{ from, result, choices },
|
|
196
|
+
{
|
|
197
|
+
done: wait,
|
|
198
|
+
interrupted: wait,
|
|
199
|
+
waiting: wait,
|
|
200
|
+
cancelled: "end_cancelled",
|
|
201
|
+
},
|
|
153
202
|
);
|
|
154
203
|
}
|
|
155
204
|
|
|
@@ -200,6 +249,31 @@ const REVERIFY: StepShape = plugin(
|
|
|
200
249
|
"unsafe",
|
|
201
250
|
);
|
|
202
251
|
|
|
252
|
+
/** The current name of a stage kind; the older `work` and `check` load as `code` and `test`. */
|
|
253
|
+
function canonicalStage(stage: DevStage): DevStage {
|
|
254
|
+
if (stage.stage === "work") return { ...stage, stage: "code" };
|
|
255
|
+
if (stage.stage === "check") return { ...stage, stage: "test" };
|
|
256
|
+
return stage;
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
function canonicalStages(stages: readonly DevStage[]): DevStage[] {
|
|
260
|
+
return stages.map(canonicalStage);
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
/** The internal step id base of a stage, with the ids earlier runs recorded. */
|
|
264
|
+
function stepNameOf(stage: DevStage): string {
|
|
265
|
+
switch (stage.stage) {
|
|
266
|
+
case "code":
|
|
267
|
+
case "work":
|
|
268
|
+
return "work";
|
|
269
|
+
case "test":
|
|
270
|
+
case "check":
|
|
271
|
+
return "check";
|
|
272
|
+
default:
|
|
273
|
+
return stage.stage;
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
|
|
203
277
|
/** True when the stages are the built-in default, so its old step ids stay. */
|
|
204
278
|
function isDefaultStages(stages: readonly DevStage[]): boolean {
|
|
205
279
|
if (stages.length !== DEFAULT_STAGES.length) return false;
|
|
@@ -210,7 +284,7 @@ function sameStage(left: DevStage, right: DevStage): boolean {
|
|
|
210
284
|
return JSON.stringify(left) === JSON.stringify(right);
|
|
211
285
|
}
|
|
212
286
|
|
|
213
|
-
/** The params a
|
|
287
|
+
/** The params a test stage gives `dev/verify`; unset fields read dev.json. */
|
|
214
288
|
function checkParams(stage: CheckStage): Readonly<Record<string, unknown>> {
|
|
215
289
|
return {
|
|
216
290
|
...(stage.commands === undefined ? {} : { commands: stage.commands }),
|
|
@@ -218,12 +292,12 @@ function checkParams(stage: CheckStage): Readonly<Record<string, unknown>> {
|
|
|
218
292
|
};
|
|
219
293
|
}
|
|
220
294
|
|
|
221
|
-
/** The params a
|
|
295
|
+
/** The params a code stage gives `dev/worktree`; unset fields read dev.json. */
|
|
222
296
|
function worktreeParams(work: WorkStage | undefined): Readonly<Record<string, unknown>> {
|
|
223
297
|
return work?.beforeAttempt === undefined ? {} : { beforeAttempt: work.beforeAttempt };
|
|
224
298
|
}
|
|
225
299
|
|
|
226
|
-
/** The params a
|
|
300
|
+
/** The params a code stage gives `dev/work`; unset fields read dev.json. */
|
|
227
301
|
function workParams(stage: WorkStage): Readonly<Record<string, unknown>> {
|
|
228
302
|
return {
|
|
229
303
|
...(stage.use === undefined ? {} : { flowUse: stage.use }),
|
|
@@ -260,6 +334,7 @@ function defaultSteps(
|
|
|
260
334
|
): StepShape[] { const check = stages[1] as CheckStage;
|
|
261
335
|
const review = stages[2] as ReviewStage;
|
|
262
336
|
const work = stages[0] as WorkStage;
|
|
337
|
+
const choices = waitChoices("person", true);
|
|
263
338
|
return [
|
|
264
339
|
{ ...WORKTREE, params: { use: "dev/worktree", params: worktreeParams(work) }, next: { ...(WORKTREE.next as Edge) } },
|
|
265
340
|
{ ...REVERIFY, next: { ...(REVERIFY.next as Edge) } },
|
|
@@ -274,9 +349,11 @@ function defaultSteps(
|
|
|
274
349
|
unavailable: "work_retry",
|
|
275
350
|
cancelled: "end_cancelled",
|
|
276
351
|
interrupted: "retry_work_stopped",
|
|
352
|
+
waiting: workQuestionWaitId("work"),
|
|
277
353
|
},
|
|
278
354
|
"unsafe",
|
|
279
355
|
),
|
|
356
|
+
waitWorkerQuestion(workQuestionWaitId("work"), "work"),
|
|
280
357
|
waitCheck("work_retry", "dev/work_due", {
|
|
281
358
|
ready: "work",
|
|
282
359
|
interrupted: "end_cancelled",
|
|
@@ -303,7 +380,7 @@ function defaultSteps(
|
|
|
303
380
|
}),
|
|
304
381
|
waitPerson(
|
|
305
382
|
WAIT_STEPS["review-timeout"],
|
|
306
|
-
"
|
|
383
|
+
"review timed out twice",
|
|
307
384
|
waitChoices("review-timeout", true),
|
|
308
385
|
{
|
|
309
386
|
merge: "integrate",
|
|
@@ -312,10 +389,11 @@ function defaultSteps(
|
|
|
312
389
|
interrupted: "end_cancelled",
|
|
313
390
|
},
|
|
314
391
|
"review timed out twice",
|
|
392
|
+
false,
|
|
315
393
|
),
|
|
316
394
|
waitPerson(
|
|
317
395
|
WAIT_STEPS["review-unavailable"],
|
|
318
|
-
"
|
|
396
|
+
"review did not finish (model unavailable)",
|
|
319
397
|
waitChoices("review-unavailable", true),
|
|
320
398
|
{
|
|
321
399
|
merge: "integrate",
|
|
@@ -325,10 +403,11 @@ function defaultSteps(
|
|
|
325
403
|
interrupted: "end_cancelled",
|
|
326
404
|
},
|
|
327
405
|
"review did not finish (model unavailable)",
|
|
406
|
+
false,
|
|
328
407
|
),
|
|
329
408
|
waitPerson(
|
|
330
409
|
WAIT_STEPS["review-out-of-time"],
|
|
331
|
-
"
|
|
410
|
+
"review did not finish (out of time)",
|
|
332
411
|
waitChoices("review-out-of-time", true),
|
|
333
412
|
{
|
|
334
413
|
merge: "integrate",
|
|
@@ -337,6 +416,7 @@ function defaultSteps(
|
|
|
337
416
|
interrupted: "end_cancelled",
|
|
338
417
|
},
|
|
339
418
|
"review did not finish (out of time)",
|
|
419
|
+
false,
|
|
340
420
|
),
|
|
341
421
|
plugin("rework", "dev/rework", {}, {
|
|
342
422
|
again: "worktree",
|
|
@@ -418,23 +498,23 @@ function defaultSteps(
|
|
|
418
498
|
"announce_work_environment",
|
|
419
499
|
"retry_work_wait",
|
|
420
500
|
),
|
|
421
|
-
announce("announce_worktree_environment", "worktree", "environment", "wait"),
|
|
422
|
-
announce("announce_reverify_environment", "reverify", "environment", "wait"),
|
|
423
|
-
announce("announce_work_environment", "work", "environment", "wait"),
|
|
424
|
-
announce("announce_blocked", "worktree", "blocked", "wait"),
|
|
425
|
-
announce("announce_worktree_stopped", "worktree", "interrupted", "wait"),
|
|
426
|
-
announce("announce_reverify_stopped", "reverify", "interrupted", "wait"),
|
|
427
|
-
announce("announce_nothing", "work", "nothing", "wait"),
|
|
428
|
-
announce("announce_work_failed", "work", "failed", "wait"),
|
|
429
|
-
announce("announce_work_stopped", "work", "interrupted", "wait"),
|
|
430
|
-
announce("announce_verify_not_code", "verify", "not_code", "wait"),
|
|
431
|
-
announce("announce_ready", "review", "pass", "wait"),
|
|
432
|
-
announce("announce_review_failed", "review", "failed", "wait"),
|
|
433
|
-
announce("announce_rework", "rework", "ask", "wait"),
|
|
434
|
-
announce("announce_integrate", "integrate", "failed", "wait"),
|
|
501
|
+
announce("announce_worktree_environment", "worktree", "environment", "wait", choices),
|
|
502
|
+
announce("announce_reverify_environment", "reverify", "environment", "wait", choices),
|
|
503
|
+
announce("announce_work_environment", "work", "environment", "wait", choices),
|
|
504
|
+
announce("announce_blocked", "worktree", "blocked", "wait", choices),
|
|
505
|
+
announce("announce_worktree_stopped", "worktree", "interrupted", "wait", choices),
|
|
506
|
+
announce("announce_reverify_stopped", "reverify", "interrupted", "wait", choices),
|
|
507
|
+
announce("announce_nothing", "work", "nothing", "wait", choices),
|
|
508
|
+
announce("announce_work_failed", "work", "failed", "wait", choices),
|
|
509
|
+
announce("announce_work_stopped", "work", "interrupted", "wait", choices),
|
|
510
|
+
announce("announce_verify_not_code", "verify", "not_code", "wait", choices),
|
|
511
|
+
announce("announce_ready", "review", "pass", "wait", choices),
|
|
512
|
+
announce("announce_review_failed", "review", "failed", "wait", choices),
|
|
513
|
+
announce("announce_rework", "rework", "ask", "wait", choices),
|
|
514
|
+
announce("announce_integrate", "integrate", "failed", "wait", choices),
|
|
435
515
|
waitPerson(
|
|
436
516
|
WAIT_STEPS.person,
|
|
437
|
-
"The task is waiting for you
|
|
517
|
+
"The task is waiting for you.",
|
|
438
518
|
waitChoices("person", true),
|
|
439
519
|
{
|
|
440
520
|
merge: "integrate",
|
|
@@ -472,12 +552,13 @@ interface NamedStage {
|
|
|
472
552
|
function namedStages(stages: readonly DevStage[]): NamedStage[] {
|
|
473
553
|
const counts = new Map<string, number>();
|
|
474
554
|
return stages.map((stage, index) => {
|
|
475
|
-
const
|
|
476
|
-
counts.
|
|
555
|
+
const base = stepNameOf(stage);
|
|
556
|
+
const seen = (counts.get(base) ?? 0) + 1;
|
|
557
|
+
counts.set(base, seen);
|
|
477
558
|
return {
|
|
478
559
|
index,
|
|
479
560
|
stage,
|
|
480
|
-
id: seen === 1 ?
|
|
561
|
+
id: seen === 1 ? base : `${base}_${seen}`,
|
|
481
562
|
};
|
|
482
563
|
});
|
|
483
564
|
}
|
|
@@ -488,11 +569,11 @@ function generatedSteps(
|
|
|
488
569
|
gradingName: string,
|
|
489
570
|
): StepShape[] {
|
|
490
571
|
const named = namedStages(stages);
|
|
491
|
-
const firstWork = named.find((item) => item.stage.stage === "
|
|
572
|
+
const firstWork = named.find((item) => item.stage.stage === "code");
|
|
492
573
|
const usedKinds = new Set(named.map((item) => item.stage.stage));
|
|
493
|
-
const hasReverify = usedKinds.has("
|
|
574
|
+
const hasReverify = usedKinds.has("test") || usedKinds.has("review");
|
|
494
575
|
const choices = waitChoices("person", hasReverify);
|
|
495
|
-
const lastWork = [...named].reverse().find((item) => item.stage.stage === "
|
|
576
|
+
const lastWork = [...named].reverse().find((item) => item.stage.stage === "code");
|
|
496
577
|
const reverifyTarget =
|
|
497
578
|
lastWork === undefined
|
|
498
579
|
? (named[0]?.id ?? "integrate")
|
|
@@ -506,11 +587,11 @@ function generatedSteps(
|
|
|
506
587
|
? "worktree"
|
|
507
588
|
: firstWork.id;
|
|
508
589
|
|
|
509
|
-
/** The entry of the nearest
|
|
590
|
+
/** The entry of the nearest code stage before a stage, or the wait. */
|
|
510
591
|
const workEntryBefore = (index: number): string | undefined => {
|
|
511
592
|
for (let at = index - 1; at >= 0; at -= 1) {
|
|
512
593
|
const item = named[at];
|
|
513
|
-
if (item?.stage.stage !== "
|
|
594
|
+
if (item?.stage.stage !== "code") continue;
|
|
514
595
|
return item.index === 0 ? "worktree" : item.id;
|
|
515
596
|
}
|
|
516
597
|
return undefined;
|
|
@@ -519,7 +600,7 @@ function generatedSteps(
|
|
|
519
600
|
const nextAfter = (index: number): string =>
|
|
520
601
|
named[index + 1]?.id ?? "integrate";
|
|
521
602
|
|
|
522
|
-
const firstWorkStage = firstWork?.stage.stage === "
|
|
603
|
+
const firstWorkStage = firstWork?.stage.stage === "code" ? firstWork.stage : undefined;
|
|
523
604
|
const steps: StepShape[] = [];
|
|
524
605
|
const waitId = WAIT_STEPS.person;
|
|
525
606
|
steps.push({
|
|
@@ -600,7 +681,7 @@ function generatedSteps(
|
|
|
600
681
|
for (const item of named) {
|
|
601
682
|
const next = nextAfter(item.index);
|
|
602
683
|
switch (item.stage.stage) {
|
|
603
|
-
case "
|
|
684
|
+
case "code": {
|
|
604
685
|
const id = item.id;
|
|
605
686
|
steps.push(
|
|
606
687
|
plugin(
|
|
@@ -614,9 +695,11 @@ function generatedSteps(
|
|
|
614
695
|
unavailable: `${id}_retry`,
|
|
615
696
|
cancelled: "end_cancelled",
|
|
616
697
|
interrupted: `retry_${id}_stopped`,
|
|
698
|
+
waiting: workQuestionWaitId(id),
|
|
617
699
|
},
|
|
618
700
|
"unsafe",
|
|
619
701
|
),
|
|
702
|
+
waitWorkerQuestion(workQuestionWaitId(id), id),
|
|
620
703
|
waitCheck(`${id}_retry`, "dev/work_due", {
|
|
621
704
|
ready: id,
|
|
622
705
|
interrupted: "end_cancelled",
|
|
@@ -652,14 +735,14 @@ function generatedSteps(
|
|
|
652
735
|
`announce_${id}_environment`,
|
|
653
736
|
`retry_${id}_wait`,
|
|
654
737
|
),
|
|
655
|
-
announce(`announce_${id}_environment`, id, "environment", waitId),
|
|
656
|
-
announce(`announce_${id}_nothing`, id, "nothing", waitId),
|
|
657
|
-
announce(`announce_${id}_failed`, id, "failed", waitId),
|
|
658
|
-
announce(`announce_${id}_stopped`, id, "interrupted", waitId),
|
|
738
|
+
announce(`announce_${id}_environment`, id, "environment", waitId, choices),
|
|
739
|
+
announce(`announce_${id}_nothing`, id, "nothing", waitId, choices),
|
|
740
|
+
announce(`announce_${id}_failed`, id, "failed", waitId, choices),
|
|
741
|
+
announce(`announce_${id}_stopped`, id, "interrupted", waitId, choices),
|
|
659
742
|
);
|
|
660
743
|
break;
|
|
661
744
|
}
|
|
662
|
-
case "
|
|
745
|
+
case "test": {
|
|
663
746
|
const id = item.id;
|
|
664
747
|
const target = workEntryBefore(item.index);
|
|
665
748
|
if (target !== undefined) {
|
|
@@ -670,13 +753,13 @@ function generatedSteps(
|
|
|
670
753
|
not_code: `announce_${id}_not_code`,
|
|
671
754
|
cancelled: "end_cancelled",
|
|
672
755
|
}),
|
|
673
|
-
announce(`announce_${id}_not_code`, id, "not_code", waitId),
|
|
756
|
+
announce(`announce_${id}_not_code`, id, "not_code", waitId, choices),
|
|
674
757
|
plugin(`rework_${id}`, "dev/rework", {}, {
|
|
675
758
|
again: target,
|
|
676
759
|
ask: `announce_rework_${id}`,
|
|
677
760
|
cancelled: "end_cancelled",
|
|
678
761
|
}),
|
|
679
|
-
announce(`announce_rework_${id}`, `rework_${id}`, "ask", waitId),
|
|
762
|
+
announce(`announce_rework_${id}`, `rework_${id}`, "ask", waitId, choices),
|
|
680
763
|
);
|
|
681
764
|
} else {
|
|
682
765
|
steps.push(
|
|
@@ -686,7 +769,7 @@ function generatedSteps(
|
|
|
686
769
|
not_code: `announce_${id}_not_code`,
|
|
687
770
|
cancelled: "end_cancelled",
|
|
688
771
|
}),
|
|
689
|
-
announce(`announce_${id}_not_code`, id, "not_code", waitId),
|
|
772
|
+
announce(`announce_${id}_not_code`, id, "not_code", waitId, choices),
|
|
690
773
|
);
|
|
691
774
|
}
|
|
692
775
|
break;
|
|
@@ -715,7 +798,7 @@ function generatedSteps(
|
|
|
715
798
|
}),
|
|
716
799
|
waitPerson(
|
|
717
800
|
`${WAIT_STEPS["review-timeout"]}_${id}`,
|
|
718
|
-
"
|
|
801
|
+
"review timed out twice",
|
|
719
802
|
waitChoices("review-timeout", hasReverify),
|
|
720
803
|
{
|
|
721
804
|
merge: "integrate",
|
|
@@ -724,10 +807,11 @@ function generatedSteps(
|
|
|
724
807
|
interrupted: "end_cancelled",
|
|
725
808
|
},
|
|
726
809
|
"review timed out twice",
|
|
810
|
+
false,
|
|
727
811
|
),
|
|
728
812
|
waitPerson(
|
|
729
813
|
`${WAIT_STEPS["review-unavailable"]}_${id}`,
|
|
730
|
-
"
|
|
814
|
+
"review did not finish (model unavailable)",
|
|
731
815
|
waitChoices("review-unavailable", hasReverify),
|
|
732
816
|
{
|
|
733
817
|
merge: "integrate",
|
|
@@ -737,10 +821,11 @@ function generatedSteps(
|
|
|
737
821
|
interrupted: "end_cancelled",
|
|
738
822
|
},
|
|
739
823
|
"review did not finish (model unavailable)",
|
|
824
|
+
false,
|
|
740
825
|
),
|
|
741
826
|
waitPerson(
|
|
742
827
|
`${WAIT_STEPS["review-out-of-time"]}_${id}`,
|
|
743
|
-
"
|
|
828
|
+
"review did not finish (out of time)",
|
|
744
829
|
waitChoices("review-out-of-time", hasReverify),
|
|
745
830
|
{
|
|
746
831
|
merge: "integrate",
|
|
@@ -749,8 +834,9 @@ function generatedSteps(
|
|
|
749
834
|
interrupted: "end_cancelled",
|
|
750
835
|
},
|
|
751
836
|
"review did not finish (out of time)",
|
|
837
|
+
false,
|
|
752
838
|
),
|
|
753
|
-
announce(`announce_review_failed_${id}`, id, "failed", waitId),
|
|
839
|
+
announce(`announce_review_failed_${id}`, id, "failed", waitId, choices),
|
|
754
840
|
);
|
|
755
841
|
if (target !== undefined) {
|
|
756
842
|
steps.push(
|
|
@@ -759,11 +845,11 @@ function generatedSteps(
|
|
|
759
845
|
ask: `announce_rework_${id}`,
|
|
760
846
|
cancelled: "end_cancelled",
|
|
761
847
|
}),
|
|
762
|
-
announce(`announce_rework_${id}`, `rework_${id}`, "ask", waitId),
|
|
848
|
+
announce(`announce_rework_${id}`, `rework_${id}`, "ask", waitId, choices),
|
|
763
849
|
);
|
|
764
850
|
}
|
|
765
851
|
if (passedTo !== next) {
|
|
766
|
-
steps.push(announce(`announce_ready_${id}`, id, "pass", next));
|
|
852
|
+
steps.push(announce(`announce_ready_${id}`, id, "pass", next, choices));
|
|
767
853
|
}
|
|
768
854
|
break;
|
|
769
855
|
}
|
|
@@ -771,7 +857,7 @@ function generatedSteps(
|
|
|
771
857
|
steps.push(
|
|
772
858
|
waitPerson(
|
|
773
859
|
item.id,
|
|
774
|
-
"The task is waiting for you
|
|
860
|
+
"The task is waiting for you.",
|
|
775
861
|
choices,
|
|
776
862
|
{
|
|
777
863
|
merge: next,
|
|
@@ -789,18 +875,18 @@ function generatedSteps(
|
|
|
789
875
|
}
|
|
790
876
|
|
|
791
877
|
steps.push(
|
|
792
|
-
announce("announce_blocked", "worktree", "blocked", waitId),
|
|
793
|
-
announce("announce_worktree_environment", "worktree", "environment", waitId),
|
|
794
|
-
announce("announce_worktree_stopped", "worktree", "interrupted", waitId),
|
|
878
|
+
announce("announce_blocked", "worktree", "blocked", waitId, choices),
|
|
879
|
+
announce("announce_worktree_environment", "worktree", "environment", waitId, choices),
|
|
880
|
+
announce("announce_worktree_stopped", "worktree", "interrupted", waitId, choices),
|
|
795
881
|
...(hasReverify
|
|
796
882
|
? [
|
|
797
|
-
announce("announce_reverify_environment", "reverify", "environment", waitId),
|
|
798
|
-
announce("announce_reverify_stopped", "reverify", "interrupted", waitId),
|
|
883
|
+
announce("announce_reverify_environment", "reverify", "environment", waitId, choices),
|
|
884
|
+
announce("announce_reverify_stopped", "reverify", "interrupted", waitId, choices),
|
|
799
885
|
]
|
|
800
886
|
: []),
|
|
801
887
|
waitPerson(
|
|
802
888
|
waitId,
|
|
803
|
-
"The task is waiting for you
|
|
889
|
+
"The task is waiting for you.",
|
|
804
890
|
choices,
|
|
805
891
|
{
|
|
806
892
|
merge: "integrate",
|
|
@@ -818,7 +904,7 @@ function generatedSteps(
|
|
|
818
904
|
failed: "announce_integrate",
|
|
819
905
|
cancelled: "end_cancelled",
|
|
820
906
|
}),
|
|
821
|
-
announce("announce_integrate", "integrate", "failed", waitId),
|
|
907
|
+
announce("announce_integrate", "integrate", "failed", waitId, choices),
|
|
822
908
|
plugin("cleanup", "dev/cleanup", {}, {
|
|
823
909
|
done: "end_done",
|
|
824
910
|
cancelled: "end_cancelled",
|
|
@@ -842,9 +928,10 @@ function visitsFor(stages: readonly DevStage[], defaults: boolean): number {
|
|
|
842
928
|
*/
|
|
843
929
|
export function compileDevFlow(
|
|
844
930
|
name: string,
|
|
845
|
-
|
|
931
|
+
written: readonly DevStage[],
|
|
846
932
|
options: { readonly gradingName?: string | undefined } = {},
|
|
847
933
|
): FlowDefinition {
|
|
934
|
+
const stages = canonicalStages(written);
|
|
848
935
|
const defaults = isDefaultStages(stages);
|
|
849
936
|
const steps = defaults
|
|
850
937
|
? defaultSteps(stages, options.gradingName ?? name)
|
package/src/followups.ts
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
|
|
12
12
|
import type { ObjectStore, StoredObject } from "@operad-io/engine";
|
|
13
13
|
import {
|
|
14
|
-
|
|
14
|
+
idOfKey,
|
|
15
15
|
changeClock,
|
|
16
16
|
listAll,
|
|
17
17
|
parseId,
|
|
@@ -81,7 +81,7 @@ function linesOf(tasks: readonly StoredObject[]): Line[] {
|
|
|
81
81
|
for (const round of taskData(object.data).reviewNotes ?? []) {
|
|
82
82
|
for (const note of round.findings) {
|
|
83
83
|
const key = JSON.stringify([note.file, note.line, textOf(note)]);
|
|
84
|
-
const line = { note, task:
|
|
84
|
+
const line = { note, task: idOfKey(object.id), round: round.round };
|
|
85
85
|
const at = seen.get(key);
|
|
86
86
|
if (at !== undefined) {
|
|
87
87
|
lines[at] = line;
|
|
@@ -129,7 +129,7 @@ async function markCollected(
|
|
|
129
129
|
for (const object of tasks) {
|
|
130
130
|
const task = taskData(object.data);
|
|
131
131
|
if (task.repository !== repository) continue;
|
|
132
|
-
if (!ids.includes(
|
|
132
|
+
if (!ids.includes(idOfKey(object.id)) || task.followups?.state !== "collect") continue;
|
|
133
133
|
await store.put(
|
|
134
134
|
"task",
|
|
135
135
|
object.id,
|
|
@@ -147,18 +147,19 @@ export async function collectFollowups(
|
|
|
147
147
|
store: ObjectStore,
|
|
148
148
|
repository: string,
|
|
149
149
|
settings: DevSettings,
|
|
150
|
+
knownTasks?: readonly StoredObject[] | undefined,
|
|
150
151
|
): Promise<string[]> {
|
|
151
152
|
// A tick that has nothing to collect must not wait for the repository lock.
|
|
152
|
-
const pending = (await listAll(store, "task")).some(
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
153
|
+
const pending = (knownTasks ?? (await listAll(store, "task", { repository }))).some(
|
|
154
|
+
(object) => {
|
|
155
|
+
const task = taskData(object.data);
|
|
156
|
+
return task.repository === repository && task.followups?.state === "collect";
|
|
157
|
+
},
|
|
158
|
+
);
|
|
156
159
|
if (!pending) return [];
|
|
157
160
|
return withRepoLock(store, repository, async (fresh) => {
|
|
158
161
|
// Finish a collection a crash cut short: a follow-up names its tasks.
|
|
159
|
-
const before =
|
|
160
|
-
(object) => taskData(object.data).repository === repository,
|
|
161
|
-
);
|
|
162
|
+
const before = await listAll(store, "task", { repository });
|
|
162
163
|
for (const object of before) {
|
|
163
164
|
const of = taskData(object.data).followupOf;
|
|
164
165
|
if (of !== undefined) await markCollected(store, repository, of, before);
|
|
@@ -166,14 +167,12 @@ export async function collectFollowups(
|
|
|
166
167
|
if (!settings.reviewer.followups) return [];
|
|
167
168
|
|
|
168
169
|
const proposed: string[] = [];
|
|
169
|
-
for (const planObject of await listAll(store, "plan")) {
|
|
170
|
+
for (const planObject of await listAll(store, "plan", { repository })) {
|
|
170
171
|
const plan = planData(planObject.data);
|
|
171
|
-
if (plan.
|
|
172
|
-
const planId =
|
|
173
|
-
const tasks = (await listAll(store, "task")).filter(
|
|
174
|
-
(object) =>
|
|
175
|
-
taskData(object.data).repository === repository &&
|
|
176
|
-
taskData(object.data).plan === planId,
|
|
172
|
+
if (plan.status !== "confirmed") continue;
|
|
173
|
+
const planId = idOfKey(planObject.id);
|
|
174
|
+
const tasks = (await listAll(store, "task", { repository })).filter(
|
|
175
|
+
(object) => taskData(object.data).plan === planId,
|
|
177
176
|
);
|
|
178
177
|
if (tasks.some((object) => OPEN_PHASES.includes(taskData(object.data).phase))) continue;
|
|
179
178
|
const marked = tasks
|
|
@@ -194,13 +193,12 @@ export async function collectFollowups(
|
|
|
194
193
|
const lines = linesOf(marked);
|
|
195
194
|
if (lines.length === 0) continue;
|
|
196
195
|
const taken = new Set<string>();
|
|
197
|
-
for (const object of await listAll(store, "task")) {
|
|
198
|
-
|
|
199
|
-
const slug = parseId(bareId(object.id), "task")?.slug;
|
|
196
|
+
for (const object of await listAll(store, "task", { repository })) {
|
|
197
|
+
const slug = parseId(idOfKey(object.id), "task")?.slug;
|
|
200
198
|
if (slug !== undefined) taken.add(slug);
|
|
201
199
|
}
|
|
202
200
|
const planSlug = parseId(planId, "plan")?.slug ?? "plan";
|
|
203
|
-
const ids = marked.map((object) =>
|
|
201
|
+
const ids = marked.map((object) => idOfKey(object.id));
|
|
204
202
|
const task = await addTaskLocked(
|
|
205
203
|
store,
|
|
206
204
|
{
|
|
@@ -216,7 +214,7 @@ export async function collectFollowups(
|
|
|
216
214
|
);
|
|
217
215
|
await followupTestHooks.afterPropose?.();
|
|
218
216
|
await markCollected(store, repository, ids, marked);
|
|
219
|
-
proposed.push(
|
|
217
|
+
proposed.push(idOfKey(task.id));
|
|
220
218
|
}
|
|
221
219
|
return proposed;
|
|
222
220
|
});
|