Skip to content

fix(doctor): allow legacy exec approvals migration - #133773

Merged
obviyus merged 4 commits into
openclaw:mainfrom
dailytrap:fix/doctor-legacy-exec-approvals
Aug 31, 2026
Merged

obviyus merged 4 commits into
openclaw:mainfrom
dailytrap:fix/doctor-legacy-exec-approvals

Conversation

@dailytrap

@dailytrap dailytrap commented Aug 31, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Updating from 2026.7.1-2 to 2026.8.1 can leave the Gateway unavailable when the old release wrote exec-approvals.json.

openclaw doctor --fix reached gated exec-approval reads and cleanup before the Doctor-owned JSON-to-SQLite import could finish. The command exited with an instruction to run itself and repeated the same failure after restart.

Root Cause

  • 2026.8.1 added a fail-closed gate around the canonical SQLite approval store.
  • Doctor security diagnostics and generated-rule cleanup called that gate before the later legacy-state owner imported the retired JSON.
  • Moving cleanup after import initially coupled it to the aggregate legacy-state prompt, so declining an unrelated migration also skipped approval cleanup.

Fix

  • Load approval state once for Doctor security diagnostics and skip only approval-dependent checks while the migration gate is pending.
  • Run generated approval cleanup in the legacy-state contribution after its import owner has run.
  • Let a declined unrelated migration skip that migration only; Doctor-only approval cleanup remains reachable.
  • Preserve the gate for every normal runtime reader and writer.

Evidence

Exact-head redacted terminal proof: #133773 (comment)

  1. Published [email protected] approvals allowlist add /usr/bin/rg created the retired version-1 JSON in an isolated state directory.
  2. Published [email protected] doctor --fix --non-interactive --no-workspace-suggestions exited 1 with Legacy exec approvals exist ... Run openclaw doctor --fix.
  3. A second process run exited 1 with the same message.
  4. The candidate source command exited 0, printed Imported legacy exec approvals into shared SQLite state. and Doctor complete., recorded a completed migration receipt, and removed the retired source.

Validation

  • Full affected Doctor suites: 193 passed.
  • Focused published-owner, security-continuation, and interactive-decline regressions: 3 passed.
  • Oxfmt, Oxlint, and git diff --check: passed.
  • Production delta: +71/-41, net +30; this is down from the prior net +43 after consolidating duplicate proof and removing avoidable branches.
  • Local TypeScript typecheck and build were not run on this host; exact-head CI owns those gates.

@clawsweeper

clawsweeper Bot commented Aug 31, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Aug 31, 2026 •

Copy link
Copy Markdown
Contributor

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-08-31T04:06:21.576625Z e30d375 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@openclaw-barnacle openclaw-barnacle Bot added commands Command implementations size: S triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. labels Aug 31, 2026
@clawsweeper clawsweeper Bot added merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P1 High-priority user-facing bug, regression, or broken workflow. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Aug 31, 2026
@clawsweeper

clawsweeper Bot commented Aug 31, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge. Reviewed August 31, 2026, 3:53 AM ET / 07:53 UTC.

ClawSweeper review

What this changes

The PR changes Doctor’s legacy-state flow so retired exec-approval JSON is imported before approval-store reads and obsolete generated approvals are renewed afterward.

Regression provenance

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

Merge readiness

⛔ Blocked until real behavior proof is added - 3 items remain

Keep this PR open: the current head addresses the prior ordering finding and no blocking code defect was found, but exact-head real behavior proof is still missing for this persistent-state upgrade repair.

Priority: P1
Reviewed head: ce3b4a64bbaf4a17d509cd80bab94197d42c13db

Review scores

