e2e.test.ts 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508
  1. /**
  2. * 端到端管线:真实脚本 → lowering → 沙箱子进程 → 引擎 → AutoDriver。断言最终 artifact、
  3. * journal 内容(节点 actorSeq / inputHash / result)、事件流合理性。见 docs/execution-engine.md。
  4. */
  5. import { describe, expect, it } from "vitest";
  6. import { InMemoryJournalStore, WorkflowError, inputHash } from "@zcode/dynamic-workflow";
  7. import { runScript } from "./helpers.js";
  8. const RUN = "run";
  9. describe("e2e — single typed ask", () => {
  10. it("lowers, runs in the sandbox, validates the submit, and returns the artifact", async () => {
  11. const script = [
  12. "interface Summary { title: string; points: string[]; }",
  13. 'const worker = agent("worker", "You summarize repos.");',
  14. 'const s = await worker.ask<Summary>("Summarize the repo");',
  15. "log(`title: ${s.title}`);",
  16. "return s;",
  17. ].join("\n");
  18. const artifact = { title: "The Repo", points: ["a", "b"] };
  19. const { settlement, journal, driver } = await runScript(script, {
  20. asks: {
  21. "ask#1": () => ({
  22. type: "submit",
  23. payload: artifact,
  24. stats: { tokens: 42, toolCalls: 1, turns: 1 },
  25. }),
  26. },
  27. });
  28. expect(settlement).toEqual({ status: "completed", artifact });
  29. // journal:ask 节点已 completed,带 actorSeq / inputHash / stats / actor 归属。
  30. const node = journal.getNode(RUN, "ask#1", 1);
  31. expect(node?.status).toBe("completed");
  32. expect(node?.kind).toBe("ask");
  33. expect(node?.result).toEqual(artifact);
  34. expect(node?.actorSeq).toBe(0);
  35. expect(node?.inputHash).toBe(inputHash("Summarize the repo"));
  36. expect(node?.stats?.tokens).toBe(42);
  37. expect(node?.actorSiteId).toBe("actor#1");
  38. // actor 落库。
  39. const actor = journal.getActor(RUN, "actor#1", 1);
  40. expect(actor?.name).toBe("worker");
  41. expect(actor?.persona?.system).toBe("You summarize repos.");
  42. // 事件流合理性:run-started → actor-created → node dispatched → settled(ok) → run-settled(completed)。
  43. const types = driver.events.map((e) => e.type);
  44. expect(types[0]).toBe("run-started");
  45. expect(types).toContain("actor-created");
  46. expect(types).toContain("node-dispatched");
  47. expect(driver.eventsOfType("log").some((e) => e.message === "title: The Repo")).toBe(true);
  48. const settled = driver.eventsOfType("node-settled");
  49. expect(settled.at(-1)?.outcome).toBe("ok");
  50. expect(types.at(-1)).toBe("run-settled");
  51. });
  52. });
  53. describe("e2e — world reads + typed ask", () => {
  54. it("journals glob/read with input hashes and threads their results into an ask", async () => {
  55. const script = [
  56. "interface Verdict { approved: boolean; reason: string; }",
  57. 'const paths = await files.glob("src/**/*.ts");',
  58. 'const first = paths[0] ?? "none";',
  59. "const text = await files.read(first);",
  60. "log(`read ${text.length} bytes from ${first}`);",
  61. 'const v = await agent("reviewer").ask<Verdict>(`Review ${first}`);',
  62. "return { count: paths.length, first, approved: v.approved };",
  63. ].join("\n");
  64. const files = { glob: ["src/a.ts", "src/b.ts"], read: "export const x = 1;\n" };
  65. const seenArgs: unknown[][] = [];
  66. const { settlement, journal } = await runScript(script, {
  67. worldReads: (op, args) => {
  68. // Boundary A 送到 driver 的是**位置实参数组**(lowering 原样打包,不看 op)。
  69. seenArgs.push(args);
  70. return op === "glob" ? files.glob : files.read;
  71. },
  72. asks: {
  73. "ask#1": ({ message }) => {
  74. // 指令里应插值了 glob 的首个结果,证明 world-read 结果确实回流进脚本。
  75. expect(message.instructions).toContain("src/a.ts");
  76. return { type: "submit", payload: { approved: true, reason: "ok" } };
  77. },
  78. },
  79. });
  80. expect(settlement).toEqual({
  81. status: "completed",
  82. artifact: { count: 2, first: "src/a.ts", approved: true },
  83. });
  84. const glob = journal.getNode(RUN, "world-read#1", 1);
  85. expect(glob?.kind).toBe("world-read");
  86. expect(glob?.result).toEqual(files.glob);
  87. // inputHash 覆盖 {op, args}:脚本实参跨沙箱边界后仍是位置数组。
  88. expect(glob?.inputHash).toBe(inputHash({ op: "glob", args: ["src/**/*.ts"] }));
  89. const read = journal.getNode(RUN, "world-read#2", 1);
  90. expect(read?.result).toBe(files.read);
  91. expect(read?.inputHash).toBe(inputHash({ op: "read", args: ["src/a.ts"] }));
  92. // 数组穿过 NDJSON 线协议后逐元素保真(protocol.ts 的 args 与 child-source 的镜像一致)。
  93. expect(seenArgs).toEqual([["src/**/*.ts"], ["src/a.ts"]]);
  94. });
  95. it("carries multi-arg and optional-arg ops through the wire unchanged", async () => {
  96. // 线协议的形状**没变**(op 串 + args 数组),所以新增的 grep / git.* 走的是同一条路。
  97. // 这条用例证明它:一份同时用到多参、可选缺省、无参、以及与顶层 `log()` 撞名的
  98. // `git.log` 的脚本,跨沙箱边界后 driver 收到的 (op, args) 逐个对得上。
  99. const script = [
  100. 'const hits = await files.grep("TODO", "*.ts");',
  101. 'const narrow = await files.grep("FIXME");',
  102. "const changed = await git.changedFiles();",
  103. 'const diff = await git.diff("main", "src/a.ts");',
  104. "const status = await git.status();",
  105. "const commits = await git.log(3);",
  106. 'log(`${hits.length} TODOs on ${status.branch ?? "detached"}`);',
  107. "return {",
  108. " hits: hits.length + narrow.length,",
  109. " changed: changed.length,",
  110. " diffBytes: diff.length,",
  111. " commits: commits.map((c) => c.hash),",
  112. "};",
  113. ].join("\n");
  114. const seen: { op: string; args: unknown[] }[] = [];
  115. const { settlement, journal } = await runScript(script, {
  116. worldReads: (op, args) => {
  117. seen.push({ op, args });
  118. switch (op) {
  119. case "grep":
  120. return [{ path: "src/a.ts", line: 7, text: "// TODO" }];
  121. case "git-changed-files":
  122. return ["src/a.ts", "src/b.ts"];
  123. case "git-diff":
  124. return "@@ -1 +1 @@\n";
  125. case "git-status":
  126. return {
  127. branch: "main",
  128. clean: false,
  129. staged: [],
  130. unstaged: ["src/a.ts"],
  131. untracked: [],
  132. };
  133. default:
  134. return [{ hash: "abc", subject: "s", author: "a", date: "2026-08-20T00:00:00+08:00" }];
  135. }
  136. },
  137. });
  138. expect(settlement).toEqual({
  139. status: "completed",
  140. artifact: { hits: 2, changed: 2, diffBytes: 12, commits: ["abc"] },
  141. });
  142. // 缺省的尾部可选实参到达时是**更短的数组**,不是一个 undefined 洞。
  143. expect(seen).toEqual([
  144. { op: "grep", args: ["TODO", "*.ts"] },
  145. { op: "grep", args: ["FIXME"] },
  146. { op: "git-changed-files", args: [] },
  147. { op: "git-diff", args: ["main", "src/a.ts"] },
  148. { op: "git-status", args: [] },
  149. { op: "git-log", args: [3] },
  150. ]);
  151. // 六个 world-read 站点共用一个 per-kind 计数器;`log(...)` 一个站点都不占。
  152. expect(journal.getNode(RUN, "world-read#6", 1)?.inputHash).toBe(
  153. inputHash({ op: "git-log", args: [3] }),
  154. );
  155. expect(journal.getNode(RUN, "world-read#7", 1)).toBeUndefined();
  156. });
  157. });
  158. describe("e2e — fan-out over Promise.all", () => {
  159. it("runs one ask instance per globbed path, each on its own actor", async () => {
  160. const script = [
  161. "interface Verdict { approved: boolean; reason: string; }",
  162. 'const paths = await files.glob("src/**/*.ts");',
  163. "const verdicts = await Promise.all(",
  164. // 逐元素名:fan-out 里每个元素都是一个新 actor,共用一个静态名会撞运行期的
  165. // DuplicateActorName(编译期另有 9005 的 fan-out 子句,见 analysis/actor-names.ts)。
  166. " paths.map((p) => agent(`reviewer-${p}`).ask<Verdict>(`Security-review ${p}`)),",
  167. ");",
  168. "return verdicts.filter((v) => !v.approved).map((v) => v.reason);",
  169. ].join("\n");
  170. const paths = ["src/a.ts", "src/b.ts", "src/c.ts"];
  171. const { settlement, journal, driver } = await runScript(script, {
  172. worldReads: () => paths,
  173. asks: {
  174. // 按指令里的路径决定裁决:b 不通过。
  175. "ask#1": ({ message }) => {
  176. const approved = !message.instructions.includes("src/b.ts");
  177. return {
  178. type: "submit",
  179. payload: { approved, reason: approved ? "clean" : "vuln in b" },
  180. };
  181. },
  182. },
  183. });
  184. expect(settlement).toEqual({ status: "completed", artifact: ["vuln in b"] });
  185. // 三个 ask 实例(ask#1@1..3),三个 actor(actor#1@1..3),全部 completed。
  186. const askNodes = journal
  187. .listNodes(RUN, { kinds: "all", withResult: true })
  188. .filter((n) => n.kind === "ask");
  189. expect(askNodes).toHaveLength(3);
  190. expect(askNodes.every((n) => n.status === "completed")).toBe(true);
  191. expect(driver.sessionCreations).toHaveLength(3);
  192. // ok 结算 = 3 个 ask + 1 个 glob world-read。
  193. expect(driver.eventsOfType("node-settled").filter((e) => e.outcome === "ok")).toHaveLength(4);
  194. });
  195. });
  196. describe("e2e — untyped ask (final text)", () => {
  197. it("settles an untyped ask on turn-end with the final text; no submit tool offered", async () => {
  198. const script = [
  199. 'const a = agent("assistant");',
  200. 'const answer = await a.ask("What is 2+2?");',
  201. "return answer;",
  202. ].join("\n");
  203. const { settlement, journal, driver } = await runScript(script, {
  204. asks: { "ask#1": () => ({ type: "text", finalText: "four" }) },
  205. });
  206. expect(settlement).toEqual({ status: "completed", artifact: "four" });
  207. expect(driver.startAsks[0]?.message.typed).toBe(false);
  208. expect(journal.getNode(RUN, "ask#1", 1)?.result).toBe("four");
  209. });
  210. });
  211. describe("e2e — report (progressive results)", () => {
  212. it("journals each reported item and emits it, without deadlocking the child", async () => {
  213. // report 走**事件通道**而不是 request/response:脚本从不 await 它,所以子进程发完就继续跑。
  214. // 这条用例同时是那件事的活性证明——若父进程误以为需要回一个 response,脚本会永远停在
  215. // 第一个 report 上,run 卡死在超时里而不是完成。
  216. const script = [
  217. "interface Plan { steps: string[]; }",
  218. 'const planner = agent("planner");',
  219. 'const plan = await planner.ask<Plan>("draft a plan");',
  220. 'report({ phase: "planned", steps: plan.steps });',
  221. "for (const step of plan.steps) {",
  222. ' report({ phase: "step", step });',
  223. "}",
  224. "return plan.steps.length;",
  225. ].join("\n");
  226. const { settlement, journal, driver } = await runScript(script, {
  227. asks: { "ask#1": () => ({ type: "submit", payload: { steps: ["a", "b"] } }) },
  228. });
  229. expect(settlement).toEqual({ status: "completed", artifact: 2 });
  230. // 三条报告:report#1 一次 + report#2 两次(循环体内同一站点,ordinal 递增)。
  231. const reports = journal
  232. .listNodes(RUN, { kinds: "all", withResult: true })
  233. .filter((n) => n.kind === "report");
  234. expect(reports.map((n) => `${n.siteId}@${n.ordinal}`)).toEqual([
  235. "report#1@1",
  236. "report#2@1",
  237. "report#2@2",
  238. ]);
  239. // 一次写、已结算、无 actor 归属、result 即 item、inputHash 覆盖 item。
  240. expect(reports.every((n) => n.status === "completed" && n.actorSeq === undefined)).toBe(true);
  241. expect(reports[0]?.result).toEqual({ phase: "planned", steps: ["a", "b"] });
  242. expect(reports[0]?.inputHash).toBe(inputHash({ phase: "planned", steps: ["a", "b"] }));
  243. expect(reports.map((n) => n.result)).toEqual([
  244. { phase: "planned", steps: ["a", "b"] },
  245. { phase: "step", step: "a" },
  246. { phase: "step", step: "b" },
  247. ]);
  248. // Boundary C:每条未被跳过的报告恰好一个事件,且按到达顺序(事件通道的 FIFO 是承重的)。
  249. expect(driver.eventsOfType("report").map((e) => e.item)).toEqual(reports.map((n) => n.result));
  250. });
  251. it("carries the reported items even though the run fails afterwards", async () => {
  252. // report 存在的理由:一个死在第十二个 ask 上的 run 仍然做完了十一个 ask 的活。
  253. // 报告必须在 journal 里活下来,而不是随失败一起蒸发。
  254. const script = [
  255. 'const scout = agent("scout");',
  256. 'const a = await scout.ask<string>("first");',
  257. "report({ done: a });",
  258. 'const b = await scout.ask<string>("second");',
  259. "report({ done: b });",
  260. "return b;",
  261. ].join("\n");
  262. const { settlement, journal } = await runScript(script, {
  263. asks: {
  264. "ask#1": () => ({ type: "text", finalText: "ok-1" }),
  265. "ask#2": () => ({ type: "fail", error: new WorkflowError("DriverError", "boom") }),
  266. },
  267. });
  268. expect(settlement.status).toBe("errored");
  269. const reports = journal
  270. .listNodes(RUN, { kinds: "all", withResult: true })
  271. .filter((n) => n.kind === "report");
  272. expect(reports).toHaveLength(1);
  273. expect(reports[0]?.result).toEqual({ done: "ok-1" });
  274. });
  275. it("emits nothing on replay: a resumed run never shows an item twice", async () => {
  276. // resume 时脚本重跑,所以每个 report 调用都会再执行一次。已 journal 的 (siteId, ordinal)
  277. // 静默跳过——这就是 report 与 log 的全部差别,也是它要落 journal 的唯一理由。
  278. const script = [
  279. 'const scout = agent("scout");',
  280. 'const a = await scout.ask<string>("first");',
  281. "report({ found: a });",
  282. "return a;",
  283. ].join("\n");
  284. const journal = new InMemoryJournalStore();
  285. const first = await runScript(script, {
  286. journal,
  287. asks: { "ask#1": () => ({ type: "text", finalText: "ok-1" }) },
  288. });
  289. expect(first.settlement.status).toBe("completed");
  290. expect(first.driver.eventsOfType("report")).toHaveLength(1);
  291. const resumed = await runScript(script, {
  292. journal,
  293. // resume 必须零派发:ask 从 journal 命中短路,report 从 journal 去重。
  294. onStartAsk: (instance) => {
  295. throw new Error(`resume 不该派发任何 ask,却派发了 ${instance.siteId}`);
  296. },
  297. });
  298. expect(resumed.settlement).toEqual({ status: "completed", artifact: "ok-1" });
  299. expect(resumed.driver.eventsOfType("report")).toEqual([]);
  300. expect(
  301. journal.listNodes(RUN, { kinds: "all", withResult: true }).filter((n) => n.kind === "report"),
  302. ).toHaveLength(1);
  303. });
  304. it("fails the run on the item past the 65,536-item cap, keeping every item before it", async () => {
  305. // 条数上限(docs/execution-engine.md「Progressive results: `report`」)走完整条沙箱链路:
  306. // 第 65,537 条让整个 run 失败,前 65,536 条全部落 journal;脚本的 try/catch 接不到它。
  307. const script = [
  308. "try {",
  309. " for (let i = 0; i < 65537; i += 1) report(i);",
  310. "} catch {",
  311. ' return "caught";',
  312. "}",
  313. 'return "not-caught";',
  314. ].join("\n");
  315. const { settlement, journal } = await runScript(script);
  316. expect(settlement.status).toBe("errored");
  317. expect((settlement as { error?: WorkflowError }).error?.code).toBe("ReportCapExceeded");
  318. expect(journal.countNodes(RUN, "report")).toBe(65_536);
  319. }, 120_000);
  320. it("carries an item just under the 1 MiB per-item cap through the sandbox intact", async () => {
  321. // 单条上限 1 MiB(docs/execution-engine.md「Progressive results: `report`」):一条接近上限的
  322. // item 必须原样穿过沙箱边界、落进 journal,run 正常结束。
  323. const script = ['report({ n: 1, big: "y".repeat(1000000) });', 'return "done";'].join("\n");
  324. const { settlement, journal } = await runScript(script);
  325. expect(settlement).toEqual({ status: "completed", artifact: "done" });
  326. const [row] = journal.listNodes(RUN, { kinds: ["report"], withResult: true });
  327. expect(row?.result).toEqual({ n: 1, big: "y".repeat(1_000_000) });
  328. });
  329. it("fails the run when a reported item exceeds the per-item cap", async () => {
  330. // 上限失败的是**整个 run**(`report` 返回 void,没有可拒绝进去的通道),所以这里断言的是
  331. // run 结算而不是一个被 catch 的异常——脚本里那句 try/catch 什么也接不到。
  332. const script = [
  333. 'const big = "x".repeat(1100000);',
  334. "try {",
  335. " report({ big });",
  336. "} catch {",
  337. ' return "caught";',
  338. "}",
  339. 'return "not-caught";',
  340. ].join("\n");
  341. const { settlement, journal } = await runScript(script);
  342. expect(settlement.status).toBe("errored");
  343. expect((settlement as { error?: WorkflowError }).error?.code).toBe("ReportCapExceeded");
  344. expect(
  345. journal.listNodes(RUN, { kinds: "all", withResult: true }).filter((n) => n.kind === "report"),
  346. ).toEqual([]);
  347. });
  348. });
  349. describe("e2e — Promise.race with a losing in-flight ask", () => {
  350. // Bug 回归(engine.complete 不中止在飞 ask):race 胜者结算、脚本返回、子进程发 complete
  351. // 之后,败者的 ask 原先继续留在 liveNodes——它的 turn 在宿主进程接着跑、turn 结束还会被
  352. // nudge 进新一轮模型调用,node-settled/usage-updated 事件全部落在 run-settled 之后。
  353. // complete 现在与 cancel/failRun 一样同步 abortInFlight:败者被 driver 侧取消、
  354. // run-settled 是事件流最后一条。
  355. it("completes with the winner and aborts the loser at the driver", async () => {
  356. const script = [
  357. 'const fast = agent("fast");',
  358. 'const slow = agent("slow");',
  359. "const winner = await Promise.race([",
  360. ' fast.ask<string>("quick answer"),',
  361. ' slow.ask<string>("slow answer"),',
  362. "]);",
  363. "return winner;",
  364. ].join("\n");
  365. const { settlement, journal, driver } = await runScript(script, {
  366. asks: {
  367. // ask<string> 是 untyped(末轮文本即结果):胜者以 turn-end 文本结算。
  368. "ask#1": () => ({
  369. type: "text",
  370. finalText: "won",
  371. stats: { tokens: 5, toolCalls: 0, turns: 1 },
  372. }),
  373. // 败者:无任何动作——ask 永远悬着,模拟一个仍在跑的慢 turn。
  374. "ask#2": () => [],
  375. },
  376. });
  377. expect(settlement).toEqual({ status: "completed", artifact: "won" });
  378. // 败者在 driver 侧被取消(宿主进程不再挂着它的 turn)。
  379. expect(driver.cancels.some((i) => i.siteId === "ask#2")).toBe(true);
  380. // 事件流不变量:run-settled 是最后一条;败者的 node-settled(cancelled) 在它之前。
  381. const types = driver.events.map((e) => e.type);
  382. expect(types.at(-1)).toBe("run-settled");
  383. const loserSettled = driver
  384. .eventsOfType("node-settled")
  385. .find((e) => e.instance.siteId === "ask#2");
  386. expect(loserSettled?.outcome).toBe("cancelled");
  387. // journal:胜者 completed;败者停在准入时的 running 记录(与 cancel 的 resume 语义对齐)。
  388. expect(journal.getNode(RUN, "ask#1", 1)?.status).toBe("completed");
  389. expect(journal.getNode(RUN, "ask#2", 1)?.status).toBe("running");
  390. });
  391. });
  392. // 阶段标记(docs/dynamic-workflow/presentation.md):lowering 把 phase("…")
  393. // 改写成 __host.enterPhase,子进程经事件通道交给引擎,引擎发 phase-entered。
  394. describe("e2e — phase markers", () => {
  395. const script = [
  396. 'phase("Prepare");',
  397. 'const scout = agent("scout");',
  398. "for (let i = 0; i < 2; i++) {",
  399. ' phase("Ask");',
  400. " await scout.ask<string>(`round ${i}`);",
  401. "}",
  402. 'phase("Wrap up");',
  403. 'return "ok";',
  404. ].join("\n");
  405. it("emits one phase-entered per evaluated marker, in evaluation order, with per-name ordinals", async () => {
  406. const { settlement, journal, driver } = await runScript(script, {
  407. asks: { "ask#1": () => ({ type: "text", finalText: "fine" }) },
  408. });
  409. expect(settlement.status).toBe("completed");
  410. expect(driver.eventsOfType("phase-entered")).toEqual([
  411. { type: "phase-entered", name: "Prepare", ordinal: 1 },
  412. { type: "phase-entered", name: "Ask", ordinal: 1 },
  413. { type: "phase-entered", name: "Ask", ordinal: 2 },
  414. { type: "phase-entered", name: "Wrap up", ordinal: 1 },
  415. ]);
  416. // 到达顺序承重:进入 Ask 先于它里面那次 ask 的派发。
  417. const order = driver.events
  418. .filter((e) => e.type === "phase-entered" || e.type === "node-queued")
  419. .map((e) =>
  420. e.type === "phase-entered"
  421. ? `phase:${e.name}@${e.ordinal}`
  422. : `node:${e.instance.siteId}@${e.instance.ordinal}`,
  423. );
  424. expect(order).toEqual([
  425. "phase:Prepare@1",
  426. "phase:Ask@1",
  427. "node:ask#1@1",
  428. "phase:Ask@2",
  429. "node:ask#1@2",
  430. "phase:Wrap up@1",
  431. ]);
  432. // 标记不是站点:journal 里没有它的行。
  433. expect(journal.listNodes(RUN, { kinds: "all", withResult: true }).map((n) => n.kind)).toEqual([
  434. "ask",
  435. "ask",
  436. ]);
  437. });
  438. it("re-emits the prefix on resume (no journal row to dedupe against); consumers reduce monotonically", async () => {
  439. const journal = new InMemoryJournalStore();
  440. const first = await runScript(script, {
  441. journal,
  442. asks: { "ask#1": () => ({ type: "text", finalText: "fine" }) },
  443. });
  444. expect(first.settlement.status).toBe("completed");
  445. const resumed = await runScript(script, {
  446. journal,
  447. onStartAsk: (instance) => {
  448. throw new Error(`resume 不该派发任何 ask,却派发了 ${instance.siteId}`);
  449. },
  450. });
  451. expect(resumed.settlement.status).toBe("completed");
  452. expect(resumed.driver.eventsOfType("phase-entered")).toEqual(
  453. first.driver.eventsOfType("phase-entered"),
  454. );
  455. });
  456. });