Skip to content

feat(mas): closed-lid repair agent, plus #80 review fixes - #81

Merged
scttbnsn merged 4 commits into
dev/m2from
feat/batch-3
Nov 3, 2026
Merged

scttbnsn merged 4 commits into
dev/m2from
feat/batch-3

Conversation

@scttbnsn

@scttbnsn scttbnsn commented Nov 3, 2026

Copy link
Copy Markdown
Contributor

MAS slice BUILD.4, plus the three CodeRabbit findings from #80.

  • BUILD.4 adds a repair LaunchAgent (com.codeswhat.dilated.closed-lid-repair, every 30s and at login) that runs dilated-power repair. Sleep comes back on its own after the MAS app crashes, gets killed, hangs, or the Mac reboots mid-session. The companion installs the agent in a later slice, and the store app never starts anything. The script now owns the session record (pid plus start time, with the file's mtime as the heartbeat), and the app beats every 20s. If the agent reverts a session, a reverted pid can't silently re-enable. The sudo lines are unchanged. scripts/mas-repair-agent-check.sh ran on real hardware without a lid close: reverted 26s after a kill -9, 123s after a hang, and 1.9s after a simulated reboot. The log is kept locally.
  • Bookmarks now start scoped access before the existence check, and they're created read-only to match the entitlement.
  • agent end with the app closed now clears its record and exits 0. A closed app holds nothing, because lease holds are dropped on relaunch.

The combined tree passed verify, check-mas-build and the MAS-filtered tests locally.

…ead-only bookmarks

The sandbox can hide a bookmarked target until scoped access starts, so resolve now starts access first and stops it exactly once. Bookmarks use withSecurityScope plus securityScopeAllowOnlyReadAccess to match the user-selected.read-only entitlement.
A closed app holds nothing because WakeEngine.init drops lease holds on relaunch, so end clears the run record and exits 0 instead of failing and leaving it behind.
…A check

dilated-power gains on <pid>, beat, check and repair. It records the owner pid and start time in a 0600 session file whose mtime is the heartbeat, and repair reverts a dead or silent session and leaves a tombstone. Test hooks only work when the script runs from a repo checkout. scripts/mas-repair-agent-check.sh installs the real script and agent, proves the revert paths on this Mac, and removes everything.
UserScriptPowerRunner sends on <pid> and maps reverted to revertedWhileUnresponsive. The session guard takes an optional script beat hook, wired only under MAS_CHANNEL at a 20s interval. Permission copy and ARCHITECTURE.md describe the repair agent.
@coderabbitai

coderabbitai Bot commented Nov 3, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 61488cfe-ae1d-497f-b953-a8f2a0e541f1

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

CodeRabbit Verify

  • Run CodeRabbit Verify to test the changes in this pull request.

@codecov

codecov Bot commented Nov 3, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 95.12195% with 2 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
...DilatedUI/Automation/SecurityScopedBookmarks.swift 91.30% 2 Missing ⚠️

📢 Thoughts on this report? Let us know!

@scttbnsn
scttbnsn merged commit 77d3bd6 into dev/m2 Nov 3, 2026
3 of 4 checks passed
@scttbnsn
scttbnsn deleted the feat/batch-3 branch November 3, 2026 17:44
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.

1 participant