Align tests with gm-first context projection and retry snapshot semantics.

History synthesis expects world-simulator slot; retryStuckRun compares artifact count against checkpoint baseline.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-08-25 01:02:23 +08:00
co-authored by Cursor
parent 6d4dfd0d89
commit 123c44ec49
2 changed files with 16 additions and 12 deletions
+11 -9
View File
@@ -88,27 +88,29 @@ describe("flat context order", () => {
const doc = synthesizeContextOrderFromWorkers(
[
{
ref: "narrator",
name: "叙事转述",
ref: "world-simulator",
name: "主世界层",
context: {
static: ["设计.叙事指南"],
dynamic: ["运行.本轮.裁决", "用户.最新输入"],
dynamic: ["用户.最新输入"],
},
},
],
{ gm: true, narrator: true, perspective: false },
)!;
expect(doc.slots[0]!.inserts.some((i) => i.ref === "对话.历史")).toBe(true);
const gmSlot = doc.slots.find((s) => s.ref === "world-simulator")!;
expect(gmSlot.inserts.some((i) => i.ref === "对话.历史")).toBe(true);
const histIdx = doc.slots[0]!.inserts.findIndex((i) => i.ref === "对话.历史");
const histIdx = gmSlot.inserts.findIndex((i) => i.ref === "对话.历史");
const moved = applyContextOrderEdit(doc, {
action: "set_anchor",
slotRef: "narrator",
index: doc.slots[0]!.inserts.length - 1,
slotRef: "world-simulator",
index: gmSlot.inserts.length - 1,
anchor: "pre_history",
});
const newHist = moved.slots[0]!.inserts.findIndex((i) => i.ref === "对话.历史");
const lastUser = moved.slots[0]!.inserts.findIndex(
const movedGm = moved.slots.find((s) => s.ref === "world-simulator")!;
const newHist = movedGm.inserts.findIndex((i) => i.ref === "对话.历史");
const lastUser = movedGm.inserts.findIndex(
(i) => i.ref === "用户.最新输入",
);
expect(lastUser).toBeLessThan(newHist);
+5 -3
View File
@@ -108,7 +108,7 @@ describe("phase runtime", () => {
);
const snap = runtime.getLastWorkerRunSnapshot();
expect(snap?.workerId).toBe("design-flow");
const artifactsBefore = runtime.getSession().artifacts.length;
const artifactsAtSnapshot = snap!.runtimeSession.artifacts.length;
const session = runtime.getSession();
session.phase = "running";
@@ -116,10 +116,12 @@ describe("phase runtime", () => {
session.currentWorkerId = "design-flow";
await runtime.retryStuckRun();
expect(runtime.getSession().artifacts.length).toBeGreaterThan(artifactsBefore);
expect(runtime.getSession().artifacts.length).toBeGreaterThan(
artifactsAtSnapshot,
);
expect(
runtime.getSession().artifacts.filter((a) => a.workerId === "design-flow").length,
).toBeGreaterThanOrEqual(2);
).toBeGreaterThanOrEqual(1);
});
it("retryStuckRun throws when nothing is running", async () => {