zcodeProtocolV4WorkflowRunsHoles.test.ts 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529
  1. // 留白(typed holes)在 shared 协议层的三份契约(docs/dynamic-workflow/presentation.md「Holes on the timeline」、
  2. // docs/dynamic-workflow/transcript-and-notifications.md「The hole row's live state」):
  3. // 1. display 载荷的 `holes` / `fill` 字段与通知载荷的 `hole` 种类过 strict schema;
  4. // 2. reducer 把 `hole-reached` / `hole-filled` 归约成 run 的 `holes[]`、并同步 `phaseNames` 与对齐的 `phaseHoles`;
  5. // 3. sessions-index 的侧栏摘要把留白站标成 open / waiting,并交出「等待补全」的那个名字。
  6. import { describe, expect, it } from "vitest";
  7. import { z } from "zod";
  8. import {
  9. WORKFLOW_RUNS_LIMITS,
  10. backgroundResultOriginMetaSchema,
  11. deriveSessionWorkflowPhases,
  12. reduceWorkflowRunsState,
  13. toolCallCreateWorkflowDisplaySchema,
  14. workflowBlockedMetaSchema,
  15. workflowNotificationMetaSchema,
  16. workflowRunsStateSchema,
  17. type WorkflowRunProgressEnvelope,
  18. type WorkflowRunState,
  19. type WorkflowRunsState,
  20. } from "../src/zcode-protocol-v4/index.js";
  21. import { deriveSessionWorkflowActivity } from "../src/zcode-protocol-v4/index.js";
  22. const RUN_ID = "dwfrun-holes";
  23. function progressLog(runId = RUN_ID) {
  24. let sequence = -1;
  25. return function progress(
  26. eventType: string,
  27. payload: Record<string, unknown> = {},
  28. ): WorkflowRunProgressEnvelope {
  29. sequence += 1;
  30. return { runId, toolCallId: "tc-1", sequence, eventType, payload };
  31. };
  32. }
  33. function step(
  34. state: WorkflowRunsState | undefined,
  35. envelope: WorkflowRunProgressEnvelope,
  36. ): WorkflowRunsState {
  37. const next = reduceWorkflowRunsState(state, envelope);
  38. if (next === null) throw new Error(`事件本应产生变化却返回 null:${envelope.eventType}`);
  39. return next;
  40. }
  41. function reduceAll(
  42. envelopes: readonly WorkflowRunProgressEnvelope[],
  43. ): WorkflowRunsState | undefined {
  44. let state: WorkflowRunsState | undefined;
  45. for (const envelope of envelopes) state = reduceWorkflowRunsState(state, envelope) ?? state;
  46. return state;
  47. }
  48. const REACHED = {
  49. instance: { siteId: "hole#1", ordinal: 1 },
  50. name: "决定分组",
  51. prompt: "侦察结果如下",
  52. phaseName: "决定分组",
  53. type: "Plan",
  54. reachedAt: 1_700_000_000_000,
  55. };
  56. describe("display 载荷:holes 与 fill", () => {
  57. const graph = {
  58. steps: [{ id: "ask#1", kind: "ask", label: "scout", lane: "actor#1", phase: "phase#1" }],
  59. lanes: [{ id: "actor#1", name: "scout" }],
  60. participants: [{ id: "p1", phase: "phase#1", lane: "actor#1", steps: ["ask#1"] }],
  61. handoffs: [],
  62. phases: [
  63. { id: "phase#1", name: "探索" },
  64. { id: "hole#1", name: "决定分组" },
  65. { id: "phase#2", name: "冒烟测试", fill: "hole#1" },
  66. ],
  67. holes: [{ siteId: "hole#2", name: "评判", type: "Verdict", tail: true }],
  68. };
  69. it("phases[].fill、steps[].fill 与 holes[] 过 strict schema;旧载荷不带它们照常通过", () => {
  70. const display = {
  71. kind: "create_workflow",
  72. ok: true,
  73. errorCount: 0,
  74. diagnostics: [],
  75. causalityGraph: graph,
  76. };
  77. const parsed = toolCallCreateWorkflowDisplaySchema.safeParse(display);
  78. expect(parsed.success).toBe(true);
  79. expect(parsed.success && parsed.data.causalityGraph?.holes?.[0]?.tail).toBe(true);
  80. expect(parsed.success && parsed.data.causalityGraph?.phases?.[2]?.fill).toBe("hole#1");
  81. const withFillStep = {
  82. ...display,
  83. causalityGraph: { ...graph, steps: [{ ...graph.steps[0], fill: "hole#1" }] },
  84. };
  85. expect(toolCallCreateWorkflowDisplaySchema.safeParse(withFillStep).success).toBe(true);
  86. const { holes: _holes, ...legacyGraph } = graph;
  87. void _holes;
  88. expect(
  89. toolCallCreateWorkflowDisplaySchema.safeParse({ ...display, causalityGraph: legacyGraph })
  90. .success,
  91. ).toBe(true);
  92. });
  93. it("开着的留白自己的站点是 kind `hole`、车道 `main` 的 step(与 contracts 的 CREATE_WORKFLOW_STEP_KINDS 同步)", () => {
  94. const holeStep = { id: "hole#2", kind: "hole", label: "评判", lane: "main", phase: "hole#2" };
  95. const parsed = toolCallCreateWorkflowDisplaySchema.safeParse({
  96. kind: "create_workflow",
  97. ok: true,
  98. errorCount: 0,
  99. diagnostics: [],
  100. causalityGraph: { ...graph, steps: [...graph.steps, holeStep] },
  101. });
  102. expect(parsed.success).toBe(true);
  103. expect(parsed.success && parsed.data.causalityGraph?.steps[1]?.kind).toBe("hole");
  104. expect(
  105. toolCallCreateWorkflowDisplaySchema.safeParse({
  106. kind: "create_workflow",
  107. ok: true,
  108. errorCount: 0,
  109. diagnostics: [],
  110. causalityGraph: { ...graph, steps: [{ ...holeStep, kind: "gap" }] },
  111. }).success,
  112. ).toBe(false);
  113. });
  114. it("display.fill:补全行的站点 id 与名字过 strict;未知键与空名被拒;缺席照常通过", () => {
  115. const display = {
  116. kind: "create_workflow",
  117. ok: true,
  118. errorCount: 0,
  119. diagnostics: [],
  120. causalityGraph: graph,
  121. };
  122. const fill = {
  123. siteId: "hole#1",
  124. name: "决定分组",
  125. draftPath: ".zcode/workflow-drafts/a.dwf.ts",
  126. line: 12,
  127. };
  128. expect(toolCallCreateWorkflowDisplaySchema.safeParse({ ...display, fill }).success).toBe(true);
  129. expect(
  130. toolCallCreateWorkflowDisplaySchema.safeParse({
  131. ...display,
  132. fill: { siteId: "hole#1", name: "" },
  133. }).success,
  134. ).toBe(false);
  135. expect(
  136. toolCallCreateWorkflowDisplaySchema.safeParse({ ...display, fill: { ...fill, type: "Plan" } })
  137. .success,
  138. ).toBe(false);
  139. });
  140. it("holes 上界 32;hole 条目里的未知键被 strict 拒绝", () => {
  141. const many = Array.from({ length: 33 }, (_, i) => ({
  142. siteId: `hole#${i + 1}`,
  143. name: `h${i + 1}`,
  144. type: "T",
  145. }));
  146. expect(
  147. toolCallCreateWorkflowDisplaySchema.safeParse({
  148. kind: "create_workflow",
  149. ok: true,
  150. errorCount: 0,
  151. diagnostics: [],
  152. causalityGraph: { ...graph, holes: many },
  153. }).success,
  154. ).toBe(false);
  155. expect(
  156. toolCallCreateWorkflowDisplaySchema.safeParse({
  157. kind: "create_workflow",
  158. ok: true,
  159. errorCount: 0,
  160. diagnostics: [],
  161. causalityGraph: { ...graph, holes: [{ siteId: "hole#9", name: "x", type: "T", extra: 1 }] },
  162. }).success,
  163. ).toBe(false);
  164. });
  165. });
  166. describe("提醒载荷:originMeta.workflowBlocked", () => {
  167. // docs/dynamic-workflow/transcript-and-notifications.md「The payload」:主代理闲着、run 还欠着问题或
  168. // 留白时的提醒走 `workflowBlocked` 这个独立的键,不是 `workflowNotification` 的新成员。
  169. const base = { backgroundSource: "workflow", workId: "dwfrun-blocked", title: "review the diff" };
  170. const blocked = { questions: 2, holes: 1, sinceMs: 17 * 60_000 };
  171. it("计数与等待时长都是非负整数", () => {
  172. expect(workflowBlockedMetaSchema.parse(blocked)).toEqual(blocked);
  173. expect(
  174. workflowBlockedMetaSchema.safeParse({ questions: 0, holes: 0, sinceMs: 0 }).success,
  175. ).toBe(true);
  176. expect(workflowBlockedMetaSchema.safeParse({ questions: 1, sinceMs: 0 }).success).toBe(false);
  177. expect(workflowBlockedMetaSchema.safeParse({ ...blocked, holes: -1 }).success).toBe(false);
  178. expect(workflowBlockedMetaSchema.safeParse({ ...blocked, sinceMs: 1.5 }).success).toBe(false);
  179. });
  180. it("随 turnHeader 的 originMeta 过线,原样保留", () => {
  181. expect(backgroundResultOriginMetaSchema.parse({ ...base, workflowBlocked: blocked })).toEqual({
  182. ...base,
  183. workflowBlocked: blocked,
  184. });
  185. });
  186. // 闭集 union 上多一个 kind,不认识它的客户端会拒掉整帧——快照里是同一行,于是整个会话打不开
  187. // 。所以 `blocked` 不得回到 union 里。
  188. it("`workflowNotification` 的闭集里没有 blocked", () => {
  189. expect(workflowNotificationMetaSchema.safeParse({ kind: "blocked", ...blocked }).success).toBe(
  190. false,
  191. );
  192. });
  193. // 老客户端的 schema 就是「没有这个键的同一个对象」:它把不认识的键剥掉,读成一条不带载荷的
  194. // workflow 通知(裸标题行),整帧照常解析。这条性质靠容器不是 strict 成立。
  195. it("不认识这个键的客户端剥掉它,其余照读", () => {
  196. const olderClient = z.object({
  197. backgroundSource: z.enum(["bash", "subagent", "workflow"]),
  198. workId: z.string().min(1),
  199. title: z.string().min(1),
  200. workflowNotification: workflowNotificationMetaSchema.optional(),
  201. });
  202. expect(olderClient.parse({ ...base, workflowBlocked: blocked })).toEqual(base);
  203. // 现在这份 schema 对将来的键同样如此。
  204. expect(backgroundResultOriginMetaSchema.parse({ ...base, someLaterKey: { any: 1 } })).toEqual(
  205. base,
  206. );
  207. });
  208. // 认识这个键的客户端宽容地读它:形状对不上就当它缺席,行退回裸标题,而不是丢掉整帧。
  209. it("形状对不上的 workflowBlocked 只丢载荷", () => {
  210. expect(
  211. backgroundResultOriginMetaSchema.parse({ ...base, workflowBlocked: { questions: "two" } }),
  212. ).toEqual(base);
  213. });
  214. });
  215. describe("通知载荷:kind = hole", () => {
  216. it("最小与完整两形都通过;prompt 超 4000 被拒", () => {
  217. expect(
  218. workflowNotificationMetaSchema.safeParse({
  219. kind: "hole",
  220. siteId: "hole#1",
  221. ordinal: 1,
  222. name: "决定分组",
  223. type: "Plan",
  224. }).success,
  225. ).toBe(true);
  226. expect(
  227. workflowNotificationMetaSchema.safeParse({
  228. kind: "hole",
  229. siteId: "hole#1",
  230. ordinal: 1,
  231. name: "决定分组",
  232. type: "Plan",
  233. prompt: "p",
  234. draftPath: "/w/.zcode/workflow-drafts/flaky.dwf.ts",
  235. line: 12,
  236. before: "探索",
  237. after: "执行",
  238. reachedAt: 1,
  239. }).success,
  240. ).toBe(true);
  241. expect(
  242. workflowNotificationMetaSchema.safeParse({
  243. kind: "hole",
  244. siteId: "hole#1",
  245. ordinal: 1,
  246. name: "n",
  247. type: "T",
  248. prompt: "x".repeat(4001),
  249. }).success,
  250. ).toBe(false);
  251. });
  252. });
  253. describe("workflowRuns reducer · hole-reached / hole-filled", () => {
  254. it("hole-reached 建一条 waiting 记录:站点 id 去重,type / prompt / since 随载荷而来", () => {
  255. const progress = progressLog();
  256. const state = reduceAll([
  257. progress("run-started", { runId: RUN_ID, caps: {} }),
  258. progress("hole-reached", REACHED),
  259. ]);
  260. expect(state?.runs[0]?.holes).toEqual([
  261. {
  262. siteId: "hole#1",
  263. ordinal: 1,
  264. name: "决定分组",
  265. type: "Plan",
  266. prompt: "侦察结果如下",
  267. state: "waiting",
  268. since: REACHED.reachedAt,
  269. },
  270. ]);
  271. expect(workflowRunsStateSchema.safeParse(state).success).toBe(true);
  272. });
  273. it("prompt 截到 500 字(499 字加 …);再次到达不带 prompt / type 时沿用记过的", () => {
  274. const progress = progressLog();
  275. const long = "长".repeat(WORKFLOW_RUNS_LIMITS.maxHolePromptLength + 40);
  276. const base = reduceAll([
  277. progress("run-started", { runId: RUN_ID, caps: {} }),
  278. progress("hole-reached", { ...REACHED, prompt: long }),
  279. ]);
  280. const prompt = base?.runs[0]?.holes?.[0]?.prompt;
  281. expect(prompt).toHaveLength(WORKFLOW_RUNS_LIMITS.maxHolePromptLength);
  282. expect(prompt?.endsWith("…")).toBe(true);
  283. expect(workflowRunsStateSchema.safeParse(base).success).toBe(true);
  284. const again = step(
  285. base,
  286. progress("hole-reached", { instance: { siteId: "hole#1", ordinal: 2 }, name: "决定分组" }),
  287. );
  288. expect(again.runs[0]?.holes?.[0]).toMatchObject({ ordinal: 2, type: "Plan", prompt });
  289. });
  290. it("同一站点再次到达(循环里的第二个 ordinal)只更新序号,不加第二条;重放幂等", () => {
  291. const progress = progressLog();
  292. const base = reduceAll([
  293. progress("run-started", { runId: RUN_ID, caps: {} }),
  294. progress("hole-reached", REACHED),
  295. ]);
  296. const second = progress("hole-reached", {
  297. ...REACHED,
  298. instance: { siteId: "hole#1", ordinal: 2 },
  299. });
  300. const again = step(base, second);
  301. expect(again.runs[0]?.holes).toHaveLength(1);
  302. expect(again.runs[0]?.holes?.[0]?.ordinal).toBe(2);
  303. // 同一条事件(同 sequence)重放:逐字节无变化 → null。
  304. expect(reduceWorkflowRunsState(again, second)).toBeNull();
  305. });
  306. it("type 与 reachedAt 缺席(旧 CLI / 简载荷)时键缺席,记录仍在", () => {
  307. const progress = progressLog();
  308. const state = reduceAll([
  309. progress("run-started", { runId: RUN_ID, caps: {} }),
  310. progress("hole-reached", { instance: { siteId: "hole#1", ordinal: 1 }, name: "n" }),
  311. ]);
  312. expect(state?.runs[0]?.holes).toEqual([
  313. { siteId: "hole#1", ordinal: 1, name: "n", state: "waiting" },
  314. ]);
  315. });
  316. it("name 缺席即整条无从展示:只抬水位", () => {
  317. const progress = progressLog();
  318. const base = step(undefined, progress("run-started", { runId: RUN_ID, caps: {} }));
  319. const next = step(
  320. base,
  321. progress("hole-reached", { instance: { siteId: "hole#1", ordinal: 1 } }),
  322. );
  323. expect(next.runs[0]).not.toHaveProperty("holes");
  324. });
  325. it("holes 上界 32:超出的站点被拒并置 truncated", () => {
  326. const progress = progressLog();
  327. let state: WorkflowRunsState | undefined = step(
  328. undefined,
  329. progress("run-started", { runId: RUN_ID, caps: {} }),
  330. );
  331. for (let i = 1; i <= WORKFLOW_RUNS_LIMITS.maxHoles + 1; i += 1) {
  332. state =
  333. reduceWorkflowRunsState(
  334. state,
  335. progress("hole-reached", {
  336. instance: { siteId: `hole#${i}`, ordinal: 1 },
  337. name: `h${i}`,
  338. }),
  339. ) ?? state;
  340. }
  341. expect(state?.runs[0]?.holes).toHaveLength(WORKFLOW_RUNS_LIMITS.maxHoles);
  342. expect(state?.runs[0]?.truncated).toBe(true);
  343. });
  344. it("hole-filled 把记录翻成 filled(提示语丢掉),并换上补全后的 phaseNames 与对齐的 phaseHoles", () => {
  345. const progress = progressLog();
  346. const state = reduceAll([
  347. progress("run-started", { runId: RUN_ID, caps: {} }),
  348. progress("run-launched", {
  349. inputId: "in-1",
  350. phaseNames: ["探索", "决定分组", "执行", "评判"],
  351. holes: [1, 3],
  352. phaseAlongside: [[], [], [3], []],
  353. }),
  354. progress("hole-reached", REACHED),
  355. progress("hole-filled", {
  356. siteId: "hole#1",
  357. filledAt: 1_700_000_001_000,
  358. filledBy: "main",
  359. phaseNames: ["探索", "决定分组", "冒烟测试", "分组", "执行", "评判"],
  360. holes: [5],
  361. }),
  362. ]);
  363. const run = state?.runs[0];
  364. expect(run?.holes).toEqual([
  365. {
  366. siteId: "hole#1",
  367. ordinal: 1,
  368. name: "决定分组",
  369. type: "Plan",
  370. state: "filled",
  371. since: REACHED.reachedAt,
  372. filledAt: 1_700_000_001_000,
  373. filledBy: "main",
  374. },
  375. ]);
  376. expect(run?.phaseNames).toEqual(["探索", "决定分组", "冒烟测试", "分组", "执行", "评判"]);
  377. expect(run?.phaseHoles).toEqual([5]);
  378. // 「同时在跑」表按插入位置右移:原来 执行(2) ∥ 评判(3) → 执行(4) ∥ 评判(5)。
  379. expect(run?.phaseAlongside).toEqual([[], [], [], [], [5], []]);
  380. expect(workflowRunsStateSchema.safeParse(state).success).toBe(true);
  381. });
  382. it("run-launched 的 holes 下标:越界、非整数、重复一律丢;phaseNames 缺席时不建 phaseHoles", () => {
  383. const progress = progressLog();
  384. const state = reduceAll([
  385. progress("run-started", { runId: RUN_ID, caps: {} }),
  386. progress("run-launched", {
  387. inputId: "in-1",
  388. phaseNames: ["a", "b"],
  389. holes: [1, 1, 7, -1, 0.5],
  390. }),
  391. ]);
  392. expect(state?.runs[0]?.phaseHoles).toEqual([1]);
  393. const bare = reduceAll([
  394. progress("run-started", { runId: RUN_ID, caps: {} }),
  395. progress("run-launched", { inputId: "in-2", holes: [0] }),
  396. ]);
  397. expect(bare?.runs[0]).not.toHaveProperty("phaseHoles");
  398. });
  399. it("hole-filled 不认识的站点:不造 holes 记录,但阶段表照换;siteId 缺席只抬水位", () => {
  400. const progress = progressLog();
  401. const base = reduceAll([
  402. progress("run-started", { runId: RUN_ID, caps: {} }),
  403. progress("run-launched", { inputId: "in-1", phaseNames: ["a", "h"], holes: [1] }),
  404. ]);
  405. const filled = step(
  406. base,
  407. progress("hole-filled", { siteId: "hole#9", filledAt: 1, phaseNames: ["a", "h", "x"] }),
  408. );
  409. expect(filled.runs[0]).not.toHaveProperty("holes");
  410. expect(filled.runs[0]?.phaseNames).toEqual(["a", "h", "x"]);
  411. expect(filled.runs[0]).not.toHaveProperty("phaseHoles");
  412. // siteId 缺席:只抬水位——除了 lastEventSequence 之外什么都不变。
  413. const bare = step(filled, progress("hole-filled", { filledAt: 2 }));
  414. expect(bare.runs[0]).toEqual({
  415. ...filled.runs[0],
  416. lastEventSequence: bare.runs[0]?.lastEventSequence,
  417. });
  418. });
  419. it("终态清掉 waiting,新的一世保留 filled,并可重新到达", () => {
  420. const progress = progressLog();
  421. const state = reduceAll([
  422. progress("run-started", { runId: RUN_ID, caps: {} }),
  423. progress("hole-reached", REACHED),
  424. progress("hole-filled", { siteId: "hole#1", filledAt: 5, phaseNames: ["决定分组"] }),
  425. progress("hole-reached", {
  426. instance: { siteId: "hole#2", ordinal: 1 },
  427. name: "评判",
  428. type: "Verdict",
  429. }),
  430. ]);
  431. expect(state?.runs[0]?.holes?.map((hole) => hole.state)).toEqual(["filled", "waiting"]);
  432. const settled = step(state, progress("run-settled", { status: "stopped", stopReason: "user" }));
  433. expect(settled.runs[0]?.holes?.map((hole) => hole.siteId)).toEqual(["hole#1"]);
  434. const resumed = step(settled, progress("run-started", { runId: RUN_ID, caps: {} }));
  435. expect(resumed.runs[0]?.holes?.map((hole) => hole.siteId)).toEqual(["hole#1"]);
  436. const reReached = step(
  437. resumed,
  438. progress("hole-reached", { instance: { siteId: "hole#2", ordinal: 1 }, name: "评判" }),
  439. );
  440. expect(reReached.runs[0]?.holes?.map((hole) => hole.state)).toEqual(["filled", "waiting"]);
  441. });
  442. });
  443. describe("sessions-index 侧栏摘要 · 留白站", () => {
  444. function run(overrides: Partial<WorkflowRunState> & { runId: string }): WorkflowRunState {
  445. return {
  446. status: "running",
  447. usage: { spentTokens: 0, nodesUsed: 0 },
  448. actors: [],
  449. nodes: [],
  450. lastEventSequence: 0,
  451. ...overrides,
  452. };
  453. }
  454. it("phaseHoles 标出的站带 hole: open;run.holes 里 waiting 的那一站带 hole: waiting", () => {
  455. const phases = deriveSessionWorkflowPhases(
  456. run({
  457. runId: "r1",
  458. phaseNames: ["探索", "决定分组", "执行", "评判"],
  459. phaseHoles: [1, 3],
  460. phases: [{ name: "探索", rounds: 1 }],
  461. currentPhase: "探索",
  462. holes: [{ siteId: "hole#1", ordinal: 1, name: "决定分组", state: "waiting" }],
  463. }),
  464. );
  465. expect(phases.map((phase) => phase.hole)).toEqual([undefined, "waiting", undefined, "open"]);
  466. expect(phases[1]?.status).toBe("pending");
  467. });
  468. it("补全后的留白不再是留白:phaseHoles 不再指向它,摘要行也没有 hole 键", () => {
  469. const phases = deriveSessionWorkflowPhases(
  470. run({
  471. runId: "r1",
  472. phaseNames: ["探索", "决定分组", "冒烟测试", "执行"],
  473. phaseHoles: [],
  474. holes: [{ siteId: "hole#1", ordinal: 1, name: "决定分组", state: "filled", filledAt: 1 }],
  475. }),
  476. );
  477. expect(phases.every((phase) => phase.hole === undefined)).toBe(true);
  478. });
  479. it("运行摘要交出 waitingHole:正在等补全的留白名(侧栏写「{name} · 等待补全」)", () => {
  480. const activity = deriveSessionWorkflowActivity({
  481. workflowRuns: {
  482. revision: 1,
  483. runs: [
  484. run({
  485. runId: "r1",
  486. phaseNames: ["探索", "决定分组"],
  487. phaseHoles: [1],
  488. holes: [{ siteId: "hole#1", ordinal: 1, name: "决定分组", state: "waiting" }],
  489. }),
  490. run({ runId: "r2", phaseNames: ["a"] }),
  491. ],
  492. },
  493. backgroundWorks: [],
  494. });
  495. expect(activity?.runs[0]?.waitingHole).toBe("决定分组");
  496. expect(activity?.runs[1]).not.toHaveProperty("waitingHole");
  497. });
  498. });