Skip to content

fix: keep Gateway responsive while Doctor runs - #157228

Merged
steipete merged 1 commit into
mainfrom
codex/hosted-doctor-process
Sep 24, 2026
Merged

steipete merged 1 commit into
mainfrom
codex/hosted-doctor-process

Conversation

@steipete

@steipete steipete commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor

Related: #119720

What Problem This Solves

Fixes Gateway stalls when the System agent runs Doctor's bulk synchronous checks in the Gateway process.

User Impact

Chats and control requests can keep progressing while Doctor inspects the installation. The existing noninteractive checks and safe migrations remain unchanged; cancellation waits for admitted work and cleanup to settle.

Why This Change Was Made

Run Doctor in a child from the same installation and runtime, through its existing command entry. Forward bounded UTF-8 output and preserve failed exits, sealed-runtime selection, and write-capable cleanup. No schema, configuration, permission, or update migration changes.

Evidence

  • The regression failed on the original direct invocation. A real child then performed synchronous work while the parent served its request; the final regression took 206 ms.
  • pnpm test src/system-agent/operations.doctor.process.test.ts src/system-agent/operations.doctor.test.ts --maxWorkers=1: 7 passed, 39.75 s Vitest / 44.10 s runner wall including cold subprocess compilation. The six output/failure/cancellation cases take milliseconds. The unchanged dispatcher suite also passed.
  • Fresh full pnpm build at 1c5f71ca7abe1b888c0d252fd210e47ad314511b passed, including all declarations (22m16s). Canonical package integrity passed (119s). Candidate tarball SHA-256: 59abdb48fdf7ce13a558b939bceace74dcfe5aec3713208f0e07da06e3818843.
  • The integrity-pinned published 2026.9.4 updater ran openclaw update --tag file:/tmp/openclaw-current.tgz --yes --json --no-restart against synthetic existing Projects/config/workspace state. All 12 steps passed, status ok, 131.343 s, no repair. This includes migration rehearsal, candidate Doctor lint, Gateway canary, installed Doctor, and final Doctor lint. The installed build identifies 1c5f71ca7abe; every application payload hash matched the candidate tarball.
  • Post-update canonical assertions verified Projects inventory, configured workspace, and sentinel preservation. Installed doctor --lint --only core/doctor/project-clone-shape --json passed twice (5.566s / 2.556s; zero findings), preserving config and SQLite-family hashes and leaving no private snapshots.
  • Core/all 25 test typecheck groups, lint/guards, and independent review through P2 passed. Published-head CI and applicable security review passed.

Harness limitations: the broad 2026.9.6/base attempt failed before candidate installation because cold baseline channel startup took 94s against its 90s budget. The focused 2026.9.4/projects-doctor aggregate lane passed the update and installed-payload verification, then its observer miscounted a generated forwarding entry and its single implementation as two owners. Its failed outcome remains unchanged. The post-update checks above completed separately in a network-disabled container through the hash-verified forwarding entry and existing canonical assertions; no candidate, fixture source, timeouts, or baselines were changed.

@clawsweeper

clawsweeper Bot commented Sep 24, 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.

@steipete
steipete marked this pull request as ready for review September 24, 2026 11:05
@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation gateway Gateway runtime commands Command implementations size: M labels Sep 24, 2026
@clawsweeper clawsweeper Bot added P1 High-priority user-facing bug, regression, or broken workflow. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. 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 Sep 24, 2026
@clawsweeper

clawsweeper Bot commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge. Reviewed September 24, 2026, 8:35 AM ET / 12:35 UTC (Revision 2).

ClawSweeper review

What this changes

The System agent launches noninteractive Doctor in a child process, forwards bounded diagnostics, and waits for cleanup so Gateway requests can continue.

Merge readiness

⛔ Blocked before merge - 1 item remains

Current main still runs System-agent Doctor inline. The updated published-updater evidence addresses the prior review blocker, and this review found no introduced correctness or security defect.

Priority: P1
Reviewed head: 1c5f71ca7abe1b888c0d252fd210e47ad314511b

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) The patch is focused, with meaningful process-boundary coverage and the previously requested upgrade result recorded in the PR body.
Proof confidence 🐚 platinum hermit (4/6) Not applicable: The member-authored PR is exempt from the external-contributor proof gate. Its boundary test exercises System-agent dispatch with a real child and HTTP response, and the PR body reports a published-updater × candidate run against existing synthetic state; this review did not rerun either result. No stored-data contract changes.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The member-authored PR is exempt from the external-contributor proof gate. Its boundary test exercises System-agent dispatch with a real child and HTTP response, and the PR body reports a published-updater × candidate run against existing synthetic state; this review did not rerun either result. No stored-data contract changes.
Evidence reviewed 6 items Introduced operation route: The pinned merge-base-to-head diff replaces the inline System-agent Doctor call with the child-process route.
Current-main necessity: Fetched main still invokes Doctor directly for the System-agent operation; the new process owner is absent there.
Child lifecycle: The new owner launches the registered Doctor entrypoint, limits forwarded output, retains admitted work through cancellation, and checks cleanup and exit status.
Findings None None.
Security None None.

