@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
package/dist/starts.d.mts CHANGED
@@ -1,113 +1,4 @@
1
- import * as Schema from "effect/Schema";
2
- import * as Effect from "effect/Effect";
3
- import * as Layer from "effect/Layer";
4
- import * as Context from "effect/Context";
5
- import * as Redacted from "effect/Redacted";
6
- export declare const Repo: Schema.brand<Schema.String, "Repo">;
7
- export type Repo = typeof Repo.Type;
8
- type Window = "minute" | "hour" | "day";
9
- type PerWindow<A> = { readonly [W in Window]: A; };
10
- type Priority = "ordinary" | "p0";
11
- type MergeCounts = {
12
- readonly repo: Repo;
13
- readonly h6: number;
14
- readonly h24: number;
15
- readonly d7: number;
16
- };
17
- type Plan = {
18
- readonly limits: PerWindow<number>;
19
- readonly used: PerWindow<number>;
20
- readonly nextStartDollars: number | undefined;
21
- };
22
- type RepoStarts = {
23
- readonly repo: Repo;
24
- readonly starts: ReadonlyArray<number>;
25
- readonly complete: boolean;
26
- };
27
- type Counts = {
28
- readonly now: number;
29
- readonly plan: Plan;
30
- readonly repo?: RepoStarts | undefined;
31
- readonly merges?: ReadonlyArray<MergeCounts> | undefined;
32
- };
33
- type StartRequest = {
34
- readonly repo: Repo;
35
- readonly jobs: number;
36
- readonly priority: Priority;
37
- };
38
- declare const Line: Schema.Union<readonly [Schema.TaggedStruct<"Unread", {
39
- readonly reason: Schema.String;
40
- }>, Schema.TaggedStruct<"Paid", {
41
- readonly nextStartDollars: Schema.UndefinedOr<Schema.Number>;
42
- }>, Schema.TaggedStruct<"Account", {
43
- readonly window: Schema.Literals<readonly ["minute", "hour", "day"]>;
44
- readonly used: Schema.Number;
45
- readonly line: Schema.Number;
46
- }>, Schema.TaggedStruct<"Budget", {
47
- readonly repo: Schema.brand<Schema.String, "Repo">;
48
- readonly window: Schema.Literals<readonly ["minute", "hour", "day"]>;
49
- readonly used: Schema.Number;
50
- readonly budget: Schema.Number;
51
- }>]>;
52
- type Line = typeof Line.Type;
53
- type Admission = {
54
- readonly _tag: "Admit";
55
- } | {
56
- readonly _tag: "Wait";
57
- readonly until: number;
58
- readonly line: Line;
59
- } | {
60
- readonly _tag: "Hold";
61
- readonly line: Line;
62
- };
63
- export declare const startRepos: ReadonlyArray<Repo>;
64
- export declare const decide: (request: StartRequest, counts: Counts | undefined, now: number) => Admission;
65
- declare const StartReadError_base: Schema.Class<StartReadError, Schema.TaggedStruct<"StartReadError", {
66
- readonly reason: Schema.String;
67
- }>, import("effect/Cause").YieldableError & {
68
- readonly brand: unique symbol;
69
- }>;
70
- export declare class StartReadError extends StartReadError_base {}
71
- declare const BoatStarts_base: Context.ServiceClass<BoatStarts, "toolchain/BoatStarts", {
72
- readonly plan: Effect.Effect<Plan, StartReadError>;
73
- readonly repoStarts: (repo: Repo) => Effect.Effect<RepoStarts, StartReadError>;
74
- }>;
75
- export declare class BoatStarts extends BoatStarts_base {
76
- static readonly layer: (key: Redacted.Redacted<string>, options?: {
77
- readonly fetch?: (url: string | URL | Request, init?: RequestInit) => Promise<Response>;
78
- }) => Layer.Layer<BoatStarts, never, never>;
79
- }
80
- declare const Merges_base: Context.ServiceClass<Merges, "toolchain/Merges", {
81
- readonly counts: Effect.Effect<ReadonlyArray<MergeCounts>, StartReadError>;
82
- }>;
83
- export declare class Merges extends Merges_base {
84
- static readonly layer: (token: Redacted.Redacted<string>, options?: {
85
- readonly fetch?: (url: string | URL | Request, init?: RequestInit) => Promise<Response>;
86
- }) => Layer.Layer<Merges, never, never>;
87
- }
88
1
  export declare const BOAT_JOBS_PER_RUN = 2;
89
2
  type WorkflowFile = readonly [path: string, text: string];
90
3
  export declare const boatJobFindings: (files: ReadonlyArray<WorkflowFile>) => ReadonlyArray<string>;
91
- declare const StartHeld_base: Schema.Class<StartHeld, Schema.TaggedStruct<"StartHeld", {
92
- readonly line: Schema.Union<readonly [Schema.TaggedStruct<"Unread", {
93
- readonly reason: Schema.String;
94
- }>, Schema.TaggedStruct<"Paid", {
95
- readonly nextStartDollars: Schema.UndefinedOr<Schema.Number>;
96
- }>, Schema.TaggedStruct<"Account", {
97
- readonly window: Schema.Literals<readonly ["minute", "hour", "day"]>;
98
- readonly used: Schema.Number;
99
- readonly line: Schema.Number;
100
- }>, Schema.TaggedStruct<"Budget", {
101
- readonly repo: Schema.brand<Schema.String, "Repo">;
102
- readonly window: Schema.Literals<readonly ["minute", "hour", "day"]>;
103
- readonly used: Schema.Number;
104
- readonly budget: Schema.Number;
105
- }>]>;
106
- }>, import("effect/Cause").YieldableError & {
107
- readonly brand: unique symbol;
108
- }>;
109
- export declare class StartHeld extends StartHeld_base {}
110
- export declare const admitStart: <A, E, R>(request: StartRequest, start: Effect.Effect<A, E, R>, args_2: {
111
- readonly deadline: number;
112
- }) => Effect.Effect<A, E | StartHeld, R | BoatStarts | Merges>;
113
- export type { Admission, Counts, Line, MergeCounts, PerWindow, Plan, Priority, RepoStarts, StartRequest, Window };
4
+ export {};
package/dist/starts.mjs CHANGED
@@ -1,310 +1,6 @@
1
+ import { i as isRenovateCi } from "./renovate-ci-BdVmECgm.mjs";
1
2
  import * as Schema from "effect/Schema";
2
- import * as Effect from "effect/Effect";
3
- import * as Layer from "effect/Layer";
4
- import * as Clock from "effect/Clock";
5
- import * as Context from "effect/Context";
6
- import { Octokit } from "@octokit/rest";
7
- import * as Redacted from "effect/Redacted";
8
- import { BoatApi, CiJobState, Configuration } from "@boatdev/sdk";
9
3
  import { parse } from "yaml";
