@milkenjoyer/toolchain 0.20.0 → 0.22.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 (71) hide show
  1. package/README.md +2 -0
  2. package/TESTING.md +26 -0
  3. package/dist/ci-budget-B2AuZ3xa.mjs +80 -0
  4. package/dist/ci-budget-cli.d.mts +2 -0
  5. package/dist/ci-budget-cli.mjs +31 -0
  6. package/dist/ci-budget.d.mts +22 -0
  7. package/dist/ci-budget.mjs +1 -0
  8. package/dist/ci-result.d.mts +1 -0
  9. package/dist/ci-result.mjs +12 -0
  10. package/dist/{compatible-DIYO9MZf.d.mts → compatible-BKEJ_p20.d.mts} +1 -1
  11. package/dist/{compatible-D54mCSlT.mjs → compatible-CRaMYpBM.mjs} +2 -2
  12. package/dist/compatible.d.mts +1 -1
  13. package/dist/compatible.mjs +1 -1
  14. package/dist/conformance.mjs +1 -1
  15. package/dist/{effect-plugin-BsrW5_nI.mjs → effect-plugin-roghk4W1.mjs} +2 -3
  16. package/dist/effect-plugin.mjs +1 -1
  17. package/dist/exceptions-D0yZUk8P.mjs +145 -0
  18. package/dist/exceptions.mjs +1 -1
  19. package/dist/foldkit-plugin.mjs +2 -2
  20. package/dist/formal.d.mts +1 -1
  21. package/dist/formal.mjs +5 -5
  22. package/dist/{guard-fFg_0NIp.mjs → guard-n0LC_buo.mjs} +6 -6
  23. package/dist/guard.d.mts +1 -1
  24. package/dist/guard.mjs +1 -1
  25. package/dist/hooks.d.mts +1 -1
  26. package/dist/hooks.mjs +2 -2
  27. package/dist/{lint-BJ6SmGk1.mjs → lint-Bx4NP_kA.mjs} +5 -5
  28. package/dist/lint.mjs +1 -1
  29. package/dist/{plugin-CwxhPtui.mjs → plugin-DUUAfi92.mjs} +326 -30
  30. package/dist/plugin.d.mts +5 -0
  31. package/dist/plugin.mjs +1 -1
  32. package/dist/proof.mjs +3 -3
  33. package/dist/renovate-ci-BdVmECgm.mjs +73 -0
  34. package/dist/renovate-ci.d.mts +10 -0
  35. package/dist/renovate-ci.mjs +1 -0
  36. package/dist/{rules-vHmNoAU0.mjs → rules-5qwzfDWJ.mjs} +3 -1
  37. package/dist/rules.d.mts +2 -0
  38. package/dist/rules.mjs +1 -1
  39. package/dist/standard.mjs +6 -6
  40. package/dist/starts.mjs +4 -2
  41. package/dist/verdict.d.mts +1 -1
  42. package/dist/verdict.mjs +2 -2
  43. package/dist/{verification-FgQFU1YN.d.mts → verification-fnhfrxmy.d.mts} +1 -1
  44. package/dist/verification.d.mts +1 -1
  45. package/dist/verification.mjs +1 -1
  46. package/dist/versions.mjs +1 -1
  47. package/package.json +13 -1
  48. package/renovate.json +29 -3
  49. package/src/ci-budget-cli.ts +39 -0
  50. package/src/ci-budget.ts +116 -0
  51. package/src/ci-result.ts +12 -0
  52. package/src/effect-plugin.ts +0 -1
  53. package/src/exceptions.ts +132 -0
  54. package/src/plugin.ts +10 -0
  55. package/src/renovate-ci.ts +96 -0
  56. package/src/rules/no-mock-call-mirrors.ts +121 -0
  57. package/src/rules/no-test-internal-imports.ts +102 -0
  58. package/src/rules/no-test-timeouts.ts +83 -0
  59. package/src/rules/no-test-waits.ts +113 -0
  60. package/src/rules/require-test-quarantine.ts +36 -0
  61. package/src/rules/test-api.ts +57 -0
  62. package/src/rules/test-hygiene.test.ts +241 -0
  63. package/src/rules/test-package.ts +32 -0
  64. package/src/rules.ts +2 -0
  65. package/src/shared/member-path.ts +7 -0
  66. package/src/starts/policy.ts +5 -1
  67. package/dist/exceptions-Dybl9xpc.mjs +0 -11
  68. package/dist/{specs-file-NsQF4V7X.mjs → specs-file-Ck9ZOt46.mjs} +1 -1
  69. package/dist/{syntax-CGEOffZK.mjs → syntax-B3n7lDYJ.mjs} +1 -1
  70. package/dist/{verification-oAc1Q6I9.mjs → verification-D4Sn2fh5.mjs} +4 -4
  71. package/dist/{versions-DpRzgSR_.mjs → versions-KbYa8kbF.mjs} +1 -1
@@ -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.20.0",
3
+ "version": "0.22.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",
@@ -16,6 +18,7 @@
16
18
  "files": [
17
19
  "dist",
18
20
  "STARTS.md",
21
+ "TESTING.md",
19
22
  "formal-tools/tla2tools-1.8.0.jar",
20
23
  "licenses",
21
24
  "node-version",
@@ -99,6 +102,14 @@
99
102
  "./conformance": {
100
103
  "types": "./dist/conformance.d.mts",
101
104
  "default": "./dist/conformance.mjs"
105
+ },
106
+ "./ci-budget": {
107
+ "types": "./dist/ci-budget.d.mts",
108
+ "default": "./dist/ci-budget.mjs"
109
+ },
110
+ "./renovate-ci": {
111
+ "types": "./dist/renovate-ci.d.mts",
112
+ "default": "./dist/renovate-ci.mjs"
102
113
  }
103
114
  },
104
115
  "publishConfig": {
@@ -108,6 +119,7 @@
108
119
  "prepack": "vp pack"
109
120
  },
110
121
  "dependencies": {
122
+ "@boatdev/sdk": "1.13.0",
111
123
  "@effect/platform-node": "4.1.4",
112
124
  "@effect/tsgo": "0.69.0",
113
125
  "@foldkit/oxlint-plugin": "0.15.4",
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);
@@ -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);
@@ -7,7 +7,6 @@ const kept: ReadonlyArray<string> = [
7
7
  "avoid-mutable-state",
8
8
  "avoid-option-getorthrow",
9
9
  "no-chained-type-assertions",
10
- "no-module-mocking",
11
10
  "prefer-redacted-config",
12
11
  "require-effect-concurrency",
13
12
  "throw-in-effect-gen",
package/src/exceptions.ts CHANGED
@@ -5,6 +5,138 @@ export type Exception = {
5
5
  };
6
6
 
7
7
  export const exceptions: ReadonlyArray<Exception> = [
8
+ {
9
+ files: [
10
+ "packages/toolchain/tests/renovate-ci.test.ts",
11
+ "packages/toolchain/tests/standard-fixture.ts",
12
+ "plugins/agent-kit/tests/board.test.ts",
13
+ "plugins/agent-kit/tests/codex-usage.test.ts",
14
+ "plugins/agent-kit/tests/kept-clock.test.ts",
15
+ "plugins/agent-kit/tests/kept-clock.ts",
16
+ "plugins/agent-kit/tests/kept-fake.ts",
17
+ "plugins/agent-kit/tests/kept-fixes.test.ts",
18
+ "plugins/agent-kit/tests/kept-plan.test.ts",
19
+ "plugins/agent-kit/tests/kept-relocation.test.ts",
20
+ "plugins/agent-kit/tests/kept-runner.test.ts",
21
+ "plugins/agent-kit/tests/kept.test.ts",
22
+ "plugins/agent-kit/tests/pool-quota.test.ts",
23
+ "plugins/agent-kit/tests/request-ready.test.ts",
24
+ "plugins/agent-kit/tests/wait-ready.test.ts",
25
+ "tests/ready-request.test.ts",
26
+ "tests/repo-guard/check.test.ts",
27
+ ],
28
+ rules: ["birbprophet/no-test-waits"],
29
+ issue: "https://github.com/birbprophet/agent-kit/issues/532",
30
+ },
31
+ {
32
+ files: [
33
+ "packages/toolchain/tests/bins-packed.test.ts",
34
+ "packages/toolchain/tests/build.test.ts",
35
+ "packages/toolchain/tests/false-positives.test.ts",
36
+ "packages/toolchain/tests/formal-arithmetic.test.ts",
37
+ "packages/toolchain/tests/formal-proofs.test.ts",
38
+ "packages/toolchain/tests/formal.test.ts",
39
+ "packages/toolchain/tests/hooks.test.ts",
40
+ "packages/toolchain/tests/knip.test.ts",
41
+ "packages/toolchain/tests/rules.test.ts",
42
+ "packages/toolchain/tests/standard-aggregate-ids.test.ts",
43
+ "packages/toolchain/tests/standard-config.test.ts",
44
+ "packages/toolchain/tests/standard-domain-layout.test.ts",
45
+ "packages/toolchain/tests/standard-domain.test.ts",
46
+ "packages/toolchain/tests/standard-infra.test.ts",
47
+ "packages/toolchain/tests/standard-pins.test.ts",
48
+ "packages/toolchain/tests/standard-rules.test.ts",
49
+ "plugins/agent-kit/tests/codex-launch.test.ts",
50
+ "plugins/agent-kit/tests/kept-admission.test.ts",
51
+ "plugins/agent-kit/tests/kept-fixes.test.ts",
52
+ "plugins/agent-kit/tests/kept-relocation.test.ts",
53
+ "plugins/agent-kit/tests/kept-runner.test.ts",
54
+ "plugins/agent-kit/tests/kept.test.ts",
55
+ "tests/no-comments.test.ts",
56
+ "tests/repo-guard/check.test.ts",
57
+ "tests/spawned-commands.test.ts",
58
+ ],
59
+ rules: ["birbprophet/no-test-timeouts"],
60
+ issue: "https://github.com/birbprophet/agent-kit/issues/532",
61
+ },
62
+ {
63
+ files: [
64
+ "packages/toolchain/tests/catalog.test.ts",
65
+ "packages/toolchain/tests/ci-budget.test.ts",
66
+ "packages/toolchain/tests/fixtures/formal/formal/counter.conformance.ts",
67
+ "packages/toolchain/tests/fixtures/proofs/formal/add32.proof.ts",
68
+ "packages/toolchain/tests/fixtures/proofs/formal/credits.proof.ts",
69
+ "packages/toolchain/tests/fixtures/proofs/formal/next-below.proof.ts",
70
+ "packages/toolchain/tests/fixtures/proofs/formal/used-percent.proof.ts",
71
+ "packages/toolchain/tests/foldkit-vite.test.ts",
72
+ "packages/toolchain/tests/formal-traces.test.ts",
73
+ "packages/toolchain/tests/hooks-fixture.ts",
74
+ "packages/toolchain/tests/hooks.test.ts",
75
+ "packages/toolchain/tests/renovate-ci.test.ts",
76
+ "packages/toolchain/tests/renovate.test.ts",
77
+ "packages/toolchain/tests/rules.test.ts",
78
+ "packages/toolchain/tests/rules/no-comments.test.ts",
79
+ "packages/toolchain/tests/rules/no-process-env.test.ts",
80
+ "packages/toolchain/tests/rules/prefer-accessible-scene-locators.test.ts",
81
+ "packages/toolchain/tests/rules/require-command-answer-names.test.ts",
82
+ "packages/toolchain/tests/rules/require-past-tense-messages.test.ts",
83
+ "packages/toolchain/tests/rules/use-temp-file-scoped.test.ts",
84
+ "packages/toolchain/tests/solver.test.ts",
85
+ "packages/toolchain/tests/standard-domain.test.ts",
86
+ "packages/toolchain/tests/standard-infra.test.ts",
87
+ "packages/toolchain/tests/standard-pins.test.ts",
88
+ "packages/toolchain/tests/standard.test.ts",
89
+ "packages/toolchain/tests/starts-policy.test.ts",
90
+ "packages/toolchain/tests/verdict.test.ts",
91
+ "packages/toolchain/tests/verification.test.ts",
92
+ "plugins/agent-kit/tests/board.test.ts",
93
+ "plugins/agent-kit/tests/boat-cost.test.ts",
94
+ "plugins/agent-kit/tests/boat-paid.test.ts",
95
+ "plugins/agent-kit/tests/cleanup.test.ts",
96
+ "plugins/agent-kit/tests/codex-launch.test.ts",
97
+ "plugins/agent-kit/tests/codex-usage.test.ts",
98
+ "plugins/agent-kit/tests/disk-policy.test.ts",
99
+ "plugins/agent-kit/tests/fixed-model-quota.test.ts",
100
+ "plugins/agent-kit/tests/free-resets.test.ts",
101
+ "plugins/agent-kit/tests/kept-admission.test.ts",
102
+ "plugins/agent-kit/tests/kept-cli.test.ts",
103
+ "plugins/agent-kit/tests/kept-clock.test.ts",
104
+ "plugins/agent-kit/tests/kept-fake.ts",
105
+ "plugins/agent-kit/tests/kept-fixes.test.ts",
106
+ "plugins/agent-kit/tests/kept-hydration.test.ts",
107
+ "plugins/agent-kit/tests/kept-observation.test.ts",
108
+ "plugins/agent-kit/tests/kept-plan.test.ts",
109
+ "plugins/agent-kit/tests/kept-relocation.test.ts",
110
+ "plugins/agent-kit/tests/kept-runner.test.ts",
111
+ "plugins/agent-kit/tests/kept.test.ts",
112
+ "plugins/agent-kit/tests/pool-order.test.ts",
113
+ "plugins/agent-kit/tests/pool-quota.test.ts",
114
+ "plugins/agent-kit/tests/provider-slots.test.ts",
115
+ "plugins/agent-kit/tests/proxy-quota.test.ts",
116
+ "plugins/agent-kit/tests/queue-fixture.ts",
117
+ "plugins/agent-kit/tests/queue-members.test.ts",
118
+ "plugins/agent-kit/tests/queue-plan.test.ts",
119
+ "plugins/agent-kit/tests/queue-resets.test.ts",
120
+ "plugins/agent-kit/tests/queue-unread.test.ts",
121
+ "plugins/agent-kit/tests/queue-upkeep.test.ts",
122
+ "plugins/agent-kit/tests/queue-usage.test.ts",
123
+ "plugins/agent-kit/tests/queue.test.ts",
124
+ "plugins/agent-kit/tests/request-ready.test.ts",
125
+ "plugins/agent-kit/tests/trust-hooks.test.ts",
126
+ "plugins/agent-kit/tests/unbound-census.test.ts",
127
+ "plugins/agent-kit/tests/wait-ready.test.ts",
128
+ "tests/exact-versions.test.ts",
129
+ "tests/ready-main.test.ts",
130
+ "tests/ready-request.test.ts",
131
+ "tests/spawned-commands.test.ts",
132
+ "tests/standard-plugin-skills.test.ts",
133
+ "tests/toolchain-adoption.test.ts",
134
+ "tests/workflow-policy.test.ts",
135
+ "tests/workflow-shell.test.ts",
136
+ ],
137
+ rules: ["birbprophet/no-test-internal-imports"],
138
+ issue: "https://github.com/birbprophet/agent-kit/issues/532",
139
+ },
8
140
  {
9
141
  files: ["packages/toolchain/src/conformance.ts"],
10
142
  rules: [
package/src/plugin.ts CHANGED
@@ -1,14 +1,24 @@
1
1
  import { Plugin } from "effect-oxlint";
2
2
 
3
3
  import { noCommentsRule } from "./rules/no-comments.ts";
4
+ import { noMockCallMirrorsRule } from "./rules/no-mock-call-mirrors.ts";
4
5
  import { noProcessEnvRule } from "./rules/no-process-env.ts";
6
+ import { noTestInternalImportsRule } from "./rules/no-test-internal-imports.ts";
7
+ import { noTestTimeoutsRule } from "./rules/no-test-timeouts.ts";
8
+ import { noTestWaitsRule } from "./rules/no-test-waits.ts";
5
9
  import { preferAccessibleSceneLocatorsRule } from "./rules/prefer-accessible-scene-locators.ts";
6
10
  import { requireCommandAnswerNamesRule } from "./rules/require-command-answer-names.ts";
7
11
  import { requirePastTenseMessagesRule } from "./rules/require-past-tense-messages.ts";
12
+ import { requireTestQuarantineRule } from "./rules/require-test-quarantine.ts";
8
13
 
9
14
  const plugin = Plugin.define({
10
15
  name: "birbprophet",
11
16
  rules: {
17
+ "no-test-internal-imports": noTestInternalImportsRule,
18
+ "no-mock-call-mirrors": noMockCallMirrorsRule,
19
+ "require-test-quarantine": requireTestQuarantineRule,
20
+ "no-test-waits": noTestWaitsRule,
21
+ "no-test-timeouts": noTestTimeoutsRule,
12
22
  "no-comments": noCommentsRule,
13
23
  "no-process-env": noProcessEnvRule,
14
24
  "prefer-accessible-scene-locators": preferAccessibleSceneLocatorsRule,
@@ -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
+ };
@@ -0,0 +1,121 @@
1
+ import { createRequire } from "node:module";
2
+ import { dirname } from "node:path";
3
+
4
+ import { Diagnostic, Rule, RuleContext } from "effect-oxlint";
5
+ import type { ESTree } from "effect-oxlint";
6
+ import * as Effect from "effect/Effect";
7
+ import * as Option from "effect/Option";
8
+
9
+ import { importedPath, lastName } from "../shared/member-path.ts";
10
+ import {
11
+ isStringLiteral,
12
+ memberPropertyName,
13
+ unwrapExpression,
14
+ } from "../shared/syntax.ts";
15
+ import { isTestFile, testPath } from "./test-api.ts";
16
+ import { packageAt } from "./test-package.ts";
17
+
18
+ export const noMockCallMirrorsRule = Rule.define({
19
+ *create() {
20
+ const context = yield* RuleContext;
21
+ if (!isTestFile(context.filename)) return {};
22
+ const own = packageAt(dirname(context.filename));
23
+ const require = createRequire(context.filename);
24
+ const local = (source: string): boolean => {
25
+ if (
26
+ /^(?:\.|#)/u.test(source) ||
27
+ Option.exists(
28
+ own,
29
+ ({ manifest }) =>
30
+ manifest.name !== undefined &&
31
+ (source === manifest.name || source.startsWith(`${manifest.name}/`))
32
+ )
33
+ )
34
+ return true;
35
+ try {
36
+ const resolved = require.resolve(source);
37
+ return resolved.startsWith("/") && !resolved.includes("/node_modules/");
38
+ } catch {
39
+ return false;
40
+ }
41
+ };
42
+ const mocked = new Set<string>();
43
+ const assertions: Array<{
44
+ readonly node: ESTree.Node;
45
+ readonly source: string;
46
+ }> = [];
47
+ const sourceOf = (node: ESTree.Node): Option.Option<string> => {
48
+ const value = unwrapExpression(node);
49
+ if (
50
+ value.type === "CallExpression" &&
51
+ ["mocked", "expect"].includes(
52
+ Option.getOrElse(lastName(value.callee), () => "")
53
+ )
54
+ ) {
55
+ const [first] = value.arguments;
56
+ return first === undefined ? Option.none() : sourceOf(first);
57
+ }
58
+ return Option.map(
59
+ importedPath(context.sourceCode, value),
60
+ ({ source }) => source
61
+ );
62
+ };
63
+ return {
64
+ CallExpression: (node: ESTree.Node) => {
65
+ if (node.type !== "CallExpression") return Effect.void;
66
+ const path = testPath(context.sourceCode, node.callee);
67
+ const [first] = node.arguments;
68
+ if (
69
+ ["vi", "vitest"].includes(path[0] ?? "") &&
70
+ ["mock", "doMock"].includes(path[1] ?? "") &&
71
+ first !== undefined &&
72
+ isStringLiteral(first)
73
+ ) {
74
+ mocked.add(first.value);
75
+ }
76
+ const callee = unwrapExpression(node.callee);
77
+ if (
78
+ callee.type === "MemberExpression" &&
79
+ Option.getOrElse(memberPropertyName(callee), () => "").startsWith(
80
+ "toHaveBeenCalled"
81
+ )
82
+ ) {
83
+ let object = unwrapExpression(callee.object);
84
+ while (object.type === "MemberExpression")
85
+ object = unwrapExpression(object.object);
86
+ if (
87
+ object.type === "CallExpression" &&
88
+ testPath(context.sourceCode, object.callee)[0] === "expect"
89
+ ) {
90
+ const [subject] = object.arguments;
91
+ if (subject !== undefined)
92
+ Option.match(sourceOf(subject), {
93
+ onNone: () => undefined,
94
+ onSome: (source) => assertions.push({ node, source }),
95
+ });
96
+ }
97
+ }
98
+ return Effect.void;
99
+ },
100
+ "Program:exit": () =>
101
+ Effect.forEach(
102
+ assertions.filter(
103
+ ({ source }) => mocked.has(source) && local(source)
104
+ ),
105
+ ({ node }) =>
106
+ context.report(Diagnostic.fromId({ node, messageId: "behavior" })),
107
+ { discard: true, concurrency: 1 }
108
+ ),
109
+ };
110
+ },
111
+ meta: Rule.meta({
112
+ description:
113
+ "Local module mocks are not asserted through their call history",
114
+ messages: {
115
+ behavior:
116
+ "Run the real local module and assert its observable result. Delete the local vi.mock and the toHaveBeenCalled mirror.",
117
+ },
118
+ type: "problem",
119
+ }),
120
+ name: "no-mock-call-mirrors",
121
+ });