@@ -638,6 +638,64 @@ describe("external firmware bundle staging", () => {
638638 ) . rejects . toThrow ( ) ;
639639 } ) ;
640640
641+ it ( "revalidates only an exact previously activated public staged release" , async ( ) => {
642+ const fixture = createFirmwareReleaseFixture ( {
643+ deployment : "public" ,
644+ accessControlled : false ,
645+ hilStatus : "passed" ,
646+ } ) ;
647+ const bundleDirectory = await temporaryDirectory (
648+ "preserved-public-source" ,
649+ ) ;
650+ const stagedRoot = await temporaryDirectory ( "preserved-public-staged" ) ;
651+ await writeExternalBundle ( bundleDirectory , fixture ) ;
652+ const descriptor = await stageFixture ( {
653+ accessControlled : false ,
654+ bundleDirectory,
655+ deployment : "public" ,
656+ outputDirectory : stagedRoot ,
657+ } ) ;
658+
659+ const stagingModule =
660+ ( await import ( "../../scripts/stage-firmware-release" ) ) as unknown as {
661+ validatePreservedPublicFirmwareRelease ?: (
662+ stagedRoot : string ,
663+ options : {
664+ releaseValidator : typeof acceptSyntheticFixture ;
665+ } ,
666+ ) => Promise < typeof descriptor > ;
667+ } ;
668+ const validatePreserved =
669+ stagingModule . validatePreservedPublicFirmwareRelease ;
670+ expect ( validatePreserved ) . toBeTypeOf ( "function" ) ;
671+ if ( ! validatePreserved ) {
672+ return ;
673+ }
674+
675+ await expect (
676+ validatePreserved ( stagedRoot , {
677+ releaseValidator : acceptSyntheticFixture ,
678+ } ) ,
679+ ) . resolves . toEqual ( descriptor ) ;
680+
681+ const selectionPath = join (
682+ stagedRoot ,
683+ ".pyble-firmware-release-selection.json" ,
684+ ) ;
685+ const selection = JSON . parse ( await readFile ( selectionPath , "utf8" ) ) as {
686+ deployment : string ;
687+ hilStatus : string ;
688+ } ;
689+ selection . deployment = "candidate" ;
690+ selection . hilStatus = "pending" ;
691+ await writeFile ( selectionPath , `${ JSON . stringify ( selection , null , 2 ) } \n` ) ;
692+ await expect (
693+ validatePreserved ( stagedRoot , {
694+ releaseValidator : acceptSyntheticFixture ,
695+ } ) ,
696+ ) . rejects . toThrow ( / p r e v i o u s l y a c t i v a t e d | p u b l i c | p a s s e d / i) ;
697+ } ) ;
698+
641699 it ( "requires explicit published-GitHub evidence with byte equality before public activation" , async ( ) => {
642700 const fixture = createFirmwareReleaseFixture ( ) ;
643701 const bundleDirectory = await temporaryDirectory (
0 commit comments