@@ -294,6 +294,101 @@ test("content digest busts when bounded PR check state changes", () => {
294294 assert . notEqual ( passing , failing ) ;
295295} ) ;
296296
297+ test ( "content digest ignores duplicate compacted PR check runs" , ( ) => {
298+ const pull = item ( { kind : "pull_request" , number : 200 } ) ;
299+ const notify = {
300+ name : "notify" ,
301+ status : "completed" ,
302+ conclusion : "success" ,
303+ app : "github-actions" ,
304+ } ;
305+ const once = itemContentDigestForTest (
306+ pull ,
307+ pullContext ( {
308+ pullChecks : {
309+ complete : true ,
310+ checkRuns : [ notify ] ,
311+ checkRunsTruncated : false ,
312+ statuses : [ ] ,
313+ statusesTruncated : false ,
314+ } ,
315+ } ) ,
316+ ) ;
317+ const repeated = itemContentDigestForTest (
318+ pull ,
319+ pullContext ( {
320+ pullChecks : {
321+ complete : true ,
322+ checkRuns : [ notify , notify ] ,
323+ checkRunsTruncated : false ,
324+ statuses : [ ] ,
325+ statusesTruncated : false ,
326+ } ,
327+ } ) ,
328+ ) ;
329+
330+ assert . equal ( once , repeated ) ;
331+ } ) ;
332+
333+ test ( "content digest keeps check runs that differ only in name or app" , ( ) => {
334+ const pull = item ( { kind : "pull_request" , number : 200 } ) ;
335+ const check = {
336+ name : "smoke" ,
337+ status : "completed" ,
338+ conclusion : "success" ,
339+ app : "github-actions" ,
340+ } ;
341+ const digest = ( checkRuns ) =>
342+ itemContentDigestForTest (
343+ pull ,
344+ pullContext ( {
345+ pullChecks : {
346+ complete : true ,
347+ checkRuns,
348+ checkRunsTruncated : false ,
349+ statuses : [ ] ,
350+ statusesTruncated : false ,
351+ } ,
352+ } ) ,
353+ ) ;
354+
355+ const alone = digest ( [ check ] ) ;
356+ const byName = digest ( [ check , { ...check , name : "smoke (windows)" } ] ) ;
357+ const byApp = digest ( [ check , { ...check , app : "blacksmith-sh" } ] ) ;
358+
359+ assert . notEqual ( alone , byName ) ;
360+ assert . notEqual ( alone , byApp ) ;
361+ assert . notEqual ( byName , byApp ) ;
362+ } ) ;
363+
364+ test ( "content digest busts when one of several repeated check runs newly fails" , ( ) => {
365+ const pull = item ( { kind : "pull_request" , number : 200 } ) ;
366+ const notify = {
367+ name : "notify" ,
368+ status : "completed" ,
369+ conclusion : "success" ,
370+ app : "github-actions" ,
371+ } ;
372+ const digest = ( checkRuns ) =>
373+ itemContentDigestForTest (
374+ pull ,
375+ pullContext ( {
376+ pullChecks : {
377+ complete : true ,
378+ checkRuns,
379+ checkRunsTruncated : false ,
380+ statuses : [ ] ,
381+ statusesTruncated : false ,
382+ } ,
383+ } ) ,
384+ ) ;
385+
386+ const allPassing = digest ( [ notify , notify , notify ] ) ;
387+ const oneFailing = digest ( [ notify , notify , { ...notify , conclusion : "failure" } ] ) ;
388+
389+ assert . notEqual ( allPassing , oneFailing ) ;
390+ } ) ;
391+
297392test ( "review comment revision covers comments outside the bounded prompt window" , ( ) => {
298393 const comments = Array . from ( { length : 81 } , ( _ , index ) => ( {
299394 id : index + 1 ,
@@ -353,6 +448,48 @@ test("cache hits when content is unchanged, fresh, complete, and policy matches"
353448 assert . equal ( cacheHit ( ) , true ) ;
354449} ) ;
355450
451+ test ( "cache hits after an equivalent check run is repeated on an unchanged head" , ( ) => {
452+ const pull = item ( { kind : "pull_request" , number : 200 } ) ;
453+ const notify = {
454+ name : "notify" ,
455+ status : "completed" ,
456+ conclusion : "success" ,
457+ app : "github-actions" ,
458+ } ;
459+ const priorDigest = itemContentDigestForTest (
460+ pull ,
461+ pullContext ( {
462+ pullChecks : {
463+ complete : true ,
464+ checkRuns : [ notify ] ,
465+ checkRunsTruncated : false ,
466+ statuses : [ ] ,
467+ statusesTruncated : false ,
468+ } ,
469+ } ) ,
470+ ) ;
471+ const currentDigest = itemContentDigestForTest (
472+ pull ,
473+ pullContext ( {
474+ pullChecks : {
475+ complete : true ,
476+ checkRuns : [ notify , notify ] ,
477+ checkRunsTruncated : false ,
478+ statuses : [ ] ,
479+ statusesTruncated : false ,
480+ } ,
481+ } ) ,
482+ ) ;
483+
484+ assert . equal (
485+ cacheHit ( {
486+ review : freshReview ( { contentDigest : priorDigest } ) ,
487+ contentDigest : currentDigest ,
488+ } ) ,
489+ true ,
490+ ) ;
491+ } ) ;
492+
356493test ( "cache misses when the content digest differs" , ( ) => {
357494 assert . equal ( cacheHit ( { contentDigest : "digest-2" } ) , false ) ;
358495} ) ;
0 commit comments