Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion packages/coding-agent/src/coordinator-mcp/question-state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,8 @@ async function readJson<T>(file: string): Promise<T | null> {
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 {
Expand Down
1 change: 1 addition & 0 deletions packages/coding-agent/src/coordinator-mcp/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 4 additions & 0 deletions packages/coding-agent/test/coordinator-mcp-server.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<Record<string, unknown>>).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();
Expand Down
Loading