Measure Result What it means
Overall readiness 🧂 unranked krab (1/6) The repair is well-scoped with meaningful regression coverage, but an external persistent-state repair needs current-head behavior proof before merge.
Proof confidence 🧂 unranked krab (1/6) Needs real behavior proof before merge: The changed production owner is Doctor’s legacy-state contribution, and the checked-in process test models the upgrade path, but the supplied evidence has no inspectable after-fix run for ce3b4a6. Attach redacted terminal output from that head showing import, generated-rule renewal, and successful completion. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Needs proof Needs real behavior proof before merge: The changed production owner is Doctor’s legacy-state contribution, and the checked-in process test models the upgrade path, but the supplied evidence has no inspectable after-fix run for ce3b4a6. Attach redacted terminal output from that head showing import, generated-rule renewal, and successful completion. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
Evidence reviewed 6 items Current-main failure path: Current main runs generated approval cleanup before the legacy-state contribution; that cleanup reaches the gated approval store before the import owner can run.
Migration owner and order: The proposed legacy-state flow performs the Doctor-only migration before cleanup; the migration plan explicitly assigns exec approvals to migrateLegacyExecApprovals.
Boundary regression coverage: The process test exercises the CLI against legacy JSON, verifies import and cleanup output, removal of the retired source, and the resulting SQLite row; it is strong regression coverage but was not executed by this read-only review.
Findings None None.
Security None None.

How this fits together

Doctor checks and repairs an OpenClaw installation’s configuration and retired state during recovery. It imports legacy approval JSON into the canonical SQLite store, then security diagnostics and approval cleanup use that store.

flowchart LR
A[Retired approval JSON] --> B[Doctor legacy-state flow]
B --> C[SQLite approval migration]
C --> D[Approval-store reads]
D --> E[Security diagnostics]
C --> F[Generated approval cleanup]
E --> G[Doctor completion]
F --> G
Loading

Before merge

  • Add real behavior proof - Needs real behavior proof before merge: The changed production owner is Doctor’s legacy-state contribution, and the checked-in process test models the upgrade path, but the supplied evidence has no inspectable after-fix run for ce3b4a6. Attach redacted terminal output from that head showing import, generated-rule renewal, and successful completion. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
  • Resolve merge risk (P1) - This changes persistent approval-state repair ordering during upgrades; merge should wait for redacted exact-head evidence that a legacy file is imported, obsolete generated rules are removed, and Doctor completes.
  • Complete next step (P2) - The code finding from the prior cycle is resolved; the remaining merge blocker is external contributor proof that an automated repair lane cannot produce.
Agent review details

Security

None.

PR surface

Source +30, Tests +70. Total +100 across 6 files.

View PR surface stats
Area Files Added Removed Net
Source 3 71 41 +30
Tests 3 72 2 +70
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 6 143 43 +100

Review metrics

Metric Value Why it matters
Production versus test delta production +71/-41 (net +30); tests +72/-2 (net +70) The production growth relocates persistent-state cleanup into its migration owner and adds the narrow gate handling; tests cover CLI, security continuation, and declined-migration behavior.

Stored data model

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

Merge-risk options

Maintainer options:

  1. Attach exact-head upgrade proof (recommended)
    Run the released-version legacy-JSON scenario against this head and attach redacted terminal output showing import, cleanup, source removal, and successful Doctor completion.

Technical review

Best possible solution:

Keep ordinary approval access fail-closed, while Doctor’s legacy-state owner imports the retired file before performing the canonical-store cleanup and demonstrates that upgrade path on the exact head.

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

Yes, source-reproducible: current main invokes a gated cleanup before the Doctor-owned import, and the supplied released-version reports document that path. This read-only review did not execute the external PR head.

Is this the best way to solve the issue?

Yes: moving cleanup behind the one migration owner preserves the normal runtime gate and fixes the actual ordering violation; disabling the gate would be a weaker alternative.

AGENTS.md: found and applied where relevant.

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

Labels

Label justifications:

  • P1: The released upgrade deadlock can prevent Doctor recovery and leave affected Gateway installations unavailable.
  • merge-risk: 🚨 compatibility: The PR changes the ordering of migration and cleanup against existing persisted exec-approval state during upgrades.
  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🐚 platinum hermit.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs real behavior proof before merge: The changed production owner is Doctor’s legacy-state contribution, and the checked-in process test models the upgrade path, but the supplied evidence has no inspectable after-fix run for ce3b4a6. Attach redacted terminal output from that head showing import, generated-rule renewal, and successful completion. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.

Evidence

What I checked:

  • Current-main failure path: Current main runs generated approval cleanup before the legacy-state contribution; that cleanup reaches the gated approval store before the import owner can run. (src/commands/doctor/repair-sequencing.ts:115, e7bacb6e552a)
  • Migration owner and order: The proposed legacy-state flow performs the Doctor-only migration before cleanup; the migration plan explicitly assigns exec approvals to migrateLegacyExecApprovals. (src/flows/doctor-health-contributions.ts:319, ce3b4a64bbaf)
  • Boundary regression coverage: The process test exercises the CLI against legacy JSON, verifies import and cleanup output, removal of the retired source, and the resulting SQLite row; it is strong regression coverage but was not executed by this read-only review. (src/commands/doctor-config-preflight.process.test.ts:206, ce3b4a64bbaf)
  • Prior finding resolved: The current head adds coverage that cleanup remains reachable when an unrelated interactive legacy migration is declined. (src/flows/doctor-health-contributions.test.ts:2206, ce3b4a64bbaf)
  • Current-head proof gap: The supplied PR body asserts successful candidate results, but includes no inspectable current-head terminal output or artifact. A supplied comment explicitly limits its reproduction evidence to the released failure rather than the candidate head. (ce3b4a64bbaf)
  • Feature-history routing: History identifies prior exec-approval CWD scoping work and repeated Doctor-flow maintenance; the partial clone could not supply raw-parent patches for source-line introduction attribution. (src/infra/exec-approvals-generated-migration.ts:8, 1c37c8cdc71b)

Likely related people:

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

Rank-up moves

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

  • Attach redacted exact-head terminal output for the released legacy-approval upgrade path; updating the PR body should trigger review, or a maintainer can request @clawsweeper re-review if needed.

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 (3 earlier review cycles)
  • reviewed 2026-08-31T04:06:59.625Z sha e30d375f29051429dde455a30860cb3c8ea6e7e9 :: needs real behavior proof before merge. :: [P1] Move exec-approval renewal after the legacy import
  • reviewed 2026-08-31T04:56:57.243Z sha 367c3fb :: needs real behavior proof before merge. :: [P2] Keep renewal reachable when another migration is declined
  • reviewed 2026-08-31T05:04:07.513Z sha 367c3fb :: needs real behavior proof before merge. :: [P2] Keep renewal reachable after declining another migration

@dailytrap
dailytrap force-pushed the fix/doctor-legacy-exec-approvals branch from e30d375 to dbe033a Compare August 31, 2026 04:48
@openclaw-barnacle openclaw-barnacle Bot added size: M and removed size: S triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. labels Aug 31, 2026
@dailytrap
dailytrap force-pushed the fix/doctor-legacy-exec-approvals branch from dbe033a to 367c3fb Compare August 31, 2026 04:49
@dailytrap

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Aug 31, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@Ma77h3hac83r

Copy link
Copy Markdown

Confirmed this is still in shipped 2026.8.1 (ea80657) on a macOS LaunchAgent upgrade from 2026.7.1-2.

openclaw doctor --fix --non-interactive --yes threw ExecApprovalsMigrationRequiredError on the gated pre-read (repairObsoleteGeneratedExecApprovals / loadExecApprovalsReadOnly) and never reached migrateLegacyExecApprovals. Calling the official migration helper directly imported the retired JSON; doctor then completed and the Gateway came up.

Filed as #133813 (prior reports #132495 / #132768 were closed as main-only).

@PollyBot13

Copy link
Copy Markdown
Contributor

I reproduced the shipped failure behind this PR in an isolated Docker fixture using exact published packages and synthetic state only.

Reproduction

Control runs (2026.7.1 -> 2026.8.1 and 2026.6.34 -> 2026.7.1 -> 2026.8.1) both exited 0 and converged core plus Discord. The intermediate 2026.7.1 Discord install path was exactly:

openclaw-discord-c0892df945__openclaw-generation__g-3a4aecad18bbe2c4

That matches the retained generation reported in #133828.

Adding a valid legacy exec-approvals.json at the retired canonical path reproduced the failure chain:

  1. Core swapped successfully from 2026.7.1 to 2026.8.1.
  2. Fresh pre-plugin Doctor exited 1 with ExecApprovalsMigrationRequiredError before migrateLegacyExecApprovals could run.
  3. Post-core plugin convergence was skipped.
  4. The authoritative Discord install record remained on 2026.7.1 at g-3a4aecad18bbe2c4.
  5. Runtime inspection under core 2026.8.1 then failed with the exact issue error:
The requested module 'openclaw/plugin-sdk/security-runtime' does not provide an export named 'privateFileStore'

Recovery control also passed: preserve/move the legacy approvals file, complete Doctor/import, then run openclaw update repair. Discord converged to 2026.8.1 and loaded from g-fbfb6662cfdac020.

This proves the immediate Doctor deadlock is a shipped, user-visible upgrade blocker and that this PR owns the correct trigger. It also exposes a separate generic updater-containment gap after any post-swap/pre-convergence failure; that should remain outside this PR.

Important scope note: this evidence reproduces the defect and recovery path. It does not yet validate PR head 367c3fb2243160e9335e1dd51bdbf6da4c3d6245; that exact-head before/after proof is the remaining contributor gate.

@openclaw-barnacle openclaw-barnacle Bot added triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. and removed size: M labels Aug 31, 2026
@openclaw-barnacle openclaw-barnacle Bot added size: S and removed triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. labels Aug 31, 2026
@ChrisSeVa1

Copy link
Copy Markdown

Confirmed this issue on a real upgrade from OpenClaw 2026.6.11 → 2026.8.1 (ea80657).

My reproduction matches the problem described in this PR:

  • Legacy ~/.openclaw/exec-approvals.json exists and is valid version 1 JSON.
  • openclaw approvals get returns ExecApprovalsMigrationRequiredError.
  • With the Gateway running, doctor --fix correctly refuses shared-state mutation.
  • I stopped the Gateway and confirmed the systemd service was inactive (dead).
  • openclaw doctor --fix then still returned:
    Legacy exec approvals exist ... Run openclaw doctor --fix before using exec approvals.
  • A second run produced the same result.
  • openclaw approvals set --file ~/.openclaw/exec-approvals.json is blocked by the same migration gate.

OPENCLAW_STATE_DIR and OPENCLAW_HOME are unset, permissions/ownership are correct, and the legacy JSON validates successfully.

So this PR's root-cause description matches the behavior I'm seeing, particularly Doctor reaching the approval migration gate before completing its own JSON → SQLite migration.

Happy to test the fix against this affected installation once there is a build/release containing it.

@PollyBot13

PollyBot13 commented Aug 31, 2026 •

Copy link
Copy Markdown
Contributor

Exact-current-head real behavior proof

PR head: ce3b4a64bbaf4a17d509cd80bab94197d42c13db

I exercised the dist-runtime-build artifact from CI run 33369638499, whose head_sha is the PR head above. GitHub built the pull-request merge ref (3891d441438bb4e91a88ab0146dab8ab8cdba44c) from that head and base 12f2f9c35510ab2c07a3525c897c0a94e75da256.

The command ran with an empty environment (env -i), an isolated temporary HOME, state directory, and config path, bundled plugins disabled, and no production Gateway or operator state. The legacy fixture contained:

  • generated legacy rule /usr/bin/rg with source: allow-always and stale usage metadata;
  • durable manual rule =command:durable with source: allow-always.

Observed terminal result:

Imported legacy exec approvals into shared SQLite state.
Removed retired exec approvals JSON after recording its migration decision.
Exec approvals updated: removed 1 older generated approval ...
Manual allowlist rules were not changed.
Plugin registry rebuilt: 0/0 enabled plugins indexed.
Doctor complete.
EXIT_STATUS=0
LEGACY_SOURCE_EXISTS=no

Persisted-state verification after the process exited:

  • migration_runs.status = completed for legacy-exec-approvals-json;
  • migration_sources.status = completed, removed_source = 1, source_record_count = 1;
  • canonical exec_approvals_config no longer contains /usr/bin/rg;
  • canonical exec_approvals_config still contains =command:durable with source: allow-always;
  • stale lastUsedAt / lastUsedCommand fields are absent.

A second fresh fixture kept bundled plugins enabled. It repeated the import and cleanup, then reached real plugin-registry convergence:

