@@ -32,8 +32,9 @@ const RELEASE_EVIDENCE_VERIFIER_PATHS = [
3232] ;
3333const GH_READ_TIMEOUT_MS = 60_000 ;
3434export const FULL_RELEASE_WAIT_TIMEOUT_MINUTES = 720 ;
35- export const FULL_RELEASE_GITHUB_POLL_INTERVAL_MS = 15 * 60_000 ;
36- const FULL_RELEASE_RUN_DISCOVERY_ATTEMPTS = 2 ;
35+ export const FULL_RELEASE_GITHUB_POLL_INTERVAL_MS = 2 * 60_000 ;
36+ const FULL_RELEASE_PROGRESS_INTERVAL_MS = 15 * 60_000 ;
37+ const FULL_RELEASE_RUN_DISCOVERY_DELAYS_MS = [ 30_000 , 60_000 , 120_000 ] ;
3738const RELEASE_DECISION_FILE = "full-release-decision.json" ;
3839const GH_READ_OPTIONS = {
3940 encoding : "utf8" ,
@@ -678,12 +679,41 @@ export function tryReadReleaseDecision(
678679 }
679680}
680681
682+ function releaseDecisionAvailable ( parentRunId : string , parentRunAttempt : number ) {
683+ const artifactName = `full-release-decision-${ parentRunId } -${ parentRunAttempt } ` ;
684+ try {
685+ const response : unknown = JSON . parse (
686+ execGhRead (
687+ [
688+ "api" ,
689+ `repos/openclaw/openclaw/actions/runs/${ parentRunId } /artifacts?per_page=100&name=${ artifactName } ` ,
690+ ] ,
691+ { ...GH_READ_OPTIONS , stdio : [ "ignore" , "pipe" , "pipe" ] } ,
692+ ) ,
693+ ) ;
694+ if ( ! isJsonRecord ( response ) || ! Array . isArray ( response . artifacts ) ) {
695+ throw new Error ( `Full Release Validation run ${ parentRunId } returned invalid artifacts` ) ;
696+ }
697+ return response . artifacts . some (
698+ ( artifact ) =>
699+ isJsonRecord ( artifact ) && artifact . name === artifactName && artifact . expired === false ,
700+ ) ;
701+ } catch ( error ) {
702+ if ( classifyReleaseGhTransportError ( error ) !== "transient" ) {
703+ throw error ;
704+ }
705+ console . warn ( `Release Decision metadata unavailable this poll; retrying: ${ String ( error ) } ` ) ;
706+ return false ;
707+ }
708+ }
709+
681710function waitForWorkflowRun ( parentRunId : string , workflowSha : string ) {
682711 let lastSummary = "" ;
683712 let consecutiveErrors = 0 ;
684713 const startedAt = Date . now ( ) ;
685714 const deadline = startedAt + FULL_RELEASE_WAIT_TIMEOUT_MINUTES * 60_000 ;
686- let nextProgressAt = startedAt + FULL_RELEASE_GITHUB_POLL_INTERVAL_MS ;
715+ let nextProgressAt = startedAt + FULL_RELEASE_PROGRESS_INTERVAL_MS ;
716+ let decision : { attempt : number ; state : "unavailable" | "ready" | "passed" } | undefined ;
687717 while ( Date . now ( ) < deadline ) {
688718 let suite : Record < string , unknown > | undefined ;
689719 try {
@@ -706,15 +736,30 @@ function waitForWorkflowRun(parentRunId: string, workflowSha: string) {
706736 lastSummary = summary ;
707737 }
708738 if ( suite ) {
709- const releaseDecision = tryReadReleaseDecision (
710- parentRunId ,
711- requiredPositiveInteger ( suite . run_attempt , "parent run attempt" ) ,
712- workflowSha ,
713- ) ;
714- if ( releaseDecision && releaseDecisionStopsForeground ( releaseDecision . state ) ) {
715- throw new Error (
716- `${ formatReleaseStateOutcome ( releaseDecision ) } \nhttps://github.com/openclaw/openclaw/actions/runs/${ parentRunId } ` ,
717- ) ;
739+ const attempt = requiredPositiveInteger ( suite . run_attempt , "parent run attempt" ) ;
740+ if ( decision ?. attempt !== attempt ) {
741+ decision = { attempt, state : "unavailable" } ;
742+ }
743+ // Metadata is only a readiness hint. Once advertised, keep trying the
744+ // authoritative download across status regressions until this attempt validates.
745+ if (
746+ decision . state === "unavailable" &&
747+ ( suite . status === "completed" || releaseDecisionAvailable ( parentRunId , attempt ) )
748+ ) {
749+ decision . state = "ready" ;
750+ }
751+ if ( decision . state === "ready" ) {
752+ const releaseDecision = tryReadReleaseDecision ( parentRunId , attempt , workflowSha ) ;
753+ if ( releaseDecision && releaseDecisionStopsForeground ( releaseDecision . state ) ) {
754+ throw new Error (
755+ `${ formatReleaseStateOutcome ( releaseDecision ) } \nhttps://github.com/openclaw/openclaw/actions/runs/${ parentRunId } ` ,
756+ ) ;
757+ }
758+ // The workflow uploads one immutable decision per attempt; final success
759+ // still requires the parent's terminal conclusion and strict evidence verifier.
760+ if ( releaseDecision ?. state === "passed" ) {
761+ decision . state = "passed" ;
762+ }
718763 }
719764 }
720765 if ( suite ?. status === "completed" && stringValue ( suite . conclusion ) ) {
@@ -741,7 +786,7 @@ function waitForWorkflowRun(parentRunId: string, workflowSha: string) {
741786 `Parent run progress query failed: ${ error instanceof Error ? error . message : String ( error ) } ` ,
742787 ) ;
743788 }
744- nextProgressAt += FULL_RELEASE_GITHUB_POLL_INTERVAL_MS ;
789+ nextProgressAt = now + FULL_RELEASE_PROGRESS_INTERVAL_MS ;
745790 }
746791 const remainingMs = deadline - Date . now ( ) ;
747792 if ( remainingMs <= 0 ) {
@@ -980,17 +1025,17 @@ function main() {
9801025 }
9811026 parentRunId = collectRunId ( dispatchOutput ) ;
9821027 if ( ! parentRunId && ! args . dryRun ) {
983- for ( let attempt = 0 ; attempt < FULL_RELEASE_RUN_DISCOVERY_ATTEMPTS ; attempt += 1 ) {
1028+ for ( let attempt = 0 ; attempt <= FULL_RELEASE_RUN_DISCOVERY_DELAYS_MS . length ; attempt += 1 ) {
9841029 parentRunId = findLatestRunId ( branch , workflowSha ) ;
9851030 if ( parentRunId ) {
9861031 break ;
9871032 }
988- if ( attempt + 1 < FULL_RELEASE_RUN_DISCOVERY_ATTEMPTS ) {
1033+ if ( attempt < FULL_RELEASE_RUN_DISCOVERY_DELAYS_MS . length ) {
9891034 Atomics . wait (
9901035 new Int32Array ( new SharedArrayBuffer ( 4 ) ) ,
9911036 0 ,
9921037 0 ,
993- FULL_RELEASE_GITHUB_POLL_INTERVAL_MS ,
1038+ FULL_RELEASE_RUN_DISCOVERY_DELAYS_MS [ attempt ] ,
9941039 ) ;
9951040 }
9961041 }
0 commit comments