Skip to content

refactor(runtime): deslop runtime caches - #164520

Merged
steipete merged 12 commits into
mainfrom
deslop/x10-unpaid-caches-20261003
Oct 4, 2026
Merged

steipete merged 12 commits into
mainfrom
deslop/x10-unpaid-caches-20261003

Conversation

@steipete

@steipete steipete commented Oct 3, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Cold commands, setup, and startup paths retained caches that duplicated the existing module, registry, or auth owner and required extra state, resets, and forwarding code.

User Impact

Configuration, protocol shapes, command output, tool descriptions, and UI appearance stay the same. Model discovery no longer lets one provider spelling poison another lookup, and Vertex requests consume refreshed tokens from Google Auth immediately.

Why This Change Was Made

  • Use native dynamic imports at the original cold boundaries instead of retaining a second promise cache. This also removes single-use loader callbacks, runtime projections, and test-only reset plumbing.
  • Read Markdown table defaults from the loaded channel registry's existing index, removing a duplicate map and registry-version invalidation.
  • Derive trusted safe-bin directories directly. The old cache already performed filesystem validation and normalization before every hit; all current-filesystem trust checks remain.
  • Keep one syntax-color callback table behind the existing live theme proxy instead of caching it by the proxy's permanent identity.
  • Remove the one-pass context estimate map, single-call Brew memo, and tiny redundant CLI lookup tables; preserve duplicate-group precedence.
  • Preserve lifecycle, authority, identity, transport, and measured hot-path caches. Deferred provider-hook binding stays in place. Retain the Gateway lifecycle and selected diagnostic, probe, metadata, login-flow, usage-format, scanner, and Secrets apply loaders to keep their broader contracts out of this batch.
  • Remove unused facade/type exports exposed by narrower imports; move test-only context cleanup into test support and exercise private sandbox, wizard, and SSH helpers through their existing production entry points.

Fixes found along the way

  • The login-gate E2E fixture now clears the rejected connection through the Gateway owner before projecting a no-error state. A forced parent render verifies that the old auth error cannot return. The original assertions, timeouts, and overlapping login test file are unchanged.

  • The channel-presentation E2E proxy now uses the canonical QA request parser through the plugin test API, including system/developer completion carriers. Its old user-only parser missed completion markers and failed to activate Slack suppression and Discord missing-message-identity faults. The existing assertions, fault injections, and timeouts are unchanged.

  • Model registry cache keys now use the exact provider identity accepted by the underlying lookup. An uppercase miss can no longer mask a later lowercase hit, or vice versa.

  • Vertex delegates token freshness to Google Auth's expiry-aware client rather than hiding refreshed tokens behind an invented five-minute cache. Manual authorized-user token caching, deadlines, and client recovery stay intact.

  • The malformed-workspace audit test now creates the SKILL.md files advertised by its mock. Missing files raced the scanner import; a warm cache masked the invalid fixture. The existing scan assertions remain, and the test now also rejects scan-failure findings.

  • Telegram and Hermes fixtures now settle Vitest’s manual-mocked imports before overlapping the live operations. Two token leases and two pending plans still coexist, with the original shutdown, reacquisition, identity, forwarding, and error assertions preserved. This avoids Vitest’s documented concurrent-import limitation without production workarounds, retries, sleeps, or weaker assertions.

Evidence

Exact-head validation for d60bfc2386ea8006309bcd67fe6d859ccb3359e8 is complete. CI run 37167324344 tested merge 29ce590ea5362538fef72275adceb853abe242de (main 5fc6683924d2033f32ac5de44aeb3983da2a8a91 plus the PR head). Its remaining failures are two test jobs and their two aggregate CI statuses. Security-fast, all seven Security High lanes, Opengrep, and the security-sensitive review passed.

Failing job Failure Independent evidence
checks-node-changed-compact-large-23-3 All five offline memory-presence cases fail resolving @openclaw/worker-runtime. Scheduled main job 111323333592, at 7fd8a8ea80e6cbf3b4cb4c2ad737fea38dce1e5d, has the same five failures and native loader stack. The native observer fails at test setup before the changed status scan runs. The test, SDK, worker package, native resolver, module loader, package/lock files, and tsconfig match the actual CI merge. Main has since added the missing worker aliases in #164662.

| checks-node-changed-compact-large-6 | Five pending-final delivery recovery cases fail: two lack pendingDeliveryNotice; three never reach the delivery callback. | Independent PR #164670, job 111335988743 fails the same five cases and assertions on tested merge 94de6acfd394062ebc61da938aaf5094b6695dbd. A separate clean Linux checkout of the candidate's main parent 5fc6683924d2033f32ac5de44aeb3983da2a8a91, with a frozen install and unchanged tests, also reproduces all five failures. Delivery recovery, completion, and worker-patch owners are unchanged by this PR. |

