@@ -1156,6 +1156,52 @@ function runProtocolSinceFixture(checkout: string, baseSha: string) {
11561156 } ) ;
11571157}
11581158
1159+ function runGuardCheckFixture ( options : { frozenTarget : boolean ; scripts : string [ ] } ) : {
1160+ calls : string [ ] ;
1161+ output : string ;
1162+ status : number | null ;
1163+ } {
1164+ const root = tempDirs . make ( "openclaw-ci-guards-" ) ;
1165+ const fakeBin = path . join ( root , "bin" ) ;
1166+ const callsPath = path . join ( root , "pnpm-calls.txt" ) ;
1167+ mkdirSync ( fakeBin ) ;
1168+ writeFileSync (
1169+ path . join ( root , "package.json" ) ,
1170+ `${ JSON . stringify ( {
1171+ scripts : Object . fromEntries ( options . scripts . map ( ( name ) => [ name , "true" ] ) ) ,
1172+ } ) } \n`,
1173+ ) ;
1174+ writeExecutable ( path . join ( fakeBin , "pnpm" ) , [
1175+ "#!/usr/bin/env bash" ,
1176+ "set -euo pipefail" ,
1177+ 'printf "%s\\n" "$*" >> "$PNPM_CALLS"' ,
1178+ ] ) ;
1179+ const checkShardRun = readCiWorkflow ( ) . jobs [ "check-shard" ] . steps . find (
1180+ ( step : WorkflowStep ) => step . name === "Run check shard" ,
1181+ ) . run ;
1182+ const run = spawnSync ( "bash" , [ "-c" , checkShardRun ] , {
1183+ cwd : root ,
1184+ encoding : "utf8" ,
1185+ env : {
1186+ ...process . env ,
1187+ FROZEN_TARGET : options . frozenTarget ? "true" : "false" ,
1188+ FORMAT_CHECK : "false" ,
1189+ HISTORICAL_TARGET : options . frozenTarget ? "true" : "false" ,
1190+ PATH : `${ fakeBin } :${ process . env . PATH ?? "" } ` ,
1191+ PNPM_CALLS : callsPath ,
1192+ PR_BASE_SHA : "" ,
1193+ TASK : "guards" ,
1194+ } ,
1195+ } ) ;
1196+ return {
1197+ calls : existsSync ( callsPath )
1198+ ? readFileSync ( callsPath , "utf8" ) . trim ( ) . split ( "\n" ) . filter ( Boolean )
1199+ : [ ] ,
1200+ output : `${ run . stdout } ${ run . stderr } ` ,
1201+ status : run . status ,
1202+ } ;
1203+ }
1204+
11591205function runDependencyCheckFixture ( options : {
11601206 historicalTarget : boolean ;
11611207 releaseToolingEntry ?: boolean ;
@@ -6192,6 +6238,50 @@ printf '%s\n' "\${CURL_SUCCESS_IP:-203.0.113.7}"
61926238 ) ;
61936239 } ) ;
61946240
6241+ it ( "runs temp path guardrails in the hosted guard shard" , ( ) => {
6242+ const requiredScripts = [ "check:doctor-deprecation-registry" , "check:coercion-helpers" ] ;
6243+ const current = runGuardCheckFixture ( {
6244+ frozenTarget : false ,
6245+ scripts : [ ...requiredScripts , "check:temp-path-guardrails" ] ,
6246+ } ) ;
6247+ expect ( current . status , current . output ) . toBe ( 0 ) ;
6248+ expect ( current . calls ) . toContain ( "check:temp-path-guardrails" ) ;
6249+ expect ( current . calls . indexOf ( "check:temp-path-guardrails" ) ) . toBeLessThan (
6250+ current . calls . indexOf ( "dup:check" ) ,
6251+ ) ;
6252+
6253+ const frozenMissing = runGuardCheckFixture ( {
6254+ frozenTarget : true ,
6255+ scripts : requiredScripts ,
6256+ } ) ;
6257+ expect ( frozenMissing . status , frozenMissing . output ) . toBe ( 0 ) ;
6258+ expect ( frozenMissing . calls ) . not . toContain ( "check:temp-path-guardrails" ) ;
6259+ expect ( frozenMissing . calls ) . toContain ( "dup:check:coverage" ) ;
6260+ expect ( frozenMissing . output ) . toContain (
6261+ "[skip] frozen target predates the temp path guardrails" ,
6262+ ) ;
6263+
6264+ const currentMissing = runGuardCheckFixture ( {
6265+ frozenTarget : false ,
6266+ scripts : requiredScripts ,
6267+ } ) ;
6268+ expect ( currentMissing . status ) . toBe ( 1 ) ;
6269+ expect ( currentMissing . calls ) . not . toContain ( "check:temp-path-guardrails" ) ;
6270+ expect ( currentMissing . calls ) . not . toContain ( "dup:check" ) ;
6271+ expect ( currentMissing . output ) . toContain (
6272+ "Current CI targets must provide the check:temp-path-guardrails package script." ,
6273+ ) ;
6274+
6275+ const workflow = readFileSync ( ".github/workflows/ci.yml" , "utf8" ) ;
6276+ const preflightGuards = workflow . slice (
6277+ workflow . indexOf ( "guards)" ) ,
6278+ workflow . indexOf ( "npm-lock)" ) ,
6279+ ) ;
6280+ expect ( preflightGuards . indexOf ( "pnpm check:temp-path-guardrails" ) ) . toBeLessThan (
6281+ preflightGuards . indexOf ( "pnpm dup:check" ) ,
6282+ ) ;
6283+ } ) ;
6284+
61956285 it ( "rejects ambiguous zero-before main pushes and preserves concrete bases" , ( ) => {
61966286 const zeroSha = "0" . repeat ( 40 ) ;
61976287 const threeCommit = runPushDiffBaseFixture ( { commitCount : 3 , eventBaseSha : zeroSha } ) ;
0 commit comments