@@ -6,6 +6,7 @@ import { fileURLToPath } from "node:url";
66import { openRootFileSync } from "../infra/boundary-file-read.js" ;
77import { sameFileIdentity } from "../infra/fs-safe-advanced.js" ;
88import { resolveBundledPluginsDir } from "./bundled-dir.js" ;
9+ import { shouldRejectHardlinkedPluginFiles } from "./hardlink-policy.js" ;
910import { registerPluginMetadataProcessMemoLifecycleClear } from "./plugin-metadata-lifecycle.js" ;
1011import {
1112 createPluginModuleLoaderCache ,
@@ -127,17 +128,23 @@ function loadValidatedPublicSurfaceModule(params: {
127128 boundaryRoot : string ;
128129 boundaryLabel : string ;
129130 surfaceLabel : string ;
131+ origin : "bundled" | "global" ;
130132} ) : object {
131133 const cached = publicSurfaceModuleCache . get ( params . modulePath ) ;
132134 if ( cached ) {
133135 return cached as object ;
134136 }
135137
138+ // Official install trust does not make mutable plugin roots immutable;
139+ // the shared policy preserves bundled and immutable Nix-store exceptions.
136140 const opened = openRootFileSync ( {
137141 absolutePath : params . modulePath ,
138142 rootPath : params . boundaryRoot ,
139143 boundaryLabel : params . boundaryLabel ,
140- rejectHardlinks : false ,
144+ rejectHardlinks : shouldRejectHardlinkedPluginFiles ( {
145+ origin : params . origin ,
146+ rootDir : params . boundaryRoot ,
147+ } ) ,
141148 } ) ;
142149 if ( ! opened . ok ) {
143150 throw new Error ( `Unable to open ${ params . surfaceLabel } ` , { cause : opened . error } ) ;
@@ -182,6 +189,7 @@ export function loadBundledPluginPublicArtifactModuleSync<T extends object>(para
182189 boundaryLabel :
183190 location . boundaryRoot === OPENCLAW_PACKAGE_ROOT ? "OpenClaw package root" : "plugin root" ,
184191 surfaceLabel : `bundled plugin public surface ${ params . dirName } /${ params . artifactBasename } ` ,
192+ origin : "bundled" ,
185193 } ) as T ;
186194}
187195
@@ -201,6 +209,7 @@ export function loadPluginPublicArtifactModuleSync<T extends object>(params: {
201209 boundaryRoot : path . resolve ( params . pluginRoot ) ,
202210 boundaryLabel : "plugin root" ,
203211 surfaceLabel : `plugin public surface ${ params . artifactBasename } ` ,
212+ origin : "global" ,
204213 } ) as T ;
205214}
206215
0 commit comments