Repository navigation
fix(doctor): honor config write refusals before gateway repair - #147120
Conversation
Keep include-expanded authored snapshots internal across valid, invalid, and cached config reads. Cover read-scoped root/include responses while preserving the paired internal trees. Defer alias migration helpers and their direct resolved-source API tests to the first consumer layer; preserve existing env-reference entrypoint coverage here.
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
@fuller-stack-dev Qualification update for signed head Job Actual tested merge: These are hosted real-writer tests with mocked service effects, not native Windows or standalone/published-updater proof. Those token-recovery, write-refusal, and service-failure qualification gaps remain. No tests were run locally. This prerequisite still depends on #147051 and supports the contributor repair in #138040. Production code is unchanged. Not merge-ready. No merges or automerge. |
|
Codex review: blocked before merge. Reviewed September 20, 2026, 3:08 PM ET / 19:08 UTC (Revision 10). ClawSweeper reviewWhat this changesDoctor now saves recovered Gateway tokens through its shared config writer, stops service repair when persistence is refused, and prevents retries after terminal write failures. Merge readiness⛔ Blocked before merge - 1 item remains This remains a useful fix absent from current main and the latest release. No introduced correctness or security defect was found; the updated evidence resolves the published-updater blocker. Priority: P2 Review scores
Verification
How this fits togetherDoctor checks and repairs OpenClaw configuration before repairing the managed Gateway service. Its config writer validates changes and preserves backups; updater-driven runs leave service publication to update finalization. flowchart TD
A[Doctor inspection] --> B[Recovered Gateway token]
B --> C[Shared config writer]
C --> D{Write accepted?}
D -->|No| E[Report refusal and skip repair]
D -->|Yes| F[Repair managed service]
G[Updater driven Doctor] --> H[Update finalizer owns service publication]
Before merge
Agent review detailsSecurityNone. PR surfaceSource +50, Tests +922. Total +972 across 21 files. View PR surface stats
Review metrics
Stored data modelPersistent data-model change detected: Technical reviewBest possible solution: Keep config persistence and refusal handling with Doctor’s existing writer while preserving the native service owner and updater finalization boundaries. Do we have a high-confidence way to reproduce the issue? Yes, from source: current main’s recovered-token path writes independently of Doctor’s recorded refusal and persistence baseline. This read-only review did not execute a failing current-main reproduction. Is this the best way to solve the issue? Yes. Passing the existing writer into both service-repair callers removes the competing write path and preserves established validation, backup, and service-ownership contracts. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against e9999a0b2526. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (9 earlier review cycles; latest 8 shown)
|
Merge the verified main baseline while retaining Vincent Koc's original three-commit ancestry. Keep authored capture and public stripping together; retain current-main migration and validation APIs and supplemental privacy tests. Co-authored-by: Vincent Koc <[email protected]>
Create the fixture owner root with the same private permissions as project preparation so permissive host umasks cannot invalidate transfer tests.
Move unchanged authored-reference helpers and private snapshot tests into coherent siblings so the provenance change satisfies the line-cap ratchet.
Keep the extracted wrapper source inventory complete after the config helper extraction; preserve eager-import closure and provisioning guards.
Preserve Vincent Koc's three contributor commits and the qualified Doctor writer layer. Retain updater service deferral, and repair the finalization fixture to exercise the current legacy CLI transport.
Keep all assertions and coverage while moving coherent gateway assertion helpers and the linked token/writer fixture to sibling test support.
Preserve Vincent Koc's original receipt commits and the accepted #147120 stack. Retain planning revisions across successive writes and qualify terminal and deferred cleanup assertions.
Security-sensitive guard clearedCurrent revision: This PR no longer changes files in the maintainer security-review tier. Separate CODEOWNERS requirements still apply to security policy and enforcement files. |
Preserve contributor ancestry and inherit the landed task-publication and compiler-lifetime repairs from main. Keep maintenance-time service token recovery with the canonical Doctor writer, including refusal settlement and service authority checks.
Keep real service auditing and runtime path classification while making the installation-only fixture independent of the host Node launcher. Cover denied, approved, and noninteractive consent for version-managed runtime drift.
|
Merged via squash.
|
…law#147120) * fix(config): preserve references across plugin owner migrations * fix(config): keep authored provenance out of config responses Keep include-expanded authored snapshots internal across valid, invalid, and cached config reads. Cover read-scoped root/include responses while preserving the paired internal trees. Defer alias migration helpers and their direct resolved-source API tests to the first consumer layer; preserve existing env-reference entrypoint coverage here. * test(config): invalidate cached provenance fixtures * fix(doctor): honor config write refusals before gateway repair * test(doctor): simplify gateway repair mock arguments * test(doctor): cover update metadata and include refusal * test(models): keep native auth refresh fixture passive * test(node): keep prepared workspace fixture owner private Create the fixture owner root with the same private permissions as project preparation so permissive host umasks cannot invalidate transfer tests. * refactor(config): split authored env-reference accounting Move unchanged authored-reference helpers and private snapshot tests into coherent siblings so the provenance change satisfies the line-cap ratchet. * fix(tooling): include authored env helper in PR wrapper archive Keep the extracted wrapper source inventory complete after the config helper extraction; preserve eager-import closure and provisioning guards. * test(doctor): extract gateway writer fixtures for line caps Keep all assertions and coverage while moving coherent gateway assertion helpers and the linked token/writer fixture to sibling test support. * test(doctor): isolate installation consent runtime fixture Keep real service auditing and runtime path classification while making the installation-only fixture independent of the host Node launcher. Cover denied, approved, and noninteractive consent for version-managed runtime drift. --------- Co-authored-by: Jason (Json) <[email protected]> Co-authored-by: Vincent Koc <[email protected]>
* fix: explain update refusals when an agent database is in use * test: require safe typed lease refusals in Doctor flows * fix: classify external agent leases before maintenance locks * refactor: isolate Doctor agent-lease admission * test(doctor): isolate installation consent runtime fixture Apply the consent-only correction published in #147120 at 3f967cf, adapted to the exact current-main fixture. Preserve real runtime-path auditing and cover denied, approved, and noninteractive version-managed runtime consent. Production and package inputs are unchanged. * test: wait for elicitation prompt delivery before inspecting it
…aw#152976) * fix: explain update refusals when an agent database is in use * test: require safe typed lease refusals in Doctor flows * fix: classify external agent leases before maintenance locks * refactor: isolate Doctor agent-lease admission * test(doctor): isolate installation consent runtime fixture Apply the consent-only correction published in openclaw#147120 at 3f967cf, adapted to the exact current-main fixture. Preserve real runtime-path auditing and cover denied, approved, and noninteractive version-managed runtime consent. Production and package inputs are unchanged. * test: wait for elicitation prompt delivery before inspecting it
Related: #136025, #145252. Predecessor #147051 is merged.
What Problem This Solves
Gateway-token service repair can bypass Doctor's config writer, ignoring a prior write refusal and leaving its saved candidate behind the configuration on disk.
User Impact
Standalone Doctor persists the gateway token through its validated writer before service changes. A refused write prevents the service change; a later service failure preserves the committed token. Updater-driven Doctor continues to defer service publication to the backup-owning update finalizer. No defaults, migrations, or operator actions change.
Why This Change Was Made
Use the existing Doctor writer at the awaited pre-service boundary instead of a second direct config replacement. Propagate the persisted candidate, honor ordinary refusals, and preserve terminal post-commit failures before later contributions can replay a write.
This preserves Vincent Koc's original three commits and aligns only this caller layer onto current main while preserving the merged #147051 predecessor. Current-main maintenance-time service repair uses the same canonical writer; no separate config replacement is introduced. It supports aniruddhaadak80's #138040; the dependent alias/provenance layers remain separate. Neither linked issue is closed by this prerequisite.
Evidence
Exact signed head:
3f967cf3f59d1acde7aad89ec9cefd8ab0fdf0d1; tree3fd3bd616a6e24c87dbdd9036baee27e6de60705. Contributor ancestry and the merged predecessor remain preserved.Existing writer-order, service-authority/sibling, Doctor-entrypoint and updater-barrier verification remains credited to its recorded source. The host-dependent consent fixture was corrected without changing production consent behavior: all 42 installation tests and type/lint/format/line-cap checks pass; independent API-only review is clean at P0–P2.
Exact-head CI and native hosted gates passed: https://github.com/openclaw/openclaw/actions/runs/35516367285. No parent-head CI reuse.
S1 passed on the installed exact-head package: plain default-identity interactive Doctor in a real PTY declined earlier token generation and approved service repair. Native syscall evidence shows one config commit and one writer-owned backup before systemd unit publication; no final-contribution rewrite; authenticated RPC passed.
S2 passed: an actual kernel
EACCESat the canonical writer callback prevented service repair. Root-config inode/content, backup state, unit bytes, and service PID/invocation remained unchanged; permissions were restored and authenticated RPC passed.S3 passed: a real
systemctl enablefailure occurred after the token commit. The committed config and single backup survived final contributions, native recovery restored the original unit, and the original running service passed authenticated RPC.U1 passed on the same installed exact-head package: unmodified published
2026.9.4drove normal parent-owned cutover in a real enabled systemd-user service. Run9f51782f-fbe8-47f3-9b3b-1bb0d7dc8340exited 0. Actual final candidate Doctor exited 0 with anokreceipt under the published external/no-activation child policy; exact-source control flow binds the maintenance-active service fence. Doctor left the unit unchanged. The candidate finalizer ran afterward, preserved the custom unit with an explicitSERVICE_DEFINITION_UNKNOWNwarning, activated it, and verified exact build2026.9.5-3f967cf3f59d-2026-09-20T17-39-12.741Z. Final authenticated RPC passed. The writer-owned config backup matches the original; no native definition-rewrite claim is made for this custom-unit cell.Compatibility diagnosis and retained failures
The earlier
--no-restartattempts remain failed, not retroactively passed. An unmodified shipped-9.4 maintenance-entry control reproduced the same lifecycle-coordinator refusal against its own live Gateway, preserving config, backups, unit and process identity. The policy builder is identical in shipped 9.4, this candidate and current main; current-main and candidate maintenance-entry blocks are identical. This was pre-existing live-writer exclusion before this PR's writer, not a demonstrated candidate regression. No lock bypass, driver patch, timeout increase or source correction was introduced. Independent API-direct diagnosis review is clean at P0–P2.A separate first normal-cutover attempt exposed a fixture defect: its manually started unit was disabled, and the shipped parent's stopped-unit
GetUnitinspection failed. The original package/config/unit were verified and its service explicitly recovered. Enabling the same unit made the stoppedGetUnitcontrol pass; the subsequent U1 above passed with the unchanged driver/package and normal final validated cutover. The failed attempt and its observer preflight omission are retained separately. The original tracing-induced scan timeout, maintenance refusal, rollback and RPC evidence are also preserved.These are narrow Linux/native caller-boundary proofs, not a whole survivor campaign, proof that
--no-restartpermits live mutable maintenance, or new native Windows/launchd installer coverage. S1–S3 and source/CI evidence remain unchanged. Related issues and downstream PRs remain separate.