@@ -8,6 +8,7 @@ import { parse as parseYaml } from "yaml";
88import { runContainedCommand } from "./command-runner.js" ;
99
1010const PINNED_OPENCLAW_KNIP_VERSION = "6.8.0" ;
11+ const PINNED_OPENCLAW_KNIP_PUBLISHED_AT = "2026-04-29T06:27:29.928Z" ;
1112const PREPARED_PNPM_HELPER_CACHE = ".__clawsweeper_pnpm_helper_cache__" ;
1213const MINIMUM_OPENCLAW_RELEASE_AGE_MINUTES = 48 * 60 ;
1314const PINNED_OPENCLAW_KNIP_LOCK = fileURLToPath (
@@ -40,12 +41,9 @@ export function preparePinnedOpenClawValidationHelper({
4041 const profileRoot = path . dirname ( String ( validationEnv . HOME ) ) ;
4142 const helperCache = path . join ( String ( validationEnv . COREPACK_HOME ) , PREPARED_PNPM_HELPER_CACHE ) ;
4243 const minimumReleaseAge = openClawMinimumReleaseAge ( cwd ) ;
43- const cacheRoot = path . join (
44- helperCache ,
45- "pnpm" ,
46- "dlx" ,
47- pinnedOpenClawDlxCacheKey ( installRegistry ) ,
48- ) ;
44+ const dlxRoot = path . join ( helperCache , "pnpm" , "dlx" ) ;
45+ const fullCacheKey = pinnedOpenClawDlxCacheKey ( installRegistry ) ;
46+ const cacheRoot = path . join ( dlxRoot , fullCacheKey ) ;
4947 const helperProject = path . join ( cacheRoot , "pinned" ) ;
5048 fs . mkdirSync ( helperProject , { recursive : true , mode : 0o700 } ) ;
5149 fs . copyFileSync ( PINNED_OPENCLAW_KNIP_LOCK , path . join ( helperProject , "pnpm-lock.yaml" ) ) ;
@@ -83,8 +81,9 @@ export function preparePinnedOpenClawValidationHelper({
8381 ) ;
8482 scopePinnedOpenClawJitiCache ( helperProject ) ;
8583 fs . symlinkSync ( "pinned" , path . join ( cacheRoot , "pkg" ) ) ;
86- seedOfflinePinnedOpenClawMetadata ( helperCache , installRegistry ) ;
84+ fs . symlinkSync ( fullCacheKey , path . join ( dlxRoot , fullCacheKey . slice ( 0 , 32 ) ) ) ;
8785 assertPinnedOpenClawValidationHelperLock ( helperCache ) ;
86+ seedOfflinePinnedOpenClawMetadata ( helperCache , helperProject , installRegistry ) ;
8887}
8988
9089function scopePinnedOpenClawJitiCache ( helperProject : string ) : void {
@@ -107,32 +106,60 @@ function pinnedOpenClawDlxCacheKey(installRegistry: string): string {
107106 ] ;
108107 return createHash ( "sha256" )
109108 . update ( JSON . stringify ( [ resolvedPackages , registries ] ) )
110- . digest ( "hex" )
111- . slice ( 0 , 32 ) ;
109+ . digest ( "hex" ) ;
112110}
113111
114- function seedOfflinePinnedOpenClawMetadata ( helperCache : string , installRegistry : string ) : void {
112+ function seedOfflinePinnedOpenClawMetadata (
113+ helperCache : string ,
114+ helperProject : string ,
115+ installRegistry : string ,
116+ ) : void {
115117 const cacheRoot = path . join ( helperCache , "pnpm" ) ;
116118 const versions = fs . readdirSync ( cacheRoot ) . filter ( ( entry ) => / ^ v \d + $ / . test ( entry ) ) ;
117119 // pnpm's encode-registry package replaces the host/port separator with `+`.
118120 const registryHost = new URL ( installRegistry ) . host . replace ( ":" , "+" ) ;
119- let seeded = false ;
121+ const manifest = JSON . parse (
122+ fs . readFileSync ( path . join ( helperProject , "node_modules" , "knip" , "package.json" ) , "utf8" ) ,
123+ ) as Record < string , unknown > ;
124+ if ( manifest . name !== "knip" || manifest . version !== PINNED_OPENCLAW_KNIP_VERSION ) {
125+ throw new Error ( "pinned OpenClaw Knip package does not match the trusted dependency graph" ) ;
126+ }
127+ const lock = parseYaml ( fs . readFileSync ( PINNED_OPENCLAW_KNIP_LOCK , "utf8" ) ) as {
128+ packages ?: Record < string , { resolution ?: { integrity ?: string } } > ;
129+ } ;
130+ const integrity = lock . packages ?. [ `knip@${ PINNED_OPENCLAW_KNIP_VERSION } ` ] ?. resolution ?. integrity ;
131+ if ( typeof integrity !== "string" || ! integrity . startsWith ( "sha512-" ) ) {
132+ throw new Error ( "pinned OpenClaw Knip integrity is missing from the trusted dependency graph" ) ;
133+ }
134+ const version = {
135+ ...manifest ,
136+ dist : {
137+ integrity,
138+ tarball : new URL ( `knip/-/knip-${ PINNED_OPENCLAW_KNIP_VERSION } .tgz` , installRegistry ) . href ,
139+ } ,
140+ } ;
141+ const metadata = {
142+ name : "knip" ,
143+ "dist-tags" : { latest : PINNED_OPENCLAW_KNIP_VERSION } ,
144+ versions : { [ PINNED_OPENCLAW_KNIP_VERSION ] : version } ,
145+ time : { [ PINNED_OPENCLAW_KNIP_VERSION ] : PINNED_OPENCLAW_KNIP_PUBLISHED_AT } ,
146+ modified : PINNED_OPENCLAW_KNIP_PUBLISHED_AT ,
147+ cachedAt : Date . now ( ) ,
148+ } ;
120149 for ( const version of versions ) {
121- const metadata = path . join ( cacheRoot , version , "metadata-full" , registryHost , "knip.jsonl" ) ;
122- if ( ! fs . existsSync ( metadata ) ) continue ;
123- const filtered = path . join (
124- cacheRoot ,
125- version ,
126- "metadata-full-filtered" ,
127- registryHost ,
128- "knip.jsonl" ,
129- ) ;
130- fs . mkdirSync ( path . dirname ( filtered ) , { recursive : true } ) ;
131- fs . copyFileSync ( metadata , filtered ) ;
132- seeded = true ;
150+ for ( const layout of [ "metadata" , "metadata-full" , "metadata-full-filtered" ] ) {
151+ const destination = path . join ( cacheRoot , version , layout , registryHost , "knip.jsonl" ) ;
152+ fs . mkdirSync ( path . dirname ( destination ) , { recursive : true } ) ;
153+ fs . writeFileSync (
154+ destination ,
155+ `${ JSON . stringify ( { modified : PINNED_OPENCLAW_KNIP_PUBLISHED_AT } ) } \n${ JSON . stringify ( metadata ) } \n` ,
156+ ) ;
157+ }
133158 }
134- if ( ! seeded ) {
135- throw new Error ( "pinned OpenClaw Knip registry metadata was not created by frozen install" ) ;
159+ for ( const layout of [ "metadata-v1.3" , "metadata-full-v1.3" , "metadata-ff-v1.3" ] ) {
160+ const destination = path . join ( cacheRoot , layout , registryHost , "knip.json" ) ;
161+ fs . mkdirSync ( path . dirname ( destination ) , { recursive : true } ) ;
162+ fs . writeFileSync ( destination , JSON . stringify ( metadata ) ) ;
136163 }
137164}
138165
0 commit comments