test: expand memory flush coverage

This commit is contained in:
Peter Steinberger
2026-01-12 07:39:41 +00:00
parent d17fc7e448
commit e1150f1b93
2 changed files with 447 additions and 1 deletions

View File

@@ -56,6 +56,17 @@ describe("shouldRunMemoryFlush", () => {
).toBe(false);
});
it("skips when entry is missing", () => {
expect(
shouldRunMemoryFlush({
entry: undefined,
contextWindowTokens: 16_000,
reserveTokensFloor: 1_000,
softThresholdTokens: DEFAULT_MEMORY_FLUSH_SOFT_TOKENS,
}),
).toBe(false);
});
it("skips when under threshold", () => {
expect(
shouldRunMemoryFlush({
@@ -67,6 +78,17 @@ describe("shouldRunMemoryFlush", () => {
).toBe(false);
});
it("triggers at the threshold boundary", () => {
expect(
shouldRunMemoryFlush({
entry: { totalTokens: 85 },
contextWindowTokens: 100,
reserveTokensFloor: 10,
softThresholdTokens: 5,
}),
).toBe(true);
});
it("skips when already flushed for current compaction count", () => {
expect(
shouldRunMemoryFlush({