Repository navigation
fix(plugins): fail closed when plugin runtime is unavailable during registration - #130597
Conversation
Core fabricated an empty object as `PluginRuntime` for the `cli-metadata` and `setup-only` registration passes, so any plugin touching `api.runtime` during `register()` died with an opaque `TypeError: Cannot read properties of undefined (reading 'openSyncKeyedStore')` that named neither the contract nor the mode. Replace those fabrications with one shared fail-closed runtime that throws a named, actionable error identifying the plugin and registration mode. Symbol reads stay inert so inspection and reflection cannot trigger the guard. Also resolve the lightweight `cli-metadata` entry beside the resolved plugin entry, not only at the package root. Published plugin packages emit it at `dist/cli-metadata.js`, so the probe always missed and the loader fell back to executing the full heavy entry for CLI metadata collection. Documents which registration modes expose a live `api.runtime`; the SDK reference previously claimed it was injected into every plugin.
Remove the redundant viewer-facepile dynamic import: sidebar consumers already register that element through the static graph. Import pet data and sprite helpers from their owning leaf modules, delete the registration module's re-export barrel, and make the element itself the lobster-pet.runtime.ts lazy boundary. Keep shared sprite styles with the look renderer so standalone pages do not need element registration. Regenerate the measured boot inventory with the canonical browser probe. Use Lit's typed lifecycle map to remove the obsolete assertion baseline entry and keep the now-private facepile variant type local. The full build has no INEFFECTIVE_DYNAMIC_IMPORT warnings. Relevant UI coverage passes (503 tests plus 5 Chromium E2E tests); the unchanged plugin runtime regression suites pass all 58 tests. The broad plugin suite still reports schema-version, doctor-closure, hook-process, and catalog failures.
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Codex review: needs maintainer review before merge. Reviewed August 26, 2026, 10:24 PM ET / August 27, 2026, 02:24 UTC. ClawSweeper reviewWhat this changesThe PR makes unavailable plugin runtimes fail with a named error during CLI-metadata and setup-only registration, finds packaged metadata beside plugin entries, and restores real Control UI sidebar lazy-loading boundaries. Regression provenancePossible regression — suspected (reviewed change). No predecessor PR is attributed. Merge readinessKeep this maintainer PR open: current main still passes an empty runtime into metadata-only registration, while this branch replaces that opaque failure with a documented, actionable contract. No discrete correctness defect was found, but the intentional fail-closed SDK behavior needs compatibility validation and exact-head CI before landing. Priority: P2 Review scores
Verification
Live VerificationCommand: Result: FAIL (failed) — step 1 Assertions:
How this fits togetherCLI command discovery reads plugin manifests first and loads a lightweight metadata entry only for legacy external plugins; registration then supplies command descriptors to the CLI. Separately, the Control UI sidebar schedules decorative component loading after startup so its initial browser bundle stays smaller. flowchart LR
A[CLI help or unknown command] --> B[Plugin command discovery]
B --> C[Light metadata entry]
C --> D[Unavailable runtime guard]
D --> E[Descriptors or actionable diagnostic]
F[Control UI sidebar] --> G[Idle pet module import]
G --> H[Registered sidebar pet element]
Decision needed
Why: This is a public plugin-SDK behavior change: source and docs support the design, but only maintainers can accept its upgrade effect on installed plugins. Before merge
Agent review detailsSecurityNone. PR surfaceSource -16, Tests +111, Docs +2, Other -1. Total +96 across 26 files. View PR surface stats
Review metrics
Stored data modelPersistent data-model change detected: Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Retain one documented unavailable-runtime contract for the two control-plane modes, prefer packaged metadata sidecars over heavy entries, and land only after compatibility and exact-head CI evidence confirms existing plugins still discover correctly. Do we have a high-confidence way to reproduce the issue? Yes in source: current main supplies an empty CLI-metadata runtime while the Codex plugin reads runtime configuration and state during its full registration path. This review did not execute the clean-install reproduction because the checkout is read-only and package-manager startup failed before any repository action. Is this the best way to solve the issue? Yes, conditionally: the repair fixes the producer-owned fabricated runtime, prefers the existing lightweight metadata seam, and aligns docs and tests; maintainers must still accept the resulting SDK compatibility contract. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 7602af0667bb. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
|
|
Maintainer decision recorded, addressing both rank-up moves before merge. Decision: adopt the explicit fail-closed contract (matching the review's own recommendation). On the P1 compatibility question — a third-party plugin that probed
Symbol reads on the unavailable runtime deliberately return Exact-head CI: green on Packaged-plugin metadata compatibility: covered by a regression test that builds a packaged layout ( One note on the review's Live Verification |
|
Merged via squash.
|
…egistration (openclaw#130597) * fix(plugins): fail closed when plugin runtime is unavailable Core fabricated an empty object as `PluginRuntime` for the `cli-metadata` and `setup-only` registration passes, so any plugin touching `api.runtime` during `register()` died with an opaque `TypeError: Cannot read properties of undefined (reading 'openSyncKeyedStore')` that named neither the contract nor the mode. Replace those fabrications with one shared fail-closed runtime that throws a named, actionable error identifying the plugin and registration mode. Symbol reads stay inert so inspection and reflection cannot trigger the guard. Also resolve the lightweight `cli-metadata` entry beside the resolved plugin entry, not only at the package root. Published plugin packages emit it at `dist/cli-metadata.js`, so the probe always missed and the loader fell back to executing the full heavy entry for CLI metadata collection. Documents which registration modes expose a live `api.runtime`; the SDK reference previously claimed it was injected into every plugin. * fix(ui): restore sidebar lazy import boundaries Remove the redundant viewer-facepile dynamic import: sidebar consumers already register that element through the static graph. Import pet data and sprite helpers from their owning leaf modules, delete the registration module's re-export barrel, and make the element itself the lobster-pet.runtime.ts lazy boundary. Keep shared sprite styles with the look renderer so standalone pages do not need element registration. Regenerate the measured boot inventory with the canonical browser probe. Use Lit's typed lifecycle map to remove the obsolete assertion baseline entry and keep the now-private facepile variant type local. The full build has no INEFFECTIVE_DYNAMIC_IMPORT warnings. Relevant UI coverage passes (503 tests plus 5 Chromium E2E tests); the unchanged plugin runtime regression suites pass all 58 tests. The broad plugin suite still reports schema-version, doctor-closure, hook-process, and catalog failures.
Related: #112248
What Problem This Solves
Fixes an issue where operators running any plugin that reads
api.runtimeduring registration would see an unexplained crash on ordinary CLI invocations. On a clean install of stable2026.7.1-2,openclaw codex --helpand any unknown command printed:The message named neither the contract that was violated nor the registration mode, so there was nothing for an operator or plugin author to act on. Reported repeatedly (#112248, #118911, #118145, #111870, #107219, #106140), each time investigated as a version-skew problem between core and
@openclaw/codex. It is not one — the pairing is irrelevant, and the trigger is the registration mode.Separately,
pnpm buildemitted two[INEFFECTIVE_DYNAMIC_IMPORT]warnings for the Control UI sidebar, meaning two intended lazy boundaries were not deferring anything.Why This Change Was Made
Root help and command-owner routing are manifest-first: a plugin that declares
cliCommandssupplies its descriptors from metadata and is never executed. A plugin without them falls back to a loader pass that actually runsregister(api)— and that pass, along withsetup-onlyregistration, built the plugin API with{} as PluginRuntime. Core was handing plugins an object that lied about its own shape, so the first property read produced an opaqueTypeErrorinstead of a contract violation.Both fabrication sites now use one shared fail-closed runtime that names the plugin, the registration mode, and the actionable next step. Symbol reads stay inert so inspection and reflection cannot trip the guard;
thendeliberately still throws, because awaiting an unavailable runtime must not silently succeed.A second defect kept the heavy path alive: the lightweight
cli-metadataentry was only probed at the package root, but published plugin packages emit it atdist/cli-metadata.js. The probe always missed for npm-installed plugins, so the loader fell back to executing the full entry. It now resolves beside the resolved plugin entry.For the Control UI,
app-sidebarlazily imported two modules that were already in the static graph —viewer-facepilevia eager side-effect imports from sidebar-adjacent components, andlobster-petbecause pages statically imported palette and lore data that its barrel re-exported. The facepile's false lazy boundary is removed, and the pet element moves behind a reallobster-pet.runtime.tsboundary with data consumers pointed at the leaf modules that own that data.User Impact
Plugin authors and operators get an actionable error naming the plugin and mode instead of an undefined-property crash, plus a documented statement of which registration modes expose a live
api.runtime— the SDK reference previously claimed it was injected into every plugin, which was never true for these two modes. Packaged plugins now genuinely skip their heavy entry during CLI metadata collection, and the Control UI sidebar's lazy boundaries actually defer.Net production change is −15 lines.
Evidence
Reported failure reproduced live in a clean
node:26-bookwormcontainer (npm i -g openclaw@latest, core2026.7.1-2, materialized plugin2026.7.1-1).openclaw codex --helpand an unknown command both reproduced the exactTypeError;--help,status,plugins list,doctor, andmodels listwere clean — confirming the CLI-metadata pass as the trigger rather than the version pairing.Regression tests fail on pre-fix code for the intended reason. Reverting only the production files and keeping the new tests produces 4 failures, including the literal
TypeError: Cannot read properties of undefined (reading 'openSyncKeyedStore')fromsetup-onlyregistration, and a packaged-layout test showing the heavy entry marker was written. With the fix, 58 tests pass.Build proves both warnings are gone.
pnpm buildcompletes with zero[INEFFECTIVE_DYNAMIC_IMPORT]warnings; the baseline had two. A built-browser probe confirmedfacepile: true, pet: falsebefore idle loading, with pet registration following afterwards.Gates:
node scripts/check-changed.mjspassed.pnpm buildpassed.oxfmtpassed on all touched paths. Relevant UI tests: 503 passed, plus 5 Chromium E2E. Codex autoreview: clean, no accepted findings.Known unrelated failure:
src/plugins/npm-install-security-scan.release.test.tsfails on this branch and fails identically on cleanorigin/main(verified at3cb0dd4851e). It flags adangerous-execpattern in the published@openclaw/openshell-sandboxpackage and is untouched by this change; its allowlist needs separate maintainer judgment..artifacts/report and container logs are local only and not committed.