@malloy-publisher/server 0.0.227 → 0.0.229

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 (106) hide show
  1. package/README.docker.md +8 -8
  2. package/dist/app/api-doc.yaml +84 -1
  3. package/dist/app/assets/EnvironmentPage-QOoHiVeJ.js +1 -0
  4. package/dist/app/assets/{HomePage-CXguJsXS.js → HomePage-C71GOfVW.js} +1 -1
  5. package/dist/app/assets/{LightMode-ZsshUznu.js → LightMode-CrgCAwLe.js} +1 -1
  6. package/dist/app/assets/MainPage-BG5__FN3.js +2 -0
  7. package/dist/app/assets/MaterializationsPage-DE6PnrDR.js +1 -0
  8. package/dist/app/assets/ModelPage-CcBjcbLm.js +1 -0
  9. package/dist/app/assets/PackagePage-JTy3ztkB.js +1 -0
  10. package/dist/app/assets/{RouteError-Chn7lL96.js → RouteError-Cymbp47a.js} +1 -1
  11. package/dist/app/assets/ThemeEditorPage-C_nMnHr8.js +1 -0
  12. package/dist/app/assets/WorkbookPage-CPQu-DQx.js +1 -0
  13. package/dist/app/assets/{core-vVgoO8IR.es-BD_THWs_.js → core-Coi3caGs.es-CSOmajHS.js} +10 -10
  14. package/dist/app/assets/{index-gEWxu09x.js → index-CM2qhQCI.js} +1 -1
  15. package/dist/app/assets/{index-D6YtyiJ0.js → index-CcuuST2X.js} +1 -1
  16. package/dist/app/assets/{index-OEjKNSYb.js → index-CkmABCAw.js} +388 -241
  17. package/dist/app/assets/{index-BioohWQj.js → index-DlWCXghy.js} +1 -1
  18. package/dist/app/assets/index-DxArlgRD.js +529 -0
  19. package/dist/app/index.html +1 -1
  20. package/dist/default-publisher.config.json +7 -7
  21. package/dist/instrumentation.mjs +1 -1
  22. package/dist/package_load_worker.mjs +1 -1
  23. package/dist/runtime/publisher.js +5 -0
  24. package/dist/server.mjs +7675 -899
  25. package/package.json +4 -2
  26. package/publisher.config.example.bigquery.json +7 -7
  27. package/publisher.config.example.duckdb.json +7 -7
  28. package/publisher.config.json +7 -11
  29. package/src/config.spec.ts +89 -3
  30. package/src/config.ts +102 -1
  31. package/src/controller/materialization.controller.spec.ts +9 -0
  32. package/src/controller/materialization.controller.ts +15 -0
  33. package/src/controller/package.controller.ts +62 -31
  34. package/src/default-publisher.config.json +7 -7
  35. package/src/materialization_metrics.ts +33 -0
  36. package/src/mcp/handler_utils.spec.ts +108 -0
  37. package/src/mcp/handler_utils.ts +98 -4
  38. package/src/mcp/server.protocol.spec.ts +58 -0
  39. package/src/mcp/server.ts +29 -1
  40. package/src/mcp/skills/build_skills_bundle.ts +29 -9
  41. package/src/mcp/skills/skills_bundle.json +1 -1
  42. package/src/mcp/skills/skills_bundle.spec.ts +31 -2
  43. package/src/mcp/tools/compile_tool.spec.ts +207 -0
  44. package/src/mcp/tools/compile_tool.ts +177 -0
  45. package/src/mcp/tools/execute_query_tool.spec.ts +143 -0
  46. package/src/mcp/tools/execute_query_tool.ts +37 -4
  47. package/src/mcp/tools/get_context_tool.ts +1 -1
  48. package/src/mcp/tools/reload_package_tool.spec.ts +232 -0
  49. package/src/mcp/tools/reload_package_tool.ts +158 -0
  50. package/src/query_param_utils.ts +11 -0
  51. package/src/runtime/publisher.js +5 -0
  52. package/src/server.ts +74 -14
  53. package/src/service/connection.spec.ts +8 -7
  54. package/src/service/cron_evaluator.spec.ts +79 -0
  55. package/src/service/cron_evaluator.ts +105 -0
  56. package/src/service/environment.ts +188 -19
  57. package/src/service/environment_store.spec.ts +372 -2
  58. package/src/service/environment_store.ts +149 -17
  59. package/src/service/environment_store_anchoring.spec.ts +107 -0
  60. package/src/service/manifest_loader.spec.ts +3 -1
  61. package/src/service/manifest_loader.ts +9 -5
  62. package/src/service/materialization_scheduler.spec.ts +260 -0
  63. package/src/service/materialization_scheduler.ts +304 -0
  64. package/src/service/materialization_service.spec.ts +167 -4
  65. package/src/service/materialization_service.ts +121 -8
  66. package/src/service/materialization_test_fixtures.ts +10 -1
  67. package/src/service/model.spec.ts +92 -0
  68. package/src/service/model.ts +58 -7
  69. package/src/service/package.ts +121 -14
  70. package/src/service/package_quote_bound_tables.spec.ts +171 -0
  71. package/src/service/package_reload_safety.spec.ts +193 -0
  72. package/src/service/persistence_policy.spec.ts +31 -0
  73. package/src/service/quoting.spec.ts +57 -1
  74. package/src/service/quoting.ts +33 -0
  75. package/src/storage/DatabaseInterface.ts +15 -0
  76. package/src/storage/duckdb/DuckDBRepository.ts +17 -0
  77. package/src/storage/duckdb/MaterializationRepository.spec.ts +154 -0
  78. package/src/storage/duckdb/MaterializationRepository.ts +56 -0
  79. package/tests/fixtures/persist-schedule-test/data/orders.csv +5 -0
  80. package/tests/fixtures/persist-schedule-test/persist_schedule_test.malloy +11 -0
  81. package/tests/fixtures/persist-schedule-test/publisher.json +7 -0
  82. package/tests/fixtures/persist-schedule-warn-test/data/orders.csv +5 -0
  83. package/tests/fixtures/persist-schedule-warn-test/persist_warn_test.malloy +11 -0
  84. package/tests/fixtures/persist-schedule-warn-test/publisher.json +6 -0
  85. package/tests/fixtures/query-givens/data/orders.csv +7 -0
  86. package/tests/fixtures/query-givens/model.malloy +34 -0
  87. package/tests/fixtures/query-givens/publisher.json +5 -0
  88. package/tests/integration/materialization/environment_list.integration.spec.ts +133 -0
  89. package/tests/integration/materialization/materialization_lifecycle.integration.spec.ts +7 -2
  90. package/tests/integration/materialization/orchestrated_rebind.integration.spec.ts +150 -0
  91. package/tests/integration/materialization/schedule_edit.integration.spec.ts +126 -0
  92. package/tests/integration/materialization/scheduler.integration.spec.ts +200 -0
  93. package/tests/integration/materialization/scheduler_recovery.integration.spec.ts +172 -0
  94. package/tests/integration/materialization/scheduler_wiring.integration.spec.ts +143 -0
  95. package/tests/integration/mcp/mcp_execute_query_tool.integration.spec.ts +22 -22
  96. package/tests/integration/query_givens/query_givens.integration.spec.ts +146 -0
  97. package/tests/integration/query_givens/query_givens_authorize.integration.spec.ts +121 -0
  98. package/tests/integration/sdk_givens/sdk_givens.integration.spec.ts +110 -0
  99. package/dist/app/assets/EnvironmentPage-DvOJ7L_b.js +0 -1
  100. package/dist/app/assets/MainPage-BIe0VwBa.js +0 -2
  101. package/dist/app/assets/MaterializationsPage-BuZ6UJVx.js +0 -1
  102. package/dist/app/assets/ModelPage-DsPf-s8B.js +0 -1
  103. package/dist/app/assets/PackagePage-CEVNAKZa.js +0 -1
  104. package/dist/app/assets/ThemeEditorPage-DWC_FdNU.js +0 -1
  105. package/dist/app/assets/WorkbookPage-CGrsFz8p.js +0 -1
  106. package/dist/app/assets/index-DNUZpnaa.js +0 -527