10
- // src/starts/budget.ts
11
- const Repo = Schema.String.check(Schema.isPattern(/^[\w.-]+\/[\w.-]+$/u)).pipe(Schema.brand("Repo"));
12
- const Window = Schema.Literals([
13
- "minute",
14
- "hour",
15
- "day"
16
- ]);
17
- const Line = Schema.Union([
18
- Schema.TaggedStruct("Unread", { reason: Schema.String }),
19
- Schema.TaggedStruct("Paid", { nextStartDollars: Schema.UndefinedOr(Schema.Number) }),
20
- Schema.TaggedStruct("Account", {
21
- window: Window,
22
- used: Schema.Number,
23
- line: Schema.Number
24
- }),
25
- Schema.TaggedStruct("Budget", {
26
- repo: Repo,
27
- window: Window,
28
- used: Schema.Number,
29
- budget: Schema.Number
30
- })
31
- ]);
32
- const windows$1 = [
33
- "minute",
34
- "hour",
35
- "day"
36
- ];
37
- const windowMillis = {
38
- minute: 6e4,
39
- hour: 36e5,
40
- day: 864e5
41
- };
42
- const pollMillis = {
43
- minute: 15e3,
44
- hour: 6e4,
45
- day: 3e5
46
- };
47
- const startRepos = [
48
- Repo.make("birbprophet/agent-kit"),
49
- Repo.make("siglata/siglata"),
50
- Repo.make("optionhouse-xyz/optionhouse"),
51
- Repo.make("birbprophet/vibebattler")
52
- ];
53
- const count = (value) => Number.isSafeInteger(value) && value >= 0;
54
- const ceiling = (request, plan, window) => Number(BigInt(plan.limits[window]) * (request.priority === "p0" ? 95n : 80n) / 100n);
55
- const sharedWindows = (request, plan) => request.priority === "p0" || plan.nextStartDollars !== 0 || !windows$1.every((window) => count(plan.limits[window]) && count(plan.used[window])) || windows$1.some((window) => plan.used[window] + request.jobs > ceiling(request, plan, window)) ? [] : windows$1.filter((window) => 2 * plan.used[window] >= plan.limits[window]);
56
- const liveShare = (repo, merges) => {
57
- if (merges === void 0 || merges.length !== startRepos.length || !startRepos.every((repo) => merges.filter((row) => row.repo === repo).length === 1) || !merges.every((row) => [
58
- row.h6,
59
- row.h24,
60
- row.d7
61
- ].every(count))) return void 0;
62
- const weights = merges.map((row) => ({
63
- repo: row.repo,
64
- weight: [
65
- 7n * BigInt(row.h24),
66
- 28n * BigInt(row.h6),
67
- BigInt(row.d7)
68
- ].reduce((largest, value) => value > largest ? value : largest, 0n)
69
- }));
70
- const total = weights.reduce((sum, row) => sum + row.weight, 0n);
71
- const weight = weights.find((row) => row.repo === repo)?.weight;
72
- return weight === void 0 ? void 0 : total === 0n ? {
73
- numerator: 1n,
74
- denominator: 4n
75
- } : {
76
- numerator: total + 6n * weight,
77
- denominator: 10n * total
78
- };
79
- };
80
- const unread = (reason) => ({
81
- _tag: "Hold",
82
- line: {
83
- _tag: "Unread",
84
- reason
85
- }
86
- });
87
- const decide = (request, counts, now) => {
88
- if (!startRepos.includes(request.repo)) return unread("repo has no start budget");
89
- if (!count(request.jobs) || request.jobs === 0) return unread("jobs must be a positive safe integer");
90
- if (!Number.isFinite(now)) return unread("start time unread");
91
- if (counts === void 0) return {
92
- _tag: "Wait",
93
- until: now + pollMillis.minute,
94
- line: {
95
- _tag: "Unread",
96
- reason: "start plan unread"
97
- }
98
- };
99
- if (!Number.isFinite(counts.now) || counts.now > now || !windows$1.every((window) => count(counts.plan.limits[window]) && count(counts.plan.used[window]))) return unread("start plan unread");
100
- const { plan } = counts;
101
- if (plan.nextStartDollars !== 0) return {
102
- _tag: "Wait",
103
- until: now + pollMillis.minute,
104
- line: {
105
- _tag: "Paid",
106
- nextStartDollars: plan.nextStartDollars
107
- }
108
- };
109
- for (const window of windows$1) {
110
- const used = plan.used[window];
111
- const line = ceiling(request, plan, window);
112
- if (used + request.jobs > line) return window === "day" ? {
113
- _tag: "Hold",
114
- line: {
115
- _tag: "Account",
116
- window,
117
- used,
118
- line
119
- }
120
- } : {
121
- _tag: "Wait",
122
- until: now + pollMillis[window],
123
- line: {
124
- _tag: "Account",
125
- window,
126
- used,
127
- line
128
- }
129
- };
130
- }
131
- const shared = sharedWindows(request, plan);
132
- if (shared.length === 0) return { _tag: "Admit" };
133
- if (counts.repo === void 0 || !counts.repo.complete) return {
134
- _tag: "Wait",
135
- until: now + pollMillis.minute,
136
- line: {
137
- _tag: "Unread",
138
- reason: "repo start history incomplete"
139
- }
140
- };
141
- if (counts.repo.repo !== request.repo || !counts.repo.starts.every((at) => Number.isFinite(at) && at <= counts.now)) return unread("repo start history incomplete");
142
- const share = liveShare(request.repo, counts.merges);
143
- if (share === void 0) return {
144
- _tag: "Wait",
145
- until: now + pollMillis.minute,
146
- line: {
147
- _tag: "Unread",
148
- reason: "merge history incomplete"
149
- }
150
- };
151
- for (const window of shared) {
152
- const starts = counts.repo.starts.filter((at) => at > now - windowMillis[window]).toSorted((left, right) => left - right);
153
- const used = starts.length;
154
- const budget = Number(share.numerator * 4n * BigInt(plan.limits[window]) / (share.denominator * 5n));
155
- if (used + request.jobs <= budget) continue;
156
- const line = {
157
- _tag: "Budget",
158
- repo: request.repo,
159
- window,
160
- used,
161
- budget
162
- };
163
- const expires = starts[used + request.jobs - budget - 1];
164
- return request.jobs > budget || expires === void 0 ? {
165
- _tag: "Hold",
166
- line
167
- } : {
168
- _tag: "Wait",
169
- until: expires + windowMillis[window],
170
- line
171
- };
172
- }
173
- return { _tag: "Admit" };
174
- };
175
- // src/starts/boat.ts
176
- var StartReadError = class extends Schema.TaggedError()("StartReadError", { reason: Schema.String }) {};
177
- const Count$1 = Schema.Number.check(Schema.makeFilter((value) => Number.isSafeInteger(value) && value >= 0));
178
- const Usage = Schema.Struct({
179
- limit: Count$1,
180
- used: Count$1
181
- });
182
- const Limits = Schema.Struct({
183
- ok: Schema.Literal(true),
184
- starts: Schema.Struct({
185
- minute: Usage,
186
- hour: Usage,
187
- day: Usage
188
- }),
189
- nextStartDollars: Schema.optional(Schema.NullOr(Schema.Finite))
190
- });
191
- const Ci = Schema.Struct({
192
- ok: Schema.Literal(true),
193
- jobs: Schema.Array(Schema.Struct({
194
- repo: Schema.String,
195
- label: Schema.String,
196
- state: Schema.String.check(Schema.isMinLength(1)),
197
- queuedAt: Schema.Date,
198
- runStartedAt: Schema.optional(Schema.NullOr(Schema.Date)),
199
- finishedAt: Schema.optional(Schema.NullOr(Schema.Date))
200
- }))
201
- });
202
- const settled = /* @__PURE__ */ new Set([
203
- CiJobState.Success,
204
- CiJobState.Failure,
205
- CiJobState.Cancelled,
206
- CiJobState.Skipped,
207
- CiJobState.Failed,
208
- CiJobState.Refused
209
- ]);
210
- var BoatStarts = class BoatStarts extends Context.Service()("toolchain/BoatStarts") {
211
- static layer = (key, options = {}) => Layer.sync(BoatStarts, () => {
212
- const api = new BoatApi(new Configuration({
213
- accessToken: Redacted.value(key),
214
- ...options.fetch === void 0 ? {} : { fetchApi: options.fetch }
215
- }));
216
- const plan = Effect.gen(function* () {
217
- const response = yield* Effect.tryPromise({
218
- try: () => api.limits(),
219
- catch: () => new StartReadError({ reason: "Boat limits request failed" })
220
- });
221
- const limits = yield* Schema.decodeUnknownEffect(Limits)(response).pipe(Effect.mapError(() => new StartReadError({ reason: "Boat limits unread" })));
222
- return {
223
- limits: {
224
- minute: limits.starts.minute.limit,
225
- hour: limits.starts.hour.limit,
226
- day: limits.starts.day.limit
227
- },
228
- used: {
229
- minute: limits.starts.minute.used,
230
- hour: limits.starts.hour.used,
231
- day: limits.starts.day.used
232
- },
233
- nextStartDollars: limits.nextStartDollars ?? void 0
234
- };
235
- });
236
- const repoStarts = Effect.fn("BoatStarts.repoStarts")(function* (repo) {
237
- const response = yield* Effect.tryPromise({
238
- try: () => api.getCiOverview({
239
- repo,
240
- limit: 500
241
- }),
242
- catch: () => new StartReadError({ reason: "Boat CI request failed" })
243
- });
244
- const now = yield* Clock.currentTimeMillis;
245
- const { jobs } = yield* Schema.decodeUnknownEffect(Ci)(response).pipe(Effect.mapError(() => new StartReadError({ reason: "Boat CI history unread" })));
246
- if (jobs.some((job) => job.repo !== repo)) return yield* new StartReadError({ reason: "Boat CI history differs from request" });
247
- const oldest = Math.min(...jobs.map((job) => Math.max(job.queuedAt.getTime(), job.runStartedAt?.getTime() ?? 0)));
248
- return {
249
- repo,
250
- starts: jobs.flatMap((job) => {
251
- const at = job.runStartedAt?.getTime() ?? (settled.has(job.state) || job.finishedAt !== void 0 && job.finishedAt !== null ? void 0 : now);
252
- return job.label.split("/")[0]?.startsWith("boat") === true && at !== void 0 && at > now - windowMillis.day ? [Math.min(at, now)] : [];
253
- }),
254
- complete: jobs.length < 500 || oldest <= now - windowMillis.day
255
- };
256
- });
257
- return BoatStarts.of({
258
- plan,
259
- repoStarts
260
- });
261
- });
262
- };
263
- // src/starts/merges.ts
264
- const Count = Schema.Struct({ issueCount: Schema.Number.check(Schema.makeFilter((value) => Number.isSafeInteger(value) && value >= 0)) });
265
- const windows = {
266
- h6: 216e5,
267
- h24: 864e5,
268
- d7: 6048e5
269
- };
270
- var Merges = class Merges extends Context.Service()("toolchain/Merges") {
271
- static layer = (token, options = {}) => Layer.sync(Merges, () => {
272
- const api = new Octokit({
273
- auth: Redacted.value(token),
274
- ...options.fetch === void 0 ? {} : { request: { fetch: options.fetch } }
275
- });
276
- const counts = Effect.gen(function* () {
277
- const now = yield* Clock.currentTimeMillis;
278
- const query = `query { ${startRepos.flatMap((repo, index) => {
279
- const [owner, name] = repo.split("/");
280
- return [`repo${index}: repository(owner: "${owner}", name: "${name}") { nameWithOwner }`, ...Object.entries(windows).map(([window, millis]) => {
281
- return `${window}_${index}: search(type: ISSUE, first: 0, query: "repo:${repo} is:pr is:merged base:main merged:>=${new Date(now - millis).toISOString().replace(/\.\d{3}Z$/u, "Z")}") { issueCount }`;
282
- })];
283
- }).join(" ")} }`;
284
- const response = yield* Effect.tryPromise({
285
- try: () => api.graphql(query),
286
- catch: () => new StartReadError({ reason: "GitHub merges request failed" })
287
- });
288
- return yield* Schema.decodeUnknownEffect(Schema.Record(Schema.String, Schema.Unknown))(response).pipe(Effect.flatMap((data) => Effect.forEach(startRepos, (repo, index) => Schema.decodeUnknownEffect(Schema.Struct({
289
- repository: Schema.Struct({ nameWithOwner: Schema.Literal(repo) }),
290
- h6: Count,
291
- h24: Count,
292
- d7: Count
293
- }))({
294
- repository: data[`repo${index}`],
295
- h6: data[`h6_${index}`],
296
- h24: data[`h24_${index}`],
297
- d7: data[`d7_${index}`]
298
- }).pipe(Effect.map((row) => ({
299
- repo,
300
- h6: row.h6.issueCount,
301
- h24: row.h24.issueCount,
302
- d7: row.d7.issueCount
303
- }))), { concurrency: 1 })), Effect.mapError(() => new StartReadError({ reason: "GitHub merges unread" })));
304
- });
305
- return Merges.of({ counts });
306
- });
307
- };
308
4
  // src/starts/policy.ts
