workspace-hook-runtime-admission.test.ts 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638
  1. import { describe, expect, it, vi } from "vitest";
  2. import {
  3. HookEventName,
  4. HookOutcome,
  5. SessionEventType,
  6. createWorkspaceHookBundleSnapshot,
  7. type ExecutionPort,
  8. type HookInput,
  9. type SessionEvent,
  10. type WorkspaceHookBundleSnapshot,
  11. } from "@zcode/contracts";
  12. import {
  13. InMemoryWorkspaceHookPolicyProvider,
  14. WorkspaceHookTrustCoordinator,
  15. createConfiguredHookRunner,
  16. createWorkspaceHookRuntimeAdmission,
  17. createWorkspaceHookTrustRecords,
  18. } from "../src/hooks/index.js";
  19. import { runSessionStartHooks } from "../src/runtime/methods/hooks.js";
  20. const WORKSPACE = "local:/workspace";
  21. const BUNDLE = "c".repeat(64);
  22. const DIGEST_A = "a".repeat(64);
  23. const DIGEST_B = "b".repeat(64);
  24. function snapshot(
  25. input: {
  26. event?: (typeof HookEventName)[keyof typeof HookEventName];
  27. matcher?: string | null;
  28. async?: boolean;
  29. command?: string;
  30. digest?: string;
  31. bundleDigest?: string;
  32. configuredEnabled?: boolean;
  33. } = {},
  34. ): WorkspaceHookBundleSnapshot {
  35. return createWorkspaceHookBundleSnapshot({
  36. schemaVersion: 1,
  37. workspaceIdentity: WORKSPACE,
  38. discoveredAt: "2026-08-06T00:00:00.000Z",
  39. sourceFiles: [
  40. {
  41. canonicalPath: "/workspace/.zcode/config.json",
  42. baseDir: "/workspace",
  43. discoveryOrder: 0,
  44. configFileKind: ".zcode/config.json",
  45. explicitProjectConfig: false,
  46. editable: true,
  47. hooksRoot: { enabled: true },
  48. },
  49. ],
  50. hooks: [
  51. {
  52. reviewItemId: "item-0",
  53. event: input.event ?? HookEventName.SessionStart,
  54. matcherIndex: 0,
  55. hookIndex: 0,
  56. sourceFileIndex: 0,
  57. sourceRelativePath: ".zcode/config.json",
  58. matcher: input.matcher === undefined ? "startup" : input.matcher,
  59. type: "command",
  60. command: input.command ?? "echo project",
  61. ...(input.async ? { async: true } : {}),
  62. resolvedTimeoutMs: 60_000,
  63. resolvedMaxOutputBytes: 32_768,
  64. sourceRootEnabled: input.configuredEnabled ?? true,
  65. declarationEnabled: input.configuredEnabled ?? true,
  66. runtimeHooksEnabled: true,
  67. configuredEnabled: input.configuredEnabled ?? true,
  68. editable: true,
  69. declarationDigestAlgorithm: "sha256",
  70. hookDeclarationDigest: input.digest ?? DIGEST_A,
  71. },
  72. ],
  73. digestAlgorithm: "sha256",
  74. bundleDigest: input.bundleDigest ?? BUNDLE,
  75. });
  76. }
  77. function createCoordinator(
  78. input: {
  79. trusted?: boolean;
  80. policy?: InMemoryWorkspaceHookPolicyProvider;
  81. } = {},
  82. ) {
  83. const coordinator = new WorkspaceHookTrustCoordinator({
  84. coordinatorEpoch: "epoch-runtime",
  85. policyProvider: input.policy,
  86. });
  87. if (input.trusted) {
  88. coordinator.replacePersistentTrustRecords(
  89. createWorkspaceHookTrustRecords({
  90. snapshot: snapshot(),
  91. reviewItemIds: ["item-0"],
  92. grantedAt: "2026-08-06T00:00:00.000Z",
  93. }),
  94. { status: "ok" },
  95. );
  96. } else {
  97. coordinator.replacePersistentTrustRecords([], { status: "missing" });
  98. }
  99. return coordinator;
  100. }
  101. function sessionStartInput(): HookInput {
  102. return {
  103. cwd: "/workspace",
  104. hookEventName: HookEventName.SessionStart,
  105. mode: "build",
  106. sessionId: "session-1" as never,
  107. source: "startup",
  108. timestamp: "2026-08-06T00:00:00.000Z",
  109. traceId: "trace-1" as never,
  110. };
  111. }
  112. function completedExecutionPort(onRun?: (command: string) => void): ExecutionPort {
  113. return {
  114. async run(request) {
  115. const command =
  116. request.command.mode === "shell" ? request.command.command : request.command.file;
  117. onRun?.(command);
  118. const now = new Date("2026-08-06T00:00:00.000Z");
  119. return {
  120. status: "completed",
  121. exitCode: 0,
  122. stdout: { text: "", bytes: 0, truncated: false },
  123. stderr: { text: "", bytes: 0, truncated: false },
  124. durationMs: 1,
  125. timedOut: false,
  126. cancelled: false,
  127. startedAt: now,
  128. completedAt: now,
  129. };
  130. },
  131. };
  132. }
  133. function configuredRunner(input: {
  134. coordinator: WorkspaceHookTrustCoordinator;
  135. hookSnapshot?: WorkspaceHookBundleSnapshot;
  136. events?: SessionEvent[];
  137. commands?: string[];
  138. onAdmissionStateChanged?: (state: { pendingCount: number; bundleDigest: string }) => void;
  139. }) {
  140. const hookSnapshot = input.hookSnapshot ?? snapshot();
  141. const admission = createWorkspaceHookRuntimeAdmission({
  142. coordinator: input.coordinator,
  143. ready: Promise.resolve(),
  144. snapshot: hookSnapshot,
  145. ...(input.onAdmissionStateChanged
  146. ? { onAdmissionStateChanged: input.onAdmissionStateChanged }
  147. : {}),
  148. });
  149. const runner = createConfiguredHookRunner({
  150. config: {
  151. enabled: true,
  152. events: {},
  153. maxOutputBytes: 32_768,
  154. timeoutMs: 60_000,
  155. },
  156. emitEvent: async (event) => input.events?.push(event),
  157. executionPort: completedExecutionPort((command) => input.commands?.push(command)),
  158. getWorkingDirectory: () => "/workspace",
  159. workspaceHookAdmission: admission,
  160. workspaceHookSnapshot: hookSnapshot,
  161. });
  162. if (!runner) throw new Error("expected configured runner");
  163. return { admission, runner };
  164. }
  165. describe("Workspace Hook Runtime admission", () => {
  166. it("feature flag 关闭时不读取 Trust store,上报 pendingCount=0,并保持 hard block", async () => {
  167. const ready = new Promise<void>(() => {
  168. // disabled rollout must not await this bootstrap promise
  169. });
  170. const stateCallback = vi.fn();
  171. const admission = createWorkspaceHookRuntimeAdmission({
  172. coordinator: createCoordinator({ trusted: true }),
  173. enabled: false,
  174. ready,
  175. onAdmissionStateChanged: stateCallback,
  176. snapshot: snapshot(),
  177. });
  178. await admission.activate("startup");
  179. // 软门禁(D1):功能关闭时上报 pendingCount=0
  180. expect(stateCallback).toHaveBeenCalledWith(expect.objectContaining({ pendingCount: 0 }));
  181. expect(stateCallback).toHaveBeenCalledTimes(1);
  182. expect(
  183. admission.evaluateDispatch({
  184. hookDeclarationDigest: DIGEST_A,
  185. reviewItemId: "item-0",
  186. }),
  187. ).toEqual({
  188. allowed: false,
  189. reasonCode: "workspace_hooks_feature_disabled",
  190. });
  191. });
  192. it("未 Trust 的 startup project Hook 在 HookRunStarted 和 ExecutionPort 前 blocked", async () => {
  193. const events: SessionEvent[] = [];
  194. const commands: string[] = [];
  195. const { admission, runner } = configuredRunner({
  196. coordinator: createCoordinator(),
  197. events,
  198. commands,
  199. });
  200. await admission.activate("startup");
  201. await runner.run(sessionStartInput(), { matchValue: "startup" });
  202. expect(commands).toEqual([]);
  203. expect(events.map((event) => event.type)).toEqual([SessionEventType.HookRunBlocked]);
  204. expect(events[0]?.payload).toMatchObject({
  205. descriptor: { sourceKind: "project", clientVisible: true },
  206. errorCode: "workspace_hooks_pending_trust",
  207. outcome: HookOutcome.Blocked,
  208. });
  209. });
  210. it("只执行 immutable snapshot 中 exact persistent digest", async () => {
  211. const commands: string[] = [];
  212. const { admission, runner } = configuredRunner({
  213. coordinator: createCoordinator({ trusted: true }),
  214. commands,
  215. });
  216. await admission.activate("startup");
  217. await runner.run(sessionStartInput(), { matchValue: "startup" });
  218. expect(commands).toEqual(["echo project"]);
  219. });
  220. it("revoke 与 policy hot deny 使旧 revision 的后续 dispatch 立即 blocked", async () => {
  221. const policy = new InMemoryWorkspaceHookPolicyProvider();
  222. const coordinator = createCoordinator({ trusted: true, policy });
  223. const events: SessionEvent[] = [];
  224. const commands: string[] = [];
  225. const { admission, runner } = configuredRunner({
  226. coordinator,
  227. events,
  228. commands,
  229. });
  230. await admission.activate("startup");
  231. await runner.run(sessionStartInput(), { matchValue: "startup" });
  232. coordinator.revoke({
  233. workspaceIdentity: WORKSPACE,
  234. hookDeclarationDigests: [DIGEST_A],
  235. });
  236. await runner.run(sessionStartInput(), { matchValue: "startup" });
  237. coordinator.replacePersistentTrustRecords(
  238. createWorkspaceHookTrustRecords({
  239. snapshot: snapshot(),
  240. reviewItemIds: ["item-0"],
  241. grantedAt: "2026-08-06T00:00:01.000Z",
  242. }),
  243. { status: "ok" },
  244. );
  245. policy.setWorkspacePolicy(WORKSPACE, {
  246. mode: "deny",
  247. reason: "managed policy denied workspace hooks",
  248. policyRevision: "managed:deny:1",
  249. });
  250. await runner.run(sessionStartInput(), { matchValue: "startup" });
  251. expect(commands).toEqual(["echo project"]);
  252. expect(
  253. events
  254. .filter((event) => event.type === SessionEventType.HookRunBlocked)
  255. .map((event) => ({
  256. code: event.payload.errorCode,
  257. source: event.payload.descriptor?.sourceKind,
  258. })),
  259. ).toEqual([
  260. { code: "workspace_hooks_revoked", source: "project" },
  261. { code: "workspace_hooks_blocked_by_policy", source: "project" },
  262. ]);
  263. });
  264. it("blocked async project Hook 不创建 callback/background Promise", async () => {
  265. const events: SessionEvent[] = [];
  266. const commands: string[] = [];
  267. const hookSnapshot = snapshot({ async: true });
  268. const { admission, runner } = configuredRunner({
  269. coordinator: createCoordinator(),
  270. events,
  271. commands,
  272. hookSnapshot,
  273. });
  274. await admission.activate("startup");
  275. await runner.run(sessionStartInput(), { matchValue: "startup" });
  276. await Promise.resolve();
  277. expect(commands).toEqual([]);
  278. expect(events.map((event) => event.type)).toEqual([SessionEventType.HookRunBlocked]);
  279. });
  280. it("snapshot/bundle/item mismatch fail closed", async () => {
  281. const hookSnapshot = snapshot();
  282. const admission = createWorkspaceHookRuntimeAdmission({
  283. coordinator: createCoordinator({ trusted: true }),
  284. ready: Promise.resolve(),
  285. snapshot: hookSnapshot,
  286. });
  287. await admission.activate("startup");
  288. expect(
  289. admission.evaluateDispatch({
  290. bundleDigest: "d".repeat(64),
  291. hookDeclarationDigest: DIGEST_A,
  292. reviewItemId: "item-0",
  293. }),
  294. ).toEqual({
  295. allowed: false,
  296. reasonCode: "workspace_hooks_snapshot_mismatch",
  297. });
  298. expect(
  299. admission.evaluateDispatch({
  300. bundleDigest: BUNDLE,
  301. hookDeclarationDigest: "e".repeat(64),
  302. reviewItemId: "item-0",
  303. }),
  304. ).toEqual({
  305. allowed: false,
  306. reasonCode: "workspace_hooks_snapshot_mismatch",
  307. });
  308. });
  309. it("按 user -> project -> internal 保持 mixed-source lifecycle 顺序", async () => {
  310. const events: SessionEvent[] = [];
  311. const coordinator = createCoordinator();
  312. const hookSnapshot = snapshot({
  313. event: HookEventName.UserPromptSubmit,
  314. matcher: null,
  315. });
  316. const admission = createWorkspaceHookRuntimeAdmission({
  317. coordinator,
  318. ready: Promise.resolve(),
  319. snapshot: hookSnapshot,
  320. });
  321. const runner = createConfiguredHookRunner({
  322. config: {
  323. enabled: true,
  324. events: {
  325. UserPromptSubmit: [
  326. {
  327. hooks: [
  328. {
  329. type: "command",
  330. command: "echo user",
  331. source: { kind: "user", path: "/home/user/config.json" },
  332. },
  333. {
  334. type: "command",
  335. command: "echo internal",
  336. source: { kind: "internal" },
  337. },
  338. ],
  339. },
  340. ],
  341. },
  342. maxOutputBytes: 32_768,
  343. timeoutMs: 60_000,
  344. },
  345. emitEvent: async (event) => events.push(event),
  346. executionPort: completedExecutionPort(),
  347. getWorkingDirectory: () => "/workspace",
  348. workspaceHookAdmission: admission,
  349. workspaceHookSnapshot: hookSnapshot,
  350. });
  351. if (!runner) throw new Error("expected configured runner");
  352. await admission.activate("startup");
  353. await runner.run({
  354. cwd: "/workspace",
  355. hookEventName: HookEventName.UserPromptSubmit,
  356. mode: "build",
  357. prompt: "hello",
  358. sessionId: "session-1" as never,
  359. timestamp: "2026-08-06T00:00:00.000Z",
  360. traceId: "trace-1" as never,
  361. });
  362. expect(events.map((event) => `${event.type}:${event.payload.descriptor?.sourceKind}`)).toEqual([
  363. "hook_run_started:user",
  364. "hook_run_completed:user",
  365. "hook_run_blocked:project",
  366. "hook_run_started:internal",
  367. "hook_run_completed:internal",
  368. ]);
  369. });
  370. it("toggle rebuild 可替换 immutable snapshot;disabled 旧 callback 不能执行", async () => {
  371. const coordinator = createCoordinator({ trusted: true });
  372. const enabledSnapshot = snapshot();
  373. const commands: string[] = [];
  374. const { admission, runner } = configuredRunner({
  375. coordinator,
  376. commands,
  377. hookSnapshot: enabledSnapshot,
  378. });
  379. await admission.activate("startup");
  380. admission.replaceSnapshot(snapshot({ bundleDigest: "d".repeat(64), configuredEnabled: false }));
  381. await runner.run(sessionStartInput(), { matchValue: "startup" });
  382. expect(commands).toEqual([]);
  383. });
  384. it("初始 disabled declaration 也可持久信任,enable rebuild 后由 exact digest 放行", async () => {
  385. const coordinator = createCoordinator();
  386. const disabledSnapshot = snapshot({ configuredEnabled: false });
  387. const commands: string[] = [];
  388. const { admission, runner } = configuredRunner({
  389. coordinator,
  390. commands,
  391. hookSnapshot: disabledSnapshot,
  392. });
  393. await admission.activate("startup");
  394. coordinator.replacePersistentTrustRecords(
  395. createWorkspaceHookTrustRecords({
  396. snapshot: disabledSnapshot,
  397. reviewItemIds: ["item-0"],
  398. grantedAt: "2026-08-06T00:00:01.000Z",
  399. }),
  400. { status: "ok" },
  401. );
  402. const enabledSnapshot = snapshot({ bundleDigest: "d".repeat(64) });
  403. admission.replaceSnapshot(enabledSnapshot);
  404. await runner.run(sessionStartInput(), { matchValue: "startup" });
  405. expect(commands).toEqual(["echo project"]);
  406. });
  407. it("手工改写 declaration 后旧 callback 即使 reviewItemId 相同也 snapshot mismatch", async () => {
  408. const coordinator = createCoordinator({ trusted: true });
  409. const events: SessionEvent[] = [];
  410. const { admission, runner } = configuredRunner({ coordinator, events });
  411. await admission.activate("startup");
  412. admission.replaceSnapshot(
  413. snapshot({
  414. bundleDigest: "d".repeat(64),
  415. command: "echo changed",
  416. digest: "e".repeat(64),
  417. }),
  418. );
  419. await runner.run(sessionStartInput(), { matchValue: "startup" });
  420. expect(events.at(-1)).toEqual(
  421. expect.objectContaining({
  422. type: SessionEventType.HookRunBlocked,
  423. payload: expect.objectContaining({
  424. errorCode: "workspace_hooks_snapshot_mismatch",
  425. }),
  426. }),
  427. );
  428. });
  429. it("shared SessionStart guard 在 startup/resume dispatch 之前 activate,且无 runner 也执行", async () => {
  430. const order: string[] = [];
  431. const fakeRuntime = {
  432. config: {},
  433. getSessionModelSelection: () => ({ providerId: "openai", modelId: "gpt-test" }),
  434. getMode: () => "build",
  435. hookRunner: {
  436. run: vi.fn(async () => {
  437. order.push("run");
  438. return { additionalContexts: [] };
  439. }),
  440. },
  441. sessionId: "session-1",
  442. sessionStartHookRan: false,
  443. workingDirectory: "/workspace",
  444. workspaceHookAdmission: {
  445. activate: vi.fn(async (source: string) => {
  446. order.push(`activate:${source}`);
  447. }),
  448. },
  449. } as never;
  450. await runSessionStartHooks.call(fakeRuntime, "startup", {
  451. traceId: "trace-1",
  452. } as never);
  453. expect(order).toEqual(["activate:startup", "run"]);
  454. order.length = 0;
  455. const withoutRunner = {
  456. ...fakeRuntime,
  457. hookRunner: undefined,
  458. sessionStartHookRan: false,
  459. } as never;
  460. await runSessionStartHooks.call(withoutRunner, "resume", {
  461. traceId: "trace-1",
  462. } as never);
  463. expect(order).toEqual(["activate:resume"]);
  464. });
  465. it("跨 workspaceIdentity 的 replaceSnapshot 必须抛错(fail-loud 不变式)", () => {
  466. const admission = createWorkspaceHookRuntimeAdmission({
  467. coordinator: createCoordinator({ trusted: true }),
  468. ready: Promise.resolve(),
  469. snapshot: snapshot(),
  470. });
  471. const crossIdentitySnapshot = createWorkspaceHookBundleSnapshot({
  472. schemaVersion: 1,
  473. workspaceIdentity: "local:/other-workspace",
  474. discoveredAt: "2026-08-06T00:00:00.000Z",
  475. sourceFiles: [],
  476. hooks: [],
  477. digestAlgorithm: "sha256",
  478. bundleDigest: "f".repeat(64),
  479. });
  480. expect(() => admission.replaceSnapshot(crossIdentitySnapshot)).toThrow(
  481. /across workspace identities/u,
  482. );
  483. expect(admission.getCurrentSnapshot().workspaceIdentity).toBe(WORKSPACE);
  484. expect(admission.getCurrentSnapshot().bundleDigest).toBe(BUNDLE);
  485. });
  486. it("同 workspaceIdentity 的 replaceSnapshot 成功替换快照", () => {
  487. const admission = createWorkspaceHookRuntimeAdmission({
  488. coordinator: createCoordinator({ trusted: true }),
  489. ready: Promise.resolve(),
  490. snapshot: snapshot(),
  491. });
  492. const newBundle = "d".repeat(64);
  493. admission.replaceSnapshot(snapshot({ bundleDigest: newBundle }));
  494. expect(admission.getCurrentSnapshot().bundleDigest).toBe(newBundle);
  495. });
  496. it("activate 中 evaluateSnapshot 抛错不冒泡,workspace Hook 保持 fail-closed", async () => {
  497. const coordinator = createCoordinator({ trusted: true });
  498. const admission = createWorkspaceHookRuntimeAdmission({
  499. coordinator,
  500. ready: Promise.resolve(),
  501. snapshot: snapshot(),
  502. });
  503. const spy = vi.spyOn(coordinator, "evaluateSnapshot").mockImplementationOnce(() => {
  504. throw new Error("zod parse failed on malformed state");
  505. });
  506. await expect(admission.activate("startup")).resolves.toBeUndefined();
  507. expect(spy).toHaveBeenCalledTimes(1);
  508. expect(
  509. admission.evaluateDispatch({
  510. hookDeclarationDigest: DIGEST_A,
  511. reviewItemId: "item-0",
  512. }),
  513. ).toEqual({
  514. allowed: false,
  515. reasonCode: "workspace_hooks_trust_store_corrupt",
  516. });
  517. });
  518. // —— 软门禁(D1) 软门禁语义测试 ——
  519. it("D1: onAdmissionStateChanged 上报 pendingCount > 0(未 trust)", async () => {
  520. const states: Array<{ pendingCount: number; bundleDigest: string }> = [];
  521. const { admission } = configuredRunner({
  522. coordinator: createCoordinator(), // 未 trust → pending
  523. onAdmissionStateChanged: (s) => states.push(s),
  524. });
  525. await admission.activate("startup");
  526. expect(states).toHaveLength(1);
  527. expect(states[0]!.pendingCount).toBe(1);
  528. expect(states[0]!.bundleDigest).toBe(BUNDLE);
  529. });
  530. it("D1: onAdmissionStateChanged 上报 pendingCount = 0(已 trust)", async () => {
  531. const states: Array<{ pendingCount: number; bundleDigest: string }> = [];
  532. const { admission } = configuredRunner({
  533. coordinator: createCoordinator({ trusted: true }),
  534. onAdmissionStateChanged: (s) => states.push(s),
  535. });
  536. await admission.activate("startup");
  537. expect(states).toHaveLength(1);
  538. expect(states[0]!.pendingCount).toBe(0);
  539. });
  540. // SessionStart 是自然生命周期事件:首次因未信任被跳过后,本任务内不会追补。
  541. it("首次 SessionStart 未信任被跳过,之后持久信任也不在下一轮补跑", async () => {
  542. const coordinator = createCoordinator();
  543. const commands: string[] = [];
  544. const hookSnapshot = snapshot();
  545. const { admission, runner } = configuredRunner({
  546. coordinator,
  547. commands,
  548. hookSnapshot,
  549. });
  550. const runtime = {
  551. config: {},
  552. getSessionModelSelection: () => ({ providerId: "openai", modelId: "gpt-test" }),
  553. getMode: () => "build",
  554. hookRunner: runner,
  555. sessionId: "session-1",
  556. sessionStartHookRan: false,
  557. workingDirectory: "/workspace",
  558. workspaceHookAdmission: admission,
  559. } as never;
  560. await runSessionStartHooks.call(runtime, "startup", {
  561. traceId: "trace-1",
  562. } as never);
  563. expect(commands).toEqual([]);
  564. coordinator.replacePersistentTrustRecords(
  565. createWorkspaceHookTrustRecords({
  566. snapshot: hookSnapshot,
  567. reviewItemIds: ["item-0"],
  568. grantedAt: "2026-08-06T00:00:01.000Z",
  569. }),
  570. { status: "ok" },
  571. );
  572. await runSessionStartHooks.call(runtime, "resume", {
  573. traceId: "trace-2",
  574. } as never);
  575. expect(commands).toEqual([]);
  576. });
  577. });