Solution (source code)

= Solution

With negligible <comet> radius and mass, the <planet>'s radius and <escape velocity> are
$$
R_p=\left(\frac{3M_p}{4\pi\rho_p}\right)^{1/3},\qquad
v_{\rm esc,p}^2=\frac{2GM_p}{R_p}.
$$
<Gravitational focusing> changes the limiting collision <impact parameter> from $R_p$ to $R_p\sqrt{1+v_{\rm esc,p}^2/v_{\rm rel}^2}$. Thus it is negligible when $v_{\rm esc,p}^2\ll v_{\rm rel}^2$.

Put $s=q/a_p$ and $\gamma=\sqrt{3-2\sqrt{2s}}$ in the $Q\gg a_p$ prograde approximation. Substituting $v_{\rm rel}=\gamma\sqrt{GM_\star/a_p}$ gives
$$
\boxed{M_p\ll\left(\frac{\gamma^2M_\star}{2a_p}\right)^{3/2}\left(\frac{3}{4\pi\rho_p}\right)^{1/2}.}
$$
Equivalently $2(M_p/M_\star)(a_p/R_p)\ll\gamma^2$. For $q\ll a_p$, use $\gamma^2\simeq3$. If negligible <gravitational focusing> is required for every coplanar near-parabolic orbit, including nearly tangential prograde encounters, use the smaller value $\gamma^2=(\sqrt2-1)^2$.