Skip to content

Commit b4e5c9a

Browse files
committed
refactor(context-engine): remove owner cleanup helper
1 parent 87d49a3 commit b4e5c9a

3 files changed

Lines changed: 9 additions & 54 deletions

File tree

‎src/context-engine/quarantine-health.test.ts‎

Lines changed: 1 addition & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,7 @@ import {
1212
clearPersistedContextEngineQuarantineForProcess,
1313
recordPersistedContextEngineQuarantine,
1414
} from "./quarantine-health.js";
15-
import {
16-
clearContextEnginesForOwner,
17-
listContextEngineQuarantines,
18-
registerContextEngineForOwner,
19-
} from "./registry.js";
15+
import { listContextEngineQuarantines } from "./registry.js";
2016
import { resetContextEngineRuntimeQuarantineForTests } from "./registry.test-support.js";
2117

2218
const CONTEXT_ENGINE_QUARANTINE_OWNER_ID = "core:context-engine-quarantine-health";
@@ -244,37 +240,4 @@ describe("context engine quarantine health", () => {
244240
});
245241
});
246242
});
247-
248-
it("clears persisted quarantine records when owner engines unload", async () => {
249-
await withStateDirEnv("openclaw-context-engine-quarantine-owner-", async () => {
250-
const owner = "plugin:lossless-claw";
251-
registerContextEngineForOwner(
252-
"lossless-claw",
253-
() => ({
254-
info: { id: "lossless-claw", name: "Lossless Claw", version: "1" },
255-
async ingest() {
256-
return { ingested: true };
257-
},
258-
async assemble({ messages }) {
259-
return { messages, estimatedTokens: 0 };
260-
},
261-
async compact() {
262-
return { ok: true, compacted: false };
263-
},
264-
}),
265-
owner,
266-
);
267-
recordPersistedContextEngineQuarantine({
268-
engineId: "lossless-claw",
269-
owner,
270-
operation: "bootstrap",
271-
reason: "plugin disabled",
272-
failedAt: new Date(123),
273-
});
274-
275-
clearContextEnginesForOwner(owner);
276-
277-
expect(listContextEngineQuarantines()).toEqual([]);
278-
});
279-
});
280243
});

‎src/context-engine/registry.ts‎

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -442,19 +442,9 @@ function listContextEngineIds(): string[] {
442442
return [...getContextEngines().keys()].toSorted();
443443
}
444444

445-
export function clearContextEnginesForOwner(owner: string): void {
446-
const normalizedOwner = requireContextEngineOwner(owner);
447-
const registry = getContextEngines();
448-
for (const [id, entry] of registry.entries()) {
449-
if (entry.owner === normalizedOwner) {
450-
registry.delete(id);
451-
clearContextEngineRuntimeQuarantine(id);
452-
}
453-
}
454-
}
455-
456445
/**
457446
* Return the trusted plugin id that registered a resolved context engine.
447+
* Downgraded engines intentionally report no plugin owner.
458448
*/
459449
export function resolveContextEngineOwnerPluginId(
460450
engine: ContextEngine | undefined | null,

‎src/gateway/server-methods/server-methods.test.ts‎

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,13 @@ import { HEARTBEAT_PROMPT } from "../../auto-reply/heartbeat.js";
1515
import type { OpenClawConfig } from "../../config/types.openclaw.js";
1616
import { registerLegacyContextEngine } from "../../context-engine/legacy.registration.js";
1717
import {
18-
clearContextEnginesForOwner,
1918
registerContextEngineForOwner,
2019
resolveContextEngine,
2120
} from "../../context-engine/registry.js";
22-
import { resetContextEngineRuntimeQuarantineForTests } from "../../context-engine/registry.test-support.js";
21+
import {
22+
captureContextEngineRegistryStateForTests,
23+
resetContextEngineRuntimeQuarantineForTests,
24+
} from "../../context-engine/registry.test-support.js";
2325
import { emitAgentEvent } from "../../infra/agent-events.js";
2426
import { formatZonedTimestamp } from "../../infra/format-time/format-datetime.js";
2527
import {
@@ -4410,6 +4412,7 @@ describe("gateway healthHandlers.status scope handling", () => {
44104412

44114413
describe("gateway healthHandlers.health cache freshness", () => {
44124414
let healthHandlers: typeof import("./health.js").healthHandlers;
4415+
let restoreContextEngineRegistryState: () => void;
44134416
const contextEngineTestOwner = "plugin:health-test";
44144417

44154418
function createHealthSnapshot<T extends Record<string, unknown>>(overrides: T) {
@@ -4508,15 +4511,14 @@ describe("gateway healthHandlers.health cache freshness", () => {
45084511
});
45094512

45104513
beforeEach(() => {
4514+
restoreContextEngineRegistryState = captureContextEngineRegistryStateForTests();
45114515
registerLegacyContextEngine();
4512-
clearContextEnginesForOwner(contextEngineTestOwner);
45134516
resetContextEngineRuntimeQuarantineForTests();
45144517
});
45154518

45164519
afterEach(() => {
45174520
vi.useRealTimers();
4518-
clearContextEnginesForOwner(contextEngineTestOwner);
4519-
resetContextEngineRuntimeQuarantineForTests();
4521+
restoreContextEngineRegistryState();
45204522
});
45214523

45224524
it("rate-limits request-driven refreshes for fresh cached health", async () => {

0 commit comments

Comments
 (0)