PEP-149: remaining old tests follow the new end-of-turn behaviour

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
Асель 2026-11-16 11:48:31 +05:00
parent 0a5eff6485
commit 5f738942e0
5 changed files with 20 additions and 18 deletions

View File

@ -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, тесты; проверка экранов; память проекта

View File

@ -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 <thread>`", 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();

View File

@ -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);
});
});

View File

@ -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 сам/);

View File

@ -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<string>((resolve, reject) => {