How this fits together

The System agent runs maintenance requests from the Gateway. Doctor inspects the installation and may perform safe migrations; its diagnostics return to the requesting agent.

flowchart LR
  A[System agent request] --> B[Gateway operation]
  B --> C[Doctor child process]
  C --> D[Installation checks]
  D --> E[Diagnostics and exit status]
  E --> F[System agent response]
  B --> G[Other Gateway requests continue]
Loading

Before merge

  • Add data-model compatibility proof - Confirm migration or upgrade compatibility proof before merge.
Agent review details

Security

None.

PR surface

Source +159, Tests +188, Docs +7. Total +354 across 8 files.

View PR surface stats
Area Files Added Removed Net
Source 5 162 3 +159
Tests 2 188 0 +188
Docs 1 7 0 +7
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 8 357 3 +354

Review metrics

None.

Stored data model

Persistent data-model change detected: migration/backfill/repair: src/commands/doctor-process.ts, migration/backfill/repair: src/commands/doctor.ts, migration/backfill/repair: src/commands/doctor.worker.ts, unknown-data-model-change: src/commands/doctor-process.ts. Confirm migration or upgrade compatibility proof before merge.

Technical review

Best possible solution:

Land the existing Doctor command through the registered child-process entrypoint while preserving noninteractive migration behavior and cleanup settlement.

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

Yes. Current-main source calls Doctor inline from the Gateway operation, and the submitted boundary regression demonstrates the event-loop stall mechanism; this reviewer did not execute it.

Is this the best way to solve the issue?

Yes. Reusing the existing noninteractive Doctor command in a registered child process confines its synchronous work without creating a second Doctor implementation.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • remove merge-risk: 🚨 compatibility: Current PR review selected no merge-risk labels.

Label justifications:

  • P1: An inline Doctor run can stall Gateway chat and control requests during installation checks.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: The member-authored PR is exempt from the external-contributor proof gate. Its boundary test exercises System-agent dispatch with a real child and HTTP response, and the PR body reports a published-updater × candidate run against existing synthetic state; this review did not rerun either result. No stored-data contract changes.

Evidence

What I checked:

  • Introduced operation route: The pinned merge-base-to-head diff replaces the inline System-agent Doctor call with the child-process route. (src/system-agent/operations-execute.ts:548, 1c5f71ca7abe)
  • Current-main necessity: Fetched main still invokes Doctor directly for the System-agent operation; the new process owner is absent there. (src/system-agent/operations-execute.ts:548, ead3b2ee776c)
  • Child lifecycle: The new owner launches the registered Doctor entrypoint, limits forwarded output, retains admitted work through cancellation, and checks cleanup and exit status. (src/commands/doctor-process.ts:19, 1c5f71ca7abe)
  • Boundary regression: The added test enters the System-agent operation with a real child performing synchronous work while an HTTP request is served; the separate tests cover failure, cancellation, output bounds, and UTF-8. (src/system-agent/operations.doctor.process.test.ts:25, 1c5f71ca7abe)
  • Prior review addressed: The previous ClawSweeper review requested a published-updater × candidate run. The updated PR body reports a published 2026.9.4 updater completing all 12 steps against synthetic existing state, followed by installed Doctor checks and state-preservation assertions. These are reported results, not commands rerun by this reviewer. (1c5f71ca7abe)
  • Related scope: The linked open issue concerns broader synchronous persistence and transcript starvation. This PR addresses a distinct Doctor entry point within the Gateway-responsiveness problem.

Likely related people:

  • Peter Steinberger: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • Ayaan Zaidi: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

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-09-24T11:17:00.093Z sha 1c5f71c :: blocked before merge. :: none

@clawsweeper clawsweeper Bot removed the merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. label Sep 24, 2026
@steipete
steipete merged commit 6ae7b96 into main Sep 24, 2026
289 of 294 checks passed
@steipete
steipete deleted the codex/hosted-doctor-process branch September 24, 2026 12:49
@steipete

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

commands Command implementations docs Improvements or additions to documentation gateway Gateway runtime P1 High-priority user-facing bug, regression, or broken workflow. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: M 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