Phase 15: add kept-window tests for skill-reinject:inject entries
Verify inject custom messages count as present in kept slice and are ignored when compaction firstKeptEntryId starts after them. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -42,6 +42,18 @@ function compactionEntry(id: string, firstKeptEntryId: string): SessionEntry {
|
||||
} as SessionEntry;
|
||||
}
|
||||
|
||||
function reinjectCustomMessage(id: string, content: string): SessionEntry {
|
||||
return {
|
||||
type: "custom_message",
|
||||
id,
|
||||
parentId: null,
|
||||
timestamp: ts,
|
||||
customType: "skill-reinject:inject",
|
||||
content,
|
||||
display: true,
|
||||
} as SessionEntry;
|
||||
}
|
||||
|
||||
const skillBlock = (name: string) =>
|
||||
`<skill name="${name}" location="/skills/${name}/SKILL.md">\nbody\n</skill>`;
|
||||
|
||||
@@ -94,6 +106,32 @@ describe("skillsPresentInKeptWindow", () => {
|
||||
expect(skillsPresentInKeptWindow([userMessage("k1", skillBlock("alpha"))], [])).toEqual(new Set());
|
||||
expect(skillsPresentInKeptWindow([], ["alpha", "beta"])).toEqual(new Set());
|
||||
});
|
||||
|
||||
it("detects skill blocks in skill-reinject:inject custom messages", () => {
|
||||
const kept = [reinjectCustomMessage("inj1", skillBlock("beta"))];
|
||||
expect(skillsPresentInKeptWindow(kept, ["alpha", "beta"])).toEqual(new Set(["beta"]));
|
||||
});
|
||||
|
||||
it("ignores reinject custom outside kept slice when slicing branch", () => {
|
||||
const branch: SessionEntry[] = [
|
||||
reinjectCustomMessage("inj0", skillBlock("alpha")),
|
||||
userMessage("e2", "kept start"),
|
||||
compactionEntry("e4", "e2"),
|
||||
];
|
||||
const kept = getKeptEntries(branch, "e2");
|
||||
expect(skillsPresentInKeptWindow(kept, ["alpha", "beta"])).toEqual(new Set());
|
||||
expect(skillsPresentInKeptWindow(kept, ["alpha"])).toEqual(new Set());
|
||||
});
|
||||
|
||||
it("counts reinject custom inside kept slice", () => {
|
||||
const branch: SessionEntry[] = [
|
||||
userMessage("e2", "kept start"),
|
||||
reinjectCustomMessage("inj1", skillBlock("alpha")),
|
||||
compactionEntry("e4", "e2"),
|
||||
];
|
||||
const kept = getKeptEntries(branch, "e2");
|
||||
expect(skillsPresentInKeptWindow(kept, ["alpha", "beta"])).toEqual(new Set(["alpha"]));
|
||||
});
|
||||
});
|
||||
|
||||
describe("filterSkillsNeedingReinjectByKept", () => {
|
||||
|
||||
Reference in New Issue
Block a user