Skip to content

fix(update): release repair leases before recovery maintenance - #157733

Merged
fuller-stack-dev merged 3 commits into
mainfrom
openclaw/issue-157234-repair-self-lease
Sep 25, 2026
Merged

fuller-stack-dev merged 3 commits into
mainfrom
openclaw/issue-157234-repair-self-lease

Conversation

@fuller-stack-dev

@fuller-stack-dev fuller-stack-dev commented Sep 24, 2026 •

Copy link
Copy Markdown
Member

Closes #157234

What Problem This Solves

Fixes automatic update recovery blocking its own Doctor step because the embedded repair agent still holds its credential database open.

User Impact

Recovery maintenance can run after the repair turn and its pending writes finish. Other live database users still block maintenance, and a deliberately stopped Gateway stays stopped.

Why This Change Was Made

The embedded repair agent now requests a typed terminal handoff instead of running maintenance within its own turn. The update owner runs the fixed Doctor/update-repair command only after database work and child processes settle. Cleanup failures remain failures, including both causes when process and database cleanup fail together.

No schema or public database-resource API changes. A successful maintenance command is not presented as proof that the original symptom is repaired.

Evidence

  • 44 original focused cases passed in 168.29 seconds across three shards, with one worker. The maintenance-deadline correction adds two deterministic cases: both failed before the correction; all eight caller cases now pass (36.24 seconds standalone wrapper wall time, 0.102 seconds test time). Maintenance outlives the agent deadline while retaining owner cancellation.
  • The new acceptance case uses the real embedded runner, client-tool admission/execution, terminal resolution, auth-success write, and Doctor admission; only inference is synthetic. Credentials survive maintenance. The causal lease regression failed before the fix; an independent same-process lease still makes Doctor refuse.
  • Deferred-write failure, schema refusal, authority revocation, subprocess cleanup, and both Gateway activation intents are covered.
  • Real allowed/revoked child proof passed: production continuation admission, requester-policy watcher, subprocess launcher, Doctor admission, and auth storage. Allowed: child exits 0 and a fresh post-exit SQLite reader finds the credential. Revoked while active: UpdateRequesterRevokedError, child exits 1, no credential persisted, and the maintenance PID is extinct. Both processes assert physically private handoff paths before use; all fixture processes settle before removal. The fixture uses a tiny CLI dispatcher around real Doctor admission/storage, not the complete Doctor CLI; it holds the child before its write until the production watcher observes revocation. This does not claim instantaneous revocation fencing between watcher polls.
  • Independent API-direct review: no actionable P0–P2 findings, including follow-up reviews of the module-private tool-name correction and the maintenance-deadline correction. Its 15 affected cases and typed lint also pass. The earlier handoff-coverage finding was addressed with the production-path acceptance case.
  • Required local checks: production typing and all other planned guards passed after correcting one unused export; 24 of 25 core-test typing groups passed. The remaining group has three untouched Promise.withResolvers errors in ui/src/pages/chat/components/chat-session-workspace.test.ts, also present on main. The aggregate is not green.
  • Actual published v2026.9.6 updater → exact candidate passed: the registry-installed eb377ac CLI installed 9669dce using the canonical full package (SHA-256 b9f9ec7af39252fa4bedb4b987ca5b9e14289b8c1275e7838d4df9e49a4abae1). Exit 0, status ok, 131.004 seconds. Candidate snapshot, Doctor migration/lint, config, plugins, recovery check, startup, package swap, full installed Doctor, service reconciliation, and final lint all passed. The legacy synthetic credential survived in canonical SQLite; final config validation passed. Real port probes confirmed the intentionally stopped Gateway before and after. This ran on task-only native Linux storage with physically verified private handoff paths; no host service or live state was mounted.
  • Installed automatic continuation → full Doctor CLI passed: after that upgrade, the actual installed continuation owner admitted a fresh real openclaw triage process. The embedded runner requested request_update_maintenance; actual Doctor PID 152 exited 0 and was extinct before the fresh-reader check. Maintenance completed. was reported. A fresh native SQLite reader verified the credential and inherited-profile lastProbeAt persisted after the tool request and before Doctor started. Only the failure context and loopback inference were synthetic; this is a separate post-upgrade continuation cell, not a claim that the successful updater itself encountered a failure. The first oracle incorrectly assumed per-agent storage/lastUsed; source-confirmed shared storage/lastProbeAt verification passed without rerunning maintenance.
  • Published-driver fixture corrections are retained in the task evidence: a macOS bind mount violated nested hard-link inode identity, so the prefix moved to native Linux storage with the guard unchanged. A denied legacy-lock directory then caused a real candidate Doctor failure and package rollback; allowing the private empty directory to be read (while retaining the SQLite-open fence) cleared that fixture problem. These failed runs are not counted as successful recovery-agent runs.
  • Hosted CI 36077880321 is now on attempt 2 for exact head 9669dce. The prior release-priority hold was verified cleared, and the exact deferred run was rerun once; required CI is still pending. The earlier three built v2026.9.4-protocol/manual-repair cases also passed in 40.03 seconds; those remain separately identified as protocol emulation.
  • No live Gateway deployment or restart.
Measured focused test cost and scope

Observed test time within the grouped run:

File Test time
update-repair-agent.handoff.test.ts 17.535 s
update-repair-agent.self-lease.test.ts 5.341 s
update-repair-agent.runtime.test.ts 3.753 s
update-repair-agent.bookkeeping.test.ts 0.057 s
update-repair-maintenance.test.ts 0.051 s
triage.maintenance.test.ts 0.184 s
Existing triage-prompt.test.ts 0.048 s

Every touched test file was audited in full. The real-runner case protects tool reachability that the cheaper runner mock cannot establish; the separate causal fixture proves lexical ownership and independent-parent refusal. The table reports test time, not standalone wall time. Hosted CI timing will be added when available.

@clawsweeper

clawsweeper Bot commented Sep 24, 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.

@fuller-stack-dev
fuller-stack-dev marked this pull request as ready for review September 24, 2026 23:53
@clawsweeper clawsweeper Bot added P0 Emergency: data loss, security bypass, crash loop, or unusable core runtime. merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Sep 25, 2026
@clawsweeper

clawsweeper Bot commented Sep 25, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge. Reviewed September 24, 2026, 9:29 PM ET / September 25, 2026, 01:29 UTC (Revision 4).

ClawSweeper review

What this changes

The branch makes automatic update triage pass Doctor or update-repair requests to the update owner after the embedded agent and its credential writes settle, with accompanying documentation and tests.

Merge readiness

⛔ Blocked before merge - 1 item remains

Keep open. Current main and v2026.9.6 still lack this fix. The prior deadline concern is resolved, the requested published-updater proof is now documented, and this review found no concrete introduced blocker.

Priority: P0
Reviewed head: 9669dceefa4b261e9d020b8838b1a22a64b4fe0d

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) The patch follows the existing update owner and has unusually detailed upgrade and final-effect evidence, with no concrete correctness or security finding.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (terminal): The changed automatic-triage owner hands maintenance to the installed CLI after the repair turn settles. The captured PR body reports both a v2026.9.6-to-exact-head upgrade preserving a stopped Gateway and a separate post-upgrade automatic continuation reaching full Doctor, with fresh SQLite reads confirming the credential and lastProbeAt. Its allowed/revoked child observation covers the requester boundary; the updater run alone is not claimed to reproduce recovery. No stored-data model contract changes.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (terminal): The changed automatic-triage owner hands maintenance to the installed CLI after the repair turn settles. The captured PR body reports both a v2026.9.6-to-exact-head upgrade preserving a stopped Gateway and a separate post-upgrade automatic continuation reaching full Doctor, with fresh SQLite reads confirming the credential and lastProbeAt. Its allowed/revoked child observation covers the requester boundary; the updater run alone is not claimed to reproduce recovery. No stored-data model contract changes.
Evidence reviewed 12 items Current main behavior: Current main runs the embedded repair turn without a terminal maintenance handoff.
Latest release behavior: The v2026.9.6 source still calls the repair turn directly; the tag resolves to the stated release commit.
Handoff ordering: The automatic caller awaits the repair turn, ends the agent timer, checks its outcome, and only then launches requested maintenance with the original owner signal.
Findings None None.
Security None None.

How this fits together

After an update failure, an authorized triage continuation runs an embedded repair agent against the installation. Its maintenance request returns to the update owner, which releases agent-held database and process resources before launching Doctor or update repair.

flowchart LR
A[Failed update] --> B[Authorized triage continuation]
B --> C[Embedded repair agent]
C --> D[Maintenance request]
D --> E[Database and process cleanup]
E --> F[Doctor or update repair]
F --> G[Credential and Gateway outcome]
Loading

Before merge

  • Add data-model compatibility proof - Confirm migration or upgrade compatibility proof before merge.
Agent review details

Security

None.

PR surface

Source +250, Tests +896, Docs +7. Total +1153 across 13 files.

View PR surface stats
Area Files Added Removed Net
Source 6 333 83 +250
Tests 6 898 2 +896
Docs 1 7 0 +7
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 13 1238 85 +1153

Review metrics

Metric Value Why it matters
Production and test growth production +250 net lines; tests +896 net lines The production growth implements an owner-controlled handoff; the tests cover the runner, lease, and Doctor boundaries.
Focused test cost 2 new files above the 5 s target: 17.535 s and 5.341 s The PR body identifies the real-runner and lease contracts these slower cases protect.

Stored data model

Persistent data-model change detected: migration/backfill/repair: src/commands/triage-automatic-repair.ts, migration/backfill/repair: src/commands/triage-prompt.ts, migration/backfill/repair: src/infra/update-repair-agent.runtime.ts, migration/backfill/repair: src/infra/update-repair-maintenance.ts, unknown-data-model-change: src/commands/triage-automatic-repair.ts. Confirm migration or upgrade compatibility proof before merge.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #157234
Summary: This PR is a candidate fix for the reported repair-agent database lease. The other linked PR addresses a separate Doctor restoration timeout.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Technical review

Best possible solution:

Keep maintenance under the update owner, retain refusal for independent database leases and revoked requesters, preserve intentional Gateway stops, and report command completion separately from symptom verification.

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

Yes. The current-main path can run maintenance from an embedded repair turn that still owns credential database resources, matching the linked failure trace. This read-only review did not execute the regression.

Is this the best way to solve the issue?

Yes. The terminal request lets the existing update owner run maintenance after resource cleanup without adding a config or stored-data contract.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • add proof: sufficient: Contributor real behavior proof is sufficient. The changed automatic-triage owner hands maintenance to the installed CLI after the repair turn settles. The captured PR body reports both a v2026.9.6-to-exact-head upgrade preserving a stopped Gateway and a separate post-upgrade automatic continuation reaching full Doctor, with fresh SQLite reads confirming the credential and lastProbeAt. Its allowed/revoked child observation covers the requester boundary; the updater run alone is not claimed to reproduce recovery. No stored-data model contract changes.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (terminal): The changed automatic-triage owner hands maintenance to the installed CLI after the repair turn settles. The captured PR body reports both a v2026.9.6-to-exact-head upgrade preserving a stopped Gateway and a separate post-upgrade automatic continuation reaching full Doctor, with fresh SQLite reads confirming the credential and lastProbeAt. Its allowed/revoked child observation covers the requester boundary; the updater run alone is not claimed to reproduce recovery. No stored-data model contract changes.
  • remove rating: 🦐 gold shrimp: Current PR rating is rating: 🐚 platinum hermit, so this older rating label is no longer current.
  • remove status: 📣 needs proof: Current PR status label is status: 👀 ready for maintainer look.

Label justifications:

  • P0: The linked report describes failed update recovery with an already stopped Gateway and no automatic path forward.
  • merge-risk: 🚨 security-boundary: A model-requested operation crosses into a privileged maintenance child, so live-owner and revocation behavior matter beyond green CI.
  • merge-risk: 🚨 availability: Maintenance ordering and Gateway activation intent can affect whether an interrupted installation recovers or remains stopped.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (terminal): The changed automatic-triage owner hands maintenance to the installed CLI after the repair turn settles. The captured PR body reports both a v2026.9.6-to-exact-head upgrade preserving a stopped Gateway and a separate post-upgrade automatic continuation reaching full Doctor, with fresh SQLite reads confirming the credential and lastProbeAt. Its allowed/revoked child observation covers the requester boundary; the updater run alone is not claimed to reproduce recovery. No stored-data model contract changes.
  • proof: sufficient: Contributor real behavior proof is sufficient. The changed automatic-triage owner hands maintenance to the installed CLI after the repair turn settles. The captured PR body reports both a v2026.9.6-to-exact-head upgrade preserving a stopped Gateway and a separate post-upgrade automatic continuation reaching full Doctor, with fresh SQLite reads confirming the credential and lastProbeAt. Its allowed/revoked child observation covers the requester boundary; the updater run alone is not claimed to reproduce recovery. No stored-data model contract changes.

Evidence

What I checked:

Likely related people:

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

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-09-25T00:01:26.850Z sha b719180 :: needs real behavior proof before merge. :: none
  • reviewed 2026-09-25T00:17:09.798Z sha be83829 :: needs real behavior proof before merge. :: [P1] End the agent timer before starting maintenance
  • reviewed 2026-09-25T00:39:38.552Z sha 9669dce :: blocked before merge. :: none

@github-actions

github-actions Bot commented Sep 25, 2026 •

Copy link
Copy Markdown
Contributor

⚠️ Security sensitive changes

This maintainer PR changes sensitive security components. This comment is informational because the PR author has repository Maintain or Admin access.

  • Current SHA: 9669dceefa4b261e9d020b8838b1a22a64b4fe0d
  • Maintainer: @fuller-stack-dev
  • Repository role: maintain

These security sensitive changes were made:

  • src/agents/embedded-agent-runner/run/auth-profile-success.ts: Controls credential persistence, secret resolution, or redaction. Check storage permissions, credential scope, and exposure in logs or responses.

Carefully review these changes before merging.

@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Sep 25, 2026
@fuller-stack-dev
fuller-stack-dev merged commit 136ce55 into main Sep 25, 2026
247 of 248 checks passed
@fuller-stack-dev
fuller-stack-dev deleted the openclaw/issue-157234-repair-self-lease branch September 25, 2026 02:58
@fuller-stack-dev

Copy link
Copy Markdown
Member Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 25, 2026
…law#157733)

* fix(update): release repair leases before recovery maintenance

* fix(update): keep maintenance tool name module-private

* fix(update): end agent deadline before maintenance handoff
roboclaw-bot added a commit that referenced this pull request Sep 26, 2026
Backport #157696: 09e30a1
Backport #157733: 136ce55
Selected backport #157730: 942a27d
Required test prerequisite #156037: 1f55d63

Keep heartbeat progress distinct from authority, settle repair-owned
resources before maintenance, and validate complete source content before
reusing decoded Doctor rows. Preserve the frozen runtime-entrypoint owner
and its standalone child protocol. Schema remains v18.

Source-bound targeted/native/built-child proof and independent review pass.
This is not a published-package or native service-recovery qualification.

Co-authored-by: Jason (Json) <[email protected]>
Co-authored-by: RomneyDa <[email protected]>
Co-authored-by: vyctorbrzezowski <[email protected]>
Co-authored-by: steipete <[email protected]>
Co-authored-by: jalehman <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. P0 Emergency: data loss, security bypass, crash loop, or unusable core runtime. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. security-sensitive-changed 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.

Update recovery fails with active agent database lease

1 participant