Skip to content

fix(doctor): reject incomplete exec approvals migration - #135454

Merged
steipete merged 1 commit into
mainfrom
codex/fix-doctor-required-migrations-20260901
Sep 1, 2026
Merged

steipete merged 1 commit into
mainfrom
codex/fix-doctor-required-migrations-20260901

Conversation

@steipete

@steipete steipete commented Sep 1, 2026 •

Copy link
Copy Markdown
Contributor

Closes #135437

What Problem This Solves

Fixes an issue where operators running openclaw doctor --fix would see Doctor complete. and a successful exit even though malformed or conflicting legacy exec approvals still blocked runtime access. A Gateway stopped for repair could also be restarted before that required migration was complete.

Why This Change Was Made

Doctor now applies the existing canonical approvals readiness assertion after all migration contributions and before completing managed maintenance. This uses the same source and interrupted-claim checks as runtime access, preserves the original legacy bytes and existing policy, and lets unrelated advisory warnings remain advisory.

The production change is three net lines inside the existing completion owner. The regression extends the existing managed repair scenarios; its unchanged mock setup moves to a test-support module to keep the test file within the existing lint limit. No schema, config, or approval policy changes are introduced.

User Impact

An incomplete explicit repair now exits nonzero and leaves the Gateway stopped when Doctor stopped it for that repair. The existing diagnostic identifies the preserved legacy state; repair that file and rerun Doctor with the same state directory. Valid migrations still complete, retain their imported policy, and allow the normal restart. The Doctor reference documents this behavior.

Evidence

The regression was run against the unchanged base first: malformed and conflicting approvals produced the two expected failures, while valid migration passed. After the change, all 126 tests across the Doctor flow, approvals migrator, and approvals store passed, including managed service ownership, release after failure, optional advisories, interrupted claims, and successful restart behavior.

Actual public CLI runs used the normal built entry point with isolated synthetic homes and no test-mode or no-respawn flags:

Legacy approvals Before: Doctor / approvals readback After: Doctor / approvals readback
Malformed exit 0 with completion / exit 1 exit 1 without completion / exit 1
Conflicts with canonical policy exit 0 with completion / exit 1 exit 1 without completion / exit 1
Valid exit 0 with completion / exit 0 exit 0 with completion / exit 0

The blocked cases retained byte-identical legacy files and unchanged canonical policy. The valid case removed its migrated source and returned the expected policy through approvals get --json. All fourteen baseline/candidate CLI commands exited naturally; the harness observed the detached CLI children and verified no owned process groups remained.

A separate proof used actual Linux user systemd with normal account home directories, isolated profiles, and token-authenticated Gateways. Before the change, malformed approvals still produced exit 0/completion and restarted the stopped service. After the change, Doctor returned 1 without completion and left the service inactive, with the original invocation timestamp unchanged, no service process or listener, and preserved source bytes, canonical policy, and unit definition. Valid controls on both revisions restarted healthily and removed a legacy source identical to the canonical policy. These controls prove native cleanup/restart; the separate public CLI fixture above proves cold policy import. All four temporary profiles, units, control groups, listeners, and CLI process groups were cleaned up.

The full baseline build and candidate sourcePerformance runtime build passed. The canonical four-file changed gate passed, including production/test types, lint, dead-export scans, and static guards; the changed MDX document also passed. An isolated P1 Codex review found no actionable issues. The local CLI proof used external service policy; native service behavior was verified separately as described above. No channel delivery or model turn is claimed.

Exact-head CI passed at 00768a3743453eefe969ec59903249539f333fb8.

Check canonical approvals readiness after migration contributions and before
managed maintenance can restart the Gateway. Preserve legacy bytes and
existing policy while reporting incomplete repair as an error.

Fixes #135437.
@clawsweeper

clawsweeper Bot commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation size: M maintainer Maintainer-authored PR labels Sep 1, 2026
@steipete
steipete marked this pull request as ready for review September 1, 2026 18:47
@clawsweeper clawsweeper Bot added P1 High-priority user-facing bug, regression, or broken workflow. merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. 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 1, 2026
@clawsweeper

clawsweeper Bot commented Sep 1, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 1, 2026, 3:05 PM ET / 19:05 UTC.

ClawSweeper review

What this changes

The branch makes explicit Doctor repair fail before managed maintenance completes when legacy exec approvals remain malformed, conflicting, or mid-import.

Regression provenance

Possible regression — probable (reproduction; reviewed change). No predecessor PR is attributed.

Merge readiness

⚠️ Ready for maintainer review - 3 items remain

No blocking correctness finding: this is a focused root-boundary repair with strong supplied before/after CLI and managed-service evidence. It remains open because it is an active maintainer-associated PR and intentionally changes explicit repair to fail closed for unresolved approval migration.

Priority: P1
Reviewed head: 00768a3743453eefe969ec59903249539f333fb8
Owner decision: Required. See Decision needed.

Review scores

Measure Result What it means
Overall readiness 🦞 diamond lobster (5/6) A compact owner-boundary fix with matching regression coverage and unusually detailed supplied real CLI and managed-service evidence.
Proof confidence 🦞 diamond lobster (5/6) Not applicable: This maintainer-associated PR is exempt from the external-contributor proof gate; its body nevertheless supplies detailed before/after built-CLI and user-systemd traces tied to the changed Doctor completion boundary.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: This maintainer-associated PR is exempt from the external-contributor proof gate; its body nevertheless supplies detailed before/after built-CLI and user-systemd traces tied to the changed Doctor completion boundary.
Evidence reviewed 7 items Current-main gap: Current main proceeds from workspace readiness to managed maintenance completion without checking pending legacy exec approvals, so a retained malformed or conflicting source can still produce a successful Doctor result.
Proposed owner-boundary repair: The PR invokes the existing approvals readiness assertion after all contributions and before maintenance finish, preventing completion and restart when the runtime would remain blocked.
Runtime invariant: Exec-approval reads already reject pending legacy source or an interrupted import claim before opening the canonical approvals row; Doctor should not report readiness while that invariant fails.
Findings None None.
Security None None.

How this fits together

Doctor coordinates persistent-state migrations and managed Gateway maintenance. Legacy exec-approval JSON is migrated into the canonical SQLite store, and the readiness result determines whether Doctor may finish and restart a Gateway.

flowchart LR
  A[Legacy approvals file] --> B[Doctor migration contributions]
  B --> C[Approval readiness gate]
  C -->|ready| D[Managed maintenance finish]
  C -->|blocked| E[Nonzero repair result]
  D --> F[Gateway restart or completion]
Loading

Decision needed

Question Recommendation
Should maintainers accept the documented fail-closed upgrade behavior for explicit Doctor repair when legacy approvals remain unresolved? Accept the fail-closed repair behavior: Merge the focused fix so incomplete approvals migration cannot be reported as successful repair or restart a stopped Gateway.

Why: The code correctly aligns Doctor completion with the established runtime gate, but it intentionally changes managed-Gateway availability for affected legacy installations.

Before merge

  • Resolve merge risk (P1) - Existing automation that treated successful explicit Doctor repair as a restart signal will now receive a nonzero result and leave the Gateway stopped until the preserved legacy approvals state is repaired; this is the intended corrective upgrade behavior.
  • Complete next step (P2) - This active maintainer-associated PR has no concrete mechanical blocker for an automated repair lane.
Agent review details

Security

None.

PR surface

Source +3, Tests +78, Docs 0. Total +81 across 4 files.

View PR surface stats
Area Files Added Removed Net
Source 1 4 1 +3
Tests 2 206 128 +78
Docs 1 1 1 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 4 211 130 +81

Review metrics

Metric Value Why it matters
Production versus test delta production +3, test support +133, tests -55, docs 0 The runtime change is confined to the existing completion owner; the remaining diff reorganizes mocks and extends migration-boundary coverage.

Stored data model

Persistent data-model change detected: migration/backfill/repair: src/flows/doctor-health.ts. Confirm migration or upgrade compatibility proof before merge.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #135437
Summary: This PR explicitly implements the linked Doctor false-success repair.

Members:

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

Merge-risk options

