Skip to content

fix(linux): retire sleep guards when logind disconnects - #146046

Merged
vincentkoc merged 1 commit into
mainfrom
fix/linux-audit-stack-02-sleep-lifecycle-20260912
Sep 13, 2026
Merged

vincentkoc merged 1 commit into
mainfrom
fix/linux-audit-stack-02-sleep-lifecycle-20260912

Conversation

@vincentkoc

@vincentkoc vincentkoc commented Sep 12, 2026 •

Copy link
Copy Markdown
Member

Related: #145355

Stack 2/8, now based on main after layer1 landed.
Previous: #146045 | Next: #146047

This same-repository branch is writable by maintainers with push access.

What Problem This Solves

Linux Gateway recovery can remain blocked after the logind sleep listener disconnects or terminates.

Why This Change Was Made

Retire the failed listener's sleep guard without consuming a later wake. Move the sleep-state API and all three WebSocket callers together.

User Impact

A terminal listener failure no longer leaves the app indefinitely treating the machine as asleep.

Evidence

  • Includes controller and logind lifecycle regressions.
  • Reused native sleep/version run: intended original failures and candidate sleep controls passed.
  • Signed head 6ef43ef4b849e3c8f0165f20c9e4bd1e548d478d replays only this layer's four-file delta onto landed layer1 f369c90e95afb636531157e6fc4e8faa1bdff726. Range-diff matches original 985a523 exactly.
  • Exact-head CI completed successfully in attempt4, including openclaw/ci-gate. Three unacquired cancelled jobs were recovered individually; no source changes or gate waivers were used.
  • Independent source review verified listener ownership, tuple values, and all three callers. This is not a newly executed intermediate native GUI run.

The original stack snapshot remains retained; no new platform qualification or release activation is claimed.

@vincentkoc vincentkoc self-assigned this Sep 12, 2026
@clawsweeper

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

@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. 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. labels Sep 12, 2026
@clawsweeper

clawsweeper Bot commented Sep 12, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 13, 2026, 12:48 AM ET / 04:48 UTC (Revision 2).

ClawSweeper review

What this changes

The Linux companion releases sleep-cycle guards when its system sleep listener terminates, preserves recovery already handed to a real wake, and adds lifecycle regression coverage.

Merge readiness

✅ Ready for maintainer review

This remains a useful, bounded fix: current main and the latest release still leave sleep-cycle cleanup unbalanced when the listener terminates. No introduced correctness defect was found.

Priority: P2
Reviewed head: 6ef43ef4b849e3c8f0165f20c9e4bd1e548d478d

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused lifecycle repair with useful boundary regressions and no blocking defect found in source review.
Proof confidence 🌊 off-meta tidepool Not applicable: The MEMBER-authored PR is exempt from ordinary contributor proof. Its tests exercise the production logind listener over private D-Bus with injected terminal loss; the reported earlier native sleep results could not be independently inspected because log retrieval was blocked.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The MEMBER-authored PR is exempt from ordinary contributor proof. Its tests exercise the production logind listener over private D-Bus with injected terminal loss; the reported earlier native sleep results could not be independently inspected because log retrieval was blocked.
Evidence reviewed 7 items Introduced scope and cleanup ownership: The pinned merge-base-to-head delta contains only the sleep controller, logind listener, integration tests, and three test-call updates in gateway_ws.rs. SleepCycleGuard drops the matching controller generation and pairs every acquired guard with its end hook; an observed wake transfers the guard into recovery.
Current main still needs the fix: Current main retains cycle_began and calls end_sleep_cycle only inside wake recovery. Stream termination, malformed signals, and cancellation have no paired cleanup. The inspected v2026.9.4 listener has the same behavior.
Lifecycle regression coverage: The integration fixture invokes the production listener through a private D-Bus daemon and covers stream loss, malformed signals, cancellation during preparation, and listener loss before wake polling or during refresh. Assertions distinguish cleanup without resume from preservation of genuine wake recovery. Tests were inspected but not executed during this read-only review.
Findings None None.
Security None None.

How this fits together

The Linux companion receives sleep and wake notifications from systemd-logind and coordinates suspension of its locally owned Gateway. Its sleep controller manages suspension leases and keeps the connection driver active while preparation or recovery is underway.

