feat: project durable agent conversations
This commit is contained in:
@@ -74,6 +74,53 @@ describe("Flue Convex persistence", () => {
|
||||
});
|
||||
});
|
||||
|
||||
test("binds a direct admission to the product turn atomically", async () => {
|
||||
const t = convexTest({ modules, schema });
|
||||
const organizationId = await t.run(async (ctx) =>
|
||||
ctx.db.insert("organizations", {
|
||||
createdAt: 1,
|
||||
createdBy: "user-1",
|
||||
kind: "personal",
|
||||
name: "Test",
|
||||
})
|
||||
);
|
||||
const conversationId = await t.run(async (ctx) =>
|
||||
ctx.db.insert("conversations", { createdAt: 1, organizationId })
|
||||
);
|
||||
const turnId = await t.run(async (ctx) =>
|
||||
ctx.db.insert("conversationTurns", {
|
||||
attemptNumber: 1,
|
||||
clientRequestId: "request-1",
|
||||
conversationId,
|
||||
createdAt: 1,
|
||||
leaseExpiresAt: 100,
|
||||
leaseOwner: "worker",
|
||||
status: "dispatching",
|
||||
})
|
||||
);
|
||||
|
||||
await t.mutation(api.fluePersistence.admitSubmission, {
|
||||
clientRequestId: "request-1",
|
||||
input: {
|
||||
acceptedAt: 1,
|
||||
chunksJson: "[]",
|
||||
inputJson: '{"kind":"direct"}',
|
||||
kind: "direct",
|
||||
sessionKey: "agent/instance/default",
|
||||
submissionId: "submission-1",
|
||||
},
|
||||
token,
|
||||
turnId,
|
||||
});
|
||||
const turn = await t.run((ctx) => ctx.db.get(turnId));
|
||||
expect(turn).toMatchObject({
|
||||
status: "running",
|
||||
submissionId: "submission-1",
|
||||
});
|
||||
expect(turn).not.toHaveProperty("leaseExpiresAt");
|
||||
expect(turn).not.toHaveProperty("leaseOwner");
|
||||
});
|
||||
|
||||
test("fences stale conversation producers and conflicting attachments", async () => {
|
||||
const t = convexTest({ modules, schema });
|
||||
await t.mutation(api.fluePersistence.createConversationStream, {
|
||||
|
||||
Reference in New Issue
Block a user