Skip to content

fix(doctor): distinguish ledger settlement from config changes - #193476

Merged
steipete merged 2 commits into
mainfrom
dbasync/postpass
Nov 5, 2026
Merged

steipete merged 2 commits into
mainfrom
dbasync/postpass

Conversation

@steipete

@steipete steipete commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

A post-plugin Doctor can finish a retained plugin-migration obligation without changing config. Preflight nevertheless sets configChanged whenever completion asks it to refresh the snapshot. That false fact widens a deferred-model-retirement pass into the full Doctor contribution list.

User Impact

Deferred model retirement can finish with the existing narrow Doctor when settling a migration ledger did not change config. Genuine changes and findings still require the full pass.

Why This Change Was Made

Keep the snapshot refresh and fresh repair plan, and use the existing config-input comparator plus validity and validated-config equality to decide whether config actually changed. Prior config changes remain sticky. Removing validation exclusions can change the validated projection even when file bytes stay equal; that still widens. No retirement implementation, fallback, state schema, SQL, authority, capture, backup, or recovery owner changes.

The existing narrow path keeps config migration writes, auth-profile migration, session transcripts and their bound post-session plugin plan, Codex session routes, final config write, and final validation. A genuine config/projection change, plugin change, unresolved migration, refusal, or new finding retains the full-pass behavior. Successful state migrations may also settle a ledger entry without changing config; this is not limited to stateless plugins. Such installs can now take the existing narrow post-plugin path. An explicit openclaw doctor still runs the full pass. The review specifically checks for downstream repairs this could omit.

This correction must be in the candidate Doctor. The installed updater must already support retirement-only requests for the contribution saving; older drivers keep their existing full-pass selection. The larger proposed completion-handoff protocol is not included.

Acceptance recorded before native measurement — POSTPASS-STAGE1-V1

Measured production head: 6c1c0dd124c69a892ae85f94e67bf712198ef85a. Final head: 7f4cfc1a0d8d3e8ba29831e8c10b5b2817f67546 (documentation only; production/test blobs identical). Baseline: 18a3a6c22624550f23852645836013dfd1765a05. Fixed installed driver: ef81b2545c8cf6f20f1b2723628fc5291d45bde0.

Use the committed scripts/perf/doctor-retirement-measure.mts cold native update workload on macOS/Node 26.12.1 with retained WAL, synthetic standing advisories, deferred-to-completed retirement, and final real loopback Gateway transport. Recreate the same explicit internal scratch root for baseline then candidate; one count sample per arm using the frozen v3.1.5 observer. Random credentials/ports are synthetic; no user state is read. Record each Doctor's sections, SQL statements, worker requests, process-main work, generation observations, and Gateway runtime MAIN separately. The wrapper is orchestration only; the workload is committed.

Pass: the candidate post-plugin Doctor runs exactly the six retained contribution IDs, completes retirement and final transport/cleanup, reduces statements and requests, and does not increase Gateway runtime MAIN. Genuine changes/findings still widen; refused and interrupted repair, captures and backups keep existing owners. Native and published-driver proof plus exact-head CI (including all three PostgreSQL shards and static gates) are required before landing.

No latency or CPU-speedup claim comes from observer counts or one diagnostic pair. Any separate timed experiment requires the timing lock, load below 24, five alternating samples per arm with cold/warm kept separate, median/p95/spread and no adverse user-facing cell. The coordinator explicitly accepts this small correctness fix without a minimum timing gain.

