Repository navigation
fix: stop calling a Git update's later checkout failure data at risk once Doctor finished - #201529
fuller-stack-dev wants to merge 5 commits into
Conversation
…rt data at risk A Gateway lock that is held, timed out or unreadable refused Doctor admission before any write, so it is now deferred contention instead of gateway-state-unverified. A live legacy owner or an owner in another process namespace, which the state lock cannot exclude, stays at risk. Git legacy updates no longer record state-migrated-no-rollback before Doctor runs; Doctor's own refusal and the measured schema decide.
|
🦞👀 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. |
|
Codex review: needs maintainer review before merge. What this changesThis PR distinguishes retryable Gateway lock failures from concrete writer risks and stops Git updates marking data at risk before Doctor runs. Example: Doctor cannot read the Gateway owner lock before opening repair writers.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review Keep open: this maintainer-authored PR addresses two false data-risk classifications still present on main, and source review found no introduced correctness bug. Priority: P1 Before mergeNone. FindingsNone. Tests
Agent review detailsHow this fits togetherDoctor classifies maintenance failures, the Git updater records recovery facts, and update finalization consumes those facts alongside persisted-state inspection to decide recovery and Gateway restart. flowchart TD
A[Update request] --> B[Git updater]
B --> C[Doctor maintenance admission]
C --> D[Lock failure classifier]
D --> E[Recovery verdict]
B --> F[Persisted state inspection]
F --> E
E --> G[Gateway recovery and guidance]
Technical reviewBest possible solution: Keep Doctor as the refusal classifier and derive Git migration risks from observed state or concrete owner refusals. Do we have a high-confidence way to reproduce the issue? Current-main source directly shows both incorrect marks; the PR reports failing-base and passing-head tests, but this read-only review ran no target code. Is this the best way to solve the issue? The patch is the smallest coherent source fix: it refines the existing classifier with a legacy error subtype and removes the premature Git risk mark while retaining rollback prohibition and downstream state checks. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 535f3ea06132. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceWhat I checked:
PR surfaceSource +11, Tests +60. Total +71 across 5 files. Added test files: 1. View PR surface stats
Preflight sourceSource unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified. Review metrics
LabelsLabel changes:
Label justifications:
Rating scale6/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. WorkflowClawSweeper edits this one comment on every review. Comment Reviewed November 18, 2026, 7:06 PM ET / November 19, 2026, 00:06 UTC. |
Only a lock held by a coordinated state owner, or a lock record that could not be read or checked in time (a typed GatewayLockInspectionError), is deferred. Every other Gateway lock failure keeps its gateway-state-unverified mark. The lock error classes move beside the namespace error so gateway-lock.ts stays under its line cap.
…ead-failures-not-at-risk
…ctor Revert the Gateway lock classifier change: GatewayLockError is thrown both for contention and for owners the state lock cannot exclude (historical and legacy locks, other namespaces, an interrupted database port, a live owner lease), so deferring by type dropped real risk marks. The Git runner keeps its pre-Doctor mark while Doctor may still have stopped part way, and clears it once Doctor finishes, so a later UI asset or HEAD check no longer names a data risk.
…ead-failures-not-at-risk
|
Closing without merging. This set out to stop two paths from recording "data at risk" without evidence: lock contention during an update, and the mark a Git update sets before Doctor starts. Neither change could be defended:
A correct version needs typed lock errors at each producer, and a restart-unsafe signal that final recovery honors without the data-at-risk label. That is a larger design and will come as its own change. The rollback half of this work (a failed schema read during rollback no longer reads as data at risk) continues in #201498. |
What Problem This Solves
A Git (in-place checkout) update marks the run
state-migrated-no-rollbackas data at risk just before it starts Doctor. That is reasonable while Doctor might stop part way through a migration, but the mark stayed after Doctor had finished: if the checkout then failed a later check (Control UI assets missing,git rev-parse HEADfailing, HEAD not at the target SHA), the run said "Keep the Gateway stopped: data at risk (state-migrated-no-rollback)" although every migration had completed and the candidate checkout owns the state it left.User Impact
User impact: a Git update whose Doctor finished and whose later asset or HEAD check fails no longer records data at risk. Code rollback is still refused (Doctor ran), the restart is still marked unsafe, and the run still fails with its own reason (
ui-assets-missing,head-verification-failed,target-sha-mismatch). A failed or refused Doctor keeps the mark, as before.Why This Change Was Made
Invariant: "data at risk" needs evidence. A Doctor that failed may have stopped part way (and its child refusals are not carried through the failed-step path), so it keeps the mark. A Doctor that finished leaves complete state; a later checkout check failure is not evidence about the data.
update-runner-git.ts: after Doctor returns a successful step,recoverybecomes{ serviceRestartSafe: false, reason: "state-migration-started" }withoutdataAtRisk.stateMigrationStartedstays set, sorollbackErrorstill refuses code rollback.History: the pre-Doctor mark came from #172784, which labeled every "cannot roll back" as data at risk.
Not shipped (reported, not changed):
GatewayLockError→gateway-state-unverified). An earlier version of this PR deferred lock errors by type. Review showedGatewayLockErroris thrown both for contention and for owners the state lock cannot exclude: historical and legacy (2026.6.33) locks, an owner in another process namespace, an interrupted database port (DatabasePortRecoveryError), a live owner lease seen after taking the state lock. Deferring by type dropped those real marks, so that change is fully reverted. A correct split needs a typed error at each producer, and then a classifier that defers only the typed contention and inspection-timeout cases. That is a follow-up.incomplete-migration). The preflight reports a held recovery store and a failed read through the same untyped "readiness could not be verified" error, so the catch cannot tell them apart without a typed cause fromopenclaw-database-preflight.ts.createPackageUpdateDoctorCompletionreturns a failed step without that verdict. The pre-Doctor mark is what keeps such a failure stopped on the Git path today, so it stays until the verdict is carried through the failed step.Update behavior for published updaters
The Git runner runs in the installed updater, so this applies from the next update driven by a fixed version. Marks shipped updaters already recorded are left to the guidance/repair owner (
verification.recovery.dataAtRisk,finalize:data-at-risk). Package installs never had the pre-Doctor mark; Git release mode does not use this runner.Evidence
Behavior checked with the real Git runner against a real git repository (Doctor writes state, then the named failure happens):
head-error,head-mismatch,ui-missing(Doctor finished): nodataAtRisk; rollback not attempted; candidate checkout and migrated state kept. Base:state-migrated-no-rollback.doctor-failedanddoctor-threwkeepstate-migrated-no-rollback;doctor-data-at-riskkeeps Doctor's ownunreadable-state.Terminal recordings (raw output, idle gaps capped at 1 s, 3x speed):
d6f628897adwith this PR's test → 3 failed (the three post-Doctor cases), 3 passed (the controls).pr2b-base-red-d6f628897ad.mp4
63a64ae9531→ 6 passed.pr2c-head-green-63a64ae9531.mp4
Full raw logs are not attached because the artifact store rejected uploads from this machine.
Commands and results
node scripts/run-vitest.mjs src/infra/update-runner-git.test.ts src/cli/update-cli.preactivation-inspection.test.ts: pass.node scripts/run-oxlint.mjs src/infra/update-runner-git.ts src/infra/update-runner-git.test.ts: pass.pnpm tsgo:core:all: pass.git diff --check: clean.Test file audited in full:
update-runner-git.test.ts. One expectation changed: the three post-Doctor failures no longer expect the mark. No case removed.Review:
autoreviewdoes not run on this machine. A fresh independent reviewer and ClawSweeper (rating F/F/F) read the earlier version; their findings are why the lock classifier change was reverted and the pre-Doctor mark kept for failed Doctors.Not proven
openclaw updatewas not run; the proof is the real runner with a real repository and a substituted Doctor callback.Steps this change still leaves to a person, and why:
openclaw update repairandopenclaw triage. Rerunning the update fixes it once the checkout is healthy.