Skip to content

fix(doctor): prevent Codex registration failures during checks - #170445

Merged
obviyus merged 1 commit into
mainfrom
fix/doctor-codex-runtime-config
Oct 13, 2026
Merged

obviyus merged 1 commit into
mainfrom
fix/doctor-codex-runtime-config

Conversation

@obviyus

@obviyus obviyus commented Oct 13, 2026 •

Copy link
Copy Markdown
Collaborator

What Problem This Solves

Fixes: openclaw doctor --fix --non-interactive exits with a Codex plugin registration error when runtime config has not yet been prepared.

User Impact

Doctor can inspect enabled Codex tools without reporting Runtime config is not prepared as a plugin failure. No configuration, schema, permissions, defaults, or plugin API changes.

Why This Change Was Made

Doctor already owns the repaired configuration, but its contribution checks can register plugins before publishing that configuration for runtime readers. Prepare it through the existing async runtime-config owner after the config flow and before contributions. This preserves the strict runtime reader introduced in #169714 rather than adding a fallback to Codex or the plugin runtime.

No overlap with Pash/Sarah changes in the changed files.

Evidence

  • Built base f9d5447c5946 and candidate ddd777e2c8c9 with pnpm build.
  • Real pnpm openclaw --profile <isolated-profile> doctor --fix --non-interactive --no-workspace-suggestions: base reported Codex registration failures and exited 1; candidate completed with no plugin load error and exited 0. Each run confirmed its own config, state, and database paths first. The fixture uses an enabled bundled Codex plugin and a local static model definition; no live user state.
  • Started a separate candidate Gateway. Its live plugins.list RPC reported Codex runtime state active. Stopped the Gateway afterward.
  • Regression test fails before the fix (plugin status error), then all 3 tests pass in pnpm test src/flows/doctor-health.plugin-load.test.ts --maxWorkers=1 (29.19s runner wall time, 25.23s Vitest duration). Targeted Oxfmt and Oxlint pass.
  • Simplification pass: one existing publication owner, no fallback or new abstraction. Production +2/-0 lines; tests +47/-0. The two production lines are the import and required preparation call.
  • No model request or channel-delivery path changed; real-provider/channel checks are not applicable. The separate update repair wrapper was not exercised; its Doctor checks use this same flow.
Observed terminal evidence (paths redacted; unrelated warnings omitted)

Base f9d5447c5946, after the initial legacy fixture was repaired and a local static model definition was configured so tool-schema inspection runs:

$ pnpm openclaw --profile pdoctorcodexbase doctor --fix --non-interactive --no-workspace-suggestions
[plugins] codex failed during register from <worktree>/dist/extensions/codex/index.js: Error: Runtime config is not prepared. Await captureRuntimeConfigAsyncReader()() first.
[error] core/doctor/workspace-status plugins.entries.codex - Plugin codex: plugin failed during register: Error: Runtime config is not prepared. Await captureRuntimeConfigAsyncReader()() first. (<worktree>/dist/extensions/codex/index.js)
└  Doctor finished with plugin load errors.
EXIT_CODE=1

Candidate ddd777e2c8c9, same configuration with separate state, home, workspace and port:

$ pnpm openclaw --profile pdoctorcodexcand doctor --fix --non-interactive --no-workspace-suggestions
└  Doctor complete.
EXIT_CODE=0

Candidate Gateway, started with pnpm openclaw --profile pdoctorcodexcand gateway run --port 19644 --bind loopback:

[gateway] ready
$ pnpm openclaw --profile pdoctorcodexcand gateway call plugins.list --json

Codex entry excerpt from the live RPC response:

{"id":"codex","runtime":{"state":"active"}}
[gateway] received SIGTERM; shutting down
[shutdown] completed cleanly in 120ms

Merge danger: two-way door; a revert fully removes this change. No new persisted representation or migration. Blast radius is Doctor's runtime-backed plugin checks; Gateway startup is unchanged and was smoke-tested with Codex enabled.

@clawsweeper

clawsweeper Bot commented Oct 13, 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.

@obviyus

obviyus commented Oct 13, 2026

Copy link
Copy Markdown
Collaborator Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. 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 13, 2026
@clawsweeper

clawsweeper Bot commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

Prepare runtime config before Doctor contributions register plugins.

Example: Run openclaw doctor --fix --non-interactive with the bundled Codex plugin enabled.

  • Before: Codex registration reports “Runtime config is not prepared” and Doctor exits 1.
  • After: Doctor completes without the registration error and exits 0.

Review scores

Measure Result What it means
Overall readiness 🦞 diamond lobster (5/6) Focused owner-level repair with shipped CLI evidence, a meaningful regression test, and no remaining findings; no persisted format or migration changes.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (terminal): Observed terminal evidence exercises the real Doctor CLI with enabled bundled Codex in isolated base and candidate environments, showing the registration error disappear and exit status change from 1 to 0.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Doctor incorrectly reports an enabled Codex plugin as broken because its runtime configuration has not been prepared.
Reason: The maintainer-authored change restores an existing diagnostic workflow with one preparation call and preserves the prior runtime design.

Merge readiness

✅ Ready for maintainer review

This PR fixes a current Doctor failure with a focused change; no actionable defects remain, and the earlier review requests are satisfied.

Priority: P2
Reviewed head: ddd777e2c8c911706674d904292978d846f6ac36

Before merge

None.

Findings

None.

Agent review details

How this fits together

Doctor passes its inspected configuration through the existing runtime snapshot owner before runtime-backed plugin checks consume it.

flowchart LR
  A[Doctor CLI] --> B[Config inspection and repair]
  B --> C[Runtime snapshot preparation]
  C --> D[Doctor contributions]
  D --> E[Plugin registration]
  E --> F[Doctor findings and exit status]
Loading

Technical review

Best possible solution:

Use Doctor’s existing runtime-config owner to prepare plugin checks while preserving strict runtime reads.

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

The strict getter and Doctor ordering establish the failure path, supported by the contributor’s observed base/candidate CLI comparison; no target code was executed during this review.

Is this the best way to solve the issue?

The change repairs missing preparation at the Doctor owner, preserves the intended strict reader, and avoids plugin-specific fallbacks.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against d70a7e7300cd.

Provenance checked

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

  • Focused introduced change: The introduced patch adds the existing async snapshot preparation call after config preparation and before contributions, plus a regression exercising real plugin registration. (src/flows/doctor-health.ts:393, ddd777e2c8c9)
  • Current main still needs preparation: Current main proceeds from config preparation toward contributions without the new call; the plugin runtime getter consumes the strict prepared-only reader. (src/flows/doctor-health.ts:391, d70a7e7300cd)
  • Existing publication owner: The async owner preserves an existing snapshot and prepares and publishes the supplied configuration only when no snapshot exists. (src/config/runtime-snapshot.ts:619, ddd777e2c8c9)
  • Observed behavior and re-review: The PR body supplies redacted base/candidate CLI output showing exit 1 versus exit 0 for the reported scenario, plus candidate Gateway evidence showing Codex active; the author subsequently marked the unchanged head ready for review. (ddd777e2c8c9)
  • Original runtime intent preserved: refactor(runtime): prepare config, auth, and session facts asynchronously #169714 explicitly made core runtime reads prepared-only; this PR supplies missing preparation without restoring synchronous fallback. (src/config/runtime-snapshot.ts:394, 7e48efba1047)
  • Exact-head checks: Both check-run pages contain no failed checks; dispatch cancellations and a neutral CodeQL result remain distinct from passing checks, while dependency-review, security-sensitive-review, and ci-gate statuses report success. (ddd777e2c8c9)

Likely related people:

  • Peter Steinberger: Raw commit abb9723 adds src/flows/doctor-health.ts:367 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: abb97239bcab; files: src/flows/doctor-health.ts)

PR surface

Source +2, Tests +47. Total +49 across 2 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 1 2 0 +2
Tests 1 47 0 +47
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 49 0 +49

Review metrics

Metric Value Why it matters
Production versus test growth Production +2/-0; tests +47/-0 The preparation call reuses an existing owner; the regression verifies that plugin registration can consume the prepared configuration.

Labels

Label changes:

  • add proof: sufficient: Contributor real behavior proof is sufficient.
  • add rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • remove rating: 🦐 gold shrimp: Current PR rating is rating: 🦞 diamond lobster, so this older rating label is no longer current.
  • remove status: ⏳ waiting on author: Current PR status label is status: 👀 ready for maintainer look.

Label justifications:

  • P2: Repairs false plugin registration failures in Doctor without changing normal agent or channel execution.
  • rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • proof: sufficient: Contributor real behavior proof is sufficient.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

History

Review history (1 earlier review cycle)
  • reviewed 2026-10-13T00:28:09.760Z sha ddd777e :: needs changes before merge. :: none

Reviewed October 12, 2026, 9:40 PM ET / October 13, 2026, 01:40 UTC (Revision 2).

@obviyus
obviyus marked this pull request as ready for review October 13, 2026 00:39
@obviyus

obviyus commented Oct 13, 2026

Copy link
Copy Markdown
Collaborator Author

Marked ready for review (no landing requested). Added redacted observed base/candidate Doctor output, exit codes, and candidate Gateway plugins.list/clean shutdown evidence to the PR body. The source remains at ddd777e2c8c911706674d904292978d846f6ac36.

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor 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 13, 2026
@obviyus
obviyus merged commit 5043798 into main Oct 13, 2026
211 of 213 checks passed
@obviyus
obviyus deleted the fix/doctor-codex-runtime-config branch October 13, 2026 04:51
@obviyus

obviyus commented Oct 13, 2026

Copy link
Copy Markdown
Collaborator Author

Landed in 5043798. Thanks for the review! The isolated Doctor reproduction now completes without Codex registration errors, and Gateway Codex registration remains healthy.

steipete added a commit that referenced this pull request Oct 13, 2026
The equivalent runtime preparation fix and regression landed in #170445. Remove this branch’s overlapping implementation and test so the PR only adds its standalone Doctor documentation clarification. Keep the original update proof in the PR body.
steipete added a commit that referenced this pull request Oct 13, 2026
* fix(doctor): prepare runtime config before plugin health checks