flowchart TD
  A[System sleep notifications] --> B[Linux sleep listener]
  B --> C[Sleep cycle guard]
  C --> D[Local Gateway preparation]
  B --> E{Wake or terminal loss}
  E -->|Wake| F[Reconnect and resume]
  E -->|Terminal loss| G[Retire cycle without resume]
  F --> H[Release connection driver guard]
  G --> H
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Tests +193, Other +143. Total +336 across 4 files.

View PR surface stats
Area Files Added Removed Net
Source 0 0 0 0
Tests 1 200 7 +193
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 3 243 100 +143
Total 4 443 107 +336

Review metrics

Metric Value Why it matters
Production versus test growth production +69 net lines; tests +267 net lines Production growth implements guard ownership and generation handling; most growth exercises terminal-loss and delayed-wake regressions.

Root-cause cluster

Relationship: canonical
Canonical: #146046
Summary: This is the focused sleep-lifecycle layer split from the closed umbrella.

Members:

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

Technical review

Best possible solution:

Keep sleep-cycle cleanup owned by the listener guard, with real wake recovery retaining its guard until completion and stale generations unable to affect newer cycles.

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

Yes, from source: begin a local sleep cycle and terminate the listener before wake; current main has no exit cleanup for the acquired driver guard. This review did not execute that scenario.

Is this the best way to solve the issue?

Yes. A drop guard repairs the existing lifecycle owner, while generation checks preserve newer cycles and recovery already transferred to a real wake.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 8194b0b966f7.

Labels

Label justifications:

  • P2: This repairs a bounded Linux sleep-listener failure without evidence of a broader urgent runtime regression.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: The MEMBER-authored PR is exempt from ordinary contributor proof. Its tests exercise the production logind listener over private D-Bus with injected terminal loss; the reported earlier native sleep results could not be independently inspected because log retrieval was blocked.

Evidence

What I checked:

  • Introduced scope and cleanup ownership: The pinned merge-base-to-head delta contains only the sleep controller, logind listener, integration tests, and three test-call updates in gateway_ws.rs. SleepCycleGuard drops the matching controller generation and pairs every acquired guard with its end hook; an observed wake transfers the guard into recovery. (apps/linux/src-tauri/src/gateway_sleep_logind_listener.rs:11, 6ef43ef4b849)
  • Current main still needs the fix: Current main retains cycle_began and calls end_sleep_cycle only inside wake recovery. Stream termination, malformed signals, and cancellation have no paired cleanup. The inspected v2026.9.4 listener has the same behavior. (apps/linux/src-tauri/src/gateway_sleep_logind_listener.rs:48, 8194b0b966f7)
  • Lifecycle regression coverage: The integration fixture invokes the production listener through a private D-Bus daemon and covers stream loss, malformed signals, cancellation during preparation, and listener loss before wake polling or during refresh. Assertions distinguish cleanup without resume from preservation of genuine wake recovery. Tests were inspected but not executed during this read-only review. (apps/linux/src-tauri/tests/logind_sleep.rs:194, 6ef43ef4b849)
  • Existing route boundary retained: The production bridge supplies the existing local-Gateway route owner; sleep RPCs retain their route and configuration generation through dispatch. The patch changes lifecycle cleanup without adding credentials, permissions, persistent state, or a parallel plugin API. (apps/linux/src-tauri/src/gateway_sleep_logind.rs:22, 6ef43ef4b849)
  • Feature-history routing: Current-main history identifies Vincent Koc's prior owned-Gateway restriction work and Peter Steinberger's earlier logind sleep integration. GitHub commit metadata resolves their handles to vincentkoc and steipete. Exact line attribution could not be completed because historical blobs were unavailable; no introducing-author claim is made. (apps/linux/src-tauri/src/gateway_sleep.rs, 3731db2cee04)
  • Historical validation limits: The body links https://github.com/openclaw/openclaw/actions/runs/34461350778 and reports passing sleep controls from an earlier candidate. GitHub identifies that run as cancelled at ff1d91f. Fetching its job logs was blocked at the artifact-storage host, so the reported individual passes were not independently verified; cancellation alone does not disprove them. (ff1d91f6711b)

