Skip to content

fix: await Doctor process and restart lease inspection - #190872

Merged
roboclaw-bot merged 61 commits into
mainfrom
roboclaw/doctor-process-reads
Nov 2, 2026
Merged

roboclaw-bot merged 61 commits into
mainfrom
roboclaw/doctor-process-reads

Conversation

@roboclaw-bot

@roboclaw-bot roboclaw-bot commented Nov 2, 2026 •

Copy link
Copy Markdown
Collaborator

Related: #178359, #187900.

What Problem This Solves

Doctor and service inspection can block cancellation while synchronously preparing Gateway process and restart lease observations. Awaited maintenance inspection also needs to follow a legitimately replaced state file rather than a retained admission's old inode.

User Impact

Process and restart observations await the existing read owner and cleanup. Offline maintenance can inspect the current physical state file after restoration or a database port. Native process signals, service actions and restart-intent writes still require current caller authority and captured process identity. This is the second split stage of the Doctor repair. Not yet released.

Why This Change Was Made

Use the canonical awaited snapshot/read transport for Promise-only lease inspection. Descriptive reads use the existing independent warm-source path when the retained writer's physical identity still matches, preserving native-transaction refusal and original-source fallback for replaced paths. Maintenance snapshot admission captures the current physical file under acquired custody while retaining caller admission, cancellation and custody checks after awaits.

Await direct service callers, preserve synchronous native-supervisor callbacks, and share the stale-process cleanup policy between async and native drivers. Restart-intent writes inspect their admitted transaction. Preserve main's live-Gateway copy exclusion.

The 37-file diff contains process/restart inspection, direct callers/tests and allocation records. Inherited backup implementation, auxiliary snapshot, schema, CI prerequisite and temporary diagnostic changes are removed. Previous stage #190870 is landed; #190873–#190875 remain separate. No stack branch was merged into another.

Evidence

  • Current lease and warm-source suites: 50 passed, one skipped, 55.72 seconds under a 180-second timeout. New real Gateway-lock regression reproduces the PG restore identity error on parent32cbe6, then passes with the fix; a retained live original is replaced by dead-owner state and maintenance preserves the replacement bytes.
  • All 16 affected state-migrations files passed 370 tests on this head in 276.78 seconds under a 420-second timeout. The original seven include shared-auth/caller-mode/retained-agent and runtime-pin migration, including SIGKILL recovery; nine direct owner consumers cover audit logs, APNs, device identity, exec approvals, lock, MCP OAuth, meeting transcripts, node host and Web Push.
  • Full canonical independent Codex P0–P2 review was scoped-clean for the complete process patch. Fresh review of the physical-identity delta and complete determining owners is also scoped-clean. Test allocation is 193 net LF (175 plus 18 for the real regression), shared scalar unchanged. Scoped format/oxlint and diff check pass.
  • Prior unchanged process/PID/restart and daemon/CLI consumer evidence is retained; broad current-head proof belongs to CI.

Parent32cbe6 CI41472933181 proved both real Bun restart cases (972ms/625ms), all three serialized lifecycle cases and the complete 166-test CLI group. Its sole product failure was PG backup restore at lease admission: a new physical file was compared with the retained old inode. Recent main41465453264/job125345759351 passed that exact restore case, so no flake exception or failed-job rerun is used. This candidate fixes the lease owner and its regression; restore implementation is unchanged. New exact-head CI must be fully green before landing.

Local full update integration was stopped when canonical preflight unexpectedly started a prohibited runtime build; no local pass claimed. That consumer stays in PR CI under production-host restrictions. Native-platform/latest-stable upgrade qualification remains unrun. Immediate-slot Testbox requests queued and were stopped; no running production Gateway or operator state is used.

Current exact-head CI: 223e606ca3a7b.

roboclaw-bot and others added 17 commits November 2, 2026 01:53
Add Doctor snapshot cancellation and capacity regressions for CI baseline proof before completing the async owner cutover.

Co-authored-by: Christian Rodrigues de Oliveira <[email protected]>

Co-authored-by: steipete <[email protected]>
Await snapshot preparation and cleanup across Doctor inspection and repair planning, preserve original-path admission, and reject snapshots that exceed measured cache capacity. Retain synchronous public and transaction authority contracts.

Co-authored-by: Christian Rodrigues de Oliveira <[email protected]>

Co-authored-by: steipete <[email protected]>
Bind task-worker cancellation to snapshot custody, retain the updater identity export, and repair async consumer fixtures and wrapper source closure. Keep the lease SQL kernel at its existing lifecycle owner.

