Skip to content

refactor: consolidate plugin cache and lifecycle owners - #178018

Merged
steipete merged 2 commits into
mainfrom
deslop/z41-6-plugin-cache-owners-20261015
Oct 20, 2026
Merged

steipete merged 2 commits into
mainfrom
deslop/z41-6-plugin-cache-owners-20261015

Conversation

@steipete

@steipete steipete commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Bundled plugins retain duplicate cache, profile-preparation, shutdown and projection owners even where an existing client or SDK operation already owns the work. Several search caches also omit the resolved credential, allowing one configured account to receive another account's cached answer.

User Impact

Search results remain scoped to the account that requested them, and Discord voice identities observe the canonical client's Gateway invalidation. Other changes remove private duplicate work without removing capabilities or requiring user action. Existing best-effort differences are listed below.

Why This Change Was Made

Reuse Discord's invalidated client entity cache instead of a second speaker cache, and resolve speaker identity once per ingress. Move Slack thread lookup onto the existing credential-scoped SDK cache. Prepare managed Chrome preferences in one pass, writing network-prediction protection before cosmetic Local State; tab readiness uses the existing tab-list operation without count/forwarding wrappers.

Keep Feishu and Teams shutdown in their sole awaited finally path. Remove Ollama's identity sanitizer implementation and its private generic adapter. Teams poll consumers now request metadata or a vote outcome rather than reconstructing unread full-vote maps. Remove unused private projections, options, defensive copies and repeated internal normalization in Discord, Matrix, Signal, Google, QA, memory, Mattermost, voice and Deepgram.

Scope Brave, Perplexity, Kimi, Gemini and Parallel search results to the actual resolved credential using the existing SDK digest helper. Preserve every existing endpoint/model/filter/header cache dimension, TTL, bounds, cancellation and authorization behavior. Firecrawl, MiniMax and Slack's account-lookup consolidation are deferred because active PRs own their exact files.

Production delta against conflict-repair base 4763b77ba572eefaef3bed12c0c17c305cd12738: 333 net lines removed (+221/-554), excluding tests, support, fixtures and generated files. This is a residue under the campaign's >=100-line waiver, not a LARGE PR. No schema, config, protocol, dependency or public SDK change. No Phase E backend changes.

Best-effort tradeoffs accepted

  • Slack cache eviction follows the existing SDK's insertion-order policy rather than refreshing hit order; an evicted optional thread lookup may repeat. No stale reads or new pending-work admission cutoff. Existing 60-second TTL, 500-value bound, credential scope and durable transient retry remain.
  • Mattermost no longer snapshots four already-resolved retry fields before a user lookup. The removed test forced in-place config mutation during that await (refactor(channels): deslop channels #166106, 6c352f4619606), not an actual-use report. Such mutation is best effort; a later send resolves current config. Live send authority remains checked.
  • Feishu probe TTL uses ordinary timestamp arithmetic instead of handling an internally generated expiry beyond the maximum JavaScript Date. The removed maximum-Date test came from 3da34a4673d086b99b4990ea299e681a704d0888, not a human incident. An extreme clock may reuse an optional result until normal TTL/restart; credential scope, real TTL, timeout, abort and bounds remain.
  • Feishu/Teams no longer memoize cleanup invoked from both an abort callback and finally. The caller now invokes cleanup only once; normal awaited response drain and write settlement remain. Teams' duplicate-call shape came from refactor(msteams): receive webhooks on Gateway routes #158939 (8864423309d3b), not an independent retry contract. No hypothetical reentrant cleanup entry point remains.
  • Chrome no longer rereads cosmetic preferences to decide whether to run preparation while two other owners always rewrite the same Preferences file. The cosmetic optimization originated in 7cdd7c5333d4d, without a linked actual-use failure. Cosmetic Local State is rewritten on reuse; a failed write warns and the next launch retries. Network-prediction protection from fix(browser): block interaction-triggered navigation SSRF #104254 is retained and written first.
  • QA outcome snapshots retain their array copy but borrow immutable/replaced outcome objects instead of cloning them and their steps. The copy came from fix(qa-lab): unify dashboard runner planning #112838 (9310586b092d24fc631135a6a4df99ef6ffaaff3); no reader mutates those objects. Future in-place consumer mutation is outside that ownership contract.
  • Discord reply roles come from the native typed member owner rather than a second shape check and copy. Consumers only read them and authorization still runs at its owner. A future in-place mutation through this private result would share the native array; no current consumer does so.
  • Discord no longer checks whether Node's successful dns.lookup(..., {all:true}) callback returned an array: Node's typed overload owns that shape. The extra check came from c3c7c2df6f62a4, with no linked human shape-failure report. Real DNS errors, empty results, IPv4 ordering and endpoint SSRF policy remain.
  • Memory citations consume the canonical config enum instead of rechecking its three values. Config schema validation already rejects other values; the helper split (d0ce2d1044430) did not establish an invalid-config runtime contract. Bypassing the config boundary is not supported; the normal auto/on/off behavior and default remain.
  • Deepgram no longer tracks a second finalizeRequested flag: the existing SDK flips its closed state before its sole onClose callback. The factory move fix(talk): avoid full plugin imports during cold catalog discovery #138483 (52644b7af6fb5) retained that redundant flag; no additional production close entry point exists. Repeated public close still emits one Finalize, while finalized text, fallback timer, reconnect and bounds remain.

Other removals delete unused private values or delegate equivalent arithmetic/collection behavior to existing SDK owners; they do not remove error handling or user-facing features. Human-reported Ollama reasoning-leak protection (#86129/#86515), ordinary concurrency, credential/effect gates, user-data durability, FIFO and resource bounds remain.

Evidence

  • Credential regressions first failed through public provider tools: Brave two modes, Perplexity two transports, Kimi, Gemini and Parallel. Each demonstrated account B receiving account A's cached result. Gemini's first setup failure was corrected and rerun to obtain the intended red before its production repair. The qualified Firecrawl fix and exclusive regression were removed together after the final collision refresh found refactor: keep private media preparation in its owners #178002 on that owner.
  • Provider-family green: 187 tests / 8 files, two serial shards, 77.87 seconds wrapper. Includes custom headers, TTL, abort and transport siblings. That run also included the subsequently withdrawn Firecrawl file; the other seven files are unchanged and their proof is reused.
  • Reused unchanged-input proof: Discord voice 62 tests/6 files; Slack 40/4; Ollama 86/4; Feishu 49/4. Client invalidation, access, thread routing, stream sanitization and webhook security/drain paths are covered.
  • Remaining touched owners: 251 tests / 21 files, nine serial shards, 477.21 seconds wrapper, passed. Includes persisted Teams votes/concurrency/reopen, Matrix lifecycle, Mattermost authority, memory citations, Google model/registration/hooks, Signal approval/mention handling, Deepgram close/reconnect and timer/model contracts.
  • Initial browser consumer shard passed 154 cases but failed two Linux-emulation fixtures on macOS before the changed preparation code. A scoped replay with both changed browser owners backed out reproduced the same two failures. Fixtures now supply the missing process census; production ownership checks and all assertions are unchanged. Full internal-owner replay passed 43 cases with one pre-existing Linux-only skip; the other five unchanged-input consumer files had passed 113 cases. This is 156 passes/one skip across separate valid runs, not a single all-green run.
  • Discord's remaining consumers passed 156 tests / 12 files; QA passed 115 / 8, Matrix's focused retirement cases passed 2 (96 name-filtered), and suppression audit passed 14 / 14. Each shard ran serially with one worker.
  • Formatting of all 74 existing TypeScript paths, focused syntax lint and whitespace checks pass. Scoped graph proof covers 2,709 production files in 18 plugins: zero runtime cycles and zero new static components against the pinned base. The deleted Ollama type-only leaf is absent from both scoped graph inventories; deleting it cannot create a cycle. This is not a whole-repository cycle claim.
  • Independent full-candidate P0-P2 review completed scoped-clean, with final source verification. The reviewer checked credential cache dimensions, SDK/client owner migrations, cleanup settlement and retired private projections. The commit hook then caught nine lines of growth in the oversized browser fixture. Replacing its duplicate deferred-promise helper with the existing SDK helper and inlining its sole-consumer options inspection keeps the file below its original counted size without changing assertions. The deferred-helper repair passed the affected browser suite (43 cases/one existing Linux-only skip) and all 14 suppression checks in a 68.82-second serial wrapper. The final inlining's focused consumer replay passed (one case; 43 name-filtered), as did the line-cap ratchet and focused syntax lint. A second complete staged P0-P2 review finished scoped-clean with final source verification after that test-only repair. No source changes followed.

Local package-boundary typechecking is unqualified without generated SDK declarations; exact-head hosted CI owns broad/type-aware proof. No broad local build, whole-graph typecheck, full suite or E2E was run. Synthetic production-path and installed-SDK loopback evidence is not live channel/provider acceptance. All proof uses isolated HOME/OpenClaw/XDG state, not the operator Gateway or real OpenClaw home.

First exact-head CI repair

Run 39367914071 found PR-caused failures, not inherited failures. The production, extension-test, core-5-test and package-boundary type jobs all identified the same Slack loader narrowing error. Capture the already-validated timestamp as a scalar before creating the asynchronous cache loader; no cast or additional validation is needed.

The browser shard found two existing oversized-timeout assertions disproving the proposed timer-helper equivalence: the SDK caps at 2,147,000,000ms, while the browser contract is 2,147,483,647ms. The entire timer migration is withdrawn, restoring the original owner byte-for-byte and keeping the assertions unchanged. Both failing browser cases pass after restoration (36 cases across the two owner files).

The ratchet job also requires removal of the obsolete Discord reply-context assertion allowance and export-preserving browser MCP mocks. Those are maintenance of our cut, not exceptions or relaxed budgets. No CI job was rerun.

Repair proof: Slack 10 cases, browser normalization/snapshot 36, and suppression audit 14 passed in a serial 176.64-second wrapper. The changed shutdown mock passed all four cases (27.15 seconds Vitest; 36.93 seconds wrapper). Formatting, focused syntax lint, whitespace, assertion-safety and mock-export ratchets pass; the latter two baseline changes only remove obsolete exceptions. Independent P0-P2 review of the exact five-file repair completed scoped-clean with final source verification. The original scoped runtime-cycle proof remains valid: the only production import change in this repair removes the withdrawn SDK timer edge.

Conflict-only integration

The repaired pre-rebase head fe9124c5be54228736c7606a06bd4a14199dddc2 passed hosted CI run 39369763617. Native landing then found a real Gemini runtime conflict and aborted before dispatch. The conflict-only rebase keeps main's newer inline search implementation and preserves cache isolation using the resolved credential and canonical operator headers. It does not replace main's owner or remove any request/cache dimensions.

On repaired head 752719c6a0923dcea7a194f12dd546c33c0e67d6, focused Google provider and credential-isolation suites passed all 62 cases across two files; suppression audit passed all 14 cases. Scoped cycles cover 2,708 production files in the same 18 plugins: zero runtime cycles and no new static components. Independent complete-candidate P0-P2 review finished scoped-clean with final source verification. The three-file package typecheck remains unqualified because generated SDK declarations are absent; no broad local generation/build was run. Exact-head hosted CI run 39376879254 completed successfully, including production/test types, lint, selected owner suites, all three PostgreSQL conformance shards and openclaw/ci-gate. No CI rerun or extra head push was used.

@clawsweeper

clawsweeper Bot commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review blocked

Automated review did not run, so no review verdict was produced.

Reason: The input-safety check rejected material in this revision. No detected value, path, or scanner output is reproduced here.

Automatic review is on hold, including after source changes. Request a fresh re-review after resolving the failure; maintainers can also release the hold through an intentional scanner-policy update.

Next step: If this is a genuine credential, remove and rotate it. If it is an intentional test fixture, a maintainer must review and qualify it.

View the workflow run.

@steipete
steipete marked this pull request as ready for review October 20, 2026 04:07
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-20T05:52:19.599174Z 752719c New commits
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

ℹ️ 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".

});
ensureNestedRecord(prefs, "savefile").default_directory = opts.downloadDir;
}
saveJsonFile(preferencesPath, prefs);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Persist the mock-keychain marker before preferences

On a new headless macOS profile, if writing Default/Preferences fails once but Chrome still launches, this throw prevents openclaw_mock_keychain from being recorded in Local State; the caller catches the error and proceeds. Chrome then creates Local State, so the next launch no longer considers the profile new and omits --use-mock-keychain, making cookies written with the automation keychain unreadable. Persist the key-source marker independently before this fallible preferences write.

Useful? React with 👍 / 👎.

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Oct 20, 2026
@steipete
steipete force-pushed the deslop/z41-6-plugin-cache-owners-20261015 branch from fe9124c to 752719c Compare October 20, 2026 05:48
@steipete
steipete merged commit 6614cf2 into main Oct 20, 2026
146 of 147 checks passed
@steipete
steipete deleted the deslop/z41-6-plugin-cache-owners-20261015 branch October 20, 2026 06:41
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 21, 2026
)

* refactor: consolidate plugin cache and lifecycle owners

* fix: preserve contracts in plugin owner cleanup
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

channel: discord Channel integration: discord channel: feishu Channel integration: feishu channel: matrix Channel integration: matrix channel: mattermost Channel integration: mattermost channel: msteams Channel integration: msteams channel: signal Channel integration: signal channel: slack Channel integration: slack channel: voice-call Channel integration: voice-call clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. extensions: brave extensions: browser extensions: deepgram extensions: google extensions: memory-core Extension: memory-core extensions: moonshot extensions: ollama extensions: parallel extensions: perplexity extensions: qa-lab size: XL

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant