@@ -262,7 +262,7 @@ describe("shouldRunMemoryFlush", () => {
262262 it ( "requires totalTokens and threshold" , ( ) => {
263263 expect (
264264 shouldRunMemoryFlush ( {
265- entry : { totalTokens : 0 } ,
265+ entry : { totalTokens : 0 , totalTokensFresh : true , totalTokensVersion : 1 } ,
266266 contextWindowTokens : 16_000 ,
267267 reserveTokensFloor : 20_000 ,
268268 softThresholdTokens : 4_000 ,
@@ -284,7 +284,7 @@ describe("shouldRunMemoryFlush", () => {
284284 it ( "skips when under threshold" , ( ) => {
285285 expect (
286286 shouldRunMemoryFlush ( {
287- entry : { totalTokens : 10_000 } ,
287+ entry : { totalTokens : 10_000 , totalTokensFresh : true , totalTokensVersion : 1 } ,
288288 contextWindowTokens : 100_000 ,
289289 reserveTokensFloor : 20_000 ,
290290 softThresholdTokens : 10_000 ,
@@ -295,7 +295,7 @@ describe("shouldRunMemoryFlush", () => {
295295 it ( "triggers at the threshold boundary" , ( ) => {
296296 expect (
297297 shouldRunMemoryFlush ( {
298- entry : { totalTokens : 85 } ,
298+ entry : { totalTokens : 85 , totalTokensFresh : true , totalTokensVersion : 1 } ,
299299 contextWindowTokens : 100 ,
300300 reserveTokensFloor : 10 ,
301301 softThresholdTokens : 5 ,
@@ -308,6 +308,8 @@ describe("shouldRunMemoryFlush", () => {
308308 shouldRunMemoryFlush ( {
309309 entry : {
310310 totalTokens : 90_000 ,
311+ totalTokensFresh : true ,
312+ totalTokensVersion : 1 ,
311313 compactionCount : 2 ,
312314 memoryFlush : { kind : "succeeded" , compactionCount : 2 } ,
313315 } ,
@@ -321,7 +323,12 @@ describe("shouldRunMemoryFlush", () => {
321323 it ( "runs when above threshold and not flushed" , ( ) => {
322324 expect (
323325 shouldRunMemoryFlush ( {
324- entry : { totalTokens : 96_000 , compactionCount : 1 } ,
326+ entry : {
327+ totalTokens : 96_000 ,
328+ totalTokensFresh : true ,
329+ totalTokensVersion : 1 ,
330+ compactionCount : 1 ,
331+ } ,
325332 contextWindowTokens : 100_000 ,
326333 reserveTokensFloor : 5_000 ,
327334 softThresholdTokens : 2_000 ,
@@ -337,14 +344,23 @@ describe("shouldRunMemoryFlush", () => {
337344 } ;
338345
339346 for ( const entry of [
340- { totalTokens : 95_000 , compactionCount : 1 } ,
341347 {
342348 totalTokens : 95_000 ,
349+ totalTokensFresh : true ,
350+ totalTokensVersion : 1 as const ,
351+ compactionCount : 1 ,
352+ } ,
353+ {
354+ totalTokens : 95_000 ,
355+ totalTokensFresh : true ,
356+ totalTokensVersion : 1 as const ,
343357 compactionCount : 2 ,
344358 memoryFlush : { kind : "succeeded" as const , compactionCount : 1 } ,
345359 } ,
346360 {
347361 totalTokens : 95_000 ,
362+ totalTokensFresh : true ,
363+ totalTokensVersion : 1 as const ,
348364 compactionCount : 3 ,
349365 memoryFlush : { kind : "succeeded" as const , compactionCount : 2 } ,
350366 } ,
0 commit comments