fix: scope jiti transform cache by OpenClaw install

Scope jiti filesystem transform caches for OpenClaw plugin loaders by package version and package.json install metadata so stale transforms cannot survive upgrades or package reinstalls.

Covers the central plugin module loader and the plugin SDK root alias CJS loader, while preserving jiti filesystem-cache env opt-outs and the TMPDIR cwd guard.

Verification: CI run 26601117143 passed; Real behavior proof run 26601445285 passed; CodeQL selected checks passed in run 26601117126; CodeQL Critical Quality plugin-boundary and plugin-sdk-package-contract passed in run 26601117074; OpenGrep PR diff passed in run 26601117137.

Refs: https://github.com/openclaw/openclaw/pull/87745
Thanks @fuller-stack-dev.
This commit is contained in:
Jason (Json)
2026-05-28 17:17:04 -06:00
committed by GitHub
parent 13c1aa7fb9
commit 1610b4983f
6 changed files with 305 additions and 2 deletions

View File

@@ -1,3 +1,4 @@
import path from "node:path";
import { importFreshModule } from "openclaw/plugin-sdk/test-fixtures";
import { afterEach, describe, expect, it, vi } from "vitest";
import type { PluginModuleLoaderFactory } from "./plugin-module-loader-cache.js";
@@ -269,6 +270,8 @@ describe("getCachedPluginModuleLoader", () => {
const options = expectJitiOptions(createJiti, 0, "file:///repo/src/plugins/loader.ts", {
tryNative: false,
});
expect(options.fsCache).toEqual(expect.any(String));
expect(String(options.fsCache)).toContain(`${path.sep}jiti${path.sep}openclaw${path.sep}`);
expect(options.alias).toEqual({
alpha: "/repo/alpha.js",
zeta: "/repo/zeta.js",