@@ -24,6 +24,7 @@ import { useAutoCleanupTempDirTracker } from "../helpers/temp-dir.js";
2424const NOW = Date . parse ( "2026-08-28T12:00:00Z" ) ;
2525const EXPIRES_AT = "2026-09-04T12:00:00Z" ;
2626const REPOSITORY = "openclaw/openclaw" ;
27+ const CONTRACT_SCRIPT = resolve ( "scripts/full-release-candidate-contract.mjs" ) ;
2728const SCRIPT = resolve ( "scripts/full-release-candidate-reuse.mjs" ) ;
2829const WORKFLOW_PATH = ".github/workflows/full-release-validation.yml" ;
2930const tempDirs = useAutoCleanupTempDirTracker ( afterEach ) ;
@@ -344,6 +345,94 @@ describe("trusted full release candidate selection", () => {
344345} ) ;
345346
346347describe ( "full release candidate discovery CLI" , ( ) => {
348+ it ( "preserves canonical request arrays when checking the expected digest" , ( ) => {
349+ const root = tempDirs . make ( "full-release-candidate-canonical-" ) ;
350+ const bin = join ( root , "bin" ) ;
351+ const rawInputPath = join ( root , "raw-request-input.json" ) ;
352+ const requestPath = join ( root , "request.json" ) ;
353+ const outputPath = join ( root , "github-output" ) ;
354+ const callLogPath = join ( root , "gh-calls" ) ;
355+ mkdirSync ( bin ) ;
356+ const ghPath = join ( bin , "gh" ) ;
357+ writeFileSync (
358+ ghPath ,
359+ `#!/bin/sh
360+ printf '%s\n' "$*" >> "$FAKE_GH_CALL_LOG"
361+ printf '%s\n' '{"artifacts":[]}'
362+ ` ,
363+ ) ;
364+ chmodSync ( ghPath , 0o755 ) ;
365+ writeFileSync (
366+ rawInputPath ,
367+ JSON . stringify (
368+ fullReleaseCandidateRequestInput ( {
369+ upgradeSurvivorBaselines : "openclaw@latest" ,
370+ upgradeSurvivorScenarios : "base" ,
371+ } ) ,
372+ ) ,
373+ ) ;
374+ const contractResult = spawnSync (
375+ process . execPath ,
376+ [ CONTRACT_SCRIPT , "request" , "--input" , rawInputPath , "--output" , requestPath ] ,
377+ { encoding : "utf8" , timeout : 10_000 } ,
378+ ) ;
379+ expect ( contractResult . status , contractResult . stderr ) . toBe ( 0 ) ;
380+ const contract = JSON . parse ( contractResult . stdout ) as {
381+ requestJson : string ;
382+ requestSha256 : string ;
383+ } ;
384+ const requestBeforeDiscovery = readFileSync ( requestPath , "utf8" ) ;
385+ const request = JSON . parse ( requestBeforeDiscovery ) as {
386+ upgradeSurvivorBaselines : string [ ] ;
387+ upgradeSurvivorScenarios : string [ ] ;
388+ } ;
389+ expect ( request . upgradeSurvivorBaselines ) . toEqual ( [ "openclaw@latest" ] ) ;
390+ expect ( request . upgradeSurvivorScenarios ) . toEqual ( [ "base" ] ) ;
391+
392+ const result = spawnSync (
393+ process . execPath ,
394+ [
395+ SCRIPT ,
396+ "discover" ,
397+ "--request-input" ,
398+ requestPath ,
399+ "--expected-request-sha256" ,
400+ contract . requestSha256 ,
401+ ] ,
402+ {
403+ encoding : "utf8" ,
404+ env : {
405+ ...process . env ,
406+ FAKE_GH_CALL_LOG : callLogPath ,
407+ GH_TOKEN : "test-token" ,
408+ GITHUB_OUTPUT : outputPath ,
409+ PATH : `${ bin } :${ process . env . PATH } ` ,
410+ } ,
411+ timeout : 10_000 ,
412+ } ,
413+ ) ;
414+ expect ( result . status , result . stderr ) . toBe ( 0 ) ;
415+ const outputs = Object . fromEntries (
416+ readFileSync ( outputPath , "utf8" )
417+ . trim ( )
418+ . split ( "\n" )
419+ . map ( ( line ) => {
420+ const separator = line . indexOf ( "=" ) ;
421+ return [ line . slice ( 0 , separator ) , line . slice ( separator + 1 ) ] ;
422+ } ) ,
423+ ) ;
424+ expect ( outputs ) . toMatchObject ( {
425+ request_json : contract . requestJson ,
426+ request_sha256 : contract . requestSha256 ,
427+ reused : "false" ,
428+ state : "miss" ,
429+ } ) ;
430+ expect ( readFileSync ( requestPath , "utf8" ) ) . toBe ( requestBeforeDiscovery ) ;
431+ expect ( readFileSync ( callLogPath , "utf8" ) . trim ( ) ) . toBe (
432+ `api repos/${ REPOSITORY } /actions/artifacts?name=full-release-candidate-v2-${ contract . requestSha256 } &per_page=100&page=1` ,
433+ ) ;
434+ } ) ;
435+
347436 it ( "marks exhausted transient reads unavailable instead of permitting preparation" , ( ) => {
348437 const root = tempDirs . make ( "full-release-candidate-discovery-" ) ;
349438 const bin = join ( root , "bin" ) ;
@@ -364,7 +453,7 @@ exit 1
364453` ,
365454 ) ;
366455 chmodSync ( ghPath , 0o755 ) ;
367- writeFileSync ( inputPath , JSON . stringify ( fullReleaseCandidateRequestInput ( ) ) ) ;
456+ writeFileSync ( inputPath , JSON . stringify ( fullReleaseCandidateManifestFixture ( ) . request ) ) ;
368457 const result = spawnSync ( process . execPath , [ SCRIPT , "discover" , "--request-input" , inputPath ] , {
369458 encoding : "utf8" ,
370459 env : {
@@ -405,7 +494,7 @@ cat "$FAKE_GH_PAYLOAD"
405494` ,
406495 ) ;
407496 chmodSync ( ghPath , 0o755 ) ;
408- writeFileSync ( inputPath , JSON . stringify ( fullReleaseCandidateRequestInput ( ) ) ) ;
497+ writeFileSync ( inputPath , JSON . stringify ( fullReleaseCandidateManifestFixture ( ) . request ) ) ;
409498 writeFileSync (
410499 payloadPath ,
411500 JSON . stringify ( { artifacts : Array . from ( { length : 100 } , ( ) => ( { } ) ) } ) ,
482571 } ,
483572 } ) ;
484573 } ) ;
485- writeFileSync ( inputPath , JSON . stringify ( fullReleaseCandidateRequestInput ( ) ) ) ;
574+ writeFileSync ( inputPath , JSON . stringify ( fullReleaseCandidateManifestFixture ( ) . request ) ) ;
486575 writeFileSync ( artifactListingPath , JSON . stringify ( { artifacts } ) ) ;
487576 const result = spawnSync ( process . execPath , [ SCRIPT , "discover" , "--request-input" , inputPath ] , {
488577 encoding : "utf8" ,
550639 ) ;
551640 chmodSync ( ghPath , 0o755 ) ;
552641 const { archive, manifest, metadata } = await fixture ( ) ;
553- writeFileSync ( inputPath , JSON . stringify ( fullReleaseCandidateRequestInput ( ) ) ) ;
642+ writeFileSync ( inputPath , JSON . stringify ( fullReleaseCandidateManifestFixture ( ) . request ) ) ;
554643 writeFileSync ( archivePath , archive ) ;
555644 writeFileSync ( artifactListingPath , JSON . stringify ( { artifacts : [ metadata ] } ) ) ;
556645 writeFileSync ( workflowRunPath , JSON . stringify ( workflowRun ( ) ) ) ;
0 commit comments