Skip to content

feat(macos): add permission probes and hardware validation script (Batch 11) - #18

Merged
Alajmah merged 1 commit into
mainfrom
batch-11/macos-hardware-validation
Jun 28, 2026
Merged

Alajmah merged 1 commit into
mainfrom
batch-11/macos-hardware-validation

Conversation

@Alajmah

@Alajmah Alajmah commented Jun 28, 2026 •

Copy link
Copy Markdown
Contributor

Batch 11 — macOS hardware validation (gate retained)

Path B: validation-first. Gate remains until real-device evidence is available.

Permission probes

macOS silently drops CGEvent input when Accessibility permission is missing. This was a false-success bug — CGEventPost returns success but the event is ignored. Now all input methods check permissions before injection:

  • _check_accessibility_permission(): AXIsProcessTrusted()
  • _check_screen_recording_permission(): CGPreflightScreenCaptureAccess()
  • All input methods (click, type_text, key_press, scroll, fill) fail with ErrorCategory.SECURITY if Accessibility is missing
  • screenshot raises PermissionError if Screen Recording is missing
  • fill checks permission before any click (no partial side effects)

Key blocklist

key_press() now enforces the key blocklist before execution (was missing on macOS).

Hardware validation script

scripts/validate_macos_adapter.py — tests construction, permissions, screenshots, input injection, key blocklist, and dry-run on real macOS hardware. Does NOT run in CI. PID-only (--bundle not supported yet).

Gate status

DESKTOP_AGENT_MACOS=1 opt-in RETAINED. Known remaining blockers for gate removal:

  1. _char_to_keycode returns 0 for all characters (needs real keycode mapping)
  2. Named target resolution incomplete (falls back to window center)
  3. No real-device validation evidence yet

Verification

  • pytest tests/test_adapters -q: 243 passed, 2 skipped
  • pytest tests/test_cli -q: 132 passed
  • pytest tests/test_release_coherence.py -q: 22 passed
  • pytest tests/integration/test_desktop_integration.py -q: 10 passed
  • ruff check src/deskaoy/adapters/macos.py scripts/validate_macos_adapter.py: clean

Issue: #11

@gitwire-hq gitwire-hq Bot added the size/L label Jun 28, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: f892d3b25d

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread scripts/validate_macos_adapter.py Outdated

# Construct adapter
try:
adapter = MacOSAdapter(pid=pid, bundle_id=bundle_id)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Resolve bundle targets before validating

When the advertised --bundle com.apple.TextEdit path is used, this constructs MacOSAdapter with _pid=None, but screenshot validation calls _get_window_bounds() and then _resolve_ax_element(), which still raises unless a PID is set. That makes a valid bundle-only validation fail as soon as Screen Recording is granted and the screenshot check runs; resolve the bundle ID to a PID before constructing the adapter, or reject --bundle until the adapter supports it.

Useful? React with 👍 / 👎.

Batch 11 — macOS hardware validation (gate retained).

Path B: validation-first, gate retained until real-device evidence is available.

Permission probes added to MacOSAdapter:

- _check_accessibility_permission(): AXIsProcessTrusted() for CGEvent injection

- _check_screen_recording_permission(): CGPreflightScreenCaptureAccess() for screenshots

- _require_accessibility(): returns SECURITY error if missing, before any CGEvent call

- _require_screen_recording(): returns None if missing, before screenshot

All input methods (click, type_text, key_press, scroll, fill) now check Accessibility permission before CGEvent injection. Previously, CGEventPost would succeed syntactically but the event would be silently dropped by macOS privacy controls — a false-success bug.

Additional fixes:

- fill() checks permission before any click (no partial side effects)

- key_press() now enforces key blocklist before execution (was missing)

Hardware validation script (scripts/validate_macos_adapter.py):

- Tests construction, permissions, screenshots, input injection, key blocklist, dry-run

- Does NOT run in CI — requires real macOS hardware and interactive session

- Documents missing implementations: _char_to_keycode returns 0, named target resolution incomplete

Gate status: DESKTOP_AGENT_MACOS=1 opt-in RETAINED. Gate removal criteria documented in RELEASE_READINESS.md.

Signed-off-by: Alajmah <55954113+Alajmah@users.noreply.github.com>
@Alajmah
Alajmah force-pushed the batch-11/macos-hardware-validation branch from f892d3b to 3091509 Compare June 28, 2026 00:48
@Alajmah
Alajmah merged commit e8c55fb into main Jun 28, 2026
8 checks passed
@Alajmah
Alajmah deleted the batch-11/macos-hardware-validation branch June 28, 2026 09:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant