Skip to content

Centralize system suspend rail#44

Merged
Staphylococcus merged 10 commits into
mainfrom
centralized-suspend-rail
Jun 15, 2026
Merged

Centralize system suspend rail#44
Staphylococcus merged 10 commits into
mainfrom
centralized-suspend-rail

Conversation

@Staphylococcus

Copy link
Copy Markdown
Owner

Summary

  • add a centralized system suspend rail so logind and NetworkManager suspend signals coordinate through lifecycle state
  • clear suspend rail state on resume and preserve the existing screen ownership marker behavior
  • document the cooperative install topology and keep the user guide focused on observable behavior
  • simplify cleanup around the suspend rail retry path and guard the retryable terminal state with the rail lock

Validation

  • cargo fmt --all
  • cargo test -p lg-buddy --lib network_teardown_waits_for_retryable_owner_before_retrying -- --nocapture
  • cargo test -p lg-buddy --lib pre_down_ -- --nocapture
  • cargo test -p lg-buddy --lib system_suspend_rail -- --nocapture
  • cargo test -p lg-buddy --lib network_teardown_ -- --nocapture
  • cargo test -p lg-buddy --lib
  • cargo test -p lg-buddy --test runtime_entrypoints

@Staphylococcus Staphylococcus marked this pull request as ready for review June 13, 2026 07:13
Copilot AI review requested due to automatic review settings June 13, 2026 07:13

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR centralizes system sleep coordination into a single “suspend rail” so logind (PrepareForSleep) and NetworkManager (pre-down) can cooperate deterministically via shared lifecycle state, while keeping user-facing documentation focused on observable behavior and validating the new install topology in release smoke tests.

Changes:

  • Introduces a cooperative suspend rail with persisted per-cycle outcome state and a bounded NetworkManager wait/retry path.
  • Updates lifecycle monitoring to handle logind pre-sleep events (including acquiring/releasing a logind delay inhibitor) and clears the new cycle state on resume.
  • Refreshes docs and release-bundle validation to reflect the cooperative suspend topology and removal of legacy hooks/handlers.

Reviewed changes

Copilot reviewed 14 out of 14 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
scripts/test-release-bundle.sh Adds explicit validation of the “cooperative lifecycle topology” and asserts legacy sleep artifacts are absent.
README.md Updates installation summary wording to describe cooperating suspend sources.
docs/user-guide.md Simplifies system sleep/wake explanation to user-observable behavior and notes legacy cleanup.
docs/testing-strategy.md Documents the smoke test’s coverage of the current lifecycle topology.
docs/runtime-event-handler-map.md Updates event mapping to reflect the centralized suspend rail behavior.
docs/release-process.md Expands smoke test description to include topology checks.
docs/architecture-overview.md Updates architecture narrative to reflect cooperative suspend rail and per-cycle state.
crates/lg-buddy/tests/support/mod.rs Extends mock logind to support Inhibit for delay inhibitor tests.
crates/lg-buddy/tests/runtime_entrypoints.rs Updates/extends entrypoint tests for cycle state clearing and logind pre-sleep handling.
crates/lg-buddy/src/state.rs Adds persisted system_sleep_cycle outcome file and related state helpers.
crates/lg-buddy/src/sources/linux/network_manager.rs Extends NM tests to cover waiting on/observing rail outcomes and retry behavior.
crates/lg-buddy/src/session/runner.rs Updates lifecycle monitor to run pre-sleep handling and manage logind delay inhibitor.
crates/lg-buddy/src/lifecycle.rs Implements the suspend rail owner/join logic, bounded wait, and retryable failure handling.
crates/lg-buddy/src/commands.rs Routes sleep-pre through the new suspend rail and clears cycle state during resume cleanup.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread crates/lg-buddy/src/session/runner.rs Outdated
Comment on lines +355 to +359
acquire_lifecycle_sleep_delay_inhibitor_if_enabled(
writer,
bus,
config_path,
&mut sleep_inhibitor,
Comment on lines +368 to +376
fn write_state_file(path: &Path, content: &str) -> io::Result<()> {
let mut file = OpenOptions::new()
.write(true)
.create(true)
.truncate(true)
.custom_flags(libc::O_NOFOLLOW)
.open(path)?;
file.write_all(content.as_bytes())
}
@Staphylococcus Staphylococcus merged commit 90d038e into main Jun 15, 2026
4 checks passed
@Staphylococcus Staphylococcus deleted the centralized-suspend-rail branch June 15, 2026 16:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants