Промты согласованы и установлены всем менеджерам: recap, Control todo (миграция 023, ControlWatcher), fallback на английском; tasks.md очищен
All checks were successful
ci / test (push) Successful in 25s
ci / deploy (push) Successful in 2m7s

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-29 08:28:06 +03:00
parent 4f287519cc
commit 7c26b38a49
34 changed files with 449 additions and 36 deletions

View File

@@ -14,6 +14,7 @@ import { buildApi } from "./http-api.js";
import { listManagers } from "./managers.js";
import { pauseState } from "./pause.js";
import { handleManagerMessages } from "./slack/chat.js";
import { ControlWatcher } from "./slack/control.js";
import type { DriveClient } from "./gdrive/client.js";
import { DriveInbox } from "./slack/drive-inbox.js";
import { SlackIntake } from "./slack/intake.js";
@@ -670,4 +671,50 @@ d("консольные агенты (временная БД, фейковый
expect(liveCalls[3]!.prompt).not.toContain("AI huddle notes are ready");
});
it("Control todo: пара пишется из раздела вывода; исполнитель закрыл - «выполнено», после срока без действий - «просрочено»; статусы меняются", async () => {
const nl = String.fromCharCode(10);
const texts: string[] = [
["## Ответ менеджеру", "(без ответа)", "## Control todo", "CTRLcccccc03 EXECcccccc03 2026-10-25", "## Память", "м-control-1"].join(nl),
["## Ответ менеджеру", "Walter closed the tile todo - you can close your Control todo. No action on the plumber todo for 2 days - marked overdue.", "## Память", "м-control-2"].join(nl),
];
const liveCalls: ClaudeCall[] = [];
const liveRunner = {
run: async (c: ClaudeCall) => { liveCalls.push(c); return { text: texts.shift()!, sessionId: c.sessionId }; },
isActive: () => false, activeSession: () => null, close: () => undefined, closeAll: () => undefined, activeCount: () => 0,
};
const base = ctx();
const live = { ...base, liveRunner, settings: { ...base.settings, live: { managerIds: [MGR], idleMinutes: 10, warmupSeconds: 0 } } };
const posted: string[] = [];
const slack = { postMessage: async (_c: string, t: string) => { posted.push(t); return true; }, fileInfo: async () => null, download: async () => 0 };
const mgr = { personId: MGR, name: "llmtest-Manager", slackUserId: "ULLMTEST", slackChannelId: "CLLMTEST" };
const noon = new Date("2026-10-21T16:00:00Z");
const deps = { ctx: live, timezone: "America/New_York", slack, now: () => noon };
// 1. агент вывел пару - она записана
await handleManagerMessages({ ...deps, dryPublish: true }, mgr, [{ channel: "CLLMTEST", ts: "1791741800.000001", text: "I noticed missing conduit", fileIds: [] }]);
const saved = (await db.pool.query("select executor_task_id, to_char(control_due,'YYYY-MM-DD') d, status from control_todo where control_task_id = 'CTRLcccccc03'")).rows[0];
expect(saved).toEqual({ executor_task_id: "EXECcccccc03", d: "2026-10-25", status: "active" });
// 2. две другие пары: исполнитель закрыл todo (событие JobTread) и срок Control todo прошёл без действий
await db.pool.query("insert into control_todo (controller_person_id, executor_task_id, control_task_id, executor_name, control_due) values ($1,'EXECaaaaaa01','CTRLaaaaaa01','Order tile','2026-10-30'), ($1,'EXECbbbbbb02','CTRLbbbbbb02','Call plumber','2026-10-20')", [MGR]);
await db.pool.query("insert into jt_event (id, type, created_at, task_id, kind) values ('llmtest-ev-ctl-1', 'taskUpdated', now(), 'EXECaaaaaa01', 'todo_closed')");
const watcher = new ControlWatcher(deps, { loadManager: async () => mgr, intervalMs: 0 });
expect(await watcher.tick()).toBe(1);
const prompt = liveCalls[1]!.prompt;
expect(prompt).toContain("ВЫПОЛНЕНО: исполнитель закрыл todo EXECaaaaaa01 «Order tile». Control todo CTRLaaaaaa01");
expect(prompt).toContain("ПРОСРОЧЕНО: по todo исполнителя EXECbbbbbb02 «Call plumber»");
expect(prompt).not.toContain("EXECcccccc03"); // срок 10/25 ещё не наступил (сегодня 10/21)
const st = (await db.pool.query("select control_task_id, status from control_todo order by control_task_id")).rows;
expect(st).toEqual([{ control_task_id: "CTRLaaaaaa01", status: "done" }, { control_task_id: "CTRLbbbbbb02", status: "overdue" }, { control_task_id: "CTRLcccccc03", status: "active" }]);
expect(posted).toHaveLength(1);
// 3. повторная проверка ничего не шлёт; ночью (вне окна 7-19 по Тампе) тоже
expect(await watcher.tick()).toBe(0);
const night = new ControlWatcher({ ...deps, now: () => new Date("2026-10-21T05:00:00Z") }, { loadManager: async () => mgr, intervalMs: 0 });
expect(await night.tick()).toBe(0);
// 4. исполнитель после «просрочено» всё же закрыл todo - снова сообщение, статус done
texts.push(["## Ответ менеджеру", "Plumber todo is done now.", "## Память", "м-control-3"].join(nl));
await db.pool.query("insert into jt_event (id, type, created_at, task_id, kind) values ('llmtest-ev-ctl-2', 'taskUpdated', now(), 'EXECbbbbbb02', 'todo_closed')");
expect(await watcher.tick()).toBe(1);
expect(liveCalls[2]!.prompt).toContain("ВЫПОЛНЕНО: исполнитель закрыл todo EXECbbbbbb02");
expect((await db.pool.query("select status from control_todo where control_task_id = 'CTRLbbbbbb02'")).rows[0].status).toBe("done");
});
});