diff --git a/packages/coding-agent/src/coordinator-mcp/question-state.ts b/packages/coding-agent/src/coordinator-mcp/question-state.ts index 837c7cd576..68aa890507 100644 --- a/packages/coding-agent/src/coordinator-mcp/question-state.ts +++ b/packages/coding-agent/src/coordinator-mcp/question-state.ts @@ -349,7 +349,8 @@ async function readJson(file: string): Promise { return JSON.parse(await fs.readFile(file, "utf8")) as T; } catch (error) { if ((error as NodeJS.ErrnoException).code === "ENOENT") return null; - throw new Error("state_corrupt"); + if (error instanceof SyntaxError) throw new Error("state_corrupt"); + throw error; } } function assertTransaction(transaction: CoordinatorSessionTransactionV1, namespaceId: string, sessionId: string): void { diff --git a/packages/coding-agent/src/coordinator-mcp/server.ts b/packages/coding-agent/src/coordinator-mcp/server.ts index 9d7a450d6a..b9f407e2c6 100644 --- a/packages/coding-agent/src/coordinator-mcp/server.ts +++ b/packages/coding-agent/src/coordinator-mcp/server.ts @@ -6055,6 +6055,7 @@ export function createCoordinatorMcpServer(options: CoordinatorMcpServerOptions const reportPath = path.join(namespaceDir, "reports", `${reportId}.json`); await writeJsonFile(reportPath, report); await appendCoordinatorEvent(namespaceDir, { + ...(sessionId == null ? { stableId: `report-written:${reportId}` } : {}), kind: "report.written", sessionId, turnId: typeof args.turn_id === "string" ? args.turn_id : null, diff --git a/packages/coding-agent/test/coordinator-mcp-server.test.ts b/packages/coding-agent/test/coordinator-mcp-server.test.ts index a638598f4a..a4573aa5e4 100644 --- a/packages/coding-agent/test/coordinator-mcp-server.test.ts +++ b/packages/coding-agent/test/coordinator-mcp-server.test.ts @@ -1756,6 +1756,10 @@ console.log(JSON.stringify(await appendCoordinatorEventForTest(${JSON.stringify( await expect(server.callTool("gjc_coordinator_read_coordination_status")).resolves.toMatchObject({ summary: { reports: 1 }, }); + const events = await server.callTool("gjc_coordinator_watch_events", { after_seq: 0 }); + expect( + (events.events as Array>).filter(event => event.kind === "report.written"), + ).toHaveLength(1); }); it("fails closed when a same-generation successor has a different endpoint incarnation", async () => { const root = await tempRoot();