309
5
  const BOAT_JOBS_PER_RUN = 2;
310
6
  const Matrix = Schema.Record(Schema.String, Schema.Array(Schema.Unknown));
@@ -356,7 +52,8 @@ const boatJobFindings = (files) => {
356
52
  for (const [path, text] of files) try {
357
53
  workflows.push({
358
54
  path,
359
- workflow: Schema.decodeUnknownSync(Workflow)(parse(text))
55
+ workflow: Schema.decodeUnknownSync(Workflow)(parse(text)),
56
+ renovate: isRenovateCi(text)
360
57
  });
361
58
  } catch {
362
59
  findings.push(`${path}: workflow unread`);
@@ -427,52 +124,9 @@ const boatJobFindings = (files) => {
427
124
  };
428
125
  for (const entry of workflows) {
429
126
  const total = count(entry, [], true);
430
- if (total > 0 && startsOnPr(entry.workflow.on)) findings.push(`${entry.path}: a pull_request or PR-branch push starts ${total} Boat jobs; PR ready starts on request`);
127
+ if (total > 0 && startsOnPr(entry.workflow.on) && !entry.renovate) findings.push(`${entry.path}: a pull_request or PR-branch push starts ${total} Boat jobs; PR ready starts on request`);
431
128
  if (total > 2) findings.push(`${entry.path}: closure starts ${total} Boat jobs, limit 2`);
432
129
  }
433
130
  return [...new Set(findings)];
434
131
  };
435
- // src/starts.ts
436
- var StartHeld = class extends Schema.TaggedError()("StartHeld", { line: Line }) {};
437
- const admitStart = Effect.fn("Starts.admitStart")(function* (request, start, { deadline }) {
438
- const boat = yield* BoatStarts;
439
- const merges = yield* Merges;
440
- let last = {
441
- _tag: "Unread",
442
- reason: "start deadline reached"
443
- };
444
- for (;;) {
445
- const remaining = deadline - (yield* Clock.currentTimeMillis);
446
- if (!Number.isFinite(remaining) || remaining <= 0) return yield* new StartHeld({ line: last });
447
- const counts = yield* Effect.gen(function* () {
448
- const plan = yield* boat.plan;
449
- if (sharedWindows(request, plan).length === 0) return {
450
- now: yield* Clock.currentTimeMillis,
451
- plan
452
- };
453
- const repo = yield* boat.repoStarts(request.repo).pipe(Effect.catchTag("StartReadError", () => Effect.undefined));
454
- const history = yield* merges.counts.pipe(Effect.catchTag("StartReadError", () => Effect.undefined));
455
- return {
456
- now: yield* Clock.currentTimeMillis,
457
- plan,
458
- repo,
459
- merges: history
460
- };
461
- }).pipe(Effect.catchTag("StartReadError", () => Effect.undefined), Effect.timeoutOrElse({
462
- duration: remaining,
463
- orElse: () => Effect.fail(new StartHeld({ line: last }))
464
- }));
465
- const now = yield* Clock.currentTimeMillis;
466
- const decision = decide(request, counts, now);
467
- if (decision._tag === "Hold") return yield* new StartHeld({ line: decision.line });
468
- if (!Number.isFinite(deadline) || now >= deadline) return yield* new StartHeld({ line: decision._tag === "Wait" ? decision.line : {
469
- _tag: "Unread",
470
- reason: "start deadline reached"
471
- } });
472
- if (decision._tag === "Admit") return yield* start;
473
- last = decision.line;
474
- const window = decision.line._tag === "Account" || decision.line._tag === "Budget" ? decision.line.window : "minute";
475
- yield* Effect.sleep(Math.max(0, Math.min(decision.until, now + pollMillis[window], deadline) - now));
476
- }
477
- });
478
- export { BOAT_JOBS_PER_RUN, BoatStarts, Merges, Repo, StartHeld, StartReadError, admitStart, boatJobFindings, decide, startRepos };
132
+ export { BOAT_JOBS_PER_RUN, boatJobFindings };
@@ -1,3 +1,3 @@
1
- import { i as VerificationError } from "./verification-FgQFU1YN.mjs";
1
+ import { i as VerificationError } from "./verification-fnhfrxmy.mjs";
2
2
  import * as Effect from "effect/Effect";
3
3
  export declare const checkVerdict: Effect.Effect<number, import("effect/Config").ConfigError | import("effect/PlatformError").PlatformError | import("effect/Schema").SchemaError | VerificationError, import("effect/FileSystem").FileSystem>;
package/dist/verdict.mjs CHANGED
@@ -1,9 +1,9 @@
1
1
  #!/usr/bin/env bun
2
- import { a as readPullRequest, i as github, n as autoPass } from "./verification-oAc1Q6I9.mjs";
2
+ import { a as readPullRequest, i as github, n as autoPass } from "./verification-D4Sn2fh5.mjs";
3
+ import * as Console from "effect/Console";
3
4
  import * as Effect from "effect/Effect";
4
5
  import { NodeServices } from "@effect/platform-node";
5
6
  import * as Cause from "effect/Cause";
6
- import * as Console from "effect/Console";
7
7
  import * as Exit from "effect/Exit";
8
8
  // src/verdict.ts
9
9
  const checkVerdict = Effect.gen(function* () {
@@ -1,6 +1,6 @@
1
- import * as Schema from "effect/Schema";
2
1
  import * as Config from "effect/Config";
3
2
  import * as Effect from "effect/Effect";
3
+ import * as Schema from "effect/Schema";
4
4
  import * as Cause from "effect/Cause";
5
5
  import { FileSystem } from "effect/FileSystem";
6
6
  import { Octokit } from "@octokit/rest";
@@ -1,2 +1,2 @@
1
- import { a as autoPass, c as readPullRequest, i as VerificationError, l as verdict, n as PullRequestContext, o as checkVerification, r as Verdict, s as github, t as PullRequest } from "./verification-FgQFU1YN.mjs";
1
+ import { a as autoPass, c as readPullRequest, i as VerificationError, l as verdict, n as PullRequestContext, o as checkVerification, r as Verdict, s as github, t as PullRequest } from "./verification-fnhfrxmy.mjs";
2
2
  export { PullRequest, PullRequestContext, Verdict, VerificationError, autoPass, checkVerification, github, readPullRequest, verdict };
@@ -1,2 +1,2 @@
1
1
  #!/usr/bin/env bun
2
- export { t as VerificationError, n as autoPass, r as checkVerification, i as github, a as readPullRequest, o as verdict } from "./verification-oAc1Q6I9.mjs";
2
+ export { t as VerificationError, n as autoPass, r as checkVerification, i as github, a as readPullRequest, o as verdict } from "./verification-D4Sn2fh5.mjs";
package/dist/versions.mjs CHANGED
@@ -1 +1 @@
1
- export { t as catalog, n as families, r as familyNamed, i as familyOf, a as fixed, o as fixedBy, s as fixedOf, c as lead, l as nodeVersion, u as ownerOf, d as pinned, f as versionOf, p as versions } from "./versions-DpRzgSR_.mjs";
1
+ export { t as catalog, n as families, r as familyNamed, i as familyOf, a as fixed, o as fixedBy, s as fixedOf, c as lead, l as nodeVersion, u as ownerOf, d as pinned, f as versionOf, p as versions } from "./versions-KbYa8kbF.mjs";
package/package.json CHANGED
@@ -1,12 +1,14 @@
1
1
  {
2
2
  "name": "@milkenjoyer/toolchain",
3
- "version": "0.19.0",
3
+ "version": "0.21.0",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/birbprophet/agent-kit.git",
7
7
  "directory": "packages/toolchain"
8
8
  },
9
9
  "bin": {
10
+ "ci-budget": "./src/ci-budget-cli.ts",
11
+ "ci-result": "./src/ci-result.ts",
10
12
  "formal": "./src/formal.ts",
11
13
  "proof": "./src/proof.ts",
12
14
  "standard": "./src/standard.ts",
@@ -99,6 +101,14 @@
99
101
  "./conformance": {
100
102
  "types": "./dist/conformance.d.mts",
101
103
  "default": "./dist/conformance.mjs"
104
+ },
105
+ "./ci-budget": {
106
+ "types": "./dist/ci-budget.d.mts",
107
+ "default": "./dist/ci-budget.mjs"
108
+ },
109
+ "./renovate-ci": {
110
+ "types": "./dist/renovate-ci.d.mts",
111
+ "default": "./dist/renovate-ci.mjs"
102
112
  }
103
113
  },
104
114
  "publishConfig": {
package/renovate.json CHANGED
@@ -14,6 +14,21 @@
14
14
  }
15
15
  ],
16
16
  "packageRules": [
17
+ {
18
+ "matchUpdateTypes": ["minor", "patch"],
19
+ "extends": ["schedule:weekly"],
20
+ "automerge": true
21
+ },
22
+ {
23
+ "matchUpdateTypes": ["minor", "patch"],
24
+ "matchDatasources": ["npm"],
25
+ "minimumReleaseAge": "3 days"
26
+ },
27
+ {
28
+ "matchUpdateTypes": ["major"],
29
+ "matchPackageNames": ["java-jre", "ubuntu"],
30
+ "enabled": false
31
+ },
17
32
  {
18
33
  "description": "Renovate refreshes bun.lock only for updates its bun manager found, so a catalog-only update leaves bun.lock stale and a frozen install fails",
19
34
  "matchManagers": ["custom.jsonata"],
@@ -39,7 +54,8 @@
39
54
  ],
40
55
  "followTag": "latest",
41
56
  "minimumReleaseAge": "0 days",
42
- "rangeStrategy": "pin"
57
+ "rangeStrategy": "pin",
58
+ "schedule": ["at any time"]
43
59
  },
44
60
  {
45
61
  "matchDepNames": [
@@ -74,12 +90,22 @@
74
90
  "matchPackageNames": ["@milkenjoyer/toolchain"],
75
91
  "prBodyNotes": [
76
92
  "This toolchain release moves `vite-plus`, the catalog's `vite` alias, `vitest`, `@vitest/browser-*` and `@effect/tsgo` together, which Renovate leaves to this PR. Set each to what the release requires (`npm view @milkenjoyer/toolchain@<version> peerDependencies dependencies`, then `npm view vite-plus@<version> dependencies`) and run `vp install` before `ready`."
77
- ]
93
+ ],
94
+ "automerge": false
78
95
  },
79
96
  {
80
97
  "description": "engines.node is a >= floor that tests hold to the toolchain's Node version, which .node-version pins, so Renovate replaces it only when a release falls outside it and never pins it",
81
98
  "matchDepTypes": ["engines"],
82
99
  "rangeStrategy": "replace"
100
+ },
101
+ {
102
+ "description": "Catalog updates need bun.lock refreshed by hand until renovatebot/renovate#42909 lands",
103
+ "matchManagers": ["custom.jsonata"],
104
+ "matchUpdateTypes": ["minor", "patch"],
105
+ "groupName": "workspace catalog",
106
+ "groupSlug": "workspace-catalog",
107
+ "automerge": false
83
108
  }
84
- ]
109
+ ],
110
+ "extends": ["group:allNonMajor"]
85
111
  }
@@ -0,0 +1,39 @@
1
+ #!/usr/bin/env bun
2
+ import { BoatApi, Configuration } from "@boatdev/sdk";
3
+ import * as Config from "effect/Config";
4
+ import * as Console from "effect/Console";
5
+ import * as DateTime from "effect/DateTime";
6
+ import * as Effect from "effect/Effect";
7
+ import * as Redacted from "effect/Redacted";
8
+ import * as Schema from "effect/Schema";
9
+
10
+ import { monthlyCiBudget, readMonthlyCiSpend } from "./ci-budget.ts";
11
+
12
+ class CiMeterUnread extends Schema.TaggedError<
13
+ CiMeterUnread,
14
+ { readonly brand: unique symbol }
15
+ >()("CiMeterUnread", {}) {}
16
+
17
+ export const checkCiBudget = Effect.gen(function* () {
18
+ const key = yield* Config.Redacted("BOAT_API_KEY");
19
+ const boat = new BoatApi(
20
+ new Configuration({ accessToken: Redacted.value(key) })
21
+ );
22
+ const now = yield* DateTime.nowAsDate;
23
+ const spend = yield* Effect.tryPromise({
24
+ try: () => readMonthlyCiSpend({ boat, now }),
25
+ catch: () => new CiMeterUnread(),
26
+ });
27
+ const budget = monthlyCiBudget(spend);
28
+ yield* Console.log({ ...budget, spend });
29
+ return budget._tag === "Allowed" ? 0 : 1;
30
+ }).pipe(
31
+ Effect.catch(() =>
32
+ Effect.as(
33
+ Console.error("Boat CI monthly meter unread; no Boat job admitted"),
34
+ 1
35
+ )
36
+ )
37
+ );
38
+
39
+ if (import.meta.main) process.exitCode = await Effect.runPromise(checkCiBudget);