Co-authored-by: Christian Rodrigues de Oliveira <[email protected]>
Co-authored-by: steipete <[email protected]>
Preserve per-run cancellation semantics in worker handler fixtures after adding the task-owned abort signal.

Co-authored-by: Christian Rodrigues de Oliveira <[email protected]>
Co-authored-by: steipete <[email protected]>
…ries

Keep inaccessible state roots in the diagnostic result, and update source-isolation, lease-poll, and PostgreSQL transport fixtures to observe the actual async owners. Complete task control fixture migration.

Co-authored-by: Christian Rodrigues de Oliveira <[email protected]>
Co-authored-by: steipete <[email protected]>
Integrate tested main 1347e90 to resolve the named numeric-parser CI contract mismatch from #189993. Preserve specific ExpectedCliError diagnostics and refused dispatch in capability fixtures. Correct the generated IPC preload newline found by review; its cooked script passes node --check.

Co-authored-by: Christian Rodrigues de Oliveira <[email protected]>
Co-authored-by: steipete <[email protected]>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Apply the repository formatter to the two exact files reported by main-tier CI.

Co-authored-by: Christian Rodrigues de Oliveira <[email protected]>
Co-authored-by: steipete <[email protected]>
Await session and legacy-auth images, private engine reads, and fresh recovery inventories through the existing cancellable snapshot owner. Preserve writer and SDK contracts and reassert effect authority after awaited reads.

Co-authored-by: Christian Rodrigues de Oliveira <[email protected]>
Co-authored-by: steipete <[email protected]>
Co-authored-by: Christian Rodrigues de Oliveira <[email protected]>
Co-authored-by: steipete <[email protected]>
Use the gateway retention role explicitly in idle coverage, await the authoritative target and presented route pane, and retain failed restart diagnostics without relaxing its assertions.

Co-authored-by: Christian Rodrigues de Oliveira <[email protected]>
Co-authored-by: steipete <[email protected]>
@clawsweeper

clawsweeper Bot commented Nov 2, 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.

@openclaw-barnacle openclaw-barnacle Bot added gateway Gateway runtime cli CLI command changes size: L labels Nov 2, 2026
@roboclaw-bot
roboclaw-bot marked this pull request as ready for review November 2, 2026 04:37
@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Nov 2, 2026
Integrate main to resolve CLI fixture and canonical locale conflicts. Retain
the Cron backup manifest owner and await the existing asynchronous schema gate.

Wait for hook notice enqueue, browser provider entry, and identity authorization
completion before checking their results; retain assertions and test budgets.
Add bounded failure diagnostics for early child termination.

Co-authored-by: Christian Rodrigues de Oliveira <[email protected]>
Co-authored-by: steipete <[email protected]>
@clawsweeper

clawsweeper Bot commented Nov 2, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge.

What this changes

This PR makes Gateway process, owner-lease, and restart preparation await existing asynchronous readers.

Example: Doctor inspects Gateway ownership for port 18789 while preparing a SQLite snapshot.

  • Before: Synchronous snapshot preparation can block JavaScript signal handling.
  • After: Converted readers await preparation and propagate cancellation while retaining process identity checks.

Review scores

Measure Result What it means
Overall readiness 🧂 unranked krab (1/6) The implementation is coherent, but the changed authority path lacks required behavior evidence and current-head validation remains unresolved.
Proof confidence 🧂 unranked krab (1/6) Real behavior proof is necessary before merge. See Before merge.
Patch quality 🦐 gold shrimp (3/6) Security review found an item that needs attention.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Partial
User problem: Doctor can appear stuck while synchronous database inspection prevents cancellation handlers from running.
Reason: Reporter evidence supports the repair, maintainer authorship establishes direction, and the PR explicitly scopes itself as one dependent caller stage.

Merge readiness

⛔ Blocked before merge - 4 items remain

Keep open: this maintainer-authored PR contributes useful staged work for documented Doctor stalls; no definite introduced correctness bug was established.

Priority: P1
Reviewed head: 54d6a40232e344d718f3bef5f8a86bfdc21de087

