repositories / pi-ext
pi-ext
bugabingas pi extensions
owned by admin
extensions/klaus/__tests__/coordinator.test.ts
Rawimport { describe, expect, it } from "vitest";
import { KlausCacheCorruptionError } from "../src/cache";
import { isReplayableResumeError } from "../src/coordinator";
describe("Klaus resume recovery", () => {
it("replays only when the SDK explicitly rejects the resume point", () => {
expect(
isReplayableResumeError(
new Error(
"Resume rejected by --resume-drops-turn: fork point is not attributable to the discarded turn",
),
),
).toBe(true);
expect(
isReplayableResumeError(
new KlausCacheCorruptionError("invalid transcript JSON."),
),
).toBe(true);
expect(
isReplayableResumeError(
new Error("Klaus cache corruption: invalid transcript JSON."),
),
).toBe(true);
expect(
isReplayableResumeError(
new Error(
"No message found with message.uuid of: 0854833d-c5fc-4acb-93c7-6c93c1d2e4c1",
),
),
).toBe(true);
});
it.each([
"rate limit: Claude subscription limit rejected the request.",
"authentication failed",
"Failed to authenticate. API Error: 401 OAuth access token has been revoked.",
"network connection reset",
"Klaus session mirror failed: write failed",
])("does not replay a full context after %s", (message) => {
expect(isReplayableResumeError(new Error(message))).toBe(false);
});
});