@operad-io/dev 0.0.0-stage → 0.0.1

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.
Files changed (48) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +795 -2
  3. package/dev.schema.json +602 -0
  4. package/flows/chat-worktree.flow.ts +18 -0
  5. package/flows/dev.flow.ts +7 -0
  6. package/package.json +29 -4
  7. package/src/actions.ts +591 -0
  8. package/src/announce.ts +225 -0
  9. package/src/chat.ts +234 -0
  10. package/src/check.ts +80 -0
  11. package/src/commands.ts +417 -0
  12. package/src/editor.ts +55 -0
  13. package/src/flaky.ts +716 -0
  14. package/src/flow-compiler.ts +858 -0
  15. package/src/followups.ts +223 -0
  16. package/src/gate.ts +2897 -0
  17. package/src/git.ts +138 -0
  18. package/src/index.ts +226 -0
  19. package/src/integrate.ts +1201 -0
  20. package/src/integration-queue.ts +393 -0
  21. package/src/lock.ts +36 -0
  22. package/src/mainclone.ts +102 -0
  23. package/src/marks.ts +126 -0
  24. package/src/model.ts +1165 -0
  25. package/src/notcode.ts +266 -0
  26. package/src/place-order.ts +161 -0
  27. package/src/place-wait.ts +64 -0
  28. package/src/places.ts +368 -0
  29. package/src/prepare.ts +106 -0
  30. package/src/progress.ts +115 -0
  31. package/src/project-flows.ts +160 -0
  32. package/src/project-settings.ts +185 -0
  33. package/src/refusals.ts +336 -0
  34. package/src/rerun.ts +378 -0
  35. package/src/reruns.ts +62 -0
  36. package/src/retry.ts +212 -0
  37. package/src/rework.ts +366 -0
  38. package/src/schedule.ts +1052 -0
  39. package/src/service.ts +2160 -0
  40. package/src/settings.ts +1463 -0
  41. package/src/standing.ts +87 -0
  42. package/src/stdin.ts +105 -0
  43. package/src/steps.ts +1775 -0
  44. package/src/stops.ts +103 -0
  45. package/src/throughput.ts +347 -0
  46. package/src/timeouts.ts +60 -0
  47. package/src/views.ts +1167 -0
  48. package/src/waits.ts +105 -0
package/src/waits.ts ADDED
@@ -0,0 +1,105 @@
1
+ /**
2
+ * What each of dev's person waits accepts.
3
+ *
4
+ * The flow's wait steps take their choices from here, and a task's actions
5
+ * offer exactly the choices of the wait the task is in, so the two cannot
6
+ * drift apart.
7
+ */
8
+
9
+ import { isIntegrating, type ReviewRecord, type TaskData } from "./model.ts";
10
+
11
+ /** The actions a person wait answers. */
12
+ export const WAIT_ACTIONS = ["merge", "reject", "rework", "reverify"] as const;
13
+ export type WaitAction = (typeof WAIT_ACTIONS)[number];
14
+
15
+ /** The waits dev's flows have, and the step id the first of each is named. */
16
+ export const WAIT_STEPS = {
17
+ person: "wait",
18
+ "review-timeout": "wait_review_timeout",
19
+ "review-unavailable": "wait_review_unavailable",
20
+ "review-out-of-time": "wait_review_out_of_time",
21
+ } as const;
22
+ export type WaitKind = keyof typeof WAIT_STEPS;
23
+
24
+ const WAIT_ACCEPTS: Readonly<Record<WaitKind, readonly WaitAction[]>> = {
25
+ person: WAIT_ACTIONS,
26
+ // A timed-out or out-of-time review is the reviewer's business: a person can
27
+ // land it or send it back to the worker, not spend another round on it.
28
+ "review-timeout": ["merge", "reject", "rework"],
29
+ "review-out-of-time": ["merge", "reject", "rework"],
30
+ // The reviewer may be back: the same commit can be checked again.
31
+ "review-unavailable": ["merge", "reject", "rework", "reverify"],
32
+ };
33
+
34
+ /** The choices of a wait; a flow with no check or review has nothing to reverify. */
35
+ export function waitChoices(
36
+ wait: WaitKind,
37
+ hasReverify: boolean,
38
+ ): readonly WaitAction[] {
39
+ const accepts = WAIT_ACCEPTS[wait];
40
+ return hasReverify ? accepts : accepts.filter((action) => action !== "reverify");
41
+ }
42
+
43
+ /**
44
+ * True while a review waits for its model to come back. The flow is not asking
45
+ * a person anything then, so no wait action is offered.
46
+ */
47
+ export function inReviewWait(task: TaskData): boolean {
48
+ const review = task.attempt?.review;
49
+ return (
50
+ typeof task.retryAt === "number" &&
51
+ review !== undefined &&
52
+ review !== null &&
53
+ review.decision === "unavailable" &&
54
+ review.reason !== "exhausted" &&
55
+ review.reason !== "out_of_time"
56
+ );
57
+ }
58
+
59
+ /** The wait a finished review leaves, when it leaves the task waiting for a person. */
60
+ export function reviewWaitKind(review: ReviewRecord): WaitKind | undefined {
61
+ if (review.reason === "timed_out") return "review-timeout";
62
+ if (review.reason === "exhausted") return "review-unavailable";
63
+ if (review.reason === "out_of_time") return "review-out-of-time";
64
+ if (review.decision === "findings" || review.result === "fail") return undefined;
65
+ if (review.decision === "unavailable" && typeof review.retryAt === "number") {
66
+ return undefined;
67
+ }
68
+ return "person";
69
+ }
70
+
71
+ /** The wait a task is in, or undefined when it is not waiting for a person. */
72
+ export function waitKindOf(task: TaskData): WaitKind | undefined {
73
+ // While integrate works the task is not asking a person anything.
74
+ if (task.phase !== "waiting" || isIntegrating(task) || inReviewWait(task)) {
75
+ return undefined;
76
+ }
77
+ if (task.waitKind !== undefined) return task.waitKind;
78
+ // A task from before the kind was written: the review record is the best it
79
+ // has, though a later ordinary wait may still carry that older record. An
80
+ // integrate result means the review wait is behind the task.
81
+ const attempt = task.attempt;
82
+ if (attempt?.integration !== undefined && attempt.integration !== null) {
83
+ return "person";
84
+ }
85
+ const reason = attempt?.review?.reason;
86
+ if (reason === "timed_out") return "review-timeout";
87
+ if (reason === "exhausted") return "review-unavailable";
88
+ if (reason === "out_of_time") return "review-out-of-time";
89
+ return "person";
90
+ }
91
+
92
+ /** True when the task's flow runs the reverify step, so its waits can take it. */
93
+ export function flowHasReverify(task: TaskData): boolean {
94
+ const graph = task.flowGraph;
95
+ // A task from before flows had graphs ran the built-in flow, which has one.
96
+ if (graph === undefined) return true;
97
+ return graph.steps.some((step) => step.id === "reverify");
98
+ }
99
+
100
+ /** True when the task's current wait takes this action. */
101
+ export function waitAccepts(task: TaskData, action: WaitAction): boolean {
102
+ const wait = waitKindOf(task);
103
+ if (wait === undefined) return false;
104
+ return waitChoices(wait, flowHasReverify(task)).includes(action);
105
+ }