Skip to content

perf(cli): skip config load for default root help#85396

Closed
FelixIsaac wants to merge 1 commit into
openclaw:mainfrom
FelixIsaac:perf/root-help-no-config-fast-path
Closed

perf(cli): skip config load for default root help#85396
FelixIsaac wants to merge 1 commit into
openclaw:mainfrom
FelixIsaac:perf/root-help-no-config-fast-path

Conversation

@FelixIsaac

@FelixIsaac FelixIsaac commented May 22, 2026

Copy link
Copy Markdown
Contributor

Summary

  • avoid importing the full config/validation stack for openclaw --help when there is no config file, no OpenClaw dotenv file, and no plugin-help-affecting env override
  • keep the existing live-config path for configured/plugin-sensitive help, invalid config handling, and injected-env tests
  • include the legacy ~/.config/openclaw/gateway.env runtime dotenv compatibility path in the fast-path precheck unless an explicit non-default OPENCLAW_STATE_DIR is active

Why

The root help fast path has precomputed help text, but it still called readConfigFileSnapshot() first to see whether plugin config could affect help output. In a default/no-config invocation that dragged in config validation before printing static help.

Real behavior proof

Behavior or issue addressed: default openclaw --help startup no longer imports the full config/validation stack when no config, dotenv, or plugin-help-affecting env can change static root help output. Plugin-sensitive help still uses the live config path, including legacy ~/.config/openclaw/gateway.env and the .env file beside an explicit OPENCLAW_CONFIG_PATH.

Real environment tested: local OpenClaw checkout on Linux, CLI startup artifacts built with node scripts/build-all.mjs cliStartup, isolated temporary HOME/state directories, real CLI startup measured with node scripts/bench-cli-startup.ts --case help, and focused Vitest regression coverage on the pushed PR head 4b2c49f3.

Exact steps or command run after this patch:

  1. Built CLI startup artifacts: node scripts/build-all.mjs cliStartup.
  2. Measured the previous root help path with isolated temp-home runs: node scripts/bench-cli-startup.ts --case help --runs 3 --warmup 0 --timeout-ms 10000 --json.
  3. Measured this PR's root help path with isolated temp-home runs: node scripts/bench-cli-startup.ts --case help --runs 5 --warmup 0 --timeout-ms 10000 --json.
  4. Added regression coverage for legacy ~/.config/openclaw/gateway.env, explicit custom OPENCLAW_STATE_DIR exclusion, and explicit OPENCLAW_CONFIG_PATH sidecar .env handling.
  5. Ran focused checks after the compatibility repair.

Evidence after fix:

Before: node scripts/bench-cli-startup.ts --case help --runs 3 --warmup 0 --timeout-ms 10000 --json
avg duration 1116.7ms, avg RSS 264.1MB

After: node scripts/bench-cli-startup.ts --case help --runs 5 --warmup 0 --timeout-ms 10000 --json
avg duration 44.4ms, avg RSS 54.1MB

Focused regression: node scripts/test-projects.mjs src/cli/root-help-live-config.test.ts
Test Files  1 passed (1)
Tests  6 passed (6)
[test] passed 1 Vitest shard in 9.79s

Format: corepack pnpm exec oxfmt --write --threads=1 src/cli/root-help-live-config.ts src/cli/root-help-live-config.test.ts
Finished in 39ms on 2 files using 1 threads.

Diff hygiene: git diff --check -- src/cli/root-help-live-config.ts src/cli/root-help-live-config.test.ts
passed

Guard check: corepack pnpm check:no-conflict-markers && node scripts/generate-npm-shrinkwrap.mjs --all --check
npm-shrinkwrap.json is current across checked packages

Observed result after fix: default root help improved by 1072.3ms (-96.0%) and 209.9MB RSS (-79.5%) in the isolated real CLI startup sample. The focused regression suite now passes 6/6 and covers the legacy gateway.env compatibility path, custom state-dir exclusion, and explicit config-path sidecar .env path. The shrinkwrap guard now reports current generated files after regeneration.

What was not tested: full repository CI was not run locally. GitHub Actions is still the broad merge gate after the pushed PR head.

Tests

  • node scripts/test-projects.mjs src/cli/root-help-live-config.test.ts - passed, 5/5 after the legacy gateway.env repair
  • corepack pnpm exec oxfmt --write --threads=1 src/cli/root-help-live-config.ts src/cli/root-help-live-config.test.ts (commit hook)
  • git diff --check HEAD~1..HEAD -- src/cli/root-help-live-config.ts src/cli/root-help-live-config.test.ts - passed after the follow-up repair

Hygiene

  • committed with GitHub noreply author email
  • staged only the two intended CLI files
  • checked the staged diff for obvious credential patterns before committing

