Repository navigation
fix(doctor): reject incomplete exec approvals migration - #135454
Conversation
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.
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Codex review: needs maintainer review before merge. Reviewed September 1, 2026, 3:05 PM ET / 19:05 UTC. ClawSweeper reviewWhat this changesThe branch makes explicit Doctor repair fail before managed maintenance completes when legacy exec approvals remain malformed, conflicting, or mid-import. Regression provenancePossible regression — probable (reproduction; reviewed change). No predecessor PR is attributed. Merge readinessNo 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 Review scores
Verification
How this fits togetherDoctor 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]
Decision needed
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
Agent review detailsSecurityNone. PR surfaceSource +3, Tests +78, Docs 0. Total +81 across 4 files. View PR surface stats
Review metrics
Stored data modelPersistent data-model change detected: Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Merge-risk optionsMaintainer options:
Technical reviewBest 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. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (1 earlier review cycle)
|
|
Merged via squash.
|
) 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.
Closes #135437
What Problem This Solves
Fixes an issue where operators running
openclaw doctor --fixwould seeDoctor 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:
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
sourcePerformanceruntime 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.