Evidence

  • Regression on unchanged main fails as intended: ledger-only settlement reports configChanged=true; expected false.
  • Focused owner, widening, cancellation and driver-capability tests: 214 passed across six files with the pinned Bun runtime. These include base-red/head-green ledger settlement, released validation exclusions, genuine config repairs, unresolved migration outcomes, new findings, plugin-change selection and interrupted/refused recovery.
  • Two isolated Codex reviews found no accepted P0–P2 findings. The first explicitly reviewed skipped repairs; the second included expanded complete-preflight and candidate-lint context. A separate source audit found no newly required repair omitted by ledger-only settlement. It confirmed that channel package checker warnings survive candidate lint and actual Gateway startup owns channel startup maintenance; it does not assert every optional inspection ran earlier.
  • Formatting and basic lint pass. Local type-aware lint refuses the campaign-mandated out-of-checkout dependency store; exact-head CI must supply that proof.
  • Native baseline/candidate update, deferred retirement completion, final real Gateway transport and process cleanup all passed. Post-plugin contribution IDs were exactly doctor:write-config-migrations, doctor:auth-profile-migration, doctor:session-transcripts, doctor:codex-session-routes, doctor:write-config, and doctor:final-config-validation; no widening diagnostic. Rehearsal and first-live counts were identical.
Native metric Baseline Candidate
Second-pass sections 91 22
Second-pass SQL 133,014 125,666
Second-pass requests 409 281
Second-pass process MAIN / worker SQL 132,202 / 812 125,232 / 434
Second-pass generation observations 19 19
Entire native SQL / requests 419,761 / 156,195 412,434 / 156,094
Entire native generation observations 64 64
Canary / final Gateway runtime MAIN 44 / 59 44 / 53

The entire-native request total includes 153,881 generation-observer requests in each arm. Final Gateway including shutdown has an adverse count cell: 580→582 SQL, 138→165 requests (cold 129→154; shutdown 9→11). The candidate ran an additional deferred startup-integrity child plus background startup/health work before the short transport-ready cutoff. The workload does not drain all deferred startup. These costs remain included in the overall reduction; no steady-state claim is made. Final launch-to-ready diagnostic was 7,848→9,306 ms with the observer, one sample each, so this is not qualified timing evidence or a speedup claim.

The coordinator accepted the final-Gateway count increase as moved background work, conditional on readiness remaining independent and completed verification being reusable. Source confirms dispatch/preparation readiness does not await the scan; successful verification publishes its age through the existing owner, then an orderly close seals it for restart. The native child ran after sidecar readiness and overlapped the transport probe; the short harness cutoff did not record its owner-completion receipt. A supplemental replay of the unchanged integrity owners passed 14 selected cases: serving/writing while verification is held, recording age/seal after success, rejecting proven corruption, and reopening from a valid on-disk seal without another integrity scan. It used the retained fixed-driver source; all relevant owner/test blobs match the reviewed candidate. Interrupted checks or unclean close still require later verification. No unconditional every-restart saving is claimed.

Generation/copy work is not solved by this correction: observations remain unchanged. Completed-retirement rows are not serialized by the analyzer; the native harness independently asserts completion. The fixture does not exercise managed-service restart; the published-driver cell supplies that coverage. Some process exit events were not serialized, while independent process-group cleanup was confirmed. Byte-copy totals are not instrumented.

Release-note context: avoid repeating full post-plugin Doctor contributions when plugin-ledger settlement leaves config unchanged, while retaining full checks for actual changes and findings.

@clawsweeper

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

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 5, 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-11-05T12:44:35.611432Z 6c1c0dd 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 labels Nov 5, 2026
@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. P2 Normal backlog priority with limited blast radius. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Nov 5, 2026
@clawsweeper

clawsweeper Bot commented Nov 5, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This PR distinguishes plugin-migration ledger settlement from actual configuration changes when selecting Doctor’s post-plugin work.

Example: Doctor settles the retained migration obligation for plugin "fixture" while its settings remain {"region":"us-en"}.

  • Before: The snapshot refresh sets configChanged=true and forces the full Doctor contribution list.
  • After: Unchanged config leaves configChanged=false, allowing the existing six-contribution retirement pass when its other eligibility checks pass.

Review scores

Measure Result What it means
Overall readiness 🧂 unranked krab (1/6) The source change is focused and appears correct, but its explicitly required production proof remains pending and exact-head CI is incomplete.
Proof confidence 🧂 unranked krab (1/6) Real behavior proof is not required for maintainer- or bot-authored pull requests.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: An update repeats the full Doctor contribution list after plugin-ledger settlement even when configuration remains unchanged.
Reason: This restores the existing retirement-only contract through a small producer-side correction, with direction already established by the maintainer-authored PR.

Merge readiness

✅ Ready for maintainer review

Keep open: this PR fixes a concrete current-main bookkeeping error with a focused change, and no introduced correctness or security defect was found.

Priority: P2
Reviewed head: 6c1c0dd124c69a892ae85f94e67bf712198ef85a

Before merge

None.

Findings

None.

Tests

  • Missing end-to-end proof: Supply the recorded native baseline/candidate update and latest-stable published-updater run showing six retained contributions, completed retirement, preserved settings and state, and final Gateway transport.
Agent review details

How this fits together

Doctor preflight reads configuration and migration obligations, completes existing repair owners, and returns snapshot and change facts to the contribution selector.

flowchart TD
  A[Updater retirement request] --> B[Doctor preflight]
  B --> C[Existing plugin migration owner]
  C --> D[Refresh config snapshot]
  D --> E[Compare inputs validity and config]
  E --> F[Doctor eligibility checks]
  F --> G[Six retained contributions or full pass]
Loading

Technical review

Best possible solution:

Keep snapshot refresh and repair replanning in the existing preflight owner while recording only actual configuration changes.

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

Current main visibly maps a ledger-triggered snapshot refresh to configChanged=true, and the existing production-preflight fixture exercises settlement with unchanged settings; no target code was executed during this review.

Is this the best way to solve the issue?

The patch corrects the fact at its existing producer, preserves sticky prior changes and projection changes, and introduces no competing owner or persistence mechanism.

AGENTS.md: found and applied where relevant.

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

Provenance checked

  • Plugin-completion configChanged assignment changes intended behavior with a stated reason (f61e550: Conservatively prevent narrow retirement selection when preflight performs other config work.)
  • Inactive-plugin validation exclusions keeps the original intent (84a12cb: Settle verified no-op obligations while retaining disabled settings and avoiding runtime activation.)
  • Interactive and structured config-warning tests keeps the original intent (26442aa: Keep interactive notes while routing non-interactive warnings through structured logging.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit f61e550 adds src/commands/doctor-config-preflight.ts:244 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: f61e550d22c4; files: src/commands/doctor-config-preflight.ts)
  • RoboClaw: Raw commit 84a12cb adds src/commands/doctor-config-preflight.plugin-deferral.test.ts:327 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: medium; commits: 84a12cb62e37; files: src/commands/doctor-config-preflight.plugin-deferral.test.ts)

PR surface

Source +6, Tests -9. Total -3 across 3 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 1 7 1 +6
Tests 2 34 43 -9
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 3 41 44 -3

Preflight source

Source unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified.

Labels

Label changes:

  • add P2: Avoids unnecessary repeated Doctor work during eligible updates without an established outage or data-loss defect.
  • add rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Label justifications:

  • P2: Avoids unnecessary repeated Doctor work during eligible updates without an established outage or data-loss defect.
  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

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 5, 2026, 8:03 AM ET / 13:03 UTC.

@openclaw-barnacle openclaw-barnacle Bot added the docs Improvements or additions to documentation label Nov 5, 2026
@steipete
steipete merged commit 152c696 into main Nov 5, 2026
152 checks passed
@steipete
steipete deleted the dbasync/postpass branch November 5, 2026 13:42
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 6, 2026
…law#193476)

Keep snapshot refresh and fresh repair planning after plugin-migration settlement, but only report a config change when input, validity, or the validated projection changes. This lets unchanged config use the existing retirement-only post-plugin Doctor while genuine changes and findings still widen. Preserve maintenance, capture, backup, refusal and recovery owners.

The fixed-driver native pair completes retirement and final transport with 91 to 22 post-plugin sections, 133014 to 125666 SQL statements and 409 to 281 requests. Runtime MAIN does not increase. Include the accepted extra deferred Gateway integrity work in whole-flow counts; generation observations remain unchanged and no timing speedup is claimed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

commands Command implementations docs Improvements or additions to documentation P2 Normal backlog priority with limited blast radius. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. size: S 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.

1 participant