The branch passed both import-cycle checks (zero), focused owner tests, all 1,132 plugin contracts, both Knip checks, relevant type graphs, and runtime builds. The final login fixture correction passed an original-defect negative control, 20 consecutive Linux runs, and all 23 login cases. The channel-presentation pair also failed with its original parser and passed with the canonical QA parser. Assertions, fault injections, and timeouts remain intact.

Review disposition: fresh independent review and the exact-head ClawSweeper technical review found no actionable introduced defect. The two generated compatibility checklist items do not identify a changed contract: sandbox helpers only become private; wizard and memory CLI changes keep the same deferred imports and operations; Ollama retains the same embedding provider arguments and result. No configuration defaults, stored formats, migration algorithms, package dependencies, or public SDK metadata change. The technical review independently confirms this.

Measured branch production delta: −842 lines across 142 files, excluding tests, fixtures, documentation, and generated files. The coordinator accepted the cross-cutting coverage exception for this one PR.

  • Login fixture proof: removing only the new owner-stop transition reproduces the original error-row assertion. The fix passed 20 consecutive Linux runs, the full 23-test login suite (36.35 seconds), both cycle checks, and all 1,132 plugin contracts. Independent P0–P2 review is clean.

  • Latest correction: both cycle checks are zero, both Knip checks pass on the rebased source, 31 boundary/audit tests and all 1,132 plugin contracts pass. The targeted E2E pair passes through the QA test API in 121.13 seconds (existing case budgets and assertions unchanged).

  • Independent review completed with no actionable P0–P2 findings, including fresh reviews of the fixture repairs and overlap exclusions.

  • Both model-discovery and Vertex regressions failed against the original production source and passed with the candidate fix.

  • The first focused run exposed the inherited inline-actions import-boundary failure introduced by refactor(skills): run skill library reads and selection authority in workers (skilllib A) #164165. Main fixed it in 5c5700d; the branch now includes that repair. None of the failing import-chain files is changed here.

  • All eleven runtime bundles, plugin packaging, CLI bootstrap import checks, and post-build preparation passed on the rebased candidate before the three ownership exclusions.

  • Audit fixture stability: 20/20 standalone runs passed using the authorized serialized local fallback after remote provisioning failed. Original four-file shard passed 3/3 runs. The remaining focused selections were completed during publication validation.

  • Both import-cycle checks report zero in an isolated Linux checkout with verified Git head and tree. The publication correction passed 1,005 focused tests in 41 files, plus both production and all-export Knip checks. Core typecheck passed; the final test-type shard exposed additional usage-cache cleanup consumers, so that cleanup export and loader were restored. The follow-up passed both dependency checks, both cycle checks, all selected focused targets, and all 27 affected test-type graphs. The login loader restoration passed 63 tests in the original login and login-runtime suites; no cancellation assertions changed.

  • Telegram monitor and Hermes lazy-provider fixtures each passed 23 consecutive Linux runs, retaining overlapping live operations and all original ownership/forwarding assertions. Hermes provider sibling tests passed as well.

  • After the conflict-only rebase: all 1,132 plugin contracts pass; both import-cycle checks report zero; core typecheck and 68 daemon-status tests pass. The one conflict preserved main's new daemon runtime-status projection while retaining this batch's direct imports.

  • Paired E2E proof uses identical rebased production source: both targeted channel-presentation cases fail with the old proxy parser and pass with the canonical parser. The remote run also built all eleven runtime bundles and packaging prerequisites. The old memory-host contract defect is repaired by main already included in the rebase.

  • The login-flow source is unchanged from the base. No package dependencies, public SDK entrypoint metadata, schemas, or protocols change.

Coverage

At the reviewed pre-rebase checkpoint, 1,149 files in fixed candidate inventories were read in full with matching SHA-256 receipts: 1,050 TypeScript/TSX, 98 Swift/Kotlin, and one current-base owner. Two explicitly requested ownership-exclusion sources were also fully reread, bringing the detailed log to 1,151 files. Rebase-changed files were reread; unchanged receipts were reused only while their hashes matched. The audit had zero unread files or stale hashes at that checkpoint; publication rebases preserve the patch and rerun affected proof.

The inventories select files above 200 lines using declared cache patterns; they are not every production file. Retained caches protect hot paths, lifecycle or identity, or real I/O/computation. The native audit found no safe removal candidate. Source coverage is separate from runtime/test validation.

The measured batch removes 842 net production lines (142 production files), excluding tests, fixtures, documentation, and generated files. The below-threshold batch excludes files owned by other open deslop PRs; the source audit retains caches with a real lifecycle, identity, or hot-path contract.

