From 5f738942e0c5cad7230bb894b392dc16626a760e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D1=81=D0=B5=D0=BB=D1=8C?= Date: Mon, 16 Nov 2026 11:48:31 +0500 Subject: [PATCH] PEP-149: remaining old tests follow the new end-of-turn behaviour Co-Authored-By: Claude Fable 5.2 --- .../changes/pep-149-agent-message-kinds/tasks.md | 2 +- packages/testkit/test/cjm.test.ts | 16 ++++++++-------- packages/testkit/test/claude-live.test.ts | 10 ++++++---- packages/testkit/test/rotation.test.ts | 4 ++-- packages/testkit/test/sandbox-hosts.test.ts | 6 +++--- 5 files changed, 20 insertions(+), 18 deletions(-) diff --git a/openspec/changes/pep-149-agent-message-kinds/tasks.md b/openspec/changes/pep-149-agent-message-kinds/tasks.md index 83ed215d..621df364 100644 --- a/openspec/changes/pep-149-agent-message-kinds/tasks.md +++ b/openspec/changes/pep-149-agent-message-kinds/tasks.md @@ -19,4 +19,4 @@ ## 4. Правила, помощь, проверки - [x] 4.1 `template/RULES.md`, «Помощь», AGENTS.md — четыре типа - [x] 4.2 Тесты по сценариям (`agent-messages.test.ts`), правка старых тестов -- [ ] 4.3 lint, typecheck, build, тесты; проверка экранов; память проекта +- [x] 4.3 lint, typecheck, build, тесты; проверка экранов; память проекта diff --git a/packages/testkit/test/cjm.test.ts b/packages/testkit/test/cjm.test.ts index d996e9ab..0baf4e8f 100644 --- a/packages/testkit/test/cjm.test.ts +++ b/packages/testkit/test/cjm.test.ts @@ -244,7 +244,7 @@ describe("Claude: failures and recovery", () => { test("tmux session killed from outside → failed, PM alerted", async () => { const p = await project({ turns: [[{ say: "Работаю." }]] }); const sid = await p.start(); - await p.waitStatus(sid, "waiting_input"); + await p.waitStatus(sid, "idle"); execFileSync("tmux", ["-L", process.env.PEPPA_TMUX_SOCKET!, "kill-session", "-t", `=${(await p.session(sid)).tmuxName}`]); await tick(); assert.equal((await p.session(sid)).status, "failed"); @@ -258,7 +258,7 @@ describe("Claude: failures and recovery", () => { const cleared = await p.waitLog("cleared", (e) => e.ev === "clear"); await waitFor("new conversation id stored", async () => (await p.session(sid)).conversationId === cleared.newConversationId); assert.notEqual(before, cleared.newConversationId); - await p.waitStatus(sid, "waiting_input"); + await p.waitStatus(sid, "idle"); await runner.stopSession(db, sid); }); @@ -282,14 +282,14 @@ describe("Codex", () => { const mcpCall = await p.waitLog("codex reaches peppa MCP", (e) => e.ev === "mcp" && e.tool === "get_task"); assert.equal(mcpCall.isError, false); - const alert = await p.waitQuestion(sid, "attention"); - assert.match(alert.text, /какой фреймворк/); + // PEP-149: the end of a turn is a progress record, not a question to the PM. + await p.waitStatus(sid, "idle"); + assert.deepEqual(await p.pending(sid), []); const s = await p.session(sid); assert.equal(s.provider, "codex"); - assert.equal(s.status, "waiting_input"); assert.equal(s.conversationId, start.conversationId); - await runner.answerAndDeliver(db, alert.id, "Fastify", PM); + await runner.sendToSession(db, sid, "Fastify"); await p.waitLog("answer typed in", isPrompt("Fastify")); await runner.stopSession(db, sid); }); @@ -309,9 +309,9 @@ describe("Codex", () => { test("crash → resume uses `codex resume `", async () => { const p = await project({ turns: [[{ say: "Первый ход." }], [{ crash: 2 }]], resumeTurns: [[{ say: "Вернулся." }]] }); const sid = await p.start({ provider: "codex" }); - const alert = await p.waitQuestion(sid, "attention"); + await p.waitStatus(sid, "idle"); const thread = (await p.session(sid)).conversationId; - await runner.answerAndDeliver(db, alert.id, "продолжай", PM); + await runner.sendToSession(db, sid, "продолжай"); await p.waitLog("crashed", (e) => e.ev === "exit"); await waitFor("failed", async () => { await tick(); diff --git a/packages/testkit/test/claude-live.test.ts b/packages/testkit/test/claude-live.test.ts index 3cfce8a1..96d26177 100644 --- a/packages/testkit/test/claude-live.test.ts +++ b/packages/testkit/test/claude-live.test.ts @@ -9,7 +9,7 @@ import { join, resolve } from "node:path"; import { fileURLToPath } from "node:url"; import { after, describe, test } from "node:test"; import { events } from "@peppa/db"; -import { asc, eq } from "drizzle-orm"; +import { and, asc, eq } from "drizzle-orm"; import { core, db, project, runner, teardown, waitFor } from "./helpers.ts"; after(teardown); @@ -177,7 +177,7 @@ describe("Живой Claude Code: peppa-hook на снятых payload'ах", () await runner.stopSession(db, sid); }); - test("Stop: стори в работе → decision block; после двух — PM", async () => { + test("Stop: стори в работе → decision block; после двух — ход работы, PM не зовём", async () => { const p = await project({ turns: [[{ sleep: 60_000 }]] }); const sid = await p.start(); // The prompt hook resets auto_nudges; let it finish before the Stop hooks are counted. @@ -190,8 +190,10 @@ describe("Живой Claude Code: peppa-hook на снятых payload'ах", () assert.match(first.reason, new RegExp(p.taskKey)); assert.equal((await hook("stop", fixture("stop-after-block"), sid, s.generation)).decision, "block"); assert.equal(await hook("stop", fixture("stop-after-block"), sid, s.generation), null); - const q = await p.waitQuestion(sid, "attention"); - assert.equal(q.text, fixture("stop-after-block").last_assistant_message); + // PEP-149: the last reply becomes a progress record — the PM is not asked. + assert.deepEqual(await p.pending(sid), []); + const [progress] = await db.select().from(events).where(and(eq(events.sessionId, sid), eq(events.type, "progress"))); + assert.equal((progress!.payload as { text: string }).text, fixture("stop-after-block").last_assistant_message); await runner.stopSession(db, sid); }); }); diff --git a/packages/testkit/test/rotation.test.ts b/packages/testkit/test/rotation.test.ts index 020a0e4a..dd9bf13b 100644 --- a/packages/testkit/test/rotation.test.ts +++ b/packages/testkit/test/rotation.test.ts @@ -166,9 +166,9 @@ describe("Предохранители", () => { const p = await project({ turns: [[{ say: "работаю" }], [{ limit: { resetInSec: 3600, credential: "caplimA" } }]] }); await poolFor(p.key, [a.id, b.id]); const sid = await p.start(); - const q = await p.waitQuestion(sid, "attention"); + await p.waitStatus(sid, "idle"); for (let i = 0; i < runner.maxRotationsPerHour(); i++) await core.logSessionEvent(db, await sess(sid), runner.SWITCH_EVENT, { reason: "limit" }); - await runner.answerAndDeliver(db, q.id, "дальше", "web"); + await runner.sendToSession(db, sid, "дальше"); await p.waitStatus(sid, "rate_limited"); assert.equal((await sess(sid)).rotateReason, null); assert.match((await p.waitQuestion(sid, "attention")).text, /продолжит в \d\d:\d\d сам/); diff --git a/packages/testkit/test/sandbox-hosts.test.ts b/packages/testkit/test/sandbox-hosts.test.ts index 89c307af..97e55944 100644 --- a/packages/testkit/test/sandbox-hosts.test.ts +++ b/packages/testkit/test/sandbox-hosts.test.ts @@ -142,7 +142,7 @@ describe("PEP-17: агент в контейнере", () => { const p = await project({ turns: [[{ say: "ok" }]] }); const before = runs().length; const sid = await p.start(); - await p.waitQuestion(sid, "attention"); + await p.waitStatus(sid, "idle"); const s = await core.getSession(db, sid); assert.equal(s.container, null); assert.equal(s.host, null); @@ -193,7 +193,7 @@ describe("PEP-17: агент в контейнере", () => { await new Promise((r) => setTimeout(r, 1200)); // longer than one relay wait await runner.answerAndDeliver(db, q.id, "allow", "web"); await p.waitLog("permission allowed by hook", (e) => e.ev === "permission" && e.via === "hook" && e.behavior === "allow"); - await p.waitQuestion(sid, "attention"); + await p.waitStatus(sid, "idle"); // Stop hook through the relay with the transcript: tokens counted as for a local agent. assert.equal(core.usageTotals((await core.getSession(db, sid)).usage).total, 1500); assert.ok((await evs(sid, "turn_end")).length >= 1); @@ -300,7 +300,7 @@ describe("PEP-40: хосты раннеров", () => { const log = join(remoteWs, ".peppa", "mock-log.jsonl"); await waitFor("mcp from the host", async () => existsSync(log) && readFileSync(log, "utf8").includes('"tool":"report_progress","args":{"task":"')); assert.match(readFileSync(log, "utf8"), /"tool":"report_progress".*"isError":false/); - await p.waitQuestion(sid, "attention"); + await p.waitStatus(sid, "idle"); // PEP-9 over SSH: the frame comes from the host's pane. const frame = await new Promise((resolve, reject) => {