Imported legacy exec approvals into shared SQLite state.
Removed retired exec approvals JSON after recording its migration decision.
Exec approvals updated: removed 1 older generated approval ...
Manual allowlist rules were not changed.
Plugin registry rebuilt: 58/63 enabled plugins indexed.
Doctor complete.
PLUGIN_PROOF_EXIT_STATUS=0
PLUGIN_PROOF_LEGACY_SOURCE_EXISTS=no

Its canonical row again preserved =command:durable, removed /usr/bin/rg and stale usage metadata, and recorded the legacy source as completed with removed_source = 1.

An immediate second isolated Doctor run converged cleanly:

Doctor complete.
SECOND_EXIT_STATUS=0
LEGACY_SOURCE_EXISTS_AFTER_RERUN=no

Current-head hosted proof also passes the relevant shards:

  • agentic-commands-doctor: 32 files / 376 tests passed, including the pending-legacy security continuation regression;
  • agentic-commands-doctor-config-state: 22 files / 460 tests passed, including the import → generated-rule renewal → source removal process regression;
  • build and all five core lint stripes passed;
  • trusted oxfmt 0.60.0 --check over all six changed files and git diff --check passed;
  • exact-head independent Autoreview reported scoped-clean with no P0 defects or credential findings.

This proof covers only the legacy exec-approval Doctor deadlock. It does not claim or absorb the generic post-swap updater-containment, Discord generation-selection, or privateFileStore compatibility work.

Terminal CI classification

CI run 33369638499 attempt 2 finished with 180 success, 17 skipped, and 13 failure. Twelve leaf failures are outside this PR's six changed Doctor files:

  • nine 120-second timeouts in agent/model fallback, OpenAI WebSocket, cron, auto-reply, Codex dynamic-tool, CLI-runner, and Windows worker-artifact tests;
  • three CI-checkout fixture failures because their synthetic report.json was missing during cancellation cleanup;
  • openclaw/ci-gate only aggregates those leaf failures.

Build, full check-lint, all five core lint stripes, and both decision-relevant Doctor shards are green. No author-owned CI failure remains.

The separate PR context and evidence check is stale: it ran at 07:46 UTC before the PR body gained its authored Evidence section and before this proof comment existed. PollyBot13 has repository permission read only, so it cannot edit the author's PR body, rerun upstream jobs, or issue an eligible ClawSweeper command. The exact author action is:

  1. add this proof comment link to the PR body's Evidence section;
  2. comment @clawsweeper re-review as the PR author.

@obviyus

obviyus commented Aug 31, 2026

Copy link
Copy Markdown
Collaborator

landpr-approve-unrelated-red
pr: 133773
head: ce3b4a6
breaking: 006527d
check: openclaw/ci-gate

@obviyus

obviyus commented Aug 31, 2026

Copy link
Copy Markdown
Collaborator

Exact-head release-regression proof for ce3b4a64bbaf4a17d509cd80bab94197d42c13db:

  • Created version-1 approval JSON with published [email protected] in an isolated state directory.
  • Included one obsolete generated rule and one durable =command: rule.
  • Ran the exact-head CLI source with doctor --fix --non-interactive --no-workspace-suggestions.
Failed migrating legacy exec approvals:
OpenClawStateDatabaseSchemaMigrationRequiredError: ... run openclaw doctor --fix to migrate it.

Auto-migrated legacy state:
...
Imported legacy exec approvals into shared SQLite state.
Removed retired exec approvals JSON after recording its migration decision.
Exec approvals updated: removed 1 older generated approval that were not tied to a working directory.
...
Doctor complete.

Final state:

{"exit":0,"sourceRemoved":true,"receipt":{"status":"completed","removed_source":1},"patterns":["=command:durable"]}

This proves the old schema is repaired first, the Doctor-owned import remains reachable, cleanup runs after import, the durable rule remains, and Doctor completes in one process run.

@obviyus
obviyus merged commit 122232d into openclaw:main Aug 31, 2026
451 of 487 checks passed
@obviyus

obviyus commented Aug 31, 2026

Copy link
Copy Markdown
Collaborator

Thanks @dailytrap!

Proof: State created by published [email protected] now completes exact-head Doctor repair with import, generated-rule cleanup, durable-rule preservation, source removal, and exit 0: #133773 (comment)

  • Bug: Published 2026.8.1 repeatedly stopped doctor --fix at the exec-approval migration gate before the Doctor-owned import.
  • Fix: Doctor now keeps the migration owner reachable and runs generated-rule cleanup only after import; declining an unrelated migration no longer skips cleanup.
Before After
Doctor exits 1 and asks the operator to run the same command again. Doctor imports the legacy state, removes the obsolete generated rule, preserves the durable rule, and exits 0.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 1, 2026
## What Problem This Solves

Updating from `2026.7.1-2` to `2026.8.1` can leave the Gateway unavailable when the old release wrote `exec-approvals.json`.

`openclaw doctor --fix` reached gated exec-approval reads and cleanup before the Doctor-owned JSON-to-SQLite import could finish. The command exited with an instruction to run itself and repeated the same failure after restart.

## Root Cause

- `2026.8.1` added a fail-closed gate around the canonical SQLite approval store.
- Doctor security diagnostics and generated-rule cleanup called that gate before the later legacy-state owner imported the retired JSON.
- Moving cleanup after import initially coupled it to the aggregate legacy-state prompt, so declining an unrelated migration also skipped approval cleanup.

## Fix

- Load approval state once for Doctor security diagnostics and skip only approval-dependent checks while the migration gate is pending.
- Run generated approval cleanup in the legacy-state contribution after its import owner has run.
- Let a declined unrelated migration skip that migration only; Doctor-only approval cleanup remains reachable.
- Preserve the gate for every normal runtime reader and writer.

## Evidence

Exact-head redacted terminal proof: openclaw#133773 (comment)

1. Published `[email protected] approvals allowlist add /usr/bin/rg` created the retired version-1 JSON in an isolated state directory.
2. Published `[email protected] doctor --fix --non-interactive --no-workspace-suggestions` exited `1` with `Legacy exec approvals exist ... Run openclaw doctor --fix`.
3. A second process run exited `1` with the same message.
4. The candidate source command exited `0`, printed `Imported legacy exec approvals into shared SQLite state.` and `Doctor complete.`, recorded a completed migration receipt, and removed the retired source.

## Validation

- Full affected Doctor suites: 193 passed.
- Focused published-owner, security-continuation, and interactive-decline regressions: 3 passed.
- Oxfmt, Oxlint, and `git diff --check`: passed.
- Production delta: `+71/-41`, net `+30`; this is down from the prior net `+43` after consolidating duplicate proof and removing avoidable branches.
- Local TypeScript typecheck and build were not run on this host; exact-head CI owns those gates.

Co-authored-by: Ayaan Zaidi <[email protected]>
steipete added a commit that referenced this pull request Sep 2, 2026
Fix the Doctor/update loop caused by empty legacy exec-approvals JSON and interrupted import claims. Recognize only the exact policy-free shape, archive and verify its bytes, and finish the existing receipt/cleanup flow. Preserve usable socket credentials through the canonical import when SQLite is absent; never replace existing policy with an empty stub.

Reported by Discord users uniqueason and Akarxo; Eisenh0rn40 highlighted the workaround. Follow-up to #133813 and #133773. Closes #135968.

Verified with failing pre-fix regressions, 134 passing migration/store/parser/socket tests, real valid/invalid-token UDS proof, and five isolated dist-backed Doctor/Gateway health checks. No configuration, schema, protocol, or dependency changes.
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 3, 2026
Fix the Doctor/update loop caused by empty legacy exec-approvals JSON and interrupted import claims. Recognize only the exact policy-free shape, archive and verify its bytes, and finish the existing receipt/cleanup flow. Preserve usable socket credentials through the canonical import when SQLite is absent; never replace existing policy with an empty stub.

Reported by Discord users uniqueason and Akarxo; Eisenh0rn40 highlighted the workaround. Follow-up to openclaw#133813 and openclaw#133773. Closes openclaw#135968.

Verified with failing pre-fix regressions, 134 passing migration/store/parser/socket tests, real valid/invalid-token UDS proof, and five isolated dist-backed Doctor/Gateway health checks. No configuration, schema, protocol, or dependency changes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

commands Command implementations merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P1 High-priority user-facing bug, regression, or broken workflow. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. size: S status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants