Repository navigation
fix(gateway): keep Doctor maintenance entry working under the shared lease liveness policy - #164697
Conversation
Inspect the Gateway lease under maintenance custody before Doctor applies runtime schema admission. Close the native reader before handing disposable snapshot cleanup back to its warning-and-retry owner. Restore the newer-schema diagnostic and session retirement manifest outcomes regressed by #164546 without changing lease liveness or data-risk refusals.
|
🦞👀 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. Reviewed October 3, 2026, 10:08 PM ET / October 4, 2026, 02:08 UTC (Revision 2). ClawSweeper reviewWhat this changesThe PR lets Doctor inspect Gateway ownership before runtime schema admission and makes disposable snapshot cleanup failures warn after the inspection reader closes. Merge readiness✅ Ready for maintainer review The repair remains useful on current main, and no introduced correctness or security defect was found. The previous review’s empty finding list remains appropriate. Priority: P2 Review scores
Verification
How this fits togetherDoctor acquires exclusive state custody before performing database maintenance. Its Gateway lease check excludes active owners, then Doctor’s schema guard determines whether repair may proceed. flowchart TD
A[Doctor maintenance request] --> B[Exclusive state custody]
B --> C[Private database snapshot]
C --> D[Gateway lease inspection]
D --> E[Refuse active owner]
D --> F[Close reader and clean snapshot]
F --> G[Doctor schema guard]
G --> H[Repair or schema refusal]
Before mergeNone. Agent review detailsSecurityNone. PR surfaceSource +14, Tests +11, Docs +5. Total +30 across 3 files. View PR surface stats
Review metricsNone. Technical reviewBest possible solution: Keep lease inspection under current maintenance custody while leaving repair compatibility with Doctor and disposable cleanup with the snapshot owner. Do we have a high-confidence way to reproduce the issue? Yes, source establishes the failure path: current main applies runtime schema admission before maintenance lease inspection, and existing Doctor regressions exercise newer-schema refusal and source preservation. No tests were executed during this read-only review. Is this the best way to solve the issue? Yes, the patch uses the existing native reader and cleanup owners while preserving Doctor’s schema guard and shared liveness predicate. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 244993e1b722. LabelsLabel changes: No label 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)
|
…lease liveness policy (#164697) After #164546 made the owner lease share the state lock's liveness policy, Doctor's maintenance entry inherited runtime schema admission and strict snapshot-cleanup requirements from the acquisition path and refused with GatewayLockError / DoctorSqliteMaintenanceLockUnavailableError on state it exists to repair (doctor-health.dangling-workshop-index and doctor-session-sqlite.retirement-disposal went red on main). Maintenance lease inspection is now separate from runtime schema admission while keeping the lease check and the native-reader closure requirement; foreign-owner refusal is unchanged. Bisected: passes at 5421a78, fails from 06da0de. (cherry picked from commit 9aee9ad)
…lease liveness policy (openclaw#164697) After openclaw#164546 made the owner lease share the state lock's liveness policy, Doctor's maintenance entry inherited runtime schema admission and strict snapshot-cleanup requirements from the acquisition path and refused with GatewayLockError / DoctorSqliteMaintenanceLockUnavailableError on state it exists to repair (doctor-health.dangling-workshop-index and doctor-session-sqlite.retirement-disposal went red on main). Maintenance lease inspection is now separate from runtime schema admission while keeping the lease check and the native-reader closure requirement; foreign-owner refusal is unchanged. Bisected: passes at 9cee184, fails from 24dbf43.
What Problem This Solves
Doctor can report a generic Gateway ownership failure instead of the real newer-schema refusal, and session recovery cleanup can stop before reaching its manifest directory-sync policy.
Related: #164546.
Why This Change Was Made
The campaign bisect passes at
5421a7803640and fails from06da0de86c0a. Its new maintenance lease inspection inherited two unrelated runtime-reader requirements: supported schema admission before inspecting the lease, and mandatory removal of the disposable snapshot afterward.The captured
gateway-ownerquery returned[]: there was no owner PID, host, boot/PID namespace, heartbeat age, or expiry. No liveness predicate branch refused the shared-schema fixture. Runtime admission threwSqliteSchemaVersionErrorfor schema 21 versus supported 20 before the predicate ran. The retirement-disposal sibling instead completed lease inspection and then failed private-snapshot cleanup before its expected manifest result.The Gateway lease owner now opens the fresh private snapshot under current maintenance custody, preserves Doctor's exact legacy catalog read admission, and leaves schema compatibility to Doctor before repair. Native reader closure remains mandatory and precedes best-effort snapshot disposal; the snapshot owner warns and retains cleanup responsibility when disposal fails. The shared liveness predicate and ordinary runtime admission remain unchanged.
User Impact
Doctor reports the actual schema or manifest outcome. Disposable snapshot cleanup problems become warnings instead of blocking maintenance entry. Live and fresh unverifiable Gateway owners still refuse maintenance, and newer schemas still refuse repair before source changes. No config, CLI, schema, dependency, or update/rollback contract changes.
Evidence
Regressions
src/flows/doctor-health.dangling-workshop-index.test.ts: reproduced the original failure on the assigned main base. The original shared-schema expectation and database/config byte-preservation assertions remain unchanged.src/commands/doctor-session-sqlite.retirement-disposal.test.ts: reproduced 2 failures / 11 passes with the earlier candidate. After separating disposable cleanup, all 13 passed unchanged: both the simulated Windows unsupported-sync case and theinjected manifest EIOcase reach their intended boundary.Local validation
node scripts/check-changed.mjspassed locally, including production/test type graphs, lint, formatting, ratchets, and runtime import-cycle checks (683.25 seconds).node scripts/run-vitest.mjs src/infra/gateway-owner-lease.test.ts --maxWorkers=1passed all 33 tests in 22.15 seconds wall time; summed reported test time was 11.479 seconds.git diff --checkpassed. Hosted PR CI is separate from this completed local proof.Slow pre-existing suites (waived)
The maintainer explicitly waived these existing timings; they are not introduced by this repair. No timeouts, retries, skips, or assertions were weakened.
src/flows/doctor-health.test.ts: 209.046 seconds of reported test time in the prior Linux run; its 46 service-inspection cases accounted for 158.697 seconds. The final local run recorded 284.838 seconds for the file.src/commands/doctor-maintenance.admission-activation.test.ts: 35.592 seconds for “restores within the native deadline when each fresh private snapshot costs two seconds,” 34.972 seconds for “refuses an update committed after native restart message preparation,” and 33.228 seconds for “retains final native custody revocation after restart message preparation.” The final local run recorded 45.395, 44.042, and 43.295 seconds respectively.Change size
Production: +22/-8 lines. Tests: +17/-6 lines. Documentation: +5/-0 lines. No new production module, exported name, or test file.