pi-mono/packages/durable/test/sync-urgency.test.ts
Cristina Poncela Cubeiro 7297af3b69 chore: move to Chord
2026-11-04 14:09:20 +01:00

20 lines
959 B
TypeScript

// `isUrgentCommit`: which Durable commits a host uploads soon (Chord's `FlushScheduler`).
import { describe, expect, it } from "vitest";
import { idFromNumber } from "../src/ids.ts";
import { isUrgentCommit } from "../src/index.ts";
import { type CommitPublication, type EntryId, ROOT_CONVERSATION_ID, type Seq } from "../src/types.ts";
const publication = (changes: CommitPublication["changes"]): CommitPublication => ({ seq: 1 as Seq, changes });
const entry = (kind: string) =>
({
type: "entry",
value: { id: idFromNumber<EntryId>(1), conversationId: ROOT_CONVERSATION_ID, kind, data: {} },
}) as never;
describe("isUrgentCommit", () => {
it("marks commits with input, answers, or settled submissions as urgent", () => {
expect(isUrgentCommit(publication([entry("pi.user")]))).toBe(true);
expect(isUrgentCommit(publication([entry("pi.assistant")]))).toBe(true);
expect(isUrgentCommit(publication([entry("message")]))).toBe(false);
});
});