Before merge

  • Add real behavior proof - Authority-chain proof required: the body and comments provide no execution of this stage's changed shutdown paths. Show the real dispatch and native termination owners allowing the captured Gateway while rejecting another task, a recycled PID, and ownership reassigned during delayed preparation before I/O; also show Doctor cancellation settling its snapshot child and temporary output. Redact credentials, IPs, and non-public endpoints. After adding proof, update the PR body, then request a new review with @clawsweeper re-review. The PR author or someone with repository write access can request it.
  • Resolve security review attention item - No concrete bypass was established, but asynchronous shutdown authority needs final-effect rejection evidence.
  • Resolve merge risk - The PR owner must establish that ownership reassignment during asynchronous preparation cannot authorize stopping a replacement Gateway or another service.
  • Resolve merge risk - The stack owner must attribute the current-head validation failures before landing; available annotations do not establish which behavioral failures this stage introduced.

Findings

None.

Tests

  • Missing end-to-end proof: Supply production-path Doctor cancellation and shutdown evidence, including replacement-owner refusal, fresh-state and latest-stable upgrade behavior; this stage's red-before/green-after regression execution is also unshown.
Agent review details

How this fits together

Doctor and Gateway lifecycle commands consume persisted ownership and native process observations to produce inspection results, restart intents, and guarded process-control effects.

flowchart TD
Commands[Doctor and lifecycle commands] --> Inspection[Async ownership inspection]
Inspection --> Worker[Existing state read worker]
Worker --> Lease[Gateway owner lease]
Inspection --> Guards[Current authority and PID checks]
Guards --> Effects[Gateway RPC and native process control]
Loading

Technical review

Best possible solution:

Complete this staged cutover through existing read owners while preserving the shared cleanup policy and current authority checks before effects.

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

Main contains synchronous lease-inspection paths and reporters captured a synchronous snapshot stall, but this stage's service-specific trigger was not reproduced during this read-only review.

Is this the best way to solve the issue?

Awaiting the existing read owners and sharing cleanup decisions between synchronous and asynchronous drivers is a coherent focused repair.

AGENTS.md: found and applied where relevant.

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

Merge-risk options

Maintainer options:

  1. Validate the existing authority boundary (recommended)
    The PR owner should demonstrate authorized shutdown and rejection of replacement or reassigned owners through the production dispatch and termination paths.
  2. Hold the dependent stage
    Keep this PR pending while its predecessor stages and unresolved validation failures are settled.

Provenance checked

  • Gateway owner discovery and stale-process cleanup keeps the original intent (5469328: Preserve live and slow-starting Gateways and restrict termination to verified ownership.)
  • macOS update shutdown and restart intent keeps the original intent (e0dc76b: Authenticate managed-update restart intent before shutting down the LaunchAgent.)
  • Stalled startup recovery keeps the original intent (f84a3aa: Recover an overdue unpublished startup holder while refusing changed ownership and recycled PIDs.)
  • Scheduled Task runtime ownership placement keeps the original intent (b34c196: Separate runtime reporting and process ownership behind the existing Scheduled Task facade.)
  • Foreground Gateway recovery keeps the original intent (d382ba7: Hand verified foreground ownership back to systemd after checking restart permission, caller authority, and process identity.)

Testing

Proof path: none.

Security

Needs attention: No concrete bypass was established, but asynchronous shutdown authority needs final-effect rejection evidence.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit 5469328 adds src/infra/gateway-owner-lease.ts:133 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 5469328b6c31; files: src/infra/gateway-owner-lease.ts)
  • Jason (Json): Raw commit e0dc76b adds src/daemon/launchd-stop.ts:239 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: e0dc76b38b0f; files: src/daemon/launchd-stop.ts)
  • RoboClaw: Raw commit d382ba7 adds src/daemon/service-foreground-recovery.ts:18 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: d382ba71fd34; files: src/daemon/service-foreground-recovery.ts)

PR surface

Source +279, Tests +132, Other +1. Total +412 across 34 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 15 476 197 +279
Tests 18 153 21 +132
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 1 1 0 +1
Total 34 630 218 +412

Labels

Label changes:

  • add P1: The linked reports document prolonged Doctor stalls and unavailable cancellation during operational recovery.
  • add merge-risk: 🚨 security-boundary: Owner checks that govern Gateway shutdown now cross asynchronous preparation boundaries; final-effect rejection of reassigned ownership has not been demonstrated.
  • add rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🦐 gold shrimp.
  • add status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Label justifications:

  • P1: The linked reports document prolonged Doctor stalls and unavailable cancellation during operational recovery.
  • merge-risk: 🚨 security-boundary: Owner checks that govern Gateway shutdown now cross asynchronous preparation boundaries; final-effect rejection of reassigned ownership has not been demonstrated.
  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🦐 gold shrimp.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Add final-effect proof that another task and a reassigned owner are rejected before Gateway RPC or native termination.
  • Resolve attributed current-head failures together with the preceding stack stages.

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.

