Severity: low / Confidence: high / Category: test-gap
Triage: test-gap
Detected against: openclaw v2026.5.18 (latest stable at time of scan, 2026-05-18)
Tooling: clawpatch 0.3.0 + acpx/claude-sonnet-4-5 via Brad Mills protocol
Evidence
extensions/twitch/src/client-manager-registry.ts:29-29 (registry)
const registry = new Map<string, RegistryEntry>();
extensions/twitch/src/twitch-client.ts:272-275 (_clearForTest)
_clearForTest(): void {
this.clients.clear();
this.messageHandlers.clear();
}
Reasoning
TwitchClientManager exports _clearForTest() acknowledging that module state needs to be reset between tests. The module-level registry Map in client-manager-registry.ts has no equivalent. Under --isolate=false (documented in CLAUDE.md), a test that calls getOrCreateClientManager will leave an entry that bleeds into subsequent tests, causing getOrCreateClientManager to return a stale/mock manager instead of creating a fresh one.
Reproduction
In a vitest run with --isolate=false, test A calls getOrCreateClientManager('default', loggerA), test B calls the same — it gets loggerA's manager silently.
Recommendation
Export a _clearRegistryForTest() function that calls registry.clear(), mirroring the pattern already used in TwitchClientManager.
Why existing tests miss this
The included tests do not call getOrCreateClientManager directly; they mock at the resolveTwitchAccountContext level, so the leak is latent rather than currently observable.
Suggested regression test
Add an afterEach that calls _clearRegistryForTest() in any test file that exercises getOrCreateClientManager, and assert each test starts with an empty registry.
Minimum fix scope
Add one exported _clearRegistryForTest(): void { registry.clear(); } function to client-manager-registry.ts.
Standardized clawpatch finding. Persistent in v2026.5.18 (not resolved by upgrading from v2026.5.12). Finding ID: fnd_sig-feat-cli-command-0c715f7406-_bd18f93218.
Severity: low / Confidence: high / Category: test-gap
Triage: test-gap
Detected against: openclaw v2026.5.18 (latest stable at time of scan, 2026-05-18)
Tooling: clawpatch 0.3.0 + acpx/claude-sonnet-4-5 via Brad Mills protocol
Evidence
extensions/twitch/src/client-manager-registry.ts:29-29(registry)extensions/twitch/src/twitch-client.ts:272-275(_clearForTest)Reasoning
TwitchClientManagerexports_clearForTest()acknowledging that module state needs to be reset between tests. The module-levelregistryMap inclient-manager-registry.tshas no equivalent. Under--isolate=false(documented in CLAUDE.md), a test that callsgetOrCreateClientManagerwill leave an entry that bleeds into subsequent tests, causinggetOrCreateClientManagerto return a stale/mock manager instead of creating a fresh one.Reproduction
In a vitest run with
--isolate=false, test A callsgetOrCreateClientManager('default', loggerA), test B calls the same — it gets loggerA's manager silently.Recommendation
Export a
_clearRegistryForTest()function that callsregistry.clear(), mirroring the pattern already used inTwitchClientManager.Why existing tests miss this
The included tests do not call
getOrCreateClientManagerdirectly; they mock at theresolveTwitchAccountContextlevel, so the leak is latent rather than currently observable.Suggested regression test
Add an
afterEachthat calls_clearRegistryForTest()in any test file that exercisesgetOrCreateClientManager, and assert each test starts with an empty registry.Minimum fix scope
Add one exported
_clearRegistryForTest(): void { registry.clear(); }function to client-manager-registry.ts.Standardized clawpatch finding. Persistent in v2026.5.18 (not resolved by upgrading from v2026.5.12). Finding ID:
fnd_sig-feat-cli-command-0c715f7406-_bd18f93218.