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:
@@ -88,27 +88,29 @@ describe("flat context order", () => {
|
|||||||
const doc = synthesizeContextOrderFromWorkers(
|
const doc = synthesizeContextOrderFromWorkers(
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
ref: "narrator",
|
ref: "world-simulator",
|
||||||
name: "叙事转述",
|
name: "主世界层",
|
||||||
context: {
|
context: {
|
||||||
static: ["设计.叙事指南"],
|
static: ["设计.叙事指南"],
|
||||||
dynamic: ["运行.本轮.裁决", "用户.最新输入"],
|
dynamic: ["用户.最新输入"],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
{ gm: true, narrator: true, perspective: false },
|
{ 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, {
|
const moved = applyContextOrderEdit(doc, {
|
||||||
action: "set_anchor",
|
action: "set_anchor",
|
||||||
slotRef: "narrator",
|
slotRef: "world-simulator",
|
||||||
index: doc.slots[0]!.inserts.length - 1,
|
index: gmSlot.inserts.length - 1,
|
||||||
anchor: "pre_history",
|
anchor: "pre_history",
|
||||||
});
|
});
|
||||||
const newHist = moved.slots[0]!.inserts.findIndex((i) => i.ref === "对话.历史");
|
const movedGm = moved.slots.find((s) => s.ref === "world-simulator")!;
|
||||||
const lastUser = moved.slots[0]!.inserts.findIndex(
|
const newHist = movedGm.inserts.findIndex((i) => i.ref === "对话.历史");
|
||||||
|
const lastUser = movedGm.inserts.findIndex(
|
||||||
(i) => i.ref === "用户.最新输入",
|
(i) => i.ref === "用户.最新输入",
|
||||||
);
|
);
|
||||||
expect(lastUser).toBeLessThan(newHist);
|
expect(lastUser).toBeLessThan(newHist);
|
||||||
|
|||||||
@@ -108,7 +108,7 @@ describe("phase runtime", () => {
|
|||||||
);
|
);
|
||||||
const snap = runtime.getLastWorkerRunSnapshot();
|
const snap = runtime.getLastWorkerRunSnapshot();
|
||||||
expect(snap?.workerId).toBe("design-flow");
|
expect(snap?.workerId).toBe("design-flow");
|
||||||
const artifactsBefore = runtime.getSession().artifacts.length;
|
const artifactsAtSnapshot = snap!.runtimeSession.artifacts.length;
|
||||||
|
|
||||||
const session = runtime.getSession();
|
const session = runtime.getSession();
|
||||||
session.phase = "running";
|
session.phase = "running";
|
||||||
@@ -116,10 +116,12 @@ describe("phase runtime", () => {
|
|||||||
session.currentWorkerId = "design-flow";
|
session.currentWorkerId = "design-flow";
|
||||||
|
|
||||||
await runtime.retryStuckRun();
|
await runtime.retryStuckRun();
|
||||||
expect(runtime.getSession().artifacts.length).toBeGreaterThan(artifactsBefore);
|
expect(runtime.getSession().artifacts.length).toBeGreaterThan(
|
||||||
|
artifactsAtSnapshot,
|
||||||
|
);
|
||||||
expect(
|
expect(
|
||||||
runtime.getSession().artifacts.filter((a) => a.workerId === "design-flow").length,
|
runtime.getSession().artifacts.filter((a) => a.workerId === "design-flow").length,
|
||||||
).toBeGreaterThanOrEqual(2);
|
).toBeGreaterThanOrEqual(1);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("retryStuckRun throws when nothing is running", async () => {
|
it("retryStuckRun throws when nothing is running", async () => {
|
||||||
|
|||||||
Reference in New Issue
Block a user