@@ -0,0 +1,107 @@
1
+ import { afterEach, beforeEach, describe, expect, it, mock } from "bun:test";
2
+ import { existsSync, mkdirSync, readFileSync, rmSync, writeFileSync } from "fs";
3
+ import * as path from "path";
4
+ import { PUBLISHER_CONFIG_NAME, TEMP_DIR_PATH } from "../constants";
5
+
6
+ /**
7
+ * A relative package `location` must anchor at the directory holding the config
8
+ * that declared it, not at the server root. Those are the same path in the
9
+ * common case (`<serverRoot>/publisher.config.json`), so a spec that lets them
10
+ * coincide cannot tell the two rules apart.
11
+ *
12
+ * Here they are deliberately different directories, driven through the real
13
+ * `PUBLISHER_CONFIG_PATH` that `--config` sets, so this exercises the actual
14
+ * resolution rather than a stub of it.
15
+ */
16
+ const serverRootPath = path.join(TEMP_DIR_PATH, "anchoring-server-root");
17
+ const configDirPath = path.join(TEMP_DIR_PATH, "anchoring-config-dir");
18
+
19
+ mock.module("../storage/StorageManager", () => ({
20
+ StorageManager: class MockStorageManager {
21
+ async initialize(): Promise<void> {}
22
+ getRepository() {
23
+ return {
24
+ listEnvironments: async () => [],
25
+ getEnvironmentByName: async () => null,
26
+ createEnvironment: async (data: Record<string, unknown>) => ({
27
+ id: "env-id",
28
+ name: data.name,
29
+ path: data.path,
30
+ }),
31
+ listPackages: async () => [],
32
+ getPackageByName: async () => null,
33
+ createPackage: async (data: Record<string, unknown>) => ({
34
+ id: "pkg-id",
35
+ name: data.name,
36
+ }),
37
+ listConnections: async () => [],
38
+ };
39
+ }
40
+ },
41
+ StorageConfig: {} as Record<string, unknown>,
42
+ }));
43
+
44
+ const { EnvironmentStore } = await import("./environment_store");
45
+
46
+ describe("relative package locations anchor at the config directory", () => {
47
+ const savedConfigPath = process.env.PUBLISHER_CONFIG_PATH;
48
+
49
+ beforeEach(() => {
50
+ for (const dir of [serverRootPath, configDirPath]) {
51
+ rmSync(dir, { recursive: true, force: true });
52
+ mkdirSync(dir, { recursive: true });
53
+ }
54
+ const configPath = path.join(configDirPath, PUBLISHER_CONFIG_NAME);
55
+ writeFileSync(configPath, JSON.stringify({ environments: [] }));
56
+ process.env.PUBLISHER_CONFIG_PATH = configPath;
57
+ });
58
+
59
+ afterEach(() => {
60
+ if (savedConfigPath === undefined) {
61
+ delete process.env.PUBLISHER_CONFIG_PATH;
62
+ } else {
63
+ process.env.PUBLISHER_CONFIG_PATH = savedConfigPath;
64
+ }
65
+ for (const dir of [serverRootPath, configDirPath]) {
66
+ rmSync(dir, { recursive: true, force: true });
67
+ }
68
+ });
69
+
70
+ it("mounts a package that sits next to the config, not next to the server root", async () => {
71
+ // A `sales` directory exists in BOTH candidate anchors, with different
72
+ // contents. If resolution silently reverted to server-root anchoring it
73
+ // would still mount successfully — off the decoy — so the existence
74
+ // check alone could not catch the regression; the content check does.
75
+ const packageSource = path.join(configDirPath, "sales");
76
+ mkdirSync(packageSource, { recursive: true });
77
+ writeFileSync(
78
+ path.join(packageSource, "publisher.json"),
79
+ JSON.stringify({ name: "sales" }),
80
+ );
81
+ const decoySource = path.join(serverRootPath, "sales");
82
+ mkdirSync(decoySource, { recursive: true });
83
+ writeFileSync(
84
+ path.join(decoySource, "publisher.json"),
85
+ JSON.stringify({ name: "decoy-from-server-root" }),
86
+ );
87
+
88
+ const store = new EnvironmentStore(serverRootPath);
89
+ await store.addEnvironment({
90
+ name: "probe",
91
+ packages: [{ name: "sales", location: "./sales" }],
92
+ connections: [],
93
+ } as never);
94
+
95
+ const mountedManifest = path.join(
96
+ serverRootPath,
97
+ "publisher_data",
98
+ "probe",
99
+ "sales",
100
+ "publisher.json",
101
+ );
102
+ expect(existsSync(mountedManifest)).toBe(true);
103
+ expect(JSON.parse(readFileSync(mountedManifest, "utf-8")).name).toBe(
104
+ "sales",
105
+ );
106
+ });
107
+ });
@@ -42,7 +42,9 @@ describe("fetchManifestEntries", () => {
42
42
 
43
43
  expect(entries).toEqual({
44
44
  b1: { tableName: "schema.orders_mz" },
45
- b2: { tableName: "schema.daily_mz" },
45
+ // connectionName is carried through so the bind step can quote the
46
+ // table path for that connection's dialect (Package.quoteBoundTableNames).
47
+ b2: { tableName: "schema.daily_mz", connectionName: "bq" },
46
48
  });
47
49
  });
