fix(philips_hue): relay bridge calls past the macOS Local-Network block on the pm2 tree#188
Merged
Merged
Conversation
…ck on the pm2 tree
macOS Sequoia's Local Network privacy denies CODEC's pm2/node process tree a
LAN route to the Hue bridge ('[Errno 65] No route to host') while the internet
still works — and there is no grantable Local-Network entry for the
python-under-node identity, so toggling permissions can't fix it. Result: every
dashboard/voice "lights off" failed with "Could not reach Hue Bridge", even
though the bridge was reachable from a plain shell on the same Mac.
Fix: when an in-process bridge request fails with ConnectionError, _get/_put
fall back to `_launchctl_request`, which runs the call OUTSIDE the pm2 tree via
`launchctl asuser` — i.e. in the GUI login session, which HAS Local-Network
access. The relay launches a python whose *launch path* is granted
(/usr/local/bin/python3.13, etc.), NOT the dashboard's raw Cellar
sys.executable, which macOS treats as a separate ungranted identity (this was
the final-mile bug). Proven live: dashboard turns the lights on/off in ~2s.
The fast in-process path is unchanged; the relay only engages on ConnectionError,
so it's a pure fallback with zero cost on networks where the pm2 tree isn't
blocked.
Regression tests: _get/_put fall back to the relay on ConnectionError; the relay
prefers a granted python over sys.executable; HUE_ERR payloads surface as
ConnectionError. Manifest regenerated for the new skill hash.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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.
The bug
After the Mac Studio reboot, every dashboard/voice "lights off" failed with
Could not reach Hue Bridge at 192.168.1.81— even though the bridge was reachable from a plain shell on the same Mac.Root cause: macOS Sequoia's Local Network privacy denies CODEC's pm2/node process tree a LAN route to the bridge (
[Errno 65] No route to host). The internet still works for it (so nothing else broke), but local devices are blocked — and there is no grantable Local-Network entry for the python-under-node identity, so toggling System Settings can't fix it.The fix
When an in-process bridge request fails with
ConnectionError,_get/_putfall back to_launchctl_request, which runs the call outside the pm2 tree vialaunchctl asuser— i.e. in the GUI login session, which does have Local-Network access.Final-mile detail: the relay launches a python whose launch path is granted (
/usr/local/bin/python3.13, …), not the dashboard's raw Cellarsys.executable— macOS treats that as a separate, ungranted identity. That last bit was the difference between "still broken" and "works."The fast in-process path is unchanged; the relay only engages on
ConnectionError, so it's a pure fallback with zero cost on networks where the pm2 tree isn't blocked.Proven live
Dashboard turned the lights ON at t+2s then OFF at t+2s through
/api/command.Tests (TDD, watched-red-then-green)
_get/_putfall back to the relay onConnectionError(instead of propagating)sys.executableHUE_ERR:payloads surface asConnectionErrorAll 23 hue tests green. Skill manifest regenerated for the new hash (PR-1A gate).
🤖 Generated with Claude Code