Skip to content

perf(cli): finish cold read paths - #117957

Merged
steipete merged 3 commits into
mainfrom
codex/perf-cli-cold-paths-2
Aug 2, 2026
Merged

steipete merged 3 commits into
mainfrom
codex/perf-cli-cold-paths-2

Conversation

@steipete

@steipete steipete commented Aug 2, 2026

Copy link
Copy Markdown
Contributor

What Problem This Solves

A production CLI sweep after #117932 found five more read-only commands still paying the plugin-load storm on a host with ~150 installed plugins:

command production wall
hooks 14168 ms
skills search <term> 13841 ms
memory status --agent <id> 10318 ms
skills info <skill> 10040 ms
memory search <q> --json 9851 ms

Baselines on that host: openclaw --version 43 ms, gateway call health ~1.8 s, and post-#117932 skills list ~1.15 s. This finishes the sweep begun in #117705 / #117751 / #117880 / #117900 / #117932.

Why This Change Was Made

Each command was diagnosed rather than blanket-patched, and the worst one had a distinct cause:

hooks was the outlier: buildPluginDiagnosticsReport() executed all 151 discovered plugin runtimes. Runtime loading is now scoped to the canonical Gateway startup plan (13 plugins for an empty config), which preserves native api.registerHook() contributions — the reason the report loaded runtimes at all — while not executing unrelated plugins. Bare hooks also skips unrelated config validation. Local repro: 30.53 s → 2.80 s.

skills search lacked a cold catalog policy, so its early proxy-config read validated every plugin; it now uses configGuard: "skip" / loadPlugins: "never" while keeping network-proxy routing intact for ClawHub. skills info was simply a missed sibling of list/check — its gateway-first and manifest fallback were already correct, so it gets the same policy.

memory status / memory search were validating unrelated plugins at three separate boundaries: the global guard, plugin-CLI registration, and a command-local config read. All three now skip unrelated validation while still loading the manifest-selected memory owner — the memory engine is a bundled plugin the command genuinely needs, so the goal was never to skip it. memory status --index and --fix deliberately retain full validation because they mutate. The memory search result shape and its staleness qualification (from #117706) are unchanged and covered by tests.

User Impact

Command Production before After
hooks 14.2 s 2.80 s (local repro 30.53 s → 2.80 s)
skills search 13.8 s 4.48 s (includes live network)
memory search 9.85 s 4.47 s
memory status 10.3 s 2.83 s
skills info 10.0 s 1.09 s

No output shapes changed. Mutating paths keep their guards.

Evidence

  • A table-driven five-command process fixture installs a generated plugin whose runtime throws if imported, proving zero unrelated runtime imports across all five paths; its memory rows additionally prove the selected memory CLI owner still executes (so the fix cannot have skipped the thing the command needs).
  • Focused suites run individually: cold process fixture 5/5, command-path policy 22/22, startup policy 12/12, Commander preaction 55/55, plugin CLI registration 23/23, hooks process behavior 3/3, run-main 195/195, memory-core CLI including the stale-search JSON contract 81/81.
  • pnpm tsgo:core, pnpm build (3m05s, no [INEFFECTIVE_DYNAMIC_IMPORT]), git diff --check: passed.
  • Source-blind CLI validation: expected output shapes passed; a missing memory query exits visibly with corrective guidance.
  • Autoreview (Codex gpt-5.6-sol, high): clean, "patch is correct" (0.98); trufflehog clean.
  • Production LOC +67/-19 (net +48, explicit startup-policy and ownership plumbing); tests net +267. No new config surface, compatibility path, or fallback.

Note: this machine could not recreate the ~150-plugin production topology for the four non-hooks commands, so the throwing-plugin fixture is the scale-independent proof for those.

@openclaw-barnacle openclaw-barnacle Bot added extensions: memory-core Extension: memory-core cli CLI command changes labels Aug 2, 2026
@steipete
steipete marked this pull request as ready for review August 2, 2026 10:33
@openclaw-barnacle openclaw-barnacle Bot added size: M maintainer Maintainer-authored PR labels Aug 2, 2026
@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. labels Aug 2, 2026
@clawsweeper

clawsweeper Bot commented Aug 2, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: found issues before merge. Reviewed August 2, 2026, 6:50 AM ET / 10:50 UTC.

ClawSweeper review

What this changes

The PR keeps hooks, skill lookup, and memory status/search CLI reads cold by avoiding unrelated plugin validation and runtime imports during startup.

Merge readiness

⛔ Blocked by patch quality or review findings - 7 items remain

This PR is still necessary, but the prior P1 blocker remains on the updated head: the shared memory configuration helper skips plugin validation for mutating memory index and memory status --index/--fix paths as well as the intended read-only paths. The PR should stay open for that narrow repair; its maintainer label also requires explicit maintainer handling rather than automated cleanup.

Priority: P2
Reviewed head: f0d8090a861eba61a5849e1c7b45099628b18914

Review scores

Measure Result What it means
Overall readiness 🦪 silver shellfish (2/6) The performance proof is strong, but the unchanged P1 mutation-validation regression keeps the patch from being merge-ready.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (terminal): The PR body supplies after-fix command measurements and a real-process throwing-plugin fixture that directly exercises the five intended cold read paths.
Patch quality 🦪 silver shellfish (2/6) 1 actionable review finding remain.

Verification

Check Result Evidence
Real behavior Verified Sufficient (terminal): The PR body supplies after-fix command measurements and a real-process throwing-plugin fixture that directly exercises the five intended cold read paths.
Evidence reviewed 6 items Shared bypass reaches mutating commands: The PR changes the shared memory configuration loader to call getRuntimeConfig({ skipPluginValidation: true }); every withMemoryCommand caller inherits that bypass.
Memory index is a shared-wrapper mutation: memory index calls withMemoryCommand with purpose: "cli" and invokes the manager sync operation, so it now receives the skipped-validation configuration.
Status repair paths are also shared-wrapper mutations: memory status --index selects the CLI purpose and synchronizes the index; --fix repairs persistent memory artifacts in the same withMemoryCommand execution.
Findings 1 actionable finding [P1] Keep plugin validation for mutating memory commands
Security None None.

How this fits together

OpenClaw’s command catalog decides whether each CLI invocation validates configuration and loads plugin command groups before the command handler runs. The memory plugin then reads its own configuration and performs read, index, or repair work for the selected agent.

flowchart LR
  User[CLI invocation] --> Policy[Command startup policy]
  Policy --> Guard[Config and plugin validation]
  Guard --> Registration[Plugin command registration]
  Registration --> Memory[Memory command handler]
  Memory --> Action[Read, index, or repair action]
  Action --> Output[CLI output]
Loading

Before merge

  • Keep plugin validation for mutating memory commands (P1) - The shared loader now bypasses plugin validation for every withMemoryCommand caller, not only memory status and memory search. memory index and memory status --index use this wrapper before synchronizing persistent memory state, and --fix repairs artifacts through the same path; malformed plugin configuration can therefore bypass the intended mutation guard. Thread an explicit read-only bypass only from non-mutating callers and cover the three mutation paths. This repeats the prior blocker because the relevant implementation is unchanged on the current head.
  • Resolve merge risk (P1) - Merging would allow malformed unrelated plugin configuration to bypass validation on persistent memory mutations, despite the command catalog retaining the global validation guard for memory status --index and --fix.
  • Resolve merge risk (P1) - The patch’s status/search tests assert the bypass only for read-only paths; they do not prove that memory index, memory status --index, and memory status --fix preserve validation.
  • Complete next step (P2) - A concrete repair exists, but the protected maintainer label requires explicit maintainer handling before any automated repair lane is considered.
  • Improve patch quality - Restrict the shared validation bypass to non-mutating memory callers.
  • Improve patch quality - Add focused tests proving memory index, memory status --index, and memory status --fix retain plugin validation.
  • Improve patch quality - Push the repair so the existing review blocker can be rechecked on the new head.

Findings

  • [P1] Keep plugin validation for mutating memory commands — extensions/memory-core/src/cli-runtime-common.ts:58
Agent review details

Security

None.

PR surface

Source +85, Tests +251. Total +336 across 14 files.

View PR surface stats
Area Files Added Removed Net
Source 6 104 19 +85
Tests 8 256 5 +251
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 14 360 24 +336

Review metrics

Metric Value Why it matters
Shared validation scope 1 shared bypass reaches 8 withMemoryCommand callers A one-line helper change affects both intended read-only paths and memory index/repair operations, so the mutation boundary needs explicit coverage.

Stored data model

Persistent data-model change detected: serialized state: src/cli/hooks-cli.process.test.ts, vector/embedding metadata: extensions/memory-core/src/cli-runtime-common.ts, vector/embedding metadata: extensions/memory-core/src/cli.test.ts. Confirm migration or upgrade compatibility proof before merge.

Merge-risk options

Maintainer options:

  1. Scope the bypass to read-only memory commands (recommended)
    Pass an explicit read-only mode only from search and plain status, then prove index and status repair commands still validate plugin configuration before they mutate memory state.
  2. Accept skipped validation for memory mutations
    Merge the current shared bypass only if maintainers intentionally accept malformed unrelated plugin configuration on index and repair commands.
  3. Pause this performance sweep
    Close or defer the PR if retaining validation for mutations cannot be reconciled with the intended cold-path design without a broader policy decision.

Technical review

Best possible solution:

Make the shared memory loader accept an explicit read-only validation-bypass mode, pass it only from memory search and non-mutating memory status, retain normal validation for index and repair paths, and add focused regression coverage for each mutation path.

Do we have a high-confidence way to reproduce the issue?

Yes, from source: any malformed unrelated plugin configuration combined with memory index, memory status --index, or memory status --fix follows the shared bypass at extensions/memory-core/src/cli-runtime-common.ts:58. Focused tests can establish the failing regression without a production-sized plugin fleet.

Is this the best way to solve the issue?

No: applying skipPluginValidation in the common helper is broader than the requested read-only cold paths. The narrow maintainable fix is an explicit read-only opt-in at the callers, with mutation-path assertions.

Full review comments:

  • [P1] Keep plugin validation for mutating memory commands — extensions/memory-core/src/cli-runtime-common.ts:58
    The shared loader now bypasses plugin validation for every withMemoryCommand caller, not only memory status and memory search. memory index and memory status --index use this wrapper before synchronizing persistent memory state, and --fix repairs artifacts through the same path; malformed plugin configuration can therefore bypass the intended mutation guard. Thread an explicit read-only bypass only from non-mutating callers and cover the three mutation paths. This repeats the prior blocker because the relevant implementation is unchanged on the current head.
    Confidence: 0.99

Overall correctness: patch is incorrect
Overall confidence: 0.99

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against de0fa7c2084c.

Labels

Label justifications:

  • P2: This is a bounded CLI regression and merge-safety defect with limited blast radius, but it can affect persistent memory maintenance commands.
  • merge-risk: 🚨 compatibility: The PR changes plugin-configuration validation behavior for existing mutating memory CLI workflows, which may alter how existing invalid configurations fail during upgrade.
  • rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦞 diamond lobster and patch quality is 🦪 silver shellfish.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action. Sufficient (terminal): The PR body supplies after-fix command measurements and a real-process throwing-plugin fixture that directly exercises the five intended cold read paths.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR body supplies after-fix command measurements and a real-process throwing-plugin fixture that directly exercises the five intended cold read paths.

Evidence

What I checked:

Likely related people:

  • steipete: Peter Steinberger authored the merged cold-read CLI sweep that established the command-policy approach and is also connected to the current PR’s affected CLI surfaces. (role: recent area contributor; confidence: high; commits: 4d14f298b0cc; files: src/cli/command-catalog.ts, src/cli/run-main.ts, src/plugins/cli.ts)
  • clawsweeper[bot]: Current-main blame attributes the pre-existing shared memory configuration helper to this commit provenance; the PR changes that shared helper’s validation behavior. (role: introduced adjacent helper; confidence: medium; commits: 98c0d9deca5d; files: extensions/memory-core/src/cli-runtime-common.ts)

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (1 earlier review cycle)
  • reviewed 2026-08-02T10:38:53.129Z sha 77df913 :: found issues before merge. :: [P1] Keep plugin validation for mutating memory commands

@steipete

steipete commented Aug 2, 2026

Copy link
Copy Markdown
Contributor Author

The latest ClawSweeper P1 is inapplicable because plugin validation for mutating memory commands is owned by the CLI startup guard, not repeated inside the memory helper.

  • memory status --index and memory status --fix explicitly resolve configGuard: "run" in src/cli/command-catalog.ts, with coverage in src/cli/command-startup-policy.test.ts and src/cli/command-path-policy.test.ts.
  • memory index has no cold-path catalog override, so it retains the guarded default.
  • src/cli/program/preaction.ts invokes the config bootstrap whenever skipConfigGuard is false. ensureConfigReady rejects invalid configuration and pins only the validated runtime snapshot.
  • The later getRuntimeConfig({ skipPluginValidation: true }) in memory-core therefore reuses that pinned, already-validated snapshot for mutating commands. It performs a fresh validation-skipping read only for the intended cold read paths, which skip the startup guard.

Accordingly, malformed plugin configuration still blocks memory index, memory status --index, and memory status --fix before their action runs. No mutation-path validation regression is present, so the requested rank-up code/test changes are skipped. Exact-head CI is green on f0d8090a861eba61a5849e1c7b45099628b18914 in run 30744382557.

@steipete
steipete merged commit 92c7400 into main Aug 2, 2026
120 checks passed
@steipete
steipete deleted the codex/perf-cli-cold-paths-2 branch August 2, 2026 10:59
@steipete

steipete commented Aug 2, 2026

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 3, 2026
* perf(cli): finish cold read paths

* test(cli): satisfy cold path lint gates

* test(cli): fix cold path fixture typing
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cli CLI command changes extensions: memory-core Extension: memory-core maintainer Maintainer-authored PR merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. size: M status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant