fix: recover session submissions and failed turn settlement

This commit is contained in:
amosblomqvist
2026-10-25 19:45:17 +02:00
parent b277ee3e0f
commit 7d65fa8754
21 changed files with 944 additions and 94 deletions
+11
View File
@@ -11,8 +11,19 @@ import assert from "node:assert/strict";
import { describe, it } from "node:test";
import { beginTurn, endTurn, isTurnRunning } from "../src/server/turn-liveness.ts";
import { subscribe, type ServerEvent } from "../src/core/events.ts";
import { rememberTurnFailure, settledTurnResponse } from "../src/server/turn-runs.ts";
describe("turn liveness registry", () => {
it("retains a late-attach failure notice until the next accepted begin", async () => {
const id = "chat_failure_notice_unit";
rememberTurnFailure(id, "The reply could not be saved.");
assert.match(await settledTurnResponse(id).text(), /The reply could not be saved\./);
assert.match(await settledTurnResponse(id).text(), /The reply could not be saved\./, "reading does not consume the notice");
assert.equal(beginTurn(id), true);
assert.doesNotMatch(await settledTurnResponse(id).text(), /"type":"error"/);
endTurn(id);
});
it("begin/end round trip; a second begin is rejected until the turn ends", () => {
const id = "chat_liveness_unit";
assert.equal(isTurnRunning(id), false, "initially idle");