Likely related people:

  • vincentkoc: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • steipete: 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 (1 earlier review cycle)
  • reviewed 2026-09-12T14:52:38.959Z sha 985a523 :: needs maintainer review before merge. :: none

@vincentkoc
vincentkoc force-pushed the fix/linux-audit-stack-01-local-status-20260912 branch from 7952564 to 158e8c4 Compare September 13, 2026 03:51
Base automatically changed from fix/linux-audit-stack-01-local-status-20260912 to main September 13, 2026 04:14
@vincentkoc
vincentkoc force-pushed the fix/linux-audit-stack-02-sleep-lifecycle-20260912 branch from 985a523 to 6ef43ef Compare September 13, 2026 04:17
@vincentkoc
vincentkoc marked this pull request as ready for review September 13, 2026 04:20
@vincentkoc
vincentkoc merged commit 4dcf238 into main Sep 13, 2026
451 of 460 checks passed
@vincentkoc
vincentkoc deleted the fix/linux-audit-stack-02-sleep-lifecycle-20260912 branch September 13, 2026 12:23
@vincentkoc

Copy link
Copy Markdown
Member Author

Merged via squash.

vincentkoc added a commit that referenced this pull request Sep 13, 2026
* commit '4aff70f27016f9acf62d0acc19c8bd3592993e4c': (1537 commits)
  test: align plugin fixtures with current runtime contracts (#147000)
  refactor(browser): separate session tab tracking from cleanup (#146973)
  fix(tests): make systemd clock fixtures private (#146990)
  fix(linux): retire sleep guards when logind disconnects (#146046)
  refactor(matrix): share draft fallback delivery (#144840)
  fix(sessions): preserve cross-agent replies after reload (#146799)
  test(models): cover quota recovery during catalog discovery (#146708)
  fix(macos): recover browser sign-in when no browser opens (#146787)
  fix(process): prevent one-shot agents exiting while polling (#144268)
  fix(status): label the session inventory as stored (#146979)
  fix: avoid repeated background reads while loading chat (#146953)
  refactor(ui): narrow Skill Workshop proposal context (#146977)
  perf(sessions): keep cleanup responsive and reuse workers (#140897)
  fix(sessions): prevent stranded writers after abort and restart (#146792)
  refactor: reuse deferred owners in Gateway and infra fixtures (#146809)
  fix: prevent queued conversation replies from switching storage (#146984)
  test(ui): preserve nested failure summaries in CI logs (#146864)
  fix(test): respect process memory limits in local scheduling (#146298)
  fix: validate large media data URLs without regexp stack exhaustion (#146972)
  fix(ui): label model usage contributions as messages (#146735)
  ...
vincentkoc added a commit that referenced this pull request Sep 13, 2026
* temp/pr-145950: (101 commits)
  refactor(memory-wiki): share freshness result construction (#146935)
  improve(gateway): use metadata projection for presence (#146817)
  test(agents): reuse complete Responses model fixtures (#147015)
  fix(sessions): align the reclamation-memory test with the archive session owner (#147028)
  refactor(terminal): simplify copy-sensitive token checks (#146934)
  refactor(media): remove duplicate spaced path fallback (#146933)
  refactor(cli): reuse command-group names (#146893)
  improve(plugins): reduce JavaScript generation capture work (#146993)
  test: align plugin fixtures with current runtime contracts (#147000)
  refactor(browser): separate session tab tracking from cleanup (#146973)
  fix(tests): make systemd clock fixtures private (#146990)
  fix(linux): retire sleep guards when logind disconnects (#146046)
  refactor(matrix): share draft fallback delivery (#144840)
  fix(sessions): preserve cross-agent replies after reload (#146799)
  test(models): cover quota recovery during catalog discovery (#146708)
  fix(macos): recover browser sign-in when no browser opens (#146787)
  fix(process): prevent one-shot agents exiting while polling (#144268)
  fix(status): label the session inventory as stored (#146979)
  fix: avoid repeated background reads while loading chat (#146953)
  refactor(ui): narrow Skill Workshop proposal context (#146977)
  ...
vincentkoc added a commit that referenced this pull request Sep 13, 2026
* commit '060e856e5f9df245d63c98990fcb47e18108c6b9': (97 commits)
  refactor(memory-wiki): share freshness result construction (#146935)
  improve(gateway): use metadata projection for presence (#146817)
  test(agents): reuse complete Responses model fixtures (#147015)
  fix(sessions): align the reclamation-memory test with the archive session owner (#147028)
  refactor(terminal): simplify copy-sensitive token checks (#146934)
  refactor(media): remove duplicate spaced path fallback (#146933)
  refactor(cli): reuse command-group names (#146893)
  improve(plugins): reduce JavaScript generation capture work (#146993)
  test: align plugin fixtures with current runtime contracts (#147000)
  refactor(browser): separate session tab tracking from cleanup (#146973)
  fix(tests): make systemd clock fixtures private (#146990)
  fix(linux): retire sleep guards when logind disconnects (#146046)
  refactor(matrix): share draft fallback delivery (#144840)
  fix(sessions): preserve cross-agent replies after reload (#146799)
  test(models): cover quota recovery during catalog discovery (#146708)
  fix(macos): recover browser sign-in when no browser opens (#146787)
  fix(process): prevent one-shot agents exiting while polling (#144268)
  fix(status): label the session inventory as stored (#146979)
  fix: avoid repeated background reads while loading chat (#146953)
  refactor(ui): narrow Skill Workshop proposal context (#146977)
  ...
vincentkoc added a commit that referenced this pull request Sep 13, 2026
* temp/pr-137049: (110 commits)
  improve: reduce GitHub OAuth maintenance work for large agent rosters (#147021)
  fix(test): avoid settings lock writer startup timeouts (#147029)
  fix(update): correct backup guidance and cover incident regressions (#147023)
  refactor(gateway): share connection lifecycle across transports (#145950)
  refactor(telegram): share HTML text escaping (#146936)
  perf(build): reduce disk use in UI performance checks (#146687)
  refactor(memory-wiki): share freshness result construction (#146935)
  improve(gateway): use metadata projection for presence (#146817)
  test(agents): reuse complete Responses model fixtures (#147015)
  fix(sessions): align the reclamation-memory test with the archive session owner (#147028)
  refactor(terminal): simplify copy-sensitive token checks (#146934)
  refactor(media): remove duplicate spaced path fallback (#146933)
  refactor(cli): reuse command-group names (#146893)
  improve(plugins): reduce JavaScript generation capture work (#146993)
  test: align plugin fixtures with current runtime contracts (#147000)
  refactor(browser): separate session tab tracking from cleanup (#146973)
  fix(tests): make systemd clock fixtures private (#146990)
  fix(linux): retire sleep guards when logind disconnects (#146046)
  refactor(matrix): share draft fallback delivery (#144840)
  fix(sessions): preserve cross-agent replies after reload (#146799)
  ...
vincentkoc added a commit that referenced this pull request Sep 13, 2026
* commit '4aff70f27016f9acf62d0acc19c8bd3592993e4c': (30 commits)
  test: align plugin fixtures with current runtime contracts (#147000)
  refactor(browser): separate session tab tracking from cleanup (#146973)
  fix(tests): make systemd clock fixtures private (#146990)
  fix(linux): retire sleep guards when logind disconnects (#146046)
  refactor(matrix): share draft fallback delivery (#144840)
  fix(sessions): preserve cross-agent replies after reload (#146799)
  test(models): cover quota recovery during catalog discovery (#146708)
  fix(macos): recover browser sign-in when no browser opens (#146787)
  fix(process): prevent one-shot agents exiting while polling (#144268)
  fix(status): label the session inventory as stored (#146979)
  fix: avoid repeated background reads while loading chat (#146953)
  refactor(ui): narrow Skill Workshop proposal context (#146977)
  perf(sessions): keep cleanup responsive and reuse workers (#140897)
  fix(sessions): prevent stranded writers after abort and restart (#146792)
  refactor: reuse deferred owners in Gateway and infra fixtures (#146809)
  fix: prevent queued conversation replies from switching storage (#146984)
  test(ui): preserve nested failure summaries in CI logs (#146864)
  fix(test): respect process memory limits in local scheduling (#146298)
  fix: validate large media data URLs without regexp stack exhaustion (#146972)
  fix(ui): label model usage contributions as messages (#146735)
  ...
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

app: linux maintainer Maintainer-authored PR P2 Normal backlog priority with limited blast radius. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: L 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