Publish the prepared Doctor config through the existing runtime snapshot owner before health contributions register plugins. Preserve an existing process snapshot and keep strict runtime readers intact.

Fixes the regression from #169714 exposed by standalone Doctor after updates. Add real plugin-registration regression coverage and document the standalone update flow.

* docs(doctor): retain post-update guidance after runtime fix

The equivalent runtime preparation fix and regression landed in #170445. Remove this branch’s overlapping implementation and test so the PR only adds its standalone Doctor documentation clarification. Keep the original update proof in the PR body.

Co-authored-by: Peter Steinberger <[email protected]>
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 14, 2026
…law#170445)

## What Problem This Solves

Fixes: `openclaw doctor --fix --non-interactive` exits with a Codex plugin registration error when runtime config has not yet been prepared.

## User Impact

Doctor can inspect enabled Codex tools without reporting `Runtime config is not prepared` as a plugin failure. No configuration, schema, permissions, defaults, or plugin API changes.

## Why This Change Was Made

Doctor already owns the repaired configuration, but its contribution checks can register plugins before publishing that configuration for runtime readers. Prepare it through the existing async runtime-config owner after the config flow and before contributions. This preserves the strict runtime reader introduced in openclaw#169714 rather than adding a fallback to Codex or the plugin runtime.

No overlap with Pash/Sarah changes in the changed files.

## Evidence

- Built base `71a78573e336` and candidate `ddd777e2c8c9` with `pnpm build`.
- Real `pnpm openclaw --profile <isolated-profile> doctor --fix --non-interactive --no-workspace-suggestions`: base reported Codex registration failures and exited **1**; candidate completed with no plugin load error and exited **0**. Each run confirmed its own config, state, and database paths first. The fixture uses an enabled bundled Codex plugin and a local static model definition; no live user state.
- Started a separate candidate Gateway. Its live `plugins.list` RPC reported Codex runtime state **active**. Stopped the Gateway afterward.
- Regression test fails before the fix (plugin status `error`), then all **3 tests pass** in `pnpm test src/flows/doctor-health.plugin-load.test.ts --maxWorkers=1` (29.19s runner wall time, 25.23s Vitest duration). Targeted Oxfmt and Oxlint pass.
- Simplification pass: one existing publication owner, no fallback or new abstraction. Production **+2/-0** lines; tests **+47/-0**. The two production lines are the import and required preparation call.
- No model request or channel-delivery path changed; real-provider/channel checks are not applicable. The separate `update repair` wrapper was not exercised; its Doctor checks use this same flow.

<details>
<summary>Observed terminal evidence (paths redacted; unrelated warnings omitted)</summary>

Base `71a78573e336`, after the initial legacy fixture was repaired and a local static model definition was configured so tool-schema inspection runs:

```text
$ pnpm openclaw --profile pdoctorcodexbase doctor --fix --non-interactive --no-workspace-suggestions
[plugins] codex failed during register from <worktree>/dist/extensions/codex/index.js: Error: Runtime config is not prepared. Await captureRuntimeConfigAsyncReader()() first.
[error] core/doctor/workspace-status plugins.entries.codex - Plugin codex: plugin failed during register: Error: Runtime config is not prepared. Await captureRuntimeConfigAsyncReader()() first. (<worktree>/dist/extensions/codex/index.js)
└  Doctor finished with plugin load errors.
EXIT_CODE=1
```

Candidate `ddd777e2c8c9`, same configuration with separate state, home, workspace and port:

```text
$ pnpm openclaw --profile pdoctorcodexcand doctor --fix --non-interactive --no-workspace-suggestions
└  Doctor complete.
EXIT_CODE=0
```

Candidate Gateway, started with `pnpm openclaw --profile pdoctorcodexcand gateway run --port 19644 --bind loopback`:

```text
[gateway] ready
$ pnpm openclaw --profile pdoctorcodexcand gateway call plugins.list --json
```

Codex entry excerpt from the live RPC response:

```json
{"id":"codex","runtime":{"state":"active"}}
```

```text
[gateway] received SIGTERM; shutting down
[shutdown] completed cleanly in 120ms
```

</details>

Merge danger: **two-way door**; a revert fully removes this change. No new persisted representation or migration. Blast radius is Doctor's runtime-backed plugin checks; Gateway startup is unchanged and was smoke-tested with Codex enabled.

Co-authored-by: Ayaan Zaidi <[email protected]>
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 14, 2026
* fix(doctor): prepare runtime config before plugin health checks

Publish the prepared Doctor config through the existing runtime snapshot owner before health contributions register plugins. Preserve an existing process snapshot and keep strict runtime readers intact.

Fixes the regression from openclaw#169714 exposed by standalone Doctor after updates. Add real plugin-registration regression coverage and document the standalone update flow.

* docs(doctor): retain post-update guidance after runtime fix

The equivalent runtime preparation fix and regression landed in openclaw#170445. Remove this branch’s overlapping implementation and test so the PR only adds its standalone Doctor documentation clarification. Keep the original update proof in the PR body.

Co-authored-by: Peter Steinberger <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. size: XS 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