Related follow-up to #85353 and #85368; this is the startup/init overhead bucket outside media provider discovery.

@openclaw-barnacle openclaw-barnacle Bot added cli CLI command changes size: S labels May 22, 2026
@openclaw-barnacle openclaw-barnacle Bot added the triage: needs-real-behavior-proof Candidate: external PR needs after-fix proof from a real setup. label May 22, 2026
@clawsweeper

clawsweeper Bot commented May 22, 2026

Copy link
Copy Markdown
Contributor

Codex review: found issues before merge. Reviewed June 24, 2026, 7:50 AM ET / 11:50 UTC.

Summary
The PR adds a root-help fast-path precheck and tests so default openclaw --help can skip live config loading when no config, dotenv file, or plugin-help-affecting environment input is present.

PR surface: Source +66, Tests +127. Total +193 across 2 files.

Reproducibility: yes. Source inspection on current main shows default root help still imports the config facade and reads a snapshot before precomputed help can render; the PR body also includes copied live before/after CLI startup output.

Review metrics: 1 noteworthy metric.

  • Startup Decision Probes: 4 dotenv probes plus 1 config-file probe added. These new probes decide when root help can bypass live config loading, so they are the compatibility-sensitive part of the optimization.

Root-cause cluster
Relationship: canonical
Canonical: #85396
Summary: This PR is the canonical open item for the root-help no-config fast path; related performance PRs are adjacent rather than replacements.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Merge readiness
Overall: 🦐 gold shrimp
Proof: 🦞 diamond lobster
Patch quality: 🦐 gold shrimp
Result: needs maintainer review before merge.

Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch.

Rank-up moves:

  • Refresh or replay the branch against current main while preserving the current root-help predicate.
  • Rerun node scripts/test-projects.mjs src/cli/root-help-live-config.test.ts and Dependency Guard after refresh.

Risk before merge

  • [P1] The branch is currently dirty, so the May 22 checks and benchmark proof do not prove the conflict-resolved merge result.
  • [P1] The PR head still carries the stale plugins.bundledDiscovery root-help predicate that current main removed, so a naive refresh could restore obsolete config sensitivity.
  • [P1] This path decides when config and dotenv inputs can affect root help, so maintainers need focused post-refresh proof before merge.

Maintainer options:

  1. Refresh Onto Current Main (recommended)
    Replay the two-file fast path onto current main, drop the stale bundledDiscovery predicate unless intentionally restored, and rerun focused root-help plus dependency checks.
  2. Pause Until A Clean Merge Result Exists
    If the branch cannot be refreshed soon, keep it paused rather than merging an unreviewed conflict resolution for a config-sensitive startup path.

Next step before merge

  • [P2] The useful PR needs an author or maintainer branch refresh, conflict-resolution review, and post-refresh proof before normal merge consideration.

Security
Cleared: The diff is limited to CLI help source and focused tests, with no dependency, workflow, lockfile, credential, generated artifact, or package execution change.

Review findings

  • [P2] Refresh the stale root-help predicate — src/cli/root-help-live-config.ts:26
Review details

Best possible solution:

Replay the fast path onto current main, preserve the current-main root-help predicate unless maintainers intentionally change it, then rerun focused root-help tests and Dependency Guard before landing.

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

Yes. Source inspection on current main shows default root help still imports the config facade and reads a snapshot before precomputed help can render; the PR body also includes copied live before/after CLI startup output.

Is this the best way to solve the issue?

Yes, with a refresh. The root-help live-config probe is the right layer for this optimization, but the branch must be replayed over current main to avoid stale predicate drift.

Full review comments:

  • [P2] Refresh the stale root-help predicate — src/cli/root-help-live-config.ts:26
    The PR head still treats plugins.bundledDiscovery as root-help-affecting, but current main removed that predicate in d81ae7a. Since the branch is dirty, refresh should preserve current-main behavior unless maintainers explicitly want this live-config path restored.
    Confidence: 0.82

Overall correctness: patch is incorrect
Overall confidence: 0.82

AGENTS.md: found and applied where relevant.

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

Label changes

Label justifications:

  • P2: This is a bounded CLI startup performance improvement with limited blast radius but real config-sensitive help behavior implications.
  • merge-risk: 🚨 compatibility: The PR changes config and dotenv-sensitive root-help startup behavior and is stale against current-main predicate changes.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦞 diamond lobster and patch quality is 🦐 gold shrimp.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action. Sufficient (live_output): The PR body includes copied live before/after CLI startup benchmark output, RSS deltas, focused regression output, and observed after-fix results from a real local checkout.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR body includes copied live before/after CLI startup benchmark output, RSS deltas, focused regression output, and observed after-fix results from a real local checkout.
