@@ -134,6 +134,254 @@ function fixturePolicy(): { policy: AuthorizedBetaFocusedPolicy; root: string }
134134 } ;
135135}
136136
137+ function runFocusedValidatorLogProbe ( outcome : "flagged" | "legacy" | "unrelated" ) {
138+ const { policy, root } = fixturePolicy ( ) ;
139+ const trustedRoot = tempDirs . make ( "authorized-beta-focused-job-log-" ) ;
140+ const validatorPath = stageValidatorClosure ( trustedRoot , false ) ;
141+ const artifactPath = join ( trustedRoot , "evidence.json" ) ;
142+ const callsPath = join ( trustedRoot , "gh-log-calls.jsonl" ) ;
143+ const historical = policy . historicalFrv ;
144+ const focused = policy . focusedProof ;
145+ const producerSha = "a" . repeat ( 40 ) ;
146+ const producerRef = "release-publish/aaaaaaaaaaaa-1" ;
147+ const producer : AuthorizedBetaFocusedProducerIdentity = {
148+ repository : "openclaw/openclaw" ,
149+ runId : "123" ,
150+ runAttempt : 1 ,
151+ workflowPath : ".github/workflows/authorized-beta-focused-validation.yml" ,
152+ workflowFullRef : `refs/tags/${ producerRef } ` ,
153+ workflowRef : producerRef ,
154+ workflowSha : producerSha ,
155+ } ;
156+ const createRun = (
157+ id : string ,
158+ name : string ,
159+ path : string ,
160+ headBranch : string ,
161+ headSha : string ,
162+ conclusion = "success" ,
163+ ) => ( {
164+ id,
165+ run_attempt : 1 ,
166+ name,
167+ path,
168+ event : "workflow_dispatch" ,
169+ status : "completed" ,
170+ conclusion,
171+ head_branch : headBranch ,
172+ head_sha : headSha ,
173+ } ) ;
174+ const createJob = ( id : string , runId : string , name : string , conclusion : string ) => ( {
175+ id,
176+ run_id : runId ,
177+ name,
178+ status : "completed" ,
179+ conclusion,
180+ head_sha : policy . historicalToolingSha ,
181+ } ) ;
182+ const historicalTitle = `full-release-validation-${ historical . runId } -${ historical . runAttempt } ` ;
183+ const historicalRun = ( id : string , name : string , path : string , conclusion = "success" ) =>
184+ createRun ( id , name , path , historical . workflowRef , policy . historicalToolingSha , conclusion ) ;
185+ const focusedRun = ( id : string , name : string , path : string , conclusion = "success" ) =>
186+ createRun (
187+ id ,
188+ name ,
189+ path ,
190+ policy . historicalToolingRef . replace ( "refs/tags/" , "" ) ,
191+ policy . historicalToolingSha ,
192+ conclusion ,
193+ ) ;
194+ const runs = [
195+ createRun (
196+ producer . runId ,
197+ "Authorized Beta Focused Validation" ,
198+ producer . workflowPath ,
199+ producerRef ,
200+ producerSha ,
201+ ) ,
202+ historicalRun ( historical . runId , "Full Release Validation" , historical . workflowPath , "failure" ) ,
203+ historicalRun (
204+ historical . ciRunId ,
205+ `CI ${ historicalTitle } -ci` ,
206+ ".github/workflows/ci.yml" ,
207+ "failure" ,
208+ ) ,
209+ historicalRun (
210+ historical . pluginRunId ,
211+ `Plugin Prerelease ${ historicalTitle } -plugin-prerelease` ,
212+ ".github/workflows/plugin-prerelease.yml" ,
213+ "failure" ,
214+ ) ,
215+ historicalRun (
216+ historical . releaseChecksRunId ,
217+ `OpenClaw Release Checks ${ historicalTitle } -release-checks` ,
218+ ".github/workflows/openclaw-release-checks.yml" ,
219+ ) ,
220+ historicalRun (
221+ historical . performanceRunId ,
222+ `OpenClaw Performance ${ historicalTitle } ` ,
223+ ".github/workflows/openclaw-performance.yml" ,
224+ "failure" ,
225+ ) ,
226+ focusedRun ( focused . ciRunId , "CI beta3-slack-proof-e347223a" , ".github/workflows/ci.yml" ) ,
227+ focusedRun (
228+ focused . pluginRunId ,
229+ "Plugin Prerelease beta3-slack-proof-e347223a" ,
230+ ".github/workflows/plugin-prerelease.yml" ,
231+ "failure" ,
232+ ) ,
233+ ] ;
234+ const jobs = [
235+ createJob ( historical . ciFailedJobId , historical . ciRunId , "check-lint" , "failure" ) ,
236+ createJob ( historical . ciAggregateJobId , historical . ciRunId , "openclaw/ci-gate" , "failure" ) ,
237+ createJob (
238+ historical . pluginFailedJobId ,
239+ historical . pluginRunId ,
240+ "checks-node-extensions-shard-7" ,
241+ "failure" ,
242+ ) ,
243+ createJob (
244+ historical . pluginAggregateJobId ,
245+ historical . pluginRunId ,
246+ "plugin-prerelease-suite" ,
247+ "failure" ,
248+ ) ,
249+ createJob (
250+ historical . releaseChecksVerifierJobId ,
251+ historical . releaseChecksRunId ,
252+ "Verify release checks" ,
253+ "success" ,
254+ ) ,
255+ createJob (
256+ historical . performanceFailedJobId ,
257+ historical . performanceRunId ,
258+ "OpenClaw source performance probes" ,
259+ "failure" ,
260+ ) ,
261+ createJob ( focused . ciSuccessJobId , focused . ciRunId , "check-lint" , "success" ) ,
262+ createJob ( focused . ciTargetLogJobId , focused . ciRunId , "preflight" , "success" ) ,
263+ createJob (
264+ focused . pluginSuccessJobId ,
265+ focused . pluginRunId ,
266+ "checks-node-extensions-shard-7" ,
267+ "success" ,
268+ ) ,
269+ createJob (
270+ focused . pluginTargetLogJobId ,
271+ focused . pluginRunId ,
272+ "Build plugin prerelease plan" ,
273+ "success" ,
274+ ) ,
275+ ] ;
276+ const plan = {
277+ parentRunId : historical . runId ,
278+ parentRunAttempt : historical . runAttempt ,
279+ workflowRef : historical . workflowRef ,
280+ workflowSha : policy . historicalToolingSha ,
281+ targetSha : historical . targetSha ,
282+ releaseProfile : "beta" ,
283+ rerunGroup : "all" ,
284+ children : [
285+ { key : "normalCi" , selected : true , runId : historical . ciRunId } ,
286+ { key : "pluginPrerelease" , selected : true , runId : historical . pluginRunId } ,
287+ { key : "releaseChecks" , selected : true , runId : historical . releaseChecksRunId } ,
288+ { key : "productPerformance" , selected : true , runId : historical . performanceRunId } ,
289+ ] ,
290+ } ;
291+ const evidence : AuthorizedBetaFocusedEvidence = {
292+ schema : "openclaw.authorized-beta-focused-evidence.v1" ,
293+ mode : "authorized-beta-focused-v1" ,
294+ policySha256 : digestAuthorizedBetaFocusedPolicy ( policy ) ,
295+ releaseTag : policy . releaseTag ,
296+ candidate : {
297+ sha : policy . candidateSha ,
298+ parentSha : policy . baseCandidateSha ,
299+ treeSha : policy . candidateTreeSha ,
300+ packageProjectionSha256 : policy . packageProjectionSha256 ,
301+ changedPaths : policy . changedPaths ,
302+ } ,
303+ producer,
304+ historical : {
305+ frvRunId : historical . runId ,
306+ frvRunAttempt : historical . runAttempt ,
307+ releaseChecksRunId : historical . releaseChecksRunId ,
308+ performanceRunId : historical . performanceRunId ,
309+ } ,
310+ focused : {
311+ ciRunId : focused . ciRunId ,
312+ ciJobId : focused . ciSuccessJobId ,
313+ pluginRunId : focused . pluginRunId ,
314+ pluginJobId : focused . pluginSuccessJobId ,
315+ reviewedHeadSha : policy . reviewedHeadSha ,
316+ } ,
317+ inventory : { eligibilityPlanDigest : policy . eligibilityPlanDigest , ...policy . inventory } ,
318+ } ;
319+ writeFileSync ( join ( trustedRoot , "authorized-beta-focused-policy.json" ) , JSON . stringify ( policy ) ) ;
320+ writeFileSync ( artifactPath , JSON . stringify ( evidence ) ) ;
321+ writeFileSync (
322+ join ( trustedRoot , "gh" ) ,
323+ [
324+ "#!/usr/bin/env node" ,
325+ 'import { appendFileSync, writeFileSync } from "node:fs";' ,
326+ 'import { join } from "node:path";' ,
327+ "const [command, route, ...args] = process.argv.slice(2);" ,
328+ `const runs = ${ JSON . stringify ( Object . fromEntries ( runs . map ( ( run ) => [ run . id , run ] ) ) ) } ;` ,
329+ `const jobs = ${ JSON . stringify ( Object . fromEntries ( jobs . map ( ( job ) => [ job . id , job ] ) ) ) } ;` ,
330+ 'if (command === "run" && route === "download") {' ,
331+ ' const directory = args[args.indexOf("--dir") + 1];' ,
332+ ` writeFileSync(join(directory, "full-release-execution-plan.json"), JSON.stringify(${ JSON . stringify ( plan ) } ));` ,
333+ '} else if (command === "api" && route.endsWith("/logs")) {' ,
334+ ` appendFileSync(${ JSON . stringify ( callsPath ) } , JSON.stringify(process.argv.slice(2)) + "\\n");` ,
335+ ` const firstFocusedLog = route.endsWith("/${ focused . ciTargetLogJobId } /logs");` ,
336+ ` if (firstFocusedLog && args.includes("--allow-escape-sequences") && ${ JSON . stringify ( outcome ) } !== "flagged") {` ,
337+ ` process.stderr.write(${ JSON . stringify ( outcome ) } === "legacy" ? "unknown flag: --allow-escape-sequences\\r\\n\\r\\nUsage: gh api <endpoint> [flags]\\r\\n" : "error: unknown flag: --allow-escape-sequences\\n");` ,
338+ " process.exit(1);" ,
339+ " }" ,
340+ ` process.stdout.write("\\u001b[32m${ policy . reviewedHeadSha } \\u001b[0m");` ,
341+ '} else if (command === "api" && route.includes("/git/ref/tags/")) {' ,
342+ ` process.stdout.write(JSON.stringify({ object: { type: "commit", sha: ${ JSON . stringify ( producerSha ) } } }));` ,
343+ '} else if (command === "api") {' ,
344+ ' const id = route.slice(route.lastIndexOf("/") + 1);' ,
345+ ' const value = route.includes("/actions/runs/") ? runs[id] : jobs[id];' ,
346+ " if (!value) throw new Error(`unexpected GitHub API route: ${route}`);" ,
347+ " process.stdout.write(JSON.stringify(value));" ,
348+ "} else {" ,
349+ " throw new Error(`unexpected gh invocation: ${JSON.stringify(process.argv.slice(2))}`);" ,
350+ "}" ,
351+ ] . join ( "\n" ) ,
352+ { mode : 0o755 } ,
353+ ) ;
354+
355+ const result = spawnSync (
356+ process . execPath ,
357+ [
358+ validatorPath ,
359+ "verify" ,
360+ "--candidate-root" ,
361+ root ,
362+ "--artifact" ,
363+ artifactPath ,
364+ "--producer-run-id" ,
365+ producer . runId ,
366+ "--producer-run-attempt" ,
367+ String ( producer . runAttempt ) ,
368+ "--producer-workflow-full-ref" ,
369+ producer . workflowFullRef ,
370+ "--producer-workflow-sha" ,
371+ producer . workflowSha ,
372+ ] ,
373+ {
374+ encoding : "utf8" ,
375+ env : { ...process . env , PATH : `${ trustedRoot } :${ process . env . PATH ?? "" } ` } ,
376+ } ,
377+ ) ;
378+ const calls = readFileSync ( callsPath , "utf8" )
379+ . trim ( )
380+ . split ( "\n" )
381+ . map ( ( line ) => JSON . parse ( line ) as string [ ] ) ;
382+ return { calls, policy, result } ;
383+ }
384+
137385function stageCandidateVerifier ( policy : AuthorizedBetaFocusedPolicy , shouldFail = false ) {
138386 const trustedRoot = tempDirs . make ( "authorized-beta-focused-trusted-" ) ;
139387 const validatorPath = stageValidatorClosure ( trustedRoot , false ) ;
@@ -520,6 +768,49 @@ describe("authorized beta focused evidence", () => {
520768 expect ( result . stderr ) . not . toContain ( "historical execution plan child run id" ) ;
521769 } ) ;
522770
771+ it . each ( [
772+ { outcome : "flagged" as const , description : "accepts ANSI-bearing flagged Actions logs" } ,
773+ { outcome : "legacy" as const , description : "retries once for the exact legacy gh flag error" } ,
774+ {
775+ outcome : "unrelated" as const ,
776+ description : "propagates unrelated gh errors without retrying" ,
777+ } ,
778+ ] ) ( "$description" , ( { outcome } ) => {
779+ const { calls, policy, result } = runFocusedValidatorLogProbe ( outcome ) ;
780+ const ciLogArgs = [
781+ "api" ,
782+ `repos/openclaw/openclaw/actions/jobs/${ policy . focusedProof . ciTargetLogJobId } /logs` ,
783+ ] ;
784+ const pluginLogArgs = [
785+ "api" ,
786+ `repos/openclaw/openclaw/actions/jobs/${ policy . focusedProof . pluginTargetLogJobId } /logs` ,
787+ ] ;
788+ const flaggedCiLogArgs = [ ...ciLogArgs , "--allow-escape-sequences" ] ;
789+ const flaggedPluginLogArgs = [ ...pluginLogArgs , "--allow-escape-sequences" ] ;
790+
791+ if ( outcome === "unrelated" ) {
792+ expect ( result . status ) . toBe ( 1 ) ;
793+ expect ( result . stderr ) . toContain ( "error: unknown flag: --allow-escape-sequences" ) ;
794+ expect ( calls ) . toEqual ( [ flaggedCiLogArgs ] ) ;
795+ return ;
796+ }
797+
798+ expect ( result . stderr ) . toBe (
799+ outcome === "legacy"
800+ ? "unknown flag: --allow-escape-sequences\r\n\r\nUsage: gh api <endpoint> [flags]\r\n"
801+ : "" ,
802+ ) ;
803+ expect ( result . status ) . toBe ( 0 ) ;
804+ expect ( result . stdout ) . toBe (
805+ `authorized beta focused evidence verified for ${ policy . releaseTag } at ${ policy . candidateSha } \n` ,
806+ ) ;
807+ expect ( calls ) . toEqual (
808+ outcome === "legacy"
809+ ? [ flaggedCiLogArgs , ciLogArgs , flaggedPluginLogArgs ]
810+ : [ flaggedCiLogArgs , flaggedPluginLogArgs ] ,
811+ ) ;
812+ } ) ;
813+
523814 it ( "binds the direct-child tree, exact diff, and unchanged published projection" , ( ) => {
524815 const { policy, root } = fixturePolicy ( ) ;
525816 const changedPath = policy . changedPaths [ 0 ] ;
0 commit comments