Maintainer options:

  1. Accept the corrective fail-closed behavior (recommended)
    Land the documented change so repair scripts cannot mistake blocked approval state for a successful Gateway restart.
  2. Pause for an alternate upgrade policy
    Do not merge if maintainers require legacy repair automation to retain a success-compatible path, because that would need an explicitly designed policy.

Technical review

Best possible solution:

Merge the final existing readiness assertion with the documented recovery path, so Doctor success and managed restart accurately mean approval state is usable.

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

Yes: current main lacks the final approvals assertion, the linked issue supplies malformed and conflicting source states, and the PR includes matching before/after real CLI observations.

Is this the best way to solve the issue?

Yes: using the already-authoritative readiness assertion at the final Doctor completion boundary is the narrowest maintainable repair; changing the migration owner or adding a restart-specific workaround would duplicate policy.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • add merge-risk: 🚨 compatibility: Affected legacy-state automation changes from exit 0 to a documented nonzero recovery result.
  • add rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • remove rating: 🐚 platinum hermit: Current PR rating is rating: 🦞 diamond lobster, so this older rating label is no longer current.

Label justifications:

  • P1: Explicit repair can currently claim success while approvals remain unusable and may restart a managed Gateway prematurely.
  • merge-risk: 🚨 compatibility: Affected legacy-state automation changes from exit 0 to a documented nonzero recovery result.
  • merge-risk: 🚨 availability: A managed Gateway remains stopped until its retained approval migration blocker is resolved.
  • 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. Not applicable: This maintainer-associated PR is exempt from the external-contributor proof gate; its body nevertheless supplies detailed before/after built-CLI and user-systemd traces tied to the changed Doctor completion boundary.

Evidence

What I checked:

  • Current-main gap: Current main proceeds from workspace readiness to managed maintenance completion without checking pending legacy exec approvals, so a retained malformed or conflicting source can still produce a successful Doctor result. (src/flows/doctor-health.ts:160, f7e62978f463)
  • Proposed owner-boundary repair: The PR invokes the existing approvals readiness assertion after all contributions and before maintenance finish, preventing completion and restart when the runtime would remain blocked. (src/flows/doctor-health.ts:163, 00768a374345)
  • Runtime invariant: Exec-approval reads already reject pending legacy source or an interrupted import claim before opening the canonical approvals row; Doctor should not report readiness while that invariant fails. (src/infra/exec-approvals-store.ts:79, 00768a374345)
  • Migration owner preserves unresolved state: The migration deliberately retains malformed or conflicting legacy source and reports warnings, so the final gate is needed rather than a downstream restart workaround. (src/infra/state-migrations.exec-approvals.ts:147, 00768a374345)
  • Regression coverage: The expanded managed-repair table covers malformed, conflicting, and successful approval migrations; blocked cases assert the migration error, retained bytes, unchanged canonical policy, and released coordinator. (src/flows/doctor-health.test.ts:330, 00768a374345)
  • Feature history: History identifies prior approval-gate work in commit 768e1f9 and a recent gate refactor in c50533f; neither is attributed as the regression source. (src/infra/exec-approvals-migration-gate.ts:34, c50533f9d944)

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • vincentkoc: 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-01T18:54:38.679Z sha 00768a3 :: needs maintainer review before merge. :: none

@clawsweeper clawsweeper Bot added merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. and removed rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. labels Sep 1, 2026
@steipete
steipete merged commit aaa7dd3 into main Sep 1, 2026
351 checks passed
@steipete
steipete deleted the codex/fix-doctor-required-migrations-20260901 branch September 1, 2026 19:23
@steipete

steipete commented Sep 1, 2026

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 2, 2026
)

Check canonical approvals readiness after migration contributions and before
managed maintenance can restart the Gateway. Preserve legacy bytes and
existing policy while reporting incomplete repair as an error.

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

Labels

docs Improvements or additions to documentation maintainer Maintainer-authored PR merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P1 High-priority user-facing bug, regression, or broken workflow. rating: 🦞 diamond lobster Very strong PR readiness with only minor 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.

[Bug]: Doctor reports success while legacy exec approvals still block runtime

1 participant