Evidence reviewed

PR surface:

Source +66, Tests +127. Total +193 across 2 files.

View PR surface stats
Area Files Added Removed Net
Source 1 66 0 +66
Tests 1 128 1 +127
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 194 1 +193

What I checked:

  • Root policy read: Root AGENTS.md was read fully and its CLI/config compatibility review rules apply to this PR. (AGENTS.md:12, 1069c60e1e25)
  • No scoped CLI AGENTS.md: No scoped AGENTS.md exists under src/cli, so the root policy is the applicable guide for the touched files. (1069c60e1e25)
  • Current main still loads config before root help: Current main imports ../config/config.js and calls readConfigFileSnapshot() before deciding whether precomputed root help can render. (src/cli/root-help-live-config.ts:16, 1069c60e1e25)
  • Root-help caller checked: The root-help path calls loadRootHelpRenderOptionsForConfigSensitivePlugins(process.env) before falling back to precomputed root help text. (src/cli/run-main.ts:760, 1069c60e1e25)
  • PR head adds the intended fast path: The PR head returns null before importing the heavy config module when the real process env has no plugin-sensitive env, dotenv, or config file. (src/cli/root-help-live-config.ts:96, 51005d23bff0)
  • Stale predicate against current main: The PR head still treats plugins.bundledDiscovery as root-help-affecting, while current main commit d81ae7a removed the exported helper and that predicate from this file. (src/cli/root-help-live-config.ts:26, d81ae7a441e2)

Likely related people:

  • joshavant: Merged PR Fix memory plugin CLI help dispatch #83841 introduced the root-help live-config module and tests that this PR optimizes. (role: introduced behavior; confidence: high; commits: eb6dd2c65d11, 93c3a8d896d3, 34c3997bb228; files: src/cli/root-help-live-config.ts, src/cli/root-help-live-config.test.ts, src/cli/run-main.ts)
  • vincentkoc: Recent current-main commit d81ae7a changed this root-help predicate shape by inlining unused CLI helpers, which is the branch-refresh concern here. (role: recent area contributor; confidence: high; commits: d81ae7a441e2; files: src/cli/root-help-live-config.ts)
What the crustacean ranks mean
  • 🦀 challenger crab: rare, exceptional readiness with strong proof, clean implementation, and convincing validation.
  • 🦞 diamond lobster: very strong readiness with only minor maintainer review expected.
  • 🐚 platinum hermit: good normal PR, likely mergeable with ordinary maintainer review.
  • 🦐 gold shrimp: useful signal, but proof or patch confidence is still limited.
  • 🦪 silver shellfish: thin signal; proof, validation, or implementation needs work.
  • 🧂 unranked krab: not merge-ready because proof is missing/unusable or there are serious correctness or safety concerns.
  • 🌊 off-meta tidepool: rating does not apply to this item.

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.

How this review workflow works
  • 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.

@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. 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. P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. labels May 22, 2026
@clawsweeper

clawsweeper Bot commented May 22, 2026

Copy link
Copy Markdown
Contributor

ClawSweeper PR egg

✨ Hatched: 🌱 uncommon Tiny Proofling

Hatch command

Comment @clawsweeper hatch when this PR is hatchable.

Hatchability rules:

  • Merged PRs are hatchable.
  • Open PRs are hatchable when they are status: 👀 ready for maintainer look, status: 🚀 automerge armed, or labeled clawsweeper:automerge.
  • Closed unmerged PRs are hatchable only when one of those hatchable labels is still present in the durable record.

Rarity: 🌱 uncommon.
Trait: guards the happy path.
Image traits: location status garden; accessory rollback rope; palette charcoal, cyan, and signal green; mood curious; pose pointing at a small proof artifact; shell smooth pearl shell; lighting tiny status-light glow; background small review tokens.
Share on X: post this hatch
Copy: My PR egg hatched a 🌱 uncommon Tiny Proofling in ClawSweeper.

What is this egg doing here?
  • Eggs appear after the PR passes real-behavior proof. It is here for vibes, not verdicts: it does not change labels, ratings, merge decisions, or automation.
  • The shell reacts to review momentum: open follow-up work warms it up, re-review makes it wobble, and a clean final review lets it hatch.
  • Hatchability usually comes from sufficient real-behavior proof, no blocking P0/P1/P2 findings, no security attention needed, and clean correctness. A merged PR is already final, so merge makes the egg hatchable independently.
  • The hatch is seeded from this repository and PR number, so the same PR keeps the same creature; the reviewed head SHA can only change safe visual details.
  • Rarity is just collectible sparkle: 🥚 common, 🌱 uncommon, 💎 rare, ✨ glimmer, and 🌈 legendary.

@FelixIsaac

Copy link
Copy Markdown
Contributor Author

Companion benchmark-harness PR: #85400 adds saved-report comparison to . I used this PR's before/after outputs as the smoke proof for the new comparison mode.

@FelixIsaac

Copy link
Copy Markdown
Contributor Author

Correction to the previous note: #85400 uses this PRs saved /tmp/root-help-before.json and /tmp/root-help-after.json benchmark reports as smoke proof for the new comparison mode.

@FelixIsaac

Copy link
Copy Markdown
Contributor Author

Updated this PR to keep the root-help fast path aligned with the legacy runtime dotenv loader.

Fix:

  • Added the ~/.config/openclaw/gateway.env compatibility file to the root-help precheck when no explicit non-default OPENCLAW_STATE_DIR is active.
  • Added regression coverage proving a plugin-help-affecting value in that legacy file prevents the precomputed-help shortcut, while a custom explicit state dir still skips the legacy file.

Checks:

  • node scripts/test-projects.mjs src/cli/root-help-live-config.test.ts - passed (5 tests)
  • git diff --check HEAD~1..HEAD -- src/cli/root-help-live-config.ts src/cli/root-help-live-config.test.ts - passed

@openclaw-barnacle openclaw-barnacle Bot removed the proof: sufficient ClawSweeper judged the real behavior proof convincing. label May 22, 2026
@FelixIsaac

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

The legacy gateway.env compatibility issue is addressed in c553706, and the PR body now has the required Real behavior proof section with live CLI startup evidence.

@clawsweeper

clawsweeper Bot commented May 22, 2026

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: the existing ClawSweeper review comment will be edited in place when the review finishes.

@FelixIsaac

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

PR body proof format has now been updated with the required behavior/environment/steps/evidence/observedResult/notTested fields. Please re-check the fixed head c553706.

@clawsweeper

clawsweeper Bot commented May 22, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Command router queued. I will update this comment with the next step.

Re-review progress:

@clawsweeper clawsweeper Bot added the proof: sufficient ClawSweeper judged the real behavior proof convincing. label May 22, 2026
@FelixIsaac
FelixIsaac requested a review from a team as a code owner May 22, 2026 19:43
@github-actions github-actions Bot added the dependencies-changed PR changes dependency-related files label May 22, 2026
@openclaw-barnacle openclaw-barnacle Bot added channel: discord Channel integration: discord channel: msteams Channel integration: msteams channel: slack Channel integration: slack channel: whatsapp-web Channel integration: whatsapp-web channel: zalouser Channel integration: zalouser and removed dependencies-changed PR changes dependency-related files labels May 22, 2026
@FelixIsaac

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

Rebuilt the branch on current main and replayed only the root-help source/test changes, with no shrinkwrap deltas. Focused checks passed: node scripts/test-projects.mjs src/cli/root-help-live-config.test.ts, node scripts/generate-npm-shrinkwrap.mjs --all --check, and git diff --check -- src/cli/root-help-live-config.ts src/cli/root-help-live-config.test.ts.

@clawsweeper

clawsweeper Bot commented May 22, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Command router queued. I will update this comment with the next step.

@clawsweeper

clawsweeper Bot commented May 22, 2026

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: the existing ClawSweeper review comment will be edited in place when the review finishes.

Re-review progress:

@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: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. labels May 22, 2026
@RomneyDa

Copy link
Copy Markdown
Member

Heads up: this PR needs to be updated against current main before the new required Dependency Guard check can pass.

@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. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. 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 Jun 21, 2026
@openclaw-barnacle

Copy link
Copy Markdown

This pull request has been automatically marked as stale due to inactivity.
Please add updates or it will be closed.

@openclaw-barnacle openclaw-barnacle Bot added the stale Marked as stale due to inactivity label Jul 14, 2026
@clawsweeper

clawsweeper Bot commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

ClawSweeper status: review started.

I am starting a fresh review of this pull request: perf(cli): skip config load for default root help This is item 1/1 in the current shard. Shard 0/31.

This placeholder means the worker is alive and reading the current context. I will edit this same comment with the actual review when the claws are done clicking.

Crustacean status: shell secured, claws on keyboard, evidence pebbles being sorted.

@openclaw-barnacle

Copy link
Copy Markdown

Closing due to inactivity.
If you believe this PR should be revived, post in #clawtributors on Discord to talk to a maintainer.
That channel is the escape hatch for high-quality PRs that get auto-closed.

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

Labels

cli CLI command changes 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. proof: supplied External PR includes structured after-fix real behavior proof. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: S stale Marked as stale due to inactivity 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.

2 participants