Reviewed November 1, 2026, 11:56 PM ET / November 2, 2026, 04:56 UTC.

roboclaw-bot and others added 3 commits November 2, 2026 05:06
Integrate the reviewed core conflict repair and retain canonical backup and
live-destination guards. Update consumer fixtures to observe asynchronous
producers and persisted shared-auth outcomes, with current source formatting.

Co-authored-by: Christian Rodrigues de Oliveira <[email protected]>
Co-authored-by: steipete <[email protected]>
Keep the existing close and no-backfill checks using logger creation metadata
instead of independently buffered file offsets. Millisecond ties remain
explicitly ambiguous; native lease lifetime assertions retain their own proof.
Add bounded diagnostics for the unresolved config admission refusal and mark
the existing platform partial mocks at their owning isolation boundaries.

Co-authored-by: Christian Rodrigues de Oliveira <[email protected]>
Co-authored-by: steipete <[email protected]>
… errors

Prepare quarantine in the existing inspection scope before native admission. Retain failed preparation outcomes to preserve optional-index tolerance without synchronous retries, and keep disposal failures visible on cancellation. Retire the unused synchronous shared-auth inspection export and calibrate the actual async copy owner.

Co-authored-by: Christian Rodrigues de Oliveira <[email protected]>

Co-authored-by: steipete <[email protected]>
@github-actions

github-actions Bot commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

Security-sensitive guard cleared

Current revision: 223e606ca3a7b65696706f7830e61f968a095bc6

This PR no longer changes files in the maintainer security-review tier.

Separate CODEOWNERS requirements still apply to security policy and enforcement files.

roboclaw-bot and others added 2 commits November 2, 2026 13:46
…ss-reads

# Conflicts:
#	config/test-lines-allocations/doctor-awaited-readers.txt
#	src/cli/update-cli/cleanup-unmanifested.test.ts
#	src/cli/update-cli/cleanup.ts
#	src/commands/doctor-session-sqlite-retirement.ts
Keep this split limited to process and restart lease inspection and direct consumer tests. Remove inherited backup, auxiliary snapshot, CI prerequisite and temporary diagnostic changes already owned elsewhere.

Co-authored-by: steipete <[email protected]>
@openclaw-barnacle openclaw-barnacle Bot added size: L and removed app: web-ui App: web-ui scripts Repository scripts commands Command implementations agents Agent runtime and tooling extensions: qa-lab size: XL labels Nov 2, 2026
roboclaw-bot and others added 5 commits November 2, 2026 14:06
…ss-reads

# Conflicts:
#	src/infra/gateway-owner-lease.ts
Record closed phase names in the existing restart regression to locate the Bun CI stall after config capture. Temporary diagnostic output, not a product fix.

Co-authored-by: steipete <[email protected]>
Select the existing awaited snapshot and transport for Promise-only lease inspection. Remove temporary native restart diagnostics after locating the stall inside the real CLI.

Co-authored-by: steipete <[email protected]>
Use the existing same-file independent read path for committed Gateway lease observations. Preserve native transaction refusal and original-source fallback after path replacement.

Co-authored-by: steipete <[email protected]>
A legitimate state-file replacement can retain the previous logical read admission. Capture the current physical file under maintenance custody for awaited lease inspection, preserving identity and authority checks.

Co-authored-by: steipete <[email protected]>
@roboclaw-bot
roboclaw-bot merged commit 72f92ef into main Nov 2, 2026
168 checks passed
@roboclaw-bot
roboclaw-bot deleted the roboclaw/doctor-process-reads branch November 2, 2026 16:39
@roboclaw-bot

Copy link
Copy Markdown
Collaborator Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 3, 2026
Await Doctor process and restart lease observations through the existing awaited cold-snapshot and committed warm-source readers. Preserve native-transaction refusal, original-source identity fallback, synchronous native supervisor callbacks, and current caller/PID checks before effects. Bind maintenance snapshots to the current physical file under custody when retained admission follows an earlier inode.

Keep the split scoped to process/restart inspection, its direct consumers and tests. Remove inherited integration work and temporary diagnostics; test allocation is 193 net LF.

Related: openclaw#178359, openclaw#187900. Not yet released.

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

Labels

clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. cli CLI command changes gateway Gateway runtime size: L

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant