@@ -3934,6 +3934,64 @@ test("state shard imports reject producer provenance outside the authenticated w
39343934 ) ;
39353935} ) ;
39363936
3937+ test ( "state shard imports accept retained prior attempts only through an explicit upper bound" , async ( ) => {
3938+ const root = tempRoot ( ) ;
3939+ const source = trustedChildRoot ( root , "source" ) ;
3940+ const destination = trustedChildRoot ( root , "destination" ) ;
3941+ const attemptOneEnv = workflowEnv ( { GITHUB_RUN_ATTEMPT : "1" } ) ;
3942+ const event = recordReview ( root , attemptOneEnv ) ;
3943+ assert . ok ( event ) ;
3944+ await flushWorkflowActionEvents ( root , {
3945+ env : attemptOneEnv ,
3946+ outputRoot : source ,
3947+ } ) ;
3948+ const expectedIdentity = {
3949+ repository : event . producer . repository ,
3950+ sha : event . producer . sha ,
3951+ workflow : event . producer . workflow ,
3952+ job : event . producer . job ,
3953+ runId : event . producer . run_id ,
3954+ } ;
3955+
3956+ assert . throws (
3957+ ( ) =>
3958+ importActionEventShards ( source , destination , {
3959+ expectedProducer : { ...expectedIdentity , runAttempt : 2 } ,
3960+ } ) ,
3961+ / p r o d u c e r p r o v e n a n c e m i s m a t c h f o r r u n _ a t t e m p t : e x p e c t e d 2 , g o t 1 / ,
3962+ ) ;
3963+ assert . equal (
3964+ importActionEventShards ( source , destination , {
3965+ expectedProducer : { ...expectedIdentity , maxRunAttempt : 2 } ,
3966+ } ) . created ,
3967+ 1 ,
3968+ ) ;
3969+
3970+ const futureRoot = tempRoot ( ) ;
3971+ const futureSource = trustedChildRoot ( futureRoot , "source" ) ;
3972+ const futureDestination = trustedChildRoot ( futureRoot , "destination" ) ;
3973+ const attemptThreeEnv = workflowEnv ( { GITHUB_RUN_ATTEMPT : "3" } ) ;
3974+ recordReview ( futureRoot , attemptThreeEnv ) ;
3975+ await flushWorkflowActionEvents ( futureRoot , {
3976+ env : attemptThreeEnv ,
3977+ outputRoot : futureSource ,
3978+ } ) ;
3979+ assert . throws (
3980+ ( ) =>
3981+ importActionEventShards ( futureSource , futureDestination , {
3982+ expectedProducer : { ...expectedIdentity , maxRunAttempt : 2 } ,
3983+ } ) ,
3984+ / p r o d u c e r p r o v e n a n c e m i s m a t c h f o r r u n _ a t t e m p t : e x p e c t e d a t m o s t 2 , g o t 3 / ,
3985+ ) ;
3986+ assert . throws (
3987+ ( ) =>
3988+ importActionEventShards ( source , trustedChildRoot ( root , "invalid-constraint" ) , {
3989+ expectedProducer : { ...expectedIdentity , maxRunAttempt : Number . NaN } ,
3990+ } ) ,
3991+ / r e q u i r e s o n e p o s i t i v e r u n a t t e m p t c o n s t r a i n t / ,
3992+ ) ;
3993+ } ) ;
3994+
39373995test ( "state shard imports validate duplicate and causal integrity across shard parts" , ( ) => {
39383996 const root = tempRoot ( ) ;
39393997 const event = recordReview ( root ) ;
0 commit comments