@@ -8,8 +8,12 @@ const MAX_MESSAGE_LENGTH = 500;
88const MAX_URL_LENGTH = 1024 ;
99const EXACT_TARGET_EVIDENCE_REUSE_POLICY = "exact-target-full-validation-v1" ;
1010const CHANGELOG_ONLY_EVIDENCE_REUSE_POLICY = "changelog-only-release-v1" ;
11+ const HARD_GH_TRANSPORT_PATTERN =
12+ / H T T P (?: 4 0 1 | 4 0 3 ) \b | B a d c r e d e n t i a l s | a u t h e n t i c a t i o n r e q u i r e d | n o t a u t h e n t i c a t e d | g h a u t h l o g i n | u n k n o w n (?: c o m m a n d | f l a g ) | U s a g e : g h \b | E N O E N T | E A C C E S / iu;
13+ const TRANSIENT_GH_TRANSPORT_PATTERN =
14+ / H T T P 4 2 9 \b | H T T P 5 [ 0 - 9 ] [ 0 - 9 ] \b | S e r v e r E r r o r | s e c o n d a r y r a t e l i m i t | A P I r a t e l i m i t | a b u s e d e t e c t i o n | e r r o r c o n n e c t i n g t o | c o n t e x t d e a d l i n e e x c e e d e d | c o n n e c t i o n r e s e t b y p e e r | c o n n e c t i o n r e f u s e d | T L S h a n d s h a k e t i m e o u t | i \/ o t i m e o u t | n e t w o r k i s u n r e a c h a b l e | u n e x p e c t e d E O F | E T I M E D O U T | E C O N N R E S E T | E A I _ A G A I N / iu;
1115
12- export const RELEASE_DECISION_STATES = Object . freeze ( [
16+ const RELEASE_DECISION_STATES = Object . freeze ( [
1317 "qualifying" ,
1418 "blocked_diagnostics_running" ,
1519 "passed" ,
@@ -70,6 +74,42 @@ const CHILD_SPECS = Object.freeze([
7074 } ,
7175] ) ;
7276
77+ function releaseGhTransportErrorText ( error ) {
78+ const values = [ error ] ;
79+ const seen = new Set ( ) ;
80+ const parts = [ ] ;
81+ while ( values . length > 0 ) {
82+ const value = values . shift ( ) ;
83+ if ( value && typeof value === "object" ) {
84+ if ( seen . has ( value ) ) {
85+ continue ;
86+ }
87+ seen . add ( value ) ;
88+ if ( value instanceof Error ) {
89+ parts . push ( value . name , value . message ) ;
90+ }
91+ for ( const key of [ "stderr" , "stdout" , "code" , "signal" , "cause" ] ) {
92+ if ( key in value && value [ key ] !== undefined ) {
93+ values . push ( value [ key ] ) ;
94+ }
95+ }
96+ continue ;
97+ }
98+ if ( value !== undefined && value !== null ) {
99+ parts . push ( String ( value ) ) ;
100+ }
101+ }
102+ return parts . join ( "\n" ) ;
103+ }
104+
105+ export function classifyReleaseGhTransportError ( error ) {
106+ const text = releaseGhTransportErrorText ( error ) ;
107+ if ( HARD_GH_TRANSPORT_PATTERN . test ( text ) ) {
108+ return "hard" ;
109+ }
110+ return TRANSIENT_GH_TRANSPORT_PATTERN . test ( text ) ? "transient" : "hard" ;
111+ }
112+
73113function stringValue ( value , fallback = "" ) {
74114 return typeof value === "string" ? value : fallback ;
75115}
@@ -193,7 +233,7 @@ function normalizedEvidenceReuse(evidenceReuse) {
193233 evidenceReuse . sourceManifest &&
194234 typeof evidenceReuse . sourceManifest === "object" &&
195235 ! Array . isArray ( evidenceReuse . sourceManifest )
196- ? JSON . parse ( JSON . stringify ( evidenceReuse . sourceManifest ) )
236+ ? structuredClone ( evidenceReuse . sourceManifest )
197237 : null ,
198238 } ;
199239}
@@ -356,7 +396,7 @@ function normalizeIssues(issues, fallbackKind) {
356396 . map ( ( issue ) => normalizeIssue ( issue , fallbackKind ) ) ;
357397}
358398
359- export function isReleaseCheckJobAdvisory ( { jobName, releaseProfile, workflowRef } ) {
399+ function isReleaseCheckJobAdvisory ( { jobName, releaseProfile, workflowRef } ) {
360400 if (
361401 jobName . startsWith ( "Run QA Lab parity lane (" ) ||
362402 jobName === "Run QA Lab parity report" ||
@@ -389,7 +429,7 @@ export function isReleaseCheckJobAdvisory({ jobName, releaseProfile, workflowRef
389429 ) ;
390430}
391431
392- export function failedJobsForPolicy ( child , releaseProfile , workflowRef ) {
432+ function failedJobsForPolicy ( child , releaseProfile , workflowRef ) {
393433 return child . jobs . filter ( ( job ) => {
394434 if (
395435 job . status !== "completed" ||
@@ -671,7 +711,8 @@ function validatePlan(value) {
671711 } ) ;
672712}
673713
674- export function validateReleaseStateArtifact ( payload , expected = { } , expectedMode ) {
714+ export function validateReleaseStateArtifact ( payload , expected , expectedMode ) {
715+ const expectedValues = expected ?? { } ;
675716 if ( ! payload || typeof payload !== "object" || Array . isArray ( payload ) ) {
676717 throw new Error ( "release state artifact is invalid" ) ;
677718 }
@@ -688,17 +729,20 @@ export function validateReleaseStateArtifact(payload, expected = {}, expectedMod
688729 ! / ^ [ a - f 0 - 9 ] { 64 } $ / u. test ( String ( payload . executionPlanSha256 ?? "" ) ) ||
689730 positiveInteger ( payload . parentRunAttempt ) === undefined ||
690731 positiveInteger ( payload . sourceParentRunAttempt ) === undefined ||
691- ( expected . parentRunId !== undefined &&
692- String ( payload . parentRunId ) !== String ( expected . parentRunId ) ) ||
693- ( expected . parentRunAttempt !== undefined &&
694- Number ( payload . parentRunAttempt ) !== Number ( expected . parentRunAttempt ) ) ||
695- ( expected . maxParentRunAttempt !== undefined &&
696- Number ( payload . parentRunAttempt ) > Number ( expected . maxParentRunAttempt ) ) ||
697- ( expected . workflowRef !== undefined && payload . workflowRef !== expected . workflowRef ) ||
698- ( expected . workflowSha !== undefined && payload . workflowSha !== expected . workflowSha ) ||
699- ( expected . targetSha !== undefined && payload . targetSha !== expected . targetSha ) ||
700- ( expected . releaseProfile !== undefined && payload . releaseProfile !== expected . releaseProfile ) ||
701- ( expected . rerunGroup !== undefined && payload . rerunGroup !== expected . rerunGroup )
732+ ( expectedValues . parentRunId !== undefined &&
733+ String ( payload . parentRunId ) !== String ( expectedValues . parentRunId ) ) ||
734+ ( expectedValues . parentRunAttempt !== undefined &&
735+ Number ( payload . parentRunAttempt ) !== Number ( expectedValues . parentRunAttempt ) ) ||
736+ ( expectedValues . maxParentRunAttempt !== undefined &&
737+ Number ( payload . parentRunAttempt ) > Number ( expectedValues . maxParentRunAttempt ) ) ||
738+ ( expectedValues . workflowRef !== undefined &&
739+ payload . workflowRef !== expectedValues . workflowRef ) ||
740+ ( expectedValues . workflowSha !== undefined &&
741+ payload . workflowSha !== expectedValues . workflowSha ) ||
742+ ( expectedValues . targetSha !== undefined && payload . targetSha !== expectedValues . targetSha ) ||
743+ ( expectedValues . releaseProfile !== undefined &&
744+ payload . releaseProfile !== expectedValues . releaseProfile ) ||
745+ ( expectedValues . rerunGroup !== undefined && payload . rerunGroup !== expectedValues . rerunGroup )
702746 ) {
703747 throw new Error ( "release state artifact binding is invalid" ) ;
704748 }
@@ -806,17 +850,15 @@ function verifyStateChildren(state, executionPlan, label) {
806850 if ( snapshot . errors . length > 0 ) {
807851 throw new Error ( `${ label } child contains collector errors: ${ child . key } ` ) ;
808852 }
809- return {
810- ...child ,
811- ...snapshot ,
853+ return Object . assign ( { } , child , snapshot , {
812854 jobs : snapshot . timing . jobs . map ( ( job ) => ( {
813855 conclusion : job . conclusion ,
814856 html_url : job . url ,
815857 name : job . name ,
816858 status : job . status ,
817859 url : job . url ,
818860 } ) ) ,
819- } ;
861+ } ) ;
820862 } ) ;
821863 const recomputed = classifyReleaseSnapshot ( {
822864 children : snapshots ,
@@ -929,8 +971,8 @@ function issueSummary(prefix, issue) {
929971 return `- ${ prefix } : ${ label } ${ result } ${ url } ` ;
930972}
931973
932- export function releaseStateDetailLines ( payload , maxItems = MAX_SUMMARY_ISSUES ) {
933- const normalizedMax = Math . max ( 1 , Math . min ( Number ( maxItems ) || MAX_SUMMARY_ISSUES , 10 ) ) ;
974+ function releaseStateDetailLines ( payload , maxItems = MAX_SUMMARY_ISSUES ) {
975+ const normalizedMax = Math . max ( 1 , Math . min ( maxItems || MAX_SUMMARY_ISSUES , 10 ) ) ;
934976 const lines = [ ] ;
935977 for ( const blocker of payload . blockers . slice ( 0 , normalizedMax ) ) {
936978 lines . push ( issueSummary ( "Blocker" , blocker ) ) ;
0 commit comments