Repository navigation
recovery: enforce battery and thermal cutoffs after the app exits - #114
Draft
sreyassabbani wants to merge 2 commits into
Draft
sreyassabbani wants to merge 2 commits into
sreyassabbani wants to merge 2 commits into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changes
Depends on #113. This draft targets main because the first branch is in a fork; its diff therefore includes both commits. The additional change is commit
ad42489, and its independent diff is sreyassabbani/Insomnia@fix/closed-lid-thermal-cutoff...fix/backstop-safety-checks . Merge or rebase after #113 first.The recovery agent currently honors a future deadline even when the GUI has exited, so battery and thermal cutoff rules stop being enforced after a crash. New sessions opt into a versioned, read-only
Insomnia --check-safety 5mode that exits before AppKit starts and uses the same end rules as the app. The existing per-minute agent requires that protocol before calling it; a cutoff, unavailable helper, timeout or unexpected output triggers owned recovery. Legacy session files retain deadline-only behavior.Arm the helper's own lifetime before any read, preserve the existing recovery lock, and validate an exact one-line response with exit status zero. Expire the saved deadline before undo so a failed restore is retried even after cooling. The GUI synchronizes every 30 seconds and before Extend; Extend and relaunch cannot revive a cutoff. No sudoers permissions are added.
How it was tested
git diff --checkpassed.New cases cover exact/invalid answers, unsupported protocols, low-battery and thermal decisions, failed configuration or sensor reads, helper timeout and lock release, failed undo with persisted cutoff, GUI cleanup, Extend, and relaunch.
Inspired by Adrafinil's independent safety monitor and latched cutoff pattern; no code copied. This implementation uses macOS thermal pressure and polling and cannot establish safe operation in a backpack.
Real-Mac evidence
Not run: the installed-app, crash, relaunch and supervised closed-lid checks affected by this change, including the new checklist item in
docs/releasing.md. The local machine is Apple Silicon on macOS 27.0 with Xcode Swift 6.4; automated tests and a source build are not an installed-app report. The head-specific report required by CONTRIBUTING.md remains outstanding before merge.The
.greptile/rules.mdupdate documents the new recovery protocol and invariant; the owner's config approval is also required by the current merge gate. Opened as a draft for acceptance and review, with no request to bypass either gate.