Scheduled runs are pre-approved: they carry out their brief instead of drafting for confirmation. A run that can't do its brief calls report_run_failed and is retried 5 and 10 minutes later; only then does the user get one "failed after N tries" message, and the routine keeps why in last_error. Every reply and task now gets ActionCheckNote: look for an existing record before creating one, and verify an action took effect before saying it's done. Memory and instructions saves are read back, and create_bot, create_schedule, start_task and delegate_task refuse duplicates. Co-Authored-By: Claude Opus 5.5 <[email protected]>
39 lines
1.3 KiB
TypeScript
39 lines
1.3 KiB
TypeScript
import { describe, expect, test } from "bun:test";
|
|
import type { BUN_SQLITE_COBBLE_CRON_JOBS } from "@/db/types/db";
|
|
import findDuplicateCronJob from "./find-duplicate-cron-job";
|
|
|
|
const digest: BUN_SQLITE_COBBLE_CRON_JOBS = {
|
|
id: 2,
|
|
title: "Morning digest",
|
|
instructions: "Email the news digest.",
|
|
schedule: "0 6 * * *",
|
|
workspace_id: undefined,
|
|
};
|
|
|
|
const find = (params: Partial<Parameters<typeof findDuplicateCronJob>[0]>) =>
|
|
findDuplicateCronJob({
|
|
cron_jobs: [digest],
|
|
title: "Other",
|
|
instructions: "Something else.",
|
|
schedule: "0 7 * * *",
|
|
...params,
|
|
});
|
|
|
|
describe("findDuplicateCronJob", () => {
|
|
test("matches the same title, ignoring case and spacing", () => {
|
|
expect(find({ title: " morning DIGEST " })?.id).toBe(2);
|
|
});
|
|
|
|
test("matches the same timing and brief under another title", () => {
|
|
expect(find({ schedule: "0 6 * * *", instructions: "Email the news digest." })?.id).toBe(2);
|
|
});
|
|
|
|
test("doesn't match the same brief at another time", () => {
|
|
expect(find({ instructions: "Email the news digest." })).toBeNull();
|
|
});
|
|
|
|
test("only matches schedules in the same place", () => {
|
|
expect(find({ title: "Morning digest", workspace_id: 4 })).toBeNull();
|
|
});
|
|
});
|