Replace the inline loop with a call to the existing primaryParentView() helper so the selection algorithm lives in exactly one place.
The binary doubles as its own healthcheck client via the SDK's -healthcheck flag, so the probe works in the scratch image (no shell, no curl, no wget).