48
50
 
@@ -58,11 +58,14 @@ async function readManifestBytes(uri: string): Promise<string> {
58
58
 
59
59
  /**
60
60
  * Fetch and parse the control-plane-computed build manifest at `uri`, returning
61
- * the full wire binding map (`sourceEntityId -> { tableName, dataAsOf,
62
- * freshnessWindowSeconds, freshnessFallback }`). The wire manifest keys physical
63
- * tables under `physicalTableName`; the Malloy runtime consumes `tableName`, so
64
- * we translate that field here but otherwise carry the control-plane freshness
65
- * fields verbatim so the serve path can gate `age vs window` per query. Entries
61
+ * the full wire binding map (`sourceEntityId -> { tableName, connectionName,
62
+ * dataAsOf, freshnessWindowSeconds, freshnessFallback }`). The wire manifest
63
+ * keys physical tables under `physicalTableName`; the Malloy runtime consumes
64
+ * `tableName`, so we translate that field here but otherwise carry the
65
+ * control-plane fields verbatim — the freshness fields so the serve path can
66
+ * gate `age vs window` per query, and `connectionName` so the bind step can
67
+ * quote the path for that connection's dialect (see
68
+ * Package.quoteBoundTableNames). Entries
66
69
  * missing a physical table are skipped. This is a pure fetch + parse: it does
67
70
  * **not** filter on freshness (that happens per query on the serve path). Throws
68
71
  * if the URI can't be read or parsed.
@@ -95,6 +98,7 @@ export async function fetchManifestEntries(
95
98
  }
96
99
  entries[sourceEntityId] = {
97
100
  tableName: physicalTableName,
101
+ connectionName: entry.connectionName,
98
102
  dataAsOf: entry.dataAsOf,
99
103
  freshnessWindowSeconds: entry.freshnessWindowSeconds,
100
104
  freshnessFallback: entry.freshnessFallback,
@@ -0,0 +1,260 @@
1
+ import { describe, expect, it } from "bun:test";
2
+ import { MaterializationConflictError } from "../errors";
3
+ import type { CronEvaluator } from "./cron_evaluator";
4
+ import type { EnvironmentStore } from "./environment_store";
5
+ import type { MaterializationService } from "./materialization_service";
6
+ import { MaterializationScheduler } from "./materialization_scheduler";
7
+
8
+ // ── Fakes ────────────────────────────────────────────────────────────────
9
+
10
+ interface FakePkgOpts {
11
+ schedule?: string | null;
12
+ manifestLocation?: string | null;
13
+ policyWarnings?: string[];
14
+ }
15
+
16
+ function fakePackage(name: string, opts: FakePkgOpts = {}) {
17
+ const {
18
+ schedule = null,
19
+ manifestLocation = null,
20
+ policyWarnings = [],
21
+ } = opts;
22
+ return {
23
+ getPackageName: () => name,
24
+ getPackageMetadata: () => ({
25
+ materialization: schedule ? { schedule } : null,
26
+ manifestLocation,
27
+ }),
28
+ persistencePolicyWarnings: () => policyWarnings,
29
+ };
30
+ }
31
+
32
+ function fakeEnv(name: string, pkgs: ReturnType<typeof fakePackage>[]) {
33
+ return {
34
+ getEnvironmentName: () => name,
35
+ getLoadedPackages: () => pkgs,
36
+ };
37
+ }
38
+
39
+ function fakeStore(envs: ReturnType<typeof fakeEnv>[]): EnvironmentStore {
40
+ return {
41
+ getLoadedEnvironments: () => envs,
42
+ } as unknown as EnvironmentStore;
43
+ }
44
+
45
+ interface FireCall {
46
+ env: string;
47
+ pkg: string;
48
+ opts: { forceRefresh?: boolean; trigger?: string };
49
+ }
50
+
51
+ function fakeService(
52
+ opts: {
53
+ throwConflict?: boolean;
54
+ throwError?: boolean;
55
+ // Newest recorded SCHEDULER fire, used by the restart-recovery anchor.
56
+ lastFireAt?: Date | null;
57
+ } = {},
58
+ ) {
59
+ const calls: FireCall[] = [];
60
+ const service = {
61
+ calls,
62
+ createMaterialization: (
63
+ env: string,
64
+ pkg: string,
65
+ o: { forceRefresh?: boolean; trigger?: string },
66
+ ) => {
67
+ calls.push({ env, pkg, opts: o });
68
+ if (opts.throwConflict) {
69
+ return Promise.reject(new MaterializationConflictError("busy"));
70
+ }
71
+ if (opts.throwError) {
72
+ return Promise.reject(new Error("boom"));
73
+ }
74
+ return Promise.resolve({});
75
+ },
76
+ getLatestScheduledFireAt: () => Promise.resolve(opts.lastFireAt ?? null),
77
+ };
78
+ return service as unknown as MaterializationService & { calls: FireCall[] };
79
+ }
80
+
81
+ // A deterministic cron: nextAfter is always `from + 60s`; isValid configurable.
82
+ function fakeCron(
83
+ isValid: (expr: string) => boolean = () => true,
84
+ ): CronEvaluator {
85
+ return {
86
+ isValid,
87
+ nextAfter: (_expr: string, from: Date) =>
88
+ new Date(from.getTime() + 60_000),
89
+ } as unknown as CronEvaluator;
90
+ }
91
+
92
+ const CONFIG = { tickIntervalMs: 60_000, maxFiresPerTick: 10 };
93
+
94
+ function makeScheduler(
95
+ pkgs: ReturnType<typeof fakePackage>[],
96
+ service: ReturnType<typeof fakeService>,
97
+ cron: CronEvaluator = fakeCron(),
98
+ config = CONFIG,
99
+ ) {
100
+ const store = fakeStore([fakeEnv("env1", pkgs)]);
101
+ return new MaterializationScheduler(store, service, config, cron);
102
+ }
103
+
104
+ // ── Tests ────────────────────────────────────────────────────────────────
105
+
106
+ describe("MaterializationScheduler", () => {
107
+ const t0 = 1_000_000_000_000; // fixed epoch ms
108
+ const dueLater = t0 + 60_001; // just past the armed nextFire (t0 + 60s)
109
+
110
+ it("does not fire on the arming tick (nextFire is strictly future)", async () => {
111
+ const service = fakeService();
112
+ const sched = makeScheduler(
113
+ [fakePackage("p", { schedule: "* * * * *" })],
114
+ service,
115
+ );
116
+ await sched.tick(t0);
117
+ expect(service.calls.length).toBe(0);
118
+ });
119
+
120
+ it("recovers a missed occurrence on first arm, firing once then jumping forward", async () => {
121
+ // A prior SCHEDULER fire well in the past: anchoring nextFire to
122
+ // nextAfter(lastFire) lands before t0, so the occurrence missed during
123
+ // "downtime" is due on the very first tick (a restart recovering).
124
+ const service = fakeService({ lastFireAt: new Date(t0 - 10 * 60_000) });
125
+ const sched = makeScheduler(
126
+ [fakePackage("p", { schedule: "* * * * *" })],
127
+ service,
128
+ );
129
+ await sched.tick(t0);
130
+ expect(service.calls.length).toBe(1); // one catch-up fire
131
+ // Jumped forward to nextAfter(now); not due again on the next tick.
132
+ await sched.tick(t0 + 1);
133
+ expect(service.calls.length).toBe(1);
134
+ });
135
+
136
+ it("does not catch up a never-fired schedule on first arm", async () => {
137
+ // No prior SCHEDULER fire on record -> anchor is now -> strictly future,
138
+ // so a freshly-scheduled (never-fired) package does not fire on arm.
139
+ const service = fakeService({ lastFireAt: null });
140
+ const sched = makeScheduler(
141
+ [fakePackage("p", { schedule: "* * * * *" })],
142
+ service,
143
+ );
144
+ await sched.tick(t0);
145
+ expect(service.calls.length).toBe(0);
146
+ });
147
+
148
+ it("fires a due, valid, standalone package as SCHEDULER + forceRefresh", async () => {
149
+ const service = fakeService();
150
+ const sched = makeScheduler(
151
+ [fakePackage("p", { schedule: "* * * * *" })],
152
+ service,
153
+ );
154
+ await sched.tick(t0); // arm
155
+ await sched.tick(dueLater); // due -> fire
156
+ expect(service.calls).toEqual([
157
+ {
158
+ env: "env1",
159
+ pkg: "p",
160
+ opts: { forceRefresh: true, trigger: "SCHEDULER" },
161
+ },
162
+ ]);
163
+ });
164
+
165
+ it("skips a package with no schedule", async () => {
166
+ const service = fakeService();
167
+ const sched = makeScheduler([fakePackage("p", {})], service);
168
+ await sched.tick(t0);
169
+ await sched.tick(dueLater);
170
+ expect(service.calls.length).toBe(0);
171
+ });
172
+
173
+ it("skips an orchestrated package (manifestLocation set) — Guard 2", async () => {
174
+ const service = fakeService();
175
+ const sched = makeScheduler(
176
+ [
177
+ fakePackage("p", {
178
+ schedule: "* * * * *",
179
+ manifestLocation: "gs://cp/manifest.json",
180
+ }),
181
+ ],
182
+ service,
183
+ );
184
+ await sched.tick(t0);
185
+ await sched.tick(dueLater);
186
+ expect(service.calls.length).toBe(0);
187
+ });
188
+
189
+ it("skips a package whose persistence policy is invalid", async () => {
190
+ const service = fakeService();
191
+ const sched = makeScheduler(
192
+ [
193
+ fakePackage("p", {
194
+ schedule: "* * * * *",
195
+ policyWarnings: ["schedule requires scope: version"],
196
+ }),
197
+ ],
198
+ service,
199
+ );
200
+ await sched.tick(t0);
201
+ await sched.tick(dueLater);
202
+ expect(service.calls.length).toBe(0);
203
+ });
204
+
205
+ it("skips an invalid cron", async () => {
206
+ const service = fakeService();
207
+ const sched = makeScheduler(
208
+ [fakePackage("p", { schedule: "not a cron" })],
209
+ service,
210
+ fakeCron(() => false),
211
+ );
212
+ await sched.tick(t0);
213
+ await sched.tick(dueLater);
214
+ expect(service.calls.length).toBe(0);
215
+ });
216
+
217
+ it("coalesces when a materialization is already active (no throw)", async () => {
218
+ const service = fakeService({ throwConflict: true });
219
+ const sched = makeScheduler(
220
+ [fakePackage("p", { schedule: "* * * * *" })],
221
+ service,
222
+ );
223
+ await sched.tick(t0);
224
+ await sched.tick(dueLater); // due -> fire attempt -> conflict, swallowed
225
+ expect(service.calls.length).toBe(1); // attempted once
226
+ // Advanced past this occurrence: not due again until the next window.
227
+ await sched.tick(dueLater + 1);
228
+ expect(service.calls.length).toBe(1);
229
+ });
230
+
231
+ it("isolates an unexpected fire error (sweep keeps going)", async () => {
232
+ const service = fakeService({ throwError: true });
233
+ const sched = makeScheduler(
234
+ [fakePackage("p", { schedule: "* * * * *" })],
235
+ service,
236
+ );
237
+ await sched.tick(t0);
238
+ await expect(sched.tick(dueLater)).resolves.toBeUndefined();
239
+ expect(service.calls.length).toBe(1);
240
+ });
241
+
242
+ it("caps fires per tick (stampede guard)", async () => {
243
+ const service = fakeService();
244
+ const pkgs = [
245
+ fakePackage("a", { schedule: "* * * * *" }),
246
+ fakePackage("b", { schedule: "* * * * *" }),
247
+ fakePackage("c", { schedule: "* * * * *" }),
248
+ ];
249
+ const sched = makeScheduler(pkgs, service, fakeCron(), {
250
+ tickIntervalMs: 60_000,
251
+ maxFiresPerTick: 2,
252
+ });
253
+ await sched.tick(t0); // arm all
254
+ await sched.tick(dueLater); // all due, but cap = 2
255
+ expect(service.calls.length).toBe(2);
256
+ // The capped one is still due and fires on the next tick.
257
+ await sched.tick(dueLater + 1);
258
+ expect(service.calls.length).toBe(3);
259
+ });
260
+ });