




















@@ -1,3 +1,4 @@
1+// Verifies restart recovery marks and resumes interrupted main-agent sessions.
12import fs from "node:fs/promises";
23import os from "node:os";
34import path from "node:path";
@@ -50,6 +51,8 @@ async function writeTranscript(
5051}
51525253function cleanedLockForPath(lockPath: string): SessionLockInspection {
54+// Simulates lock cleanup after process restart: stale lock removed, owning
55+// PID dead, and the transcript path available for recovery.
5356return {
5457 lockPath,
5558pid: 999_999,
@@ -67,6 +70,8 @@ function cleanedLock(sessionsDir: string, sessionId: string): SessionLockInspect
6770}
68716972function firstGatewayParams(): Record<string, unknown> {
73+// Recovery resumes through the gateway. Narrow the first mock call so tests
74+// assert request payloads without depending on the gateway return type.
7075const call = vi.mocked(callGateway).mock.calls[0];
7176if (!call) {
7277throw new Error("expected gateway call");
@@ -80,6 +85,8 @@ function firstGatewayParams(): Record<string, unknown> {
80858186describe("main-session-restart-recovery", () => {
8287it("marks only matching running main sessions by active session key", async () => {
88+// Only top-level running main sessions are restart-recoverable. Completed,
89+// child, cron, and non-active sessions must not be marked.
8390const sessionsDir = await makeSessionsDir();
8491await writeStore(sessionsDir, {
8592"agent:main:main": {
@@ -165,6 +172,8 @@ describe("main-session-restart-recovery", () => {
165172});
166173167174it("uses active session ids to avoid marking stale duplicate keys in another store", async () => {
175+// Custom and default stores can contain the same session key. Active ids
176+// keep restart marking tied to the store that owned the interrupted run.
168177const defaultSessionsDir = await makeSessionsDir();
169178await writeStore(defaultSessionsDir, {
170179"agent:main:issue-82433": {
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。