@operad-io/dev 0.1.1 → 0.3.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.
Files changed (50) hide show
  1. package/README.md +1 -1
  2. package/dev.schema.json +53 -31
  3. package/package.json +9 -6
  4. package/skills/git/SKILL.md +70 -0
  5. package/skills/setup/SKILL.md +74 -0
  6. package/src/access-grants.ts +59 -0
  7. package/src/actions.ts +81 -17
  8. package/src/announce.ts +134 -17
  9. package/src/chat.ts +586 -36
  10. package/src/check-host.ts +111 -0
  11. package/src/check-load.ts +67 -0
  12. package/src/check.ts +45 -22
  13. package/src/clock.ts +29 -0
  14. package/src/clone-chat.ts +32 -0
  15. package/src/commands.ts +103 -34
  16. package/src/create-actions.ts +210 -0
  17. package/src/flaky.ts +45 -29
  18. package/src/flow-compiler.ts +156 -69
  19. package/src/followups.ts +20 -22
  20. package/src/gate.ts +254 -88
  21. package/src/git-state.ts +155 -0
  22. package/src/git.ts +92 -4
  23. package/src/index.ts +52 -6
  24. package/src/integrate.ts +162 -62
  25. package/src/integration-queue.ts +23 -10
  26. package/src/lock.ts +101 -5
  27. package/src/mainclone.ts +61 -5
  28. package/src/model-error.ts +70 -0
  29. package/src/model.ts +61 -35
  30. package/src/notcode.ts +51 -15
  31. package/src/places.ts +2 -2
  32. package/src/prepare.ts +7 -2
  33. package/src/project-flows.ts +135 -4
  34. package/src/project-settings.ts +110 -3
  35. package/src/register-requests.ts +121 -0
  36. package/src/repository-key.ts +4 -0
  37. package/src/rerun.ts +23 -7
  38. package/src/retry.ts +2 -12
  39. package/src/rework.ts +8 -0
  40. package/src/schedule.ts +342 -93
  41. package/src/service.ts +241 -185
  42. package/src/settings.ts +409 -65
  43. package/src/setup-git.ts +366 -0
  44. package/src/standing.ts +23 -6
  45. package/src/step-edge.ts +22 -0
  46. package/src/steps.ts +945 -179
  47. package/src/throughput.ts +4 -21
  48. package/src/timeouts.ts +10 -2
  49. package/src/views.ts +325 -86
  50. package/src/waits.ts +59 -0
package/src/throughput.ts CHANGED
@@ -8,11 +8,12 @@
8
8
 
9
9
  import {
10
10
  foldObjectFacts,
11
- type PluginFact,
11
+ formatElapsed,
12
12
  type StoredObject,
13
13
  type ViewContext,
14
14
  } from "@operad-io/engine";
15
15
  import {
16
+ allFactsOf,
16
17
  listAll,
17
18
  repositoryData,
18
19
  taskData,
@@ -60,14 +61,6 @@ export function percentile(values: readonly number[], p: number): number {
60
61
  return sorted[Math.min(sorted.length, rank) - 1] ?? 0;
61
62
  }
62
63
 
63
- function duration(ms: number): string {
64
- const total = Math.max(0, Math.round(ms / 1000));
65
- if (total < 60) return `${total}s`;
66
- const minutes = Math.round(total / 60);
67
- if (minutes < 60) return `${minutes}m`;
68
- return `${Math.floor(minutes / 60)}h${String(minutes % 60).padStart(2, "0")}m`;
69
- }
70
-
71
64
  function pad(value: number): string {
72
65
  return String(value).padStart(2, "0");
73
66
  }
@@ -156,17 +149,7 @@ async function readTask(
156
149
  // Each attempt's cost, the latest recorded for it: a rework is paid for too.
157
150
  const attemptCosts = new Map<number, number>();
158
151
  const reasons = new Set<string>();
159
- const facts: PluginFact[] = [];
160
- let cursor: string | undefined;
161
- for (;;) {
162
- const page = await ctx.store.facts(
163
- { type: object.type, id: object.id },
164
- cursor === undefined ? {} : { cursor },
165
- );
166
- facts.push(...page.facts);
167
- if (page.next === undefined) break;
168
- cursor = page.next;
169
- }
152
+ const facts = await allFactsOf(ctx.store, object);
170
153
  for (const version of foldObjectFacts(facts)) {
171
154
  const data = taskData(version.data);
172
155
  const attempt = data.attempt;
@@ -309,7 +292,7 @@ export async function repositoryMetrics(
309
292
  }
310
293
  const stepRows = STEP_ROWS.map((step) => {
311
294
  const values = timed.map((times) => times[step]);
312
- return [step, duration(percentile(values, 50)), duration(percentile(values, 90))];
295
+ return [step, formatElapsed(percentile(values, 50)), formatElapsed(percentile(values, 90))];
313
296
  });
314
297
  const reworks = merged.map((task) => task.reworks);
315
298
  const rounds = (value: number): string => String(value);
package/src/timeouts.ts CHANGED
@@ -30,6 +30,14 @@ export function reviewWaitMs(retrySecs: number, n: number): number {
30
30
  return Math.min(retrySecs * 2 ** doublings, cap) * 1000;
31
31
  }
32
32
 
33
+ /**
34
+ * The longest a model's `retry_after_secs` is waited out by dev. Past it, or
35
+ * on a usage limit, the task waits for a person: half an hour is as long as a
36
+ * review wait is allowed to last, and a longer wait is usually a quota period
37
+ * the owner must decide about (switch the worker or wait for the reset).
38
+ */
39
+ export const MAX_MODEL_RETRY_SECS = 30 * 60;
40
+
33
41
  /**
34
42
  * How many times one review round may wait for an unavailable model before it
35
43
  * waits for a person instead. It was 36 waits of a flat `retrySecs` (about 72
@@ -42,8 +50,8 @@ export const MAX_REVIEW_WAITS = 6;
42
50
 
43
51
  /**
44
52
  * How many times one attempt's work step may wait for an unavailable model
45
- * before the failure goes to a person. The work wait stays flat at
46
- * `reviewer.retrySecs`.
53
+ * before the failure goes to a person. The work wait is the model's
54
+ * `retry_after_secs` when it gives one, else flat at `reviewer.retrySecs`.
47
55
  */
48
56
  export const MAX_WORK_WAITS = 36;
49
57