@clawsweeper

clawsweeper Bot commented Oct 3, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@github-actions

github-actions Bot commented Oct 3, 2026 •

Copy link
Copy Markdown
Contributor

⚠️ Security sensitive changes

This maintainer PR changes sensitive security components.

No secops approval is required. This comment is informational because the PR author has Maintain or Admin access.

  • Current SHA: d60bfc2386ea8006309bcd67fe6d859ccb3359e8
  • Maintainer: @steipete
  • Repository role: admin

These security sensitive changes were made:

  • src/agents/sandbox/config.ts: Controls sandbox containment or tool execution authority. Check filesystem and network isolation, approval scope, and command allowlists.
  • src/agents/tool-policy-shared.ts: Controls sandbox containment or tool execution authority. Check filesystem and network isolation, approval scope, and command allowlists.
  • src/agents/tool-policy.ts: Controls sandbox containment or tool execution authority. Check filesystem and network isolation, approval scope, and command allowlists.
  • src/infra/exec-approval-forwarder.ts: Controls sandbox containment or tool execution authority. Check filesystem and network isolation, approval scope, and command allowlists.
  • src/infra/exec-safe-bin-trust.ts: Controls sandbox containment or tool execution authority. Check filesystem and network isolation, approval scope, and command allowlists.
  • src/secrets/resolve.ts: Controls credential persistence, secret resolution, or redaction. Check storage permissions, credential scope, and exposure in logs or responses.
  • src/security/audit-deep-code-safety.ts: Controls product security checks or trust decisions. Check whether the change weakens detection, protection, or remediation.
  • src/security/audit-plugins-trust.ts: Controls product security checks or trust decisions. Check whether the change weakens detection, protection, or remediation.
  • src/security/audit.deep.runtime.ts: Controls product security checks or trust decisions. Check whether the change weakens detection, protection, or remediation.
  • src/security/audit.ts: Controls product security checks or trust decisions. Check whether the change weakens detection, protection, or remediation.

Carefully review these changes before merging.

@openclaw-barnacle openclaw-barnacle Bot added channel: discord Channel integration: discord channel: line Channel integration: line channel: matrix Channel integration: matrix channel: slack Channel integration: slack channel: telegram Channel integration: telegram channel: voice-call Channel integration: voice-call channel: whatsapp-web Channel integration: whatsapp-web channel: zalo Channel integration: zalo app: web-ui App: web-ui gateway Gateway runtime extensions: memory-core Extension: memory-core cli CLI command changes commands Command implementations agents Agent runtime and tooling channel: feishu Channel integration: feishu channel: irc extensions: openai extensions: qa-lab plugin: migrate-hermes extensions: amazon-bedrock extensions: google extensions: ollama extensions: policy fleet channel: reef Channel integration: reef size: XL labels Oct 3, 2026
@steipete
steipete enabled auto-merge (squash) October 3, 2026 20:31
@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Oct 3, 2026
@steipete
steipete disabled auto-merge October 3, 2026 23:54
@steipete
steipete enabled auto-merge (squash) October 3, 2026 23:56
@clawsweeper clawsweeper Bot added rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Oct 4, 2026
Stop the rejected mock connection before installing the no-error fixture, then verify the state survives the owning app render. Preserve the original assertions and the overlapping login test file.
@steipete

steipete commented Oct 4, 2026

Copy link
Copy Markdown
Contributor Author

Exact-head validation for d60bfc2386ea8006309bcd67fe6d859ccb3359e8 is complete. CI run 37167324344 tested merge 29ce590ea5362538fef72275adceb853abe242de (main 5fc6683924d2033f32ac5de44aeb3983da2a8a91 plus the PR head). Its remaining failures are two test jobs and their two aggregate CI statuses. Security-fast, all seven Security High lanes, Opengrep, and the security-sensitive review passed.

Failing job Failure Independent evidence
checks-node-changed-compact-large-23-3 All five offline memory-presence cases fail resolving @openclaw/worker-runtime. Scheduled main job 111323333592, at 7fd8a8ea80e6cbf3b4cb4c2ad737fea38dce1e5d, has the same five failures and native loader stack. The native observer fails at test setup before the changed status scan runs. The test, SDK, worker package, native resolver, module loader, package/lock files, and tsconfig match the actual CI merge. Main has since added the missing worker aliases in #164662.

| checks-node-changed-compact-large-6 | Five pending-final delivery recovery cases fail: two lack pendingDeliveryNotice; three never reach the delivery callback. | Independent PR #164670, job 111335988743 fails the same five cases and assertions on tested merge 94de6acfd394062ebc61da938aaf5094b6695dbd. A separate clean Linux checkout of the candidate's main parent 5fc6683924d2033f32ac5de44aeb3983da2a8a91, with a frozen install and unchanged tests, also reproduces all five failures. Delivery recovery, completion, and worker-patch owners are unchanged by this PR. |

The branch passed both import-cycle checks (zero), focused owner tests, all 1,132 plugin contracts, both Knip checks, relevant type graphs, and runtime builds. The final login fixture correction passed an original-defect negative control, 20 consecutive Linux runs, and all 23 login cases. The channel-presentation pair also failed with its original parser and passed with the canonical QA parser. Assertions, fault injections, and timeouts remain intact.

Review disposition: fresh independent review and the exact-head ClawSweeper technical review found no actionable introduced defect. The two generated compatibility checklist items do not identify a changed contract: sandbox helpers only become private; wizard and memory CLI changes keep the same deferred imports and operations; Ollama retains the same embedding provider arguments and result. No configuration defaults, stored formats, migration algorithms, package dependencies, or public SDK metadata change. The technical review independently confirms this.

Measured branch production delta: −842 lines across 142 files, excluding tests, fixtures, documentation, and generated files. The coordinator accepted the cross-cutting coverage exception for this one PR.

@steipete
steipete merged commit 19e87bf into main Oct 4, 2026
212 of 216 checks passed
@steipete
steipete deleted the deslop/x10-unpaid-caches-20261003 branch October 4, 2026 01:56
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 4, 2026
* refactor(runtime): deslop redundant caches

Use the existing module and registry owners directly for cold command, setup, and startup lookups. Preserve lifecycle, authority, identity, and measured hot-path caches.

Fix model lookup cache keys to match exact provider identity, and let Google Auth own Vertex token expiry instead of masking refreshes behind a second fixed-lifetime cache.

* refactor(runtime): drop remaining cold setup import caches

* test(security): complete audit workspace fixtures

Create the skill files advertised by the malformed-workspace fixture so missing-file rejection cannot race directory scanning. Keep the scan assertions and reject scan-failure findings.

Defer cache changes in status.scan-overview, the legacy session importer, and audit-extra.async to their active deslop owners.

* test(plugins): verify markdown defaults use the loaded registry

* test(telegram): stabilize concurrent monitor startup fixtures

* test(migrate-hermes): preserve concurrent plans across mocked imports

* refactor(runtime): close unused exports exposed by direct imports

Remove dead facade and test-only exports exposed by the narrower import graph. Keep tests on existing production owners and retain loaders whose removal would expand lifecycle, diagnostic, probe, or externally owned secret-apply contracts.

* test(runtime): retain usage cache cleanup consumers

Keep the existing usage cache reset and loader while model-catalog and publication tests still consume that cleanup contract.

* refactor(auth): retain shared login runtime loading

Exclude the login runtime loader from this batch so simultaneous login flows keep their existing shared import and cancellation test contract.

* test(qa): decode completion context through the shared mock parser

* fix(ci): preserve scanner and QA test boundaries

* test(ui): align login fixture with gateway owner state

Stop the rejected mock connection before installing the no-error fixture, then verify the state survives the owning app render. Preserve the original assertions and the overlapping login test file.
RomneyDa added a commit that referenced this pull request Oct 8, 2026
Use the shared mock-provider turn resolver for protected developer/system completion context. Preserve suppressed delivery, observer, and ambiguous-custody assertions.

Companion backported from 19e87bf (#164520). Thanks @steipete.
wheakerd pushed a commit to wheakerd/clawdbot that referenced this pull request Oct 22, 2026
Use the shared mock-provider turn resolver for protected developer/system completion context. Preserve suppressed delivery, observer, and ambiguous-custody assertions.

Companion backported from 19e87bf (openclaw#164520). Thanks @steipete.

(cherry picked from commit c695668)
Co-authored-by: RomneyDa <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling app: web-ui App: web-ui channel: discord Channel integration: discord channel: feishu Channel integration: feishu channel: irc channel: line Channel integration: line channel: matrix Channel integration: matrix channel: reef Channel integration: reef channel: slack Channel integration: slack channel: telegram Channel integration: telegram channel: voice-call Channel integration: voice-call channel: whatsapp-web Channel integration: whatsapp-web channel: zalo Channel integration: zalo cli CLI command changes commands Command implementations docker Docker and sandbox tooling extensions: amazon-bedrock extensions: google extensions: memory-core Extension: memory-core extensions: ollama extensions: openai extensions: policy extensions: qa-lab fleet gateway Gateway runtime P2 Normal backlog priority with limited blast radius. plugin: migrate-hermes rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. security-sensitive-changed size: XL status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant