@milkenjoyer/toolchain 0.19.0 → 0.21.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 (55) hide show
  1. package/STARTS.md +5 -13
  2. package/dist/ci-budget-B2AuZ3xa.mjs +80 -0
  3. package/dist/ci-budget-cli.d.mts +2 -0
  4. package/dist/ci-budget-cli.mjs +31 -0
  5. package/dist/ci-budget.d.mts +22 -0
  6. package/dist/ci-budget.mjs +1 -0
  7. package/dist/ci-result.d.mts +1 -0
  8. package/dist/ci-result.mjs +12 -0
  9. package/dist/{compatible-DIYO9MZf.d.mts → compatible-BKEJ_p20.d.mts} +1 -1
  10. package/dist/{compatible-D54mCSlT.mjs → compatible-CRaMYpBM.mjs} +2 -2
  11. package/dist/compatible.d.mts +1 -1
  12. package/dist/compatible.mjs +1 -1
  13. package/dist/conformance.mjs +1 -1
  14. package/dist/{effect-plugin-BsrW5_nI.mjs → effect-plugin-BiskbKO9.mjs} +2 -2
  15. package/dist/effect-plugin.mjs +1 -1
  16. package/dist/foldkit-plugin.mjs +2 -2
  17. package/dist/formal.d.mts +1 -1
  18. package/dist/formal.mjs +5 -5
  19. package/dist/{guard-fFg_0NIp.mjs → guard-CAm90ZGy.mjs} +5 -5
  20. package/dist/guard.d.mts +1 -1
  21. package/dist/guard.mjs +1 -1
  22. package/dist/hooks.d.mts +1 -1
  23. package/dist/hooks.mjs +2 -2
  24. package/dist/{lint-BJ6SmGk1.mjs → lint-CiO5Etue.mjs} +3 -3
  25. package/dist/lint.mjs +1 -1
  26. package/dist/{plugin-CwxhPtui.mjs → plugin-DwQM07Ih.mjs} +2 -2
  27. package/dist/plugin.mjs +1 -1
  28. package/dist/proof.mjs +3 -3
  29. package/dist/renovate-ci-BdVmECgm.mjs +73 -0
  30. package/dist/renovate-ci.d.mts +10 -0
  31. package/dist/renovate-ci.mjs +1 -0
  32. package/dist/standard.mjs +6 -6
  33. package/dist/starts.d.mts +1 -110
  34. package/dist/starts.mjs +5 -351
  35. package/dist/verdict.d.mts +1 -1
  36. package/dist/verdict.mjs +2 -2
  37. package/dist/{verification-FgQFU1YN.d.mts → verification-fnhfrxmy.d.mts} +1 -1
  38. package/dist/verification.d.mts +1 -1
  39. package/dist/verification.mjs +1 -1
  40. package/dist/versions.mjs +1 -1
  41. package/package.json +11 -1
  42. package/renovate.json +29 -3
  43. package/src/ci-budget-cli.ts +39 -0
  44. package/src/ci-budget.ts +116 -0
  45. package/src/ci-result.ts +12 -0
  46. package/src/renovate-ci.ts +96 -0
  47. package/src/starts/policy.ts +5 -1
  48. package/src/starts.ts +0 -100
  49. package/src/starts/boat.ts +0 -144
  50. package/src/starts/budget.ts +0 -224
  51. package/src/starts/merges.ts +0 -99
  52. package/dist/{specs-file-NsQF4V7X.mjs → specs-file-Ck9ZOt46.mjs} +1 -1
  53. package/dist/{syntax-CGEOffZK.mjs → syntax-B3n7lDYJ.mjs} +1 -1
  54. package/dist/{verification-oAc1Q6I9.mjs → verification-D4Sn2fh5.mjs} +4 -4
  55. package/dist/{versions-DpRzgSR_.mjs → versions-KbYa8kbF.mjs} +1 -1
@@ -0,0 +1,116 @@
1
+ import type { BoatApi } from "@boatdev/sdk";
2
+ import * as Schema from "effect/Schema";
3
+
4
+ const Nonnegative = Schema.Finite.check(Schema.isGreaterThanOrEqualTo(0));
5
+ const Cost = Schema.Struct({ since: Schema.String, dollars: Nonnegative });
6
+ const Page = Schema.Struct({
7
+ sandboxes: Schema.Array(
8
+ Schema.Struct({ id: Schema.String, name: Schema.String, cost: Cost })
9
+ ),
10
+ deletedCost: Cost,
11
+ pageInfo: Schema.Struct({
12
+ hasMore: Schema.Boolean,
13
+ nextCursor: Schema.NullOr(Schema.String),
14
+ }),
15
+ });
16
+ export type MonthlyCiSpend = {
17
+ readonly since: string;
18
+ readonly readAt: string;
19
+ readonly dollars: number;
20
+ readonly deletedDollars: number;
21
+ readonly sandboxes: number;
22
+ };
23
+ export const monthlyCiBudget = (
24
+ spend: MonthlyCiSpend
25
+ ):
26
+ | {
27
+ readonly _tag: "Refused";
28
+ readonly reason: string;
29
+ readonly since: string;
30
+ readonly dollars: number;
31
+ }
32
+ | {
33
+ readonly _tag: "Allowed";
34
+ readonly dollars: number;
35
+ readonly warning: string | null;
36
+ } => {
37
+ const dollars = Schema.decodeSync(Nonnegative)(spend.dollars);
38
+ const warning =
39
+ dollars >= 160
40
+ ? `Boat CI month-to-date $${dollars.toFixed(2)} has reached 80% of the $200 monthly budget`
41
+ : null;
42
+ return dollars >= 200
43
+ ? {
44
+ _tag: "Refused",
45
+ reason: `Boat CI month-to-date $${dollars.toFixed(2)} >= $200 monthly CI budget; no CI requested`,
46
+ since: spend.since,
47
+ dollars,
48
+ }
49
+ : { _tag: "Allowed", dollars, warning };
50
+ };
51
+
52
+ export const readMonthlyCiSpend = async ({
53
+ boat,
54
+ now,
55
+ }: {
56
+ readonly boat: BoatApi;
57
+ readonly now: Date;
58
+ }): Promise<MonthlyCiSpend> => {
59
+ const since = new Date(
60
+ Date.UTC(now.getUTCFullYear(), now.getUTCMonth(), 1)
61
+ ).toISOString();
62
+ const monthly = boat.withPreMiddleware(({ url, init }) => {
63
+ const request = new URL(url);
64
+ request.searchParams.set("include", "cost,deletedCost");
65
+ return Promise.resolve({ url: request.href, init });
66
+ });
67
+ const ids = new Set<string>();
68
+ const cursors = new Set<string>();
69
+ let cursor: string | undefined;
70
+ let deletedDollars: number | undefined;
71
+ let dollars = 0;
72
+ for (;;) {
73
+ const response = await monthly.sandboxesRaw({
74
+ namePrefix: "ci-",
75
+ include: "cost",
76
+ limit: 200,
77
+ sort: "asc",
78
+ ...(cursor === undefined ? {} : { cursor }),
79
+ });
80
+ const page = Schema.decodeUnknownSync(Page)(await response.raw.json());
81
+ if (
82
+ page.deletedCost.since !== since ||
83
+ page.sandboxes.some(({ cost }) => cost.since !== since)
84
+ )
85
+ throw new Error("Monthly Boat CI meter changed month; read again");
86
+ if (
87
+ deletedDollars !== undefined &&
88
+ deletedDollars !== page.deletedCost.dollars
89
+ )
90
+ throw new Error(
91
+ "Monthly Boat CI deleted cost changed during pagination; read again"
92
+ );
93
+ deletedDollars = page.deletedCost.dollars;
94
+ for (const sandbox of page.sandboxes) {
95
+ if (!sandbox.name.startsWith("ci-") || ids.has(sandbox.id))
96
+ throw new Error(
97
+ "Monthly Boat CI page contains an unexpected or repeated sandbox"
98
+ );
99
+ ids.add(sandbox.id);
100
+ dollars += sandbox.cost.dollars;
101
+ }
102
+ if (!page.pageInfo.hasMore) break;
103
+ const next = page.pageInfo.nextCursor;
104
+ if (next === null || cursors.has(next))
105
+ throw new Error("Monthly Boat CI pagination is incomplete");
106
+ cursors.add(next);
107
+ cursor = next;
108
+ }
109
+ return {
110
+ since,
111
+ readAt: now.toISOString(),
112
+ dollars: Schema.decodeSync(Nonnegative)(dollars + deletedDollars),
113
+ deletedDollars,
114
+ sandboxes: ids.size,
115
+ };
116
+ };
@@ -0,0 +1,12 @@
1
+ #!/usr/bin/env bun
2
+ import * as Config from "effect/Config";
3
+ import * as Console from "effect/Console";
4
+ import * as Effect from "effect/Effect";
5
+
6
+ const result = Effect.gen(function* () {
7
+ const checks = yield* Config.String("CI_RESULT");
8
+ yield* Console.log(`Ready checks: ${checks}`);
9
+ return checks === "success" ? 0 : 1;
10
+ }).pipe(Effect.orElseSucceed(() => 1));
11
+
12
+ if (import.meta.main) process.exitCode = await Effect.runPromise(result);
@@ -0,0 +1,96 @@
1
+ import * as Schema from "effect/Schema";
2
+ import { parse } from "yaml";
3
+
4
+ export const headRequest =
5
+ "github.event.action == 'labeled' && github.event.label.name == format('ready:{0}', github.event.pull_request.head.sha)";
6
+ export const renovateRequest =
7
+ "github.event.action != 'labeled' && github.event.pull_request.user.login == 'renovate[bot]' && github.event.pull_request.head.repo.full_name == github.repository";
8
+ export const readyRequest = `github.event_name == 'push' || (github.event.pull_request.draft == false && !startsWith(github.head_ref, 'probe/') && ((${headRequest}) || (${renovateRequest})))`;
9
+ export const budgetRequest = `github.event_name == 'pull_request' && github.event.pull_request.draft == false && (${renovateRequest})`;
10
+ export const checksRequest = `always() && (${readyRequest}) && (needs.budget.result == 'success' || needs.budget.result == 'skipped')`;
11
+ export const resultRequest = `always() && (${readyRequest})`;
12
+ export const readyGroup = `\${{ github.workflow }}-\${{ github.event_name == 'pull_request' && !((${headRequest}) || (${renovateRequest})) && format('label-{0}-{1}', github.event.pull_request.number, github.event.label.name) || github.event.pull_request.number || github.ref }}`;
13
+ export const readyCancellation = `\${{ github.event_name == 'pull_request' && ((${headRequest}) || (${renovateRequest})) }}`;
14
+ export const readyRunName = `\${{ github.event_name == 'push' && format('ready {0} at {1}', github.ref_name, github.sha) || ((${headRequest}) || (${renovateRequest})) && format('ready #{0} at {1}', github.event.pull_request.number, github.event.pull_request.head.sha) || format('label {0} on #{1}', github.event.label.name, github.event.pull_request.number) }}`;
15
+
16
+ const BudgetStep = Schema.Struct({
17
+ if: Schema.optionalKey(Schema.Never),
18
+ "continue-on-error": Schema.optionalKey(Schema.Literal(false)),
19
+ run: Schema.Literal("vp exec ci-budget"),
20
+ env: Schema.Struct({
21
+ BOAT_API_KEY: Schema.Literal(`\${{ secrets.BOAT_CI_READ_KEY }}`),
22
+ }),
23
+ });
24
+ const ResultStep = Schema.Struct({
25
+ if: Schema.optionalKey(Schema.Never),
26
+ "continue-on-error": Schema.optionalKey(Schema.Literal(false)),
27
+ run: Schema.Literal("vp exec ci-result"),
28
+ env: Schema.Struct({
29
+ CI_RESULT: Schema.Literal(`\${{ needs.checks.result }}`),
30
+ }),
31
+ });
32
+ const Workflow = Schema.Struct({
33
+ on: Schema.Struct({
34
+ push: Schema.Struct({ branches: Schema.Array(Schema.String) }),
35
+ pull_request: Schema.Struct({ types: Schema.Array(Schema.String) }),
36
+ }),
37
+ concurrency: Schema.Struct({
38
+ group: Schema.Literal(readyGroup),
39
+ "cancel-in-progress": Schema.Literal(readyCancellation),
40
+ }),
41
+ jobs: Schema.Struct({
42
+ budget: Schema.Struct({
43
+ "continue-on-error": Schema.optionalKey(Schema.Literal(false)),
44
+ if: Schema.Literal(budgetRequest),
45
+ "runs-on": Schema.Literal("ubuntu-24.04"),
46
+ steps: Schema.Array(Schema.Unknown),
47
+ }),
48
+ checks: Schema.Struct({
49
+ "continue-on-error": Schema.optionalKey(Schema.Literal(false)),
50
+ needs: Schema.Literal("budget"),
51
+ if: Schema.Literal(checksRequest),
52
+ }),
53
+ ready: Schema.Struct({
54
+ "continue-on-error": Schema.optionalKey(Schema.Literal(false)),
55
+ needs: Schema.Array(Schema.String),
56
+ if: Schema.Literal(resultRequest),
57
+ "runs-on": Schema.Literal("ubuntu-24.04"),
58
+ steps: Schema.Array(Schema.Unknown),
59
+ }),
60
+ }),
61
+ });
62
+
63
+ const Layout = Schema.Struct({
64
+ on: Schema.Record(Schema.String, Schema.Unknown),
65
+ jobs: Schema.Record(Schema.String, Schema.Unknown),
66
+ });
67
+
68
+ const MainOnlyJob = Schema.Struct({
69
+ if: Schema.Literal("github.event_name == 'push'"),
70
+ });
71
+
72
+ export const isRenovateCi = (text: string): boolean => {
73
+ const parsed: unknown = parse(text);
74
+ const decoded = Schema.decodeUnknownOption(Workflow)(parsed);
75
+ if (decoded._tag === "None") return false;
76
+ const layout = Schema.decodeUnknownSync(Layout)(parsed);
77
+ const push = Schema.decodeUnknownSync(
78
+ Schema.Record(Schema.String, Schema.Unknown)
79
+ )(layout.on.push);
80
+ const workflow = decoded.value;
81
+ return (
82
+ Object.keys(layout.on).toSorted().join(",") === "pull_request,push" &&
83
+ Object.keys(push).join(",") === "branches" &&
84
+ workflow.on.push.branches.join(",") === "main" &&
85
+ Object.entries(layout.jobs).every(
86
+ ([name, job]) =>
87
+ ["budget", "checks", "ready"].includes(name) ||
88
+ Schema.is(MainOnlyJob)(job)
89
+ ) &&
90
+ workflow.on.pull_request.types.join(",") ===
91
+ "labeled,opened,synchronize,reopened,ready_for_review" &&
92
+ workflow.jobs.ready.needs.join(",") === "budget,checks" &&
93
+ workflow.jobs.budget.steps.some(Schema.is(BudgetStep)) &&
94
+ workflow.jobs.ready.steps.some(Schema.is(ResultStep))
95
+ );
96
+ };
@@ -1,6 +1,8 @@
1
1
  import * as Schema from "effect/Schema";
2
2
  import { parse } from "yaml";
3
3
 
4
+ import { isRenovateCi } from "../renovate-ci.ts";
5
+
4
6
  export const BOAT_JOBS_PER_RUN = 2;
5
7
 
6
8
  const Matrix = Schema.Record(Schema.String, Schema.Array(Schema.Unknown));
@@ -43,6 +45,7 @@ type WorkflowFile = readonly [path: string, text: string];
43
45
  type Parsed = {
44
46
  readonly path: string;
45
47
  readonly workflow: typeof Workflow.Type;
48
+ readonly renovate: boolean;
46
49
  };
47
50
 
48
51
  const dynamic = (value: unknown): boolean => {
@@ -84,6 +87,7 @@ export const boatJobFindings = (
84
87
  workflows.push({
85
88
  path,
86
89
  workflow: Schema.decodeUnknownSync(Workflow)(parse(text)),
90
+ renovate: isRenovateCi(text),
87
91
  });
88
92
  } catch {
89
93
  findings.push(`${path}: workflow unread`);
@@ -186,7 +190,7 @@ export const boatJobFindings = (
186
190
  };
187
191
  for (const entry of workflows) {
188
192
  const total = count(entry, [], true);
189
- if (total > 0 && startsOnPr(entry.workflow.on))
193
+ if (total > 0 && startsOnPr(entry.workflow.on) && !entry.renovate)
190
194
  findings.push(
191
195
  `${entry.path}: a pull_request or PR-branch push starts ${total} Boat jobs; PR ready starts on request`
192
196
  );
package/src/starts.ts CHANGED
@@ -1,101 +1 @@
1
- import * as Clock from "effect/Clock";
2
- import * as Effect from "effect/Effect";
3
- import * as Schema from "effect/Schema";
4
-
5
- import { BoatStarts } from "./starts/boat.ts";
6
- import {
7
- decide,
8
- Line,
9
- pollMillis,
10
- sharedWindows,
11
- type StartRequest,
12
- } from "./starts/budget.ts";
13
- import { Merges } from "./starts/merges.ts";
14
-
15
- export { BoatStarts, StartReadError } from "./starts/boat.ts";
16
- export { decide, Repo, startRepos } from "./starts/budget.ts";
17
- export { Merges } from "./starts/merges.ts";
18
- export type {
19
- Admission,
20
- Counts,
21
- MergeCounts,
22
- PerWindow,
23
- Plan,
24
- Priority,
25
- RepoStarts,
26
- StartRequest,
27
- Window,
28
- } from "./starts/budget.ts";
29
1
  export { boatJobFindings, BOAT_JOBS_PER_RUN } from "./starts/policy.ts";
30
- export type { Line } from "./starts/budget.ts";
31
-
32
- export class StartHeld extends Schema.TaggedError<
33
- StartHeld,
34
- { readonly brand: unique symbol }
35
- >()("StartHeld", {
36
- line: Line,
37
- }) {}
38
-
39
- export const admitStart = Effect.fn("Starts.admitStart")(function* <A, E, R>(
40
- request: StartRequest,
41
- start: Effect.Effect<A, E, R>,
42
- { deadline }: { readonly deadline: number }
43
- ) {
44
- const boat = yield* BoatStarts;
45
- const merges = yield* Merges;
46
- let last: Line = {
47
- _tag: "Unread",
48
- reason: "start deadline reached",
49
- };
50
- for (;;) {
51
- const remaining = deadline - (yield* Clock.currentTimeMillis);
52
- if (!Number.isFinite(remaining) || remaining <= 0)
53
- return yield* new StartHeld({ line: last });
54
- const counts = yield* Effect.gen(function* () {
55
- const plan = yield* boat.plan;
56
- if (sharedWindows(request, plan).length === 0)
57
- return { now: yield* Clock.currentTimeMillis, plan };
58
- const repo = yield* boat
59
- .repoStarts(request.repo)
60
- .pipe(Effect.catchTag("StartReadError", () => Effect.undefined));
61
- const history = yield* merges.counts.pipe(
62
- Effect.catchTag("StartReadError", () => Effect.undefined)
63
- );
64
- return {
65
- now: yield* Clock.currentTimeMillis,
66
- plan,
67
- repo,
68
- merges: history,
69
- };
70
- }).pipe(
71
- Effect.catchTag("StartReadError", () => Effect.undefined),
72
- Effect.timeoutOrElse({
73
- duration: remaining,
74
- orElse: () => Effect.fail(new StartHeld({ line: last })),
75
- })
76
- );
77
- const now = yield* Clock.currentTimeMillis;
78
- const decision = decide(request, counts, now);
79
- if (decision._tag === "Hold")
80
- return yield* new StartHeld({ line: decision.line });
81
- if (!Number.isFinite(deadline) || now >= deadline)
82
- return yield* new StartHeld({
83
- line:
84
- decision._tag === "Wait"
85
- ? decision.line
86
- : { _tag: "Unread", reason: "start deadline reached" },
87
- });
88
- if (decision._tag === "Admit") return yield* start;
89
- last = decision.line;
90
- const window =
91
- decision.line._tag === "Account" || decision.line._tag === "Budget"
92
- ? decision.line.window
93
- : "minute";
94
- yield* Effect.sleep(
95
- Math.max(
96
- 0,
97
- Math.min(decision.until, now + pollMillis[window], deadline) - now
98
- )
99
- );
100
- }
101
- });
@@ -1,144 +0,0 @@
1
- import { BoatApi, CiJobState, Configuration } from "@boatdev/sdk";
2
- import * as Clock from "effect/Clock";
3
- import * as Context from "effect/Context";
4
- import * as Effect from "effect/Effect";
5
- import * as Layer from "effect/Layer";
6
- import * as Redacted from "effect/Redacted";
7
- import * as Schema from "effect/Schema";
8
-
9
- import {
10
- type Plan,
11
- type Repo,
12
- type RepoStarts,
13
- windowMillis,
14
- } from "./budget.ts";
15
-
16
- export class StartReadError extends Schema.TaggedError<
17
- StartReadError,
18
- { readonly brand: unique symbol }
19
- >()("StartReadError", { reason: Schema.String }) {}
20
-
21
- const Count = Schema.Number.check(
22
- Schema.makeFilter((value) => Number.isSafeInteger(value) && value >= 0)
23
- );
24
- const Usage = Schema.Struct({ limit: Count, used: Count });
25
- const Limits = Schema.Struct({
26
- ok: Schema.Literal(true),
27
- starts: Schema.Struct({ minute: Usage, hour: Usage, day: Usage }),
28
- nextStartDollars: Schema.optional(Schema.NullOr(Schema.Finite)),
29
- });
30
- const Ci = Schema.Struct({
31
- ok: Schema.Literal(true),
32
- jobs: Schema.Array(
33
- Schema.Struct({
34
- repo: Schema.String,
35
- label: Schema.String,
36
- state: Schema.String.check(Schema.isMinLength(1)),
37
- queuedAt: Schema.Date,
38
- runStartedAt: Schema.optional(Schema.NullOr(Schema.Date)),
39
- finishedAt: Schema.optional(Schema.NullOr(Schema.Date)),
40
- })
41
- ),
42
- });
43
- const settled = new Set<string>([
44
- CiJobState.Success,
45
- CiJobState.Failure,
46
- CiJobState.Cancelled,
47
- CiJobState.Skipped,
48
- CiJobState.Failed,
49
- CiJobState.Refused,
50
- ]);
51
-
52
- export class BoatStarts extends Context.Service<
53
- BoatStarts,
54
- {
55
- readonly plan: Effect.Effect<Plan, StartReadError>;
56
- readonly repoStarts: (
57
- repo: Repo
58
- ) => Effect.Effect<RepoStarts, StartReadError>;
59
- }
60
- >()("toolchain/BoatStarts") {
61
- static readonly layer = (
62
- key: Redacted.Redacted<string>,
63
- options: {
64
- readonly fetch?: (
65
- url: string | URL | Request,
66
- init?: RequestInit
67
- ) => Promise<Response>;
68
- } = {}
69
- ) =>
70
- Layer.sync(BoatStarts, () => {
71
- const api = new BoatApi(
72
- new Configuration({
73
- accessToken: Redacted.value(key),
74
- ...(options.fetch === undefined ? {} : { fetchApi: options.fetch }),
75
- })
76
- );
77
- const plan = Effect.gen(function* () {
78
- const response = yield* Effect.tryPromise({
79
- try: () => api.limits(),
80
- catch: () =>
81
- new StartReadError({ reason: "Boat limits request failed" }),
82
- });
83
- const limits = yield* Schema.decodeUnknownEffect(Limits)(response).pipe(
84
- Effect.mapError(
85
- () => new StartReadError({ reason: "Boat limits unread" })
86
- )
87
- );
88
- return {
89
- limits: {
90
- minute: limits.starts.minute.limit,
91
- hour: limits.starts.hour.limit,
92
- day: limits.starts.day.limit,
93
- },
94
- used: {
95
- minute: limits.starts.minute.used,
96
- hour: limits.starts.hour.used,
97
- day: limits.starts.day.used,
98
- },
99
- nextStartDollars: limits.nextStartDollars ?? undefined,
100
- };
101
- });
102
- const repoStarts = Effect.fn("BoatStarts.repoStarts")(function* (
103
- repo: Repo
104
- ) {
105
- const response = yield* Effect.tryPromise({
106
- try: () => api.getCiOverview({ repo, limit: 500 }),
107
- catch: () => new StartReadError({ reason: "Boat CI request failed" }),
108
- });
109
- const now = yield* Clock.currentTimeMillis;
110
- const { jobs } = yield* Schema.decodeUnknownEffect(Ci)(response).pipe(
111
- Effect.mapError(
112
- () => new StartReadError({ reason: "Boat CI history unread" })
113
- )
114
- );
115
- if (jobs.some((job) => job.repo !== repo))
116
- return yield* new StartReadError({
117
- reason: "Boat CI history differs from request",
118
- });
119
- const oldest = Math.min(
120
- ...jobs.map((job) =>
121
- Math.max(job.queuedAt.getTime(), job.runStartedAt?.getTime() ?? 0)
122
- )
123
- );
124
- return {
125
- repo,
126
- starts: jobs.flatMap((job) => {
127
- const at =
128
- job.runStartedAt?.getTime() ??
129
- (settled.has(job.state) ||
130
- (job.finishedAt !== undefined && job.finishedAt !== null)
131
- ? undefined
132
- : now);
133
- return job.label.split("/")[0]?.startsWith("boat") === true &&
134
- at !== undefined &&
135
- at > now - windowMillis.day
136
- ? [Math.min(at, now)]
137
- : [];
138
- }),
139
- complete: jobs.length < 500 || oldest <= now - windowMillis.day,
140
- };
141
- });
142
- return BoatStarts.of({ plan, repoStarts });
143
- });
144
- }