fix: test bundled public surface loading
Some checks failed
CI / linux (push) Has been cancelled
CI / macos (push) Has been cancelled

The stable and dogfood OpenClaw source pins need different public-surface hardlink patch shapes while upstream is still catching up. Select the right patch per source and make package contents import the OpenAI provider policy public surface, which is the path the gateway uses before a model run.

Tests: nix fmt --accept-flake-config; git diff --check; remote mac-mini nix build .#checks.aarch64-darwin.package-contents-dogfood --no-link; remote mac-mini nix build .#checks.aarch64-darwin.package-contents --no-link

Co-authored-by: Codex <noreply@openai.com>
This commit is contained in:
joshp123 2026-05-09 01:50:13 +08:00
parent 0b25e889a5
commit c8f8e92aba
6 changed files with 60 additions and 5 deletions

View File

@ -1,6 +1,7 @@
{ {
lib, lib,
stdenv, stdenv,
nodejs_22,
openclawGateway, openclawGateway,
}: }:
@ -17,6 +18,7 @@ stdenv.mkDerivation {
}; };
doCheck = true; doCheck = true;
nativeCheckInputs = [ nodejs_22 ];
checkPhase = "${../scripts/check-package-contents.sh}"; checkPhase = "${../scripts/check-package-contents.sh}";
installPhase = "${../scripts/empty-install.sh}"; installPhase = "${../scripts/empty-install.sh}";
} }

View File

@ -40,6 +40,7 @@ let
"releaseVersion" "releaseVersion"
"applyPublicSurfaceHardlinksPatch" "applyPublicSurfaceHardlinksPatch"
"applySkipPluginAutoEnableNixModePatch" "applySkipPluginAutoEnableNixModePatch"
"publicSurfaceHardlinksPatch"
"fsSafeSource" "fsSafeSource"
]; ];
@ -59,6 +60,8 @@ let
fetchFromGitHub sourceFetch; fetchFromGitHub sourceFetch;
fsSafeSource = if sourceInfo ? fsSafeSource then fetchFromGitHub sourceInfo.fsSafeSource else null; fsSafeSource = if sourceInfo ? fsSafeSource then fetchFromGitHub sourceInfo.fsSafeSource else null;
publicSurfaceHardlinksPatch =
sourceInfo.publicSurfaceHardlinksPatch or ../patches/allow-package-public-surface-hardlinks.patch;
nodeAddonApi = import ../packages/node-addon-api.nix { inherit stdenv fetchurl; }; nodeAddonApi = import ../packages/node-addon-api.nix { inherit stdenv fetchurl; };
@ -88,7 +91,7 @@ let
PATCH_BUNDLED_RUNTIME_DEPS_SCRIPT = "${../patches/stage-bundled-plugin-runtime-deps.mjs}"; PATCH_BUNDLED_RUNTIME_DEPS_SCRIPT = "${../patches/stage-bundled-plugin-runtime-deps.mjs}";
PATCH_PUBLIC_SURFACE_HARDLINKS = PATCH_PUBLIC_SURFACE_HARDLINKS =
if sourceInfo.applyPublicSurfaceHardlinksPatch or true then if sourceInfo.applyPublicSurfaceHardlinksPatch or true then
"${../patches/allow-package-public-surface-hardlinks.patch}" "${publicSurfaceHardlinksPatch}"
else else
""; "";
PATCH_SKIP_PLUGIN_AUTO_ENABLE_NIX_MODE = PATCH_SKIP_PLUGIN_AUTO_ENABLE_NIX_MODE =

View File

@ -0,0 +1,20 @@
diff --git a/src/plugins/public-surface-loader.ts b/src/plugins/public-surface-loader.ts
index 5f6f939..b8d27c8 100644
--- a/src/plugins/public-surface-loader.ts
+++ b/src/plugins/public-surface-loader.ts
@@ -133,8 +133,12 @@ export function loadBundledPluginPublicArtifactModuleSync<T extends object>(para
- const opened = openRootFileSync({
+ const packageRoot = path.resolve(OPENCLAW_PACKAGE_ROOT);
+ const resolvedModulePath = path.resolve(location.modulePath);
+ const isPackagePublicSurface = resolvedModulePath.startsWith(`${packageRoot}${path.sep}`);
+
+ const opened = openRootFileSync({
absolutePath: location.modulePath,
rootPath: location.boundaryRoot,
boundaryLabel:
location.boundaryRoot === OPENCLAW_PACKAGE_ROOT ? "OpenClaw package root" : "plugin root",
- rejectHardlinks: true,
+ rejectHardlinks: !isPackagePublicSurface,
});
if (!opened.ok) {
throw new Error(

View File

@ -1,13 +1,20 @@
diff --git a/src/plugins/public-surface-loader.ts b/src/plugins/public-surface-loader.ts diff --git a/src/plugins/public-surface-loader.ts b/src/plugins/public-surface-loader.ts
index 5f6f939..8cb550f 100644 index 1f5b5ab..a08ef8a 100644
--- a/src/plugins/public-surface-loader.ts --- a/src/plugins/public-surface-loader.ts
+++ b/src/plugins/public-surface-loader.ts +++ b/src/plugins/public-surface-loader.ts
@@ -128,7 +128,7 @@ export function loadBundledPluginPublicArtifactModuleSync<T extends object>(para @@ -124,8 +124,12 @@ export function loadBundledPluginPublicArtifactModuleSync<T extends object>(para
- const opened = openBoundaryFileSync({
+ const packageRoot = path.resolve(OPENCLAW_PACKAGE_ROOT);
+ const resolvedModulePath = path.resolve(location.modulePath);
+ const isPackagePublicSurface = resolvedModulePath.startsWith(`${packageRoot}${path.sep}`);
+
+ const opened = openBoundaryFileSync({
absolutePath: location.modulePath,
rootPath: location.boundaryRoot, rootPath: location.boundaryRoot,
boundaryLabel: boundaryLabel:
location.boundaryRoot === OPENCLAW_PACKAGE_ROOT ? "OpenClaw package root" : "plugin root", location.boundaryRoot === OPENCLAW_PACKAGE_ROOT ? "OpenClaw package root" : "plugin root",
- rejectHardlinks: true, - rejectHardlinks: true,
+ rejectHardlinks: location.boundaryRoot !== OPENCLAW_PACKAGE_ROOT, + rejectHardlinks: !isPackagePublicSurface,
}); });
if (!opened.ok) { if (!opened.ok) {
throw new Error( throw new Error(

View File

@ -36,7 +36,7 @@ require_path "${root}/node_modules/hasown"
require_path "${root}/node_modules/combined-stream" require_path "${root}/node_modules/combined-stream"
public_surface_loader="$( public_surface_loader="$(
grep -Rsl "function loadBundledPluginPublicArtifactModuleSync" "${root}/dist" | head -1 find "${root}/dist" -name "*.js" -type f -exec grep -sl "function loadBundledPluginPublicArtifactModuleSync" {} + | head -1
)" )"
if [ -z "$public_surface_loader" ]; then if [ -z "$public_surface_loader" ]; then
echo "Missing bundled plugin public surface loader" >&2 echo "Missing bundled plugin public surface loader" >&2
@ -46,6 +46,28 @@ if grep -q "rejectHardlinks: true" "$public_surface_loader"; then
echo "Bundled plugin public surface loader still rejects hardlinked package files" >&2 echo "Bundled plugin public surface loader still rejects hardlinked package files" >&2
exit 1 exit 1
fi fi
export PUBLIC_SURFACE_LOADER="$public_surface_loader"
node --input-type=module <<'NODE'
import { pathToFileURL } from "node:url";
const loaderPath = process.env.PUBLIC_SURFACE_LOADER;
if (!loaderPath) {
throw new Error("PUBLIC_SURFACE_LOADER is not set");
}
const loader = await import(pathToFileURL(loaderPath).href);
const loadBundledPluginPublicArtifactModuleSync =
loader.loadBundledPluginPublicArtifactModuleSync ?? loader.t;
if (typeof loadBundledPluginPublicArtifactModuleSync !== "function") {
throw new Error("Bundled plugin public surface loader export not found");
}
loadBundledPluginPublicArtifactModuleSync({
dirName: "openai",
artifactBasename: "provider-policy-api.js",
});
NODE
require_js_alias_target() { require_js_alias_target() {
alias="$1" alias="$1"

View File

@ -12,5 +12,6 @@
hash = "sha256-jndOOSSFROyrK4RiwAsJfUuCJTj7qbmmm4Qz8BqtJ/c="; hash = "sha256-jndOOSSFROyrK4RiwAsJfUuCJTj7qbmmm4Qz8BqtJ/c=";
}; };
publicSurfaceHardlinksPatch = ../patches/allow-package-public-surface-hardlinks-open-root.patch;
applySkipPluginAutoEnableNixModePatch = false; applySkipPluginAutoEnableNixModePatch = false;
} }