Skip to content

fix(cli): reduce plugins list startup memory - #103132

Merged
steipete merged 1 commit into
mainfrom
codex/plugins-list-startup-memory
Jul 9, 2026
Merged

steipete merged 1 commit into
mainfrom
codex/plugins-list-startup-memory

Conversation

@steipete

@steipete steipete commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Closes #103131

What Problem This Solves

Fixes an issue where users listing plugins from a fresh packaged install would load the doctor and bundled-channel state-migration runtime graph, increasing peak memory from about 376.5 MiB in v2026.6.11 to 636-638 MiB in the reproduced current release artifact.

Why This Change Was Made

plugins list now uses the existing lightweight migration-input detector before running the state-migration preflight. The preflight still runs for legacy plugin indexes, an existing shared state database, legacy channel sidecars and state roots, or configured session stores, so shipped upgrades retain the same migration behavior. The packaged CLI startup-memory gate now covers plugin listing directly.

User Impact

Fresh and already-migrated installs can list plugin metadata with substantially lower cold-start memory. Existing installs that still need a state migration continue to migrate before the command reads config or plugin metadata.

Evidence

  • Equivalent packaged installs, fresh empty HOME, normal npm postinstall, NODE_DISABLE_COMPILE_CACHE=1, OPENCLAW_NO_RESPAWN=1:
    • v2026.6.11: 376.5 MiB peak RSS, 1,656 translated ESM modules.
    • Reproduced current artifact before fix: 636-638 MiB peak RSS, 2,816 translated ESM modules.
    • Fixed package: about 273 MiB peak RSS, 1,356 translated ESM modules, with no iMessage or Telegram setup/migration entry imports.
  • Focused Testbox tests: 52/52 passed across the config guard and startup-memory tooling.
  • corepack pnpm build: passed on Blacksmith Testbox.
  • corepack pnpm check:changed: passed on Blacksmith Testbox.
  • Startup-memory gate: plugins list --json measured 275.4 MiB against the new 350 MiB Linux ceiling; the existing help/status/gateway cases also passed.
  • Fresh autoreview found the shared-state-database compatibility edge; the fix and regression test are included, and the follow-up review reported no actionable findings.

AI-assisted implementation and review; all cited tests and package measurements were run against the branch artifacts.

@openclaw-barnacle openclaw-barnacle Bot added cli CLI command changes scripts Repository scripts size: S maintainer Maintainer-authored PR labels Jul 9, 2026
@steipete

steipete commented Jul 9, 2026 •

Copy link
Copy Markdown
Contributor Author

Land-ready proof for exact PR head ebd9ec90f1d0c2c1edfa9fd7ba5a582f655ebc21:

  • Blacksmith Testbox lease tbx_01kx4cnb66f9vqtbvw2hshgcys:
    • corepack pnpm test src/cli/program/config-guard.test.ts test/scripts/check-cli-startup-memory.test.ts — 52/52 passed.
    • corepack pnpm build — passed.
    • corepack pnpm check:changed — passed.
    • node scripts/check-cli-startup-memory.mjs — help 47.1/100 MB, plugins list 277.5/350 MB, status 358.7/400 MB, gateway status 266.7/500 MB.
  • Equivalent packaged npm consumer proof, fresh empty HOME, normal postinstall: reproduced current artifact 636-638 MiB peak RSS / 2,816 translated ESM modules; exact PR-head package 271.3 MiB (277,804 KiB) / 1,356 modules, with no iMessage or Telegram setup/migration entry imports. Final tarball SHA-256: bd5edaecd387d80ca0b5a604217a7fb45f2ba5e0acf0f03fe642d45c099809b3 (OpenClaw) and 003d486f4b8684c9c9e6627de1c9c955736a94e3dc035f1485e652be16c75583 (@openclaw/ai).
  • Fresh autoreview after compatibility fixes: no accepted/actionable findings.
  • Review artifacts validate with recommendation READY FOR /prepare-pr and zero findings.

Migration compatibility remains explicit: the doctor preflight still runs for the legacy plugin install index, existing shared state database, SQLite sidecars, legacy channel/state markers, and configured session stores. No proof gaps known.

@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.

Reviewed commit: ebd9ec90f1

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

path.join(stateDir, "agents"),
path.join(stateDir, "plugins", "installs.json"),
path.join(stateDir, "sessions"),
path.join(stateDir, "state", "openclaw.sqlite"),

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.

P2 Badge Narrow the shared-state migration trigger

When a user already has a normal, current state/openclaw.sqlite but no legacy sidecars or custom session store, this existence check makes plugins list --json run the full doctor state-migration preflight anyway. That reintroduces the doctor/channel runtime imports for already-migrated installs, so the cold-start memory reduction only applies to completely empty homes; this should gate on an actual pending shared-DB schema migration instead of any shared DB file.

Useful? React with 👍 / 👎.

@steipete
steipete merged commit a1ce77d into main Jul 9, 2026
125 of 129 checks passed
@steipete
steipete deleted the codex/plugins-list-startup-memory branch July 9, 2026 22:28
@steipete

steipete commented Jul 9, 2026

Copy link
Copy Markdown
Contributor Author

Merged via squash.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cli CLI command changes maintainer Maintainer-authored PR scripts Repository scripts size: S

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: plugins list loads state-migration runtimes with empty state

1 participant