Repository navigation
fix(plugins): guard runtime facade activation - #59412
Conversation
Greptile SummaryThis PR introduces an activation-aware facade boundary for bundled plugin runtime surfaces. It adds Key points:
Confidence Score: 4/5
Prompt To Fix All With AIThis is a comment left during a code review.
Path: src/plugin-sdk/facade-runtime.ts
Line: 136-153
Comment:
**Cache validity depends on `loadConfig()` reference stability**
`getFacadeBoundaryResolvedConfig` uses reference equality (`===`) to decide whether to reuse the cached resolved config. This works correctly as long as `loadConfig()` returns the same object reference when the config hasn't changed — which is guaranteed by the `runtimeConfigSnapshot` singleton in `io.ts`.
However, there's one edge case: if `loadConfig()` throws (e.g., no config file present in the environment), `readFacadeBoundaryConfigSafely()` returns a fresh `{}` literal on every call, so the cache will never hit. The consequence is that `loadPluginManifestRegistry` and `resolveEffectiveEnableState` get re-invoked on every facade access in that environment. Since `loadPluginManifestRegistry` uses `cache: true` internally, the practical impact is low — but the intent of the outer cache is silently defeated.
Consider documenting this implicit dependency on `loadConfig()`'s snapshot semantics, or adding a fallback stable sentinel for the "no config" path:
```typescript
// Example: replace the bare {} fallback with a stable reference
const EMPTY_CONFIG: OpenClawConfig = {};
function readFacadeBoundaryConfigSafely(): OpenClawConfig {
try {
return loadConfig();
} catch {
return EMPTY_CONFIG;
}
}
```
This would make the cache effective even when no config file is present.
How can I resolve this? If you propose a fix, please make it concise.
---
This is a comment left during a code review.
Path: src/channels/plugins/session-conversation.ts
Line: 156-169
Comment:
**Redundant double invocation of `resolveBundledPluginPublicSurfaceAccess`**
`canLoadActivatedBundledPluginPublicSurface` and `loadActivatedBundledPluginPublicSurfaceModuleSync` both call `resolveBundledPluginPublicSurfaceAccess` internally, so the access check is performed twice for every path that reaches the `loadActivated…` call.
The pattern is understandable — using `canLoad` to return `null` gracefully instead of catching an exception — but the double-resolve includes a manifest registry scan each time (even with `cache: true`, it iterates the plugin list). Since `session-conversation.ts` can be called in a hot path before bootstrap, consider consolidating into a single access-check call, for example by letting `loadActivated…` accept an optional "or return null" mode, or by simply adding a try/catch here so the full resolve only happens once:
```typescript
let resolveSessionConversation: BundledSessionKeyModule["resolveSessionConversation"];
try {
resolveSessionConversation = loadActivatedBundledPluginPublicSurfaceModuleSync<BundledSessionKeyModule>({
dirName,
artifactBasename: SESSION_KEY_API_ARTIFACT_BASENAME,
}).resolveSessionConversation;
} catch {
return null;
}
```
This is a minor efficiency suggestion — the current code is functionally correct because both calls share the same `getFacadeBoundaryResolvedConfig` cache and `loadPluginManifestRegistry({cache: true})`.
How can I resolve this? If you propose a fix, please make it concise.Reviews (1): Last reviewed commit: "fix(plugins): guard runtime facade activ..." | Re-trigger Greptile |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 671dcd9903
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 7470d8b9d0
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 06ca15e938
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 6ca97f9cba
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
* fix(plugins): guard runtime facade activation * refactor(plugin-sdk): localize facade load policy * fix(plugin-sdk): narrow facade activation guards * fix(browser): keep cleanup helpers outside activation guard * style(browser): apply formatter follow-ups * chore(changelog): note plugin activation guard regressions * fix(discord): keep cleanup thread unbinds outside activation guard * fix(browser): fallback when trash exits non-zero
* fix(plugins): guard runtime facade activation * refactor(plugin-sdk): localize facade load policy * fix(plugin-sdk): narrow facade activation guards * fix(browser): keep cleanup helpers outside activation guard * style(browser): apply formatter follow-ups * chore(changelog): note plugin activation guard regressions * fix(discord): keep cleanup thread unbinds outside activation guard * fix(browser): fallback when trash exits non-zero
* fix(plugins): guard runtime facade activation * refactor(plugin-sdk): localize facade load policy * fix(plugin-sdk): narrow facade activation guards * fix(browser): keep cleanup helpers outside activation guard * style(browser): apply formatter follow-ups * chore(changelog): note plugin activation guard regressions * fix(discord): keep cleanup thread unbinds outside activation guard * fix(browser): fallback when trash exits non-zero
* fix(plugins): guard runtime facade activation * refactor(plugin-sdk): localize facade load policy * fix(plugin-sdk): narrow facade activation guards * fix(browser): keep cleanup helpers outside activation guard * style(browser): apply formatter follow-ups * chore(changelog): note plugin activation guard regressions * fix(discord): keep cleanup thread unbinds outside activation guard * fix(browser): fallback when trash exits non-zero
* fix(plugins): guard runtime facade activation * refactor(plugin-sdk): localize facade load policy * fix(plugin-sdk): narrow facade activation guards * fix(browser): keep cleanup helpers outside activation guard * style(browser): apply formatter follow-ups * chore(changelog): note plugin activation guard regressions * fix(discord): keep cleanup thread unbinds outside activation guard * fix(browser): fallback when trash exits non-zero
* fix(plugins): guard runtime facade activation * refactor(plugin-sdk): localize facade load policy * fix(plugin-sdk): narrow facade activation guards * fix(browser): keep cleanup helpers outside activation guard * style(browser): apply formatter follow-ups * chore(changelog): note plugin activation guard regressions * fix(discord): keep cleanup thread unbinds outside activation guard * fix(browser): fallback when trash exits non-zero
* fix(plugins): guard runtime facade activation * refactor(plugin-sdk): localize facade load policy * fix(plugin-sdk): narrow facade activation guards * fix(browser): keep cleanup helpers outside activation guard * style(browser): apply formatter follow-ups * chore(changelog): note plugin activation guard regressions * fix(discord): keep cleanup thread unbinds outside activation guard * fix(browser): fallback when trash exits non-zero
* fix(plugins): guard runtime facade activation * refactor(plugin-sdk): localize facade load policy * fix(plugin-sdk): narrow facade activation guards * fix(browser): keep cleanup helpers outside activation guard * style(browser): apply formatter follow-ups * chore(changelog): note plugin activation guard regressions * fix(discord): keep cleanup thread unbinds outside activation guard * fix(browser): fallback when trash exits non-zero
* fix(plugins): guard runtime facade activation * refactor(plugin-sdk): localize facade load policy * fix(plugin-sdk): narrow facade activation guards * fix(browser): keep cleanup helpers outside activation guard * style(browser): apply formatter follow-ups * chore(changelog): note plugin activation guard regressions * fix(discord): keep cleanup thread unbinds outside activation guard * fix(browser): fallback when trash exits non-zero
Summary
runtime-api.jsfacades and thesession-key-api.jsfallback insrc/channels/plugins/session-conversation.tscould still import bundled plugin code without going through an activation-aware boundary.Change Type (select all)
Scope (select all touched areas)
Linked Issue/PR
Root Cause / Regression History (if applicable)
src/plugin-sdk/facade-runtime.tswas a raw bundled public-surface loader with no activation check, andsrc/channels/plugins/session-conversation.tsbypassed plugin activation by deep-loadingsession-key-api.jsdirectly.git blame, prior PR, issue, or refactor if known): this is the next tranche after the earlier ambient-load cleanup on plugin loading.Regression Test Plan (if applicable)
src/plugin-sdk/facade-runtime.test.tssrc/channels/plugins/session-conversation.test.tssrc/plugin-activation-boundary.test.tssrc/tts/tts.test.tssrc/plugin-activation-boundary.test.tsalready covered the ambient-load tranche and now remains green with the guarded runtime seam.User-visible / Behavior Changes
Disabled bundled channel/runtime plugins no longer load through generated runtime facades or bundled session-conversation fallback parsing unless current config semantics activate them.
Diagram (if applicable)
Security Impact (required)
Yes, explain risk + mitigation: N/A.Repro + Verification
Environment
Steps
session-key-api.jsfallback before registry bootstrap.Expected
Actual
Evidence
Human Verification (required)
pnpm test -- src/plugin-sdk/facade-runtime.test.ts src/channels/plugins/session-conversation.test.ts src/plugin-activation-boundary.test.ts src/tts/tts.test.ts src/plugins/runtime/index.test.tspnpm buildpnpm checkbefore rebase; post-rebase targeted tests + build re-run cleanollama.tsintentionally left unguarded after build proved it is a helper surface, not a runtime-only entrypointpnpm testpnpm plugin-sdk:facades:checkpass was not kept as a gate because the generator process was abnormally slow/noisy in this worktree while the committed/generated outputs were already validated bypnpm buildReview Conversations
Compatibility / Migration
Risks and Mitigations
Risk:
runtime-api.jsfacade was too broad and broke helper-style surfaces such asollama.tsduring plugin bootstrap.Mitigation:
runtime-api.jssurface is runtime-only.Risk:
Mitigation: