Repository navigation
fix(desktop): make LocalAgentProviderDetector hermetic (#9033) - #9047
Conversation
adapterActivationSearchDirectories hard-coded /opt/homebrew/bin and /usr/local/bin, so local-agent (Hermes/OpenClaw) availability depended on the host machine's global installs instead of only the injected homeDirectory/environment. On any machine where those agents are installed in a system bin dir, testLocalAgentProviderDetectorMissingPromptIsUserFacing (missing home + missing PATH) wrongly reported the agent as available. Drop the two absolute system dirs so detection consults only home-relative activation directories plus the explicit OMI_*_ADAPTER_COMMAND env — matching the ratified test contract (arbitrary $PATH already intentionally ignored). The resolved command path is used only as an availability gate, not to spawn, so the actual launch path is unchanged. 🤖 automated by hourly watchdog; opened for review, not merged.
|
Static review of this small hermeticity fix (automated by Omi PR monitor, model: glm-5.2). Verified correct: The change correctly removes Launch path unchanged — confirmed: I checked that the actual spawn path resolution in UX trade-off to flag for maintainer awareness: After this change the availability detector is narrower than the launcher. A user who installed CI note: Flagging for human maintainer review on the detection-breadth trade-off. Not approving — the UX implication and failing CI warrant human judgment. |
Git-on-my-level
left a comment
There was a problem hiding this comment.
Thanks for the focused fix. The code change looks directionally right to me: it removes the non-hermetic /opt/homebrew/bin and /usr/local/bin probes, while still preserving the explicit OMI_*_ADAPTER_COMMAND escape hatch and the home-relative activation locations. That matches the detector tests' existing contract of not trusting arbitrary host PATH state.
Blocking before merge: the required lint/format workflow is currently failing because this desktop change does not include an unreleased desktop changelog fragment:
FAIL: desktop changes require an unreleased changelog fragment.
Add a one-line user-facing JSON fragment under desktop/macos/changelog/unreleased/, or label the PR no-changelog-needed for internal-only changes.
Please either add the changelog fragment, or have a maintainer decide this is internal-only and apply no-changelog-needed. I did not formally approve because the PR is marked for maintainer review and the required check is failing.
Verification from my side:
- Reviewed the one-file Swift diff and surrounding detector/tests.
- Reproduced the changelog gate failure locally with
python3 .github/scripts/check-desktop-changelog.py --base origin/main --head HEAD. - Could not rerun the macOS Swift test here because this Linux runner does not have
xcruninstalled.
Bug
LocalAgentProviderDetector.availabilityis meant to detect whether a local agent runtime (Hermes / OpenClaw) is installed, using only the injectedhomeDirectory+environmentso it is deterministic across machines and CI runners (issue #9033).But
adapterActivationSearchDirectorieshard-coded two absolute system dirs:These are outside the injected environment, so on any machine where
openclaw/hermesare installed in a system bin dir,testLocalAgentProviderDetectorMissingPromptIsUserFacing(injects a missingPATH+/tmp/missing-home, expects unavailable) reportsisAvailable == true. Detection leaks the host's global installs.Root cause
Filesystem search included absolute system paths that ignore the injected environment/home. The committed test contract already establishes the intended design:
testLocalAgentProviderDetectorIgnoresArbitraryPathEntriesdeliberately does not trust arbitrary$PATH; only home-relative activation dirs and the explicitOMI_*_ADAPTER_COMMANDenv are trusted.Fix
Drop
/opt/homebrew/binand/usr/local/binfromadapterActivationSearchDirectories, so detection consults only home-relative activation directories plus the explicit command env. Detection is now hermetic w.r.t. the injectedhomeDirectory/environment.availabilityis used only as an availability gate (RealtimeHubControllerline ~1496); the resolved command path is not used to spawn the agent, so the actual launch path is unchanged.Verification
xcrun swift test --filter PiMonoWiringTests/testLocalAgentProviderDetector— all 4 detector tests pass (0 failures); clean debug compile.🤖 automated by hourly watchdog; opened for review, not merged.