mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 07:50:43 +00:00
fix(plugins): invalidate index on policy changes
This commit is contained in:
@@ -154,6 +154,30 @@ describe("installed plugin index persistence", () => {
|
||||
},
|
||||
});
|
||||
|
||||
await expect(
|
||||
inspectPersistedInstalledPluginIndex({
|
||||
stateDir,
|
||||
candidates: [candidate],
|
||||
config: {
|
||||
plugins: {
|
||||
entries: {
|
||||
demo: {
|
||||
enabled: false,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
env,
|
||||
}),
|
||||
).resolves.toMatchObject({
|
||||
state: "stale",
|
||||
refreshReasons: ["policy-changed"],
|
||||
persisted: current,
|
||||
current: {
|
||||
plugins: [expect.objectContaining({ pluginId: "demo", enabled: false })],
|
||||
},
|
||||
});
|
||||
|
||||
fs.writeFileSync(
|
||||
path.join(pluginDir, "openclaw.plugin.json"),
|
||||
JSON.stringify({
|
||||
|
||||
@@ -466,6 +466,40 @@ describe("installed plugin index", () => {
|
||||
]);
|
||||
});
|
||||
|
||||
it("treats enablement changes as policy invalidation", () => {
|
||||
const fixture = createRichPluginFixture();
|
||||
const previous = loadInstalledPluginIndex({
|
||||
candidates: [fixture.candidate],
|
||||
config: {
|
||||
plugins: {
|
||||
entries: {
|
||||
demo: {
|
||||
enabled: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
env: hermeticEnv(),
|
||||
});
|
||||
const current = loadInstalledPluginIndex({
|
||||
candidates: [fixture.candidate],
|
||||
config: {
|
||||
plugins: {
|
||||
entries: {
|
||||
demo: {
|
||||
enabled: false,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
env: hermeticEnv(),
|
||||
});
|
||||
|
||||
expect(diffInstalledPluginIndexInvalidationReasons(previous, current)).toEqual([
|
||||
"policy-changed",
|
||||
]);
|
||||
});
|
||||
|
||||
it("marks disabled plugins without dropping their cold contributions", () => {
|
||||
const fixture = createRichPluginFixture();
|
||||
|
||||
|
||||
@@ -29,6 +29,7 @@ export type InstalledPluginIndexRefreshReason =
|
||||
| "stale-manifest"
|
||||
| "stale-package"
|
||||
| "source-changed"
|
||||
| "policy-changed"
|
||||
| "host-contract-changed"
|
||||
| "compat-registry-changed"
|
||||
| "manual";
|
||||
@@ -613,6 +614,9 @@ export function diffInstalledPluginIndexInvalidationReasons(
|
||||
) {
|
||||
reasons.add("source-changed");
|
||||
}
|
||||
if (previousPlugin.enabled !== currentPlugin.enabled) {
|
||||
reasons.add("policy-changed");
|
||||
}
|
||||
if (previousPlugin.manifestHash !== currentPlugin.manifestHash) {
|
||||
reasons.add("stale-manifest");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user