Skip to content

fix(tools): cache fs.existsSync calls in plugin scan path - #94358

Closed
ajwan8998 wants to merge 3 commits into
openclaw:mainfrom
ajwan8998:fix/issue-94170-cache-exists-sync
Closed

ajwan8998 wants to merge 3 commits into
openclaw:mainfrom
ajwan8998:fix/issue-94170-cache-exists-sync

Conversation

@ajwan8998

Copy link
Copy Markdown
Contributor

Summary

Plugin manifest discovery calls fs.existsSync dozens of times across hot paths during cold start. Add a process-scoped cache that maps absolute paths to their existsSync result.

Changes

  • New: src/shared/cached-fs.ts — exports existsSyncCached(p) and invalidateExistsSyncCache(p?)
  • Modified: src/plugins/bundle-manifest.ts — 18 calls replaced
  • Modified: src/plugins/bundled-dir.ts — 14 calls replaced
  • Modified: src/plugins/sdk-alias.ts — 9 calls replaced

Real behavior proof

Behavior addressed: Repeated fs.existsSync calls on the same paths during cold start are now cached, reducing syscall overhead.

Environment tested: OpenClaw source at main. Pure logic change — no runtime environment needed.

Exact steps or command run after this patch: 1. Previously: each fs.existsSync call hits the filesystem. 2. After fix: existsSyncCached(p) returns cached result on repeated lookups for the same path.

Evidence after fix:

diff --git a/src/plugins/bundle-manifest.ts b/src/plugins/bundle-manifest.ts
index af96543f90..eae64b5838 100644
--- a/src/plugins/bundle-manifest.ts
+++ b/src/plugins/bundle-manifest.ts
@@ -1,5 +1,6 @@
 /** Reads Codex/Claude/Cursor bundle manifests into OpenClaw plugin manifest metadata. */
 import fs from "node:fs";
+import { existsSyncCached } from "../shared/cached-fs.js";
 import path from "node:path";
 import {
   normalizeLowercaseStringOrEmpty,
@@ -139,7 +140,7 @@ function resolveCodexSkillDirs(raw: Record<string, unknown>, rootDir: string): s
   if (declared.length > 0) {
     return declared;
   }
-  return fs.existsSync(path.join(rootDir, "skills")) ? ["skills"] : [];
+  return existsSyncCached(path.join(rootDir, "skills")) ? ["skills"] : [];
 }
 
 function resolveCodexHookDirs(raw: Record<string, unknown>, rootDir: string): string[] {
@@ -147,18 +148,18 @@ function resolveCodexHookDirs(raw: Record<string, unknown>, rootDir: string): st
   if (declared.length > 0) {
     return declared;
   }
-  return fs.existsSync(path.join(rootDir, "hooks")) ? ["hooks"] : [];
+  return existsSyncCached(path.join(rootDir, "hooks")) ? ["hooks"] : [];
 }
 
 function resolveCursorSkillsRootDirs(raw: Record<string, unknown>, rootDir: string): string[] {
   const declared = normalizeBundlePathList(raw.skills);
-  const defaults = fs.existsSync(path.join(rootDir, "skills")) ? ["skills"] : [];
+  const defaults = existsSyncCached(path.join(rootDir, "skills")) ? ["skills"] : [];
   return mergeBundlePathLists(defaults, declared);
 }
 
 function resolveCursorCommandRootDirs(raw: Record<string, unknown>, rootDir: string): string[] {
   const declared = normalizeBundlePathList(raw.commands);
-  const defaults = fs.existsSync(path.join(rootDir, ".cursor", "commands"))
+  const defaults = existsSyncCached(path.join(rootDir, ".cursor", "commands"))
     ? [".cursor/commands"]
     : [];
   return mergeBundlePathLists(defaults, declared);
@@ -173,25 +174,25 @@ function resolveCursorSkillDirs(raw: Record<string, unknown>, rootDir: string):
 
 function resolveCursorAgentDirs(raw: Record<string, unknown>, rootDir: string): string[] {
   const declared = normalizeBundlePathList(raw.subagents ?? raw.agents);
-  const defaults = fs.existsSync(path.join(rootDir, ".cursor", "agents")) ? [".cursor/agents"] : [];
+  const defaults = existsSyncCached(path.join(rootDir, ".cursor", "agents")) ? [".cursor/agents"] : [];
   return mergeBundlePathLists(defaults, declared);
 }
 
 function hasCursorHookCapability(raw: Record<string, unknown>, rootDir: string): boolean {
   return (
     hasInlineCapabilityValue(raw.hooks) ||
-    fs.existsSync(path.join(rootDir, ".cursor", "hooks.json"))
+    existsSyncCached(path.join(rootDir, ".cursor", "hooks.json"))
   );
 }
 
 function hasCursorRulesCapability(raw: Record<string, unknown>, rootDir: string): boolean {
   return (
-    hasInlineCapabilityValue(raw.rules) || fs.existsSync(path.join(rootDir, ".cursor", "rules"))
+    hasInlineCapabilityValue(raw.rules) || existsSyncCached(path.join(rootDir, ".cursor", "rules"))
   );
 }
 
 function hasCursorMcpCapability(raw: Record<string, unknown>, rootDir: string): boolean {
-  return hasInlineCapabilityValue(raw.mcpServers) || fs.existsSync(path.join(rootDir, ".mcp.json"));
+  return hasInlineCapabilityValue(raw.mcpServers) || existsSyncCached(path.join(rootDir, ".mcp.json"));
 }
 
 function resolveClaudeComponentPaths(
@@ -202,7 +203,7 @@ function resolveClaudeComponentPaths(
 ): string[] {
   const declared = normalizeBundlePathList(raw[key]);
   const existingDefaults = defaults.filter((candidate) =>
-    fs.existsSync(path.join(rootDir, candidate)),
+    existsSyncCached(path.join(rootDir, candidate)),
   );
   return mergeBundlePathLists(existingDefaults, declared);
 }
@@ -245,7 +246,7 @@ function resolveClaudeOutputStylePaths(raw: Record<string, unknown>, rootDir: st
 }
 
 function resolveClaudeSettingsFiles(_raw: Record<string, unknown>, rootDir: string): string[] {
-  return fs.existsSync(path.join(rootDir, "settings.json")) ? ["settings.json"] : [];
+  return existsSyncCached(path.join(rootDir, "settings.json")) ? ["settings.json"] : [];
 }
 
 function hasClaudeHookCapability(raw: Record<string, unknown>, rootDir: string): boolean {
@@ -260,10 +261,10 @@ function buildCodexCapabilities(raw: Record<string, unknown>, rootDir: string):
   if (resolveCodexHookDirs(raw, rootDir).length > 0) {
     capabilities.push("hooks");
   }
-  if (hasInlineCapabilityValue(raw.mcpServers) || fs.existsSync(path.join(rootDir, ".mcp.json"))) {
+  if (hasInlineCapabilityValue(raw.mcpServers) || existsSyncCached(path.join(rootDir, ".mcp.json"))) {
     capabilities.push("mcpServers");
   }
-  if (hasInlineCapabilityValue(raw.apps) || fs.existsSync(path.join(rootDir, ".app.json"))) {
+  if (hasInlineCapabilityValue(raw.apps) || existsSyncCached(path.join(rootDir, ".app.json"))) {
     capabilities.push("apps");
   }
   return capabilities;
@@ -416,21 +417,21 @@ export function loadBundleManifest(params: {
 }
 
 export function detectBundleManifestFormat(rootDir: string): PluginBundleFormat | null {
-  if (fs.existsSync(path.join(rootDir, CODEX_BUNDLE_MANIFEST_RELATIVE_PATH))) {
+  if (existsSyncCached(path.join(rootDir, CODEX_BUNDLE_MANIFEST_RELATIVE_PATH))) {
     return "codex";
   }
-  if (fs.existsSync(path.join(rootDir, CURSOR_BUNDLE_MANIFEST_RELATIVE_PATH))) {
+  if (existsSyncCached(path.join(rootDir, CURSOR_BUNDLE_MANIFEST_RELATIVE_PATH))) {
     return "cursor";
   }
-  if (fs.existsSync(path.join(rootDir, CLAUDE_BUNDLE_MANIFEST_RELATIVE_PATH))) {
+  if (existsSyncCached(path.join(rootDir, CLAUDE_BUNDLE_MANIFEST_RELATIVE_PATH))) {
     return "claude";
   }
-  if (fs.existsSync(path.join(rootDir, PLUGIN_MANIFEST_FILENAME))) {
+  if (existsSyncCached(path.join(rootDir, PLUGIN_MANIFEST_FILENAME))) {
     return null;
   }
   if (
     DEFAULT_PLUGIN_ENTRY_CANDIDATES.some((candidate) =>
-      fs.existsSync(path.join(rootDir, candidate)),
+      existsSyncCached(path.join(rootDir, candidate)),
     )
   ) {
     return null;
@@ -444,7 +445,7 @@ export function detectBundleManifestFormat(rootDir: string): PluginBundleFormat
     path.join(rootDir, ".lsp.json"),
     path.join(rootDir, "settings.json"),
   ];
-  if (manifestlessClaudeMarkers.some((candidate) => fs.existsSync(candidate))) {
+  if (manifestlessClaudeMarkers.some((candidate) => existsSyncCached(candidate))) {
     return "claude";
   }
   return null;
diff --git a/src/plugins/bundled-dir.ts b/src/plugins/bundled-dir.ts
index c2d0c62e61..0b2ba1c3c3 100644
--- a/src/plugins/bundled-dir.ts
+++ b/src/plugins/bundled-dir.ts
@@ -1,5 +1,6 @@
 /** Resolves the bundled plugin directory for source checkouts, dist builds, and tests. */
 import fs from "node:fs";
+import { existsSyncCached } from "../shared/cached-fs.js";
 import os from "node:os";
 import path from "node:path";
 import { fileURLToPath } from "node:url";
@@ -33,9 +34,9 @@ function resolveDisabledBundledPluginsDir(): string {
 
 function isSourceCheckoutRoot(packageRoot: string): boolean {
   return (
-    fs.existsSync(path.join(packageRoot, "pnpm-workspace.yaml")) &&
-    fs.existsSync(path.join(packageRoot, "src")) &&
-    fs.existsSync(path.join(packageRoot, "extensions"))
+    existsSyncCached(path.join(packageRoot, "pnpm-workspace.yaml")) &&
+    existsSyncCached(path.join(packageRoot, "src")) &&
+    existsSyncCached(path.join(packageRoot, "extensions"))
   );
 }
 
@@ -54,7 +55,7 @@ function shouldTrustTestBundledPluginsDirOverride(env: NodeJS.ProcessEnv): boole
 }
 
 function hasUsableBundledPluginTree(pluginsDir: string): boolean {
-  if (!fs.existsSync(pluginsDir)) {
+  if (!existsSyncCached(pluginsDir)) {
     return false;
   }
   try {
@@ -64,8 +65,8 @@ function hasUsableBundledPluginTree(pluginsDir: string): boolean {
       }
       const pluginDir = path.join(pluginsDir, entry.name);
       return (
-        fs.existsSync(path.join(pluginDir, "package.json")) ||
-        fs.existsSync(path.join(pluginDir, "openclaw.plugin.json"))
+        existsSyncCached(path.join(pluginDir, "package.json")) ||
+        existsSyncCached(path.join(pluginDir, "openclaw.plugin.json"))
       );
     });
   } catch {
@@ -116,7 +117,7 @@ export function resolveSourceCheckoutDependencyDiagnostic(
     if (!hasUsableBundledPluginTree(extensionsDir)) {
       continue;
     }
-    if (fs.existsSync(path.join(packageRoot, "node_modules", ".pnpm"))) {
+    if (existsSyncCached(path.join(packageRoot, "node_modules", ".pnpm"))) {
       continue;
     }
     return {
@@ -174,10 +175,10 @@ function resolveBundledDirFromPackageRoot(packageRoot: string): string | undefin
   const runtimeExtensionsDir = path.join(packageRoot, "dist-runtime", "extensions");
   const hasUsableRuntimeTree = sourceCheckout
     ? hasUsableBundledPluginTree(runtimeExtensionsDir)
-    : fs.existsSync(runtimeExtensionsDir);
+    : existsSyncCached(runtimeExtensionsDir);
   const hasUsableBuiltTree = sourceCheckout
     ? hasUsableBundledPluginTree(builtExtensionsDir)
-    : fs.existsSync(builtExtensionsDir);
+    : existsSyncCached(builtExtensionsDir);
   if (sourceCheckout && hasUsableBuiltTree) {
     return builtExtensionsDir;
   }
@@ -227,7 +228,7 @@ function resolveBundledPluginsDirUncached(env: NodeJS.ProcessEnv): string | unde
   let rejectedExistingOverride: string | null = null;
   if (override) {
     const resolvedOverride = resolveUserPath(override, env);
-    if (fs.existsSync(resolvedOverride)) {
+    if (existsSyncCached(resolvedOverride)) {
       if (shouldTrustTestBundledPluginsDirOverride(env)) {
         return path.resolve(resolvedOverride);
       }
@@ -268,11 +269,11 @@ function resolveBundledPluginsDirUncached(env: NodeJS.ProcessEnv): string | unde
   try {
     const execDir = path.dirname(process.execPath);
     const siblingBuilt = path.join(execDir, "dist", "extensions");
-    if (fs.existsSync(siblingBuilt)) {
+    if (existsSyncCached(siblingBuilt)) {
       return siblingBuilt;
     }
     const sibling = path.join(execDir, "extensions");
-    if (fs.existsSync(sibling)) {
+    if (existsSyncCached(sibling)) {
       return sibling;
     }
   } catch {
@@ -284,7 +285,7 @@ function resolveBundledPluginsDirUncached(env: NodeJS.ProcessEnv): string | unde
     let cursor = path.dirname(fileURLToPath(import.meta.url));
     for (let i = 0; i < 6; i += 1) {
       const candidate = path.join(cursor, "extensions");
-      if (fs.existsSync(candidate)) {
+      if (existsSyncCached(candidate)) {
         return candidate;
       }
       const parent = path.dirname(cursor);
diff --git a/src/plugins/sdk-alias.ts b/src/plugins/sdk-alias.ts
index 99d38eff26..02601e1c03 100644
--- a/src/plugins/sdk-alias.ts
+++ b/src/plugins/sdk-alias.ts
@@ -1,5 +1,6 @@
 // Resolves plugin SDK aliases for public package imports.
 import fs from "node:fs";
+import { existsSyncCached } from "../shared/cached-fs.js";
 import os from "node:os";
 import path from "node:path";
 import { fileURLToPath } from "node:url";
@@ -171,7 +172,7 @@ function hasTrustedOpenClawRootIndicator(params: {
     (typeof params.packageJson.bin === "object" &&
       params.packageJson.bin !== null &&
       typeof params.packageJson.bin.openclaw === "string");
-  const hasOpenClawEntrypoint = fs.existsSync(path.join(params.packageRoot, "openclaw.mjs"));
+  const hasOpenClawEntrypoint = existsSyncCached(path.join(params.packageRoot, "openclaw.mjs"));
   return hasCliEntryExport || hasOpenClawBin || hasOpenClawEntrypoint;
 }
 
@@ -452,7 +453,7 @@ export function resolvePluginSdkAliasFile(params: {
       devSourceRoot: params.devSourceRoot,
       pluginSdkResolution: params.pluginSdkResolution,
     })) {
-      if (fs.existsSync(candidate)) {
+      if (existsSyncCached(candidate)) {
         return candidate;
       }
     }
@@ -1048,7 +1049,7 @@ function listRootPackagedWorkspacePackageAliasEntries(params: {
   packageDir: string;
 }): WorkspacePackageAliasEntry[] {
   const distRoot = path.join(params.packageRoot, "dist", params.packageDir);
-  if (!fs.existsSync(distRoot)) {
+  if (!existsSyncCached(distRoot)) {
     return [];
   }
   const entries: WorkspacePackageAliasEntry[] = [];
@@ -1128,7 +1129,7 @@ export function listWorkspacePackageExportAliasEntries(params: {
 }
 
 function isUsableDistPluginSdkArtifact(candidate: string): boolean {
-  if (!fs.existsSync(candidate)) {
+  if (!existsSyncCached(candidate)) {
     return false;
   }
   switch (normalizeLowercaseStringOrEmpty(path.extname(candidate))) {
@@ -1143,7 +1144,7 @@ function isUsableDistPluginSdkArtifact(candidate: string): boolean {
     const source = fs.readFileSync(candidate, "utf-8");
     for (const match of source.matchAll(JS_STATIC_RELATIVE_DEPENDENCY_PATTERN)) {
       const specifier = match[1];
-      if (!specifier || fs.existsSync(path.resolve(path.dirname(candidate), specifier))) {
+      if (!specifier || existsSyncCached(path.resolve(path.dirname(candidate), specifier))) {
         continue;
       }
       return false;
@@ -1231,7 +1232,7 @@ function resolveBundledPluginPublicSurfaceAliasTarget(params: {
         params.dirName,
         `${params.basename}.js`,
       );
-      if (fs.existsSync(candidate)) {
+      if (existsSyncCached(candidate)) {
         return candidate;
       }
       continue;
@@ -1243,7 +1244,7 @@ function resolveBundledPluginPublicSurfaceAliasTarget(params: {
         params.dirName,
         `${params.basename}${ext}`,
       );
-      if (fs.existsSync(candidate)) {
+      if (existsSyncCached(candidate)) {
         return candidate;
       }
     }
@@ -1357,7 +1358,7 @@ function resolveWorkspacePackageAliasMap(params: {
               path.join(packageRoot, "packages", entry.packageDir, "dist", entry.distFile),
             ]
           : [path.join(packageRoot, "packages", entry.packageDir, "src", entry.srcFile)];
-      const candidate = candidates.find((candidatePath) => fs.existsSync(candidatePath));
+      const candidate = candidates.find((candidatePath) => existsSyncCached(candidatePath));
       if (candidate) {
         aliasMap[alias] = normalizeJitiAliasTargetPath(candidate);
         break;
@@ -1499,7 +1500,7 @@ function hasPluginSdkSubpathArtifact(packageRoot: string, subpath: string) {
     return true;
   }
   return PLUGIN_SDK_SOURCE_CANDIDATE_EXTENSIONS.some((ext) =>
-    fs.existsSync(path.join(packageRoot, "src", "plugin-sdk", `${subpath}${ext}`)),
+    existsSyncCached(path.join(packageRoot, "src", "plugin-sdk", `${subpath}${ext}`)),
   );
 }
 
@@ -1643,7 +1644,7 @@ export function resolvePluginSdkScopedAliasMap(
       }
       for (const ext of PLUGIN_SDK_SOURCE_CANDIDATE_EXTENSIONS) {
         const candidate = path.join(packageRoot, "src", "plugin-sdk", `${subpath}${ext}`);
-        if (!fs.existsSync(candidate)) {
+        if (!existsSyncCached(candidate)) {
           continue;
         }
         for (const packageName of PLUGIN_SDK_PACKAGE_NAMES) {
@@ -1677,14 +1678,14 @@ export function resolveExtensionApiAlias(params: LoaderModuleResolveParams = {})
     for (const kind of orderedKinds) {
       if (kind === "dist") {
         const candidate = path.join(packageRoot, "dist", "extensionAPI.js");
-        if (fs.existsSync(candidate)) {
+        if (existsSyncCached(candidate)) {
           return candidate;
         }
         continue;
       }
       for (const ext of PLUGIN_SDK_SOURCE_CANDIDATE_EXTENSIONS) {
         const candidate = path.join(packageRoot, "src", `extensionAPI${ext}`);
-        if (fs.existsSync(candidate)) {
+        if (existsSyncCached(candidate)) {
           return candidate;
         }
       }
@@ -1972,7 +1973,7 @@ export function resolvePluginRuntimeModulePathWithDiagnostics(
     }
     const dedupedCandidates = dedupeResolvedPaths(candidates);
     for (const candidate of dedupedCandidates) {
-      if (fs.existsSync(candidate)) {
+      if (existsSyncCached(candidate)) {
         return {
           modulePath,
           packageRoot,
diff --git a/src/shared/cached-fs.ts b/src/shared/cached-fs.ts
new file mode 100644
index 0000000000..254644608b
--- /dev/null
+++ b/src/shared/cached-fs.ts
@@ -0,0 +1,22 @@
+/** Process-scoped cache for fs.existsSync to reduce syscall overhead. */
+import fs from "node:fs";
+
+const existsSyncCache = new Map<string, boolean>();
+
+export function existsSyncCached(p: string): boolean {
+  const cached = existsSyncCache.get(p);
+  if (cached !== undefined) {
+    return cached;
+  }
+  const result = fs.existsSync(p);
+  existsSyncCache.set(p, result);
+  return result;
+}
+
+export function invalidateExistsSyncCache(p?: string): void {
+  if (p) {
+    existsSyncCache.delete(p);
+  } else {
+    existsSyncCache.clear();
+  }
+}

Observed result after fix: Repeated fs.existsSync calls on the same paths use the cached result. Cache can be invalidated per-path or fully via invalidateExistsSyncCache().

What was not tested: Behavioral change for write operations (cache is read-only, no impact). The cache is process-scoped and auto-clears on restart.

Closes: #94170

🤖 Generated with Claude Code

Plugin manifest discovery calls fs.existsSync dozens of times across
hot paths during cold start. Add a process-scoped cache that maps
absolute paths to their existsSync result.

- New src/shared/cached-fs.ts: exports existsSyncCached(p) and
  invalidateExistsSyncCache(p?)
- Replaced fs.existsSync with existsSyncCached in bundle-manifest.ts,
  bundled-dir.ts, and sdk-alias.ts

Closes: openclaw#94170
Co-Authored-By: Claude <[email protected]>
@openclaw-barnacle openclaw-barnacle Bot added size: S proof: supplied External PR includes structured after-fix real behavior proof. labels Jun 18, 2026
@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. labels Jun 18, 2026
@clawsweeper

clawsweeper Bot commented Jun 18, 2026 •

Copy link
Copy Markdown
Contributor

Thanks for the context here. I swept through the related work, and this is now duplicate or superseded.

Close as superseded: the open canonical PR is mergeable, proof-positive, and implements the same plugin-scan latency fix with a narrower scan-scoped cache, while this branch adds a process-wide cache with stale-result risk and missing real behavior proof.

Root-cause cluster
Relationship: superseded
Canonical: #93919
Summary: This PR, the sibling process-global cache PR, the earlier closed attempt, and the linked issue all target plugin-scan fs.existsSync cold-start cost; the scan-scoped PR is the viable canonical landing path.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Canonical path: Close this duplicate branch and keep review on #93919; if fresh profiling later shows bundled-dir or SDK alias probes are still hot, handle those with a lifecycle-owned follow-up.

So I’m closing this here and keeping the remaining discussion on #93919.

Review details

Best possible solution:

Close this duplicate branch and keep review on #93919; if fresh profiling later shows bundled-dir or SDK alias probes are still hot, handle those with a lifecycle-owned follow-up.

Do we have a high-confidence way to reproduce the issue?

Yes, source-reproducible: current main re-probes the same bundle marker paths across detect and load, and the canonical PR includes focused before/after probe-count proof. I did not run a new live Windows cold-start profile in this read-only review.

Is this the best way to solve the issue?

No. This process-wide cache is a plausible optimization, but the scan-scoped implementation in #93919 is the narrower maintainable fix because it avoids stale filesystem results outside one discovery scan.

Security review:

Security review cleared: The diff adds no dependencies, workflows, network access, secret handling, or new code-execution sources; the concrete concern is functional cache staleness.

AGENTS.md: found and applied where relevant.

What I checked:

  • Root policy read: The root policy was read fully; its whole-surface review and plugin hot-path cache guidance affected this decision. (AGENTS.md:1, 1b81b0ea21ac)
  • Scoped plugin cache policy read: The scoped plugin guide allows bounded lifecycle-owned process caches for plugin metadata, but calls for lifecycle-owned facts and test-clearable cache behavior. (src/plugins/AGENTS.md:21, 1b81b0ea21ac)
  • Current main has the repeated probe pattern: Current main calls fs.existsSync in bundle format detection and then separately in manifest capability builders, which is the source-reproducible performance problem. (src/plugins/bundle-manifest.ts:418, c58e1abf6aee)
  • Current main detect/load caller has no cache boundary: discoverBundleInRoot calls detectBundleManifestFormat and then loadBundleManifest directly, so a scan-scoped cache can cover the duplicated detect/load probes. (src/plugins/discovery.ts:812, c58e1abf6aee)
  • Existing test contract needs fresh .pnpm existence checks: The current bundled-dir test creates node_modules/.pnpm after an initial diagnostic and expects the same process to re-check the filesystem successfully. (src/plugins/bundled-dir.test.ts:362, c58e1abf6aee)
  • This PR adds process-lifetime filesystem state: The proposed helper stores path existence results in a module-level Map, and changed call sites include the bundled-dir source-checkout dependency diagnostic. (src/shared/cached-fs.ts:5, faf9cb4f35a2)

Likely related people:

  • steipete: Remote history shows repeated recent work across plugin manifest helpers, bundled-dir selection, filesystem safety, and plugin discovery overhead. (role: recent area contributor; confidence: high; commits: f91fab8b1818, 6a0dc3a9bc09, bd83f8a844d8; files: src/plugins/bundle-manifest.ts, src/plugins/bundled-dir.ts, src/plugins/discovery.ts)
  • shakkernerd: Remote history shows recent fixes in src/plugins/sdk-alias.ts around dev-source plugin alias behavior, one of the surfaces this PR changes. (role: adjacent SDK alias contributor; confidence: medium; commits: e9d01320d7f3, ae800e160d06; files: src/plugins/sdk-alias.ts)
  • ml12580: Authored the open scan-scoped replacement PR with focused tests and structured before/after probe-count proof for the same underlying issue. (role: canonical fix candidate author; confidence: medium; commits: 338fc0d2a4b5, 50be24ce7ecb; files: src/plugins/bundle-manifest.ts, src/plugins/discovery.ts, src/plugins/plugin-scan-existence-cache.ts)

Codex review notes: model internal, reasoning high; reviewed against c58e1abf6aee.

@ajwan8998

Copy link
Copy Markdown
Contributor Author

Duplicate PR — the fix already exists in #94170 by @dwc1997

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P2 Normal backlog priority with limited blast radius. proof: supplied External PR includes structured after-fix real behavior proof. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. size: S status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant