Question about a specific geometrical optics/Fermat's principle problem and it's given solution I'm studying the following question

P119 On a spherical planet, the refractive index of the atmosphere, as a function of altitude $h$ above the surface, varies according to the formula
$$n(h) = \frac{n_0}{1 + \epsilon h},$$
where $n_0$ and $\epsilon$ are constants. Curiously, any laser beam, directed horizontally, but at an arbitrary altitude, follows a trajectory that circles the planet. What is the radius of the planet?

from the book 200 More Puzzling Physics Problems (Gnädig, Honyek, Vigh). The proposed solutions seems a little off to me.
The first approach is by Fermat's principle of least time. The time taken for light to travel around a circular trajectory must not change for a small perturbation in it's path; from there, by equating the flight time for two circular trajectories, we would get $$\frac{2\pi R n_0}{c} = \frac{2\pi (R+h) n(h)}{c} \Rightarrow n_0R=n(h)(R+h)$$
My question for this approach: I was under the impression Fermat's principle applies when considering fixed starting and ending points. That is light travels from point $A$ to $B$ in the least time. In situation like lenses and mirrors, light does take multiple paths going from object to image and we can equate the time taken in all of those, but our situation seems different: Why can we equate the time taken for 2 different circular trajectories if they do not share their starting and ending points? I will add, however, that properly writing the integral, the Euler-Lagrange equations and imposing that $r=\text{constant}$ is a solution, does yield the same condition, although it requires us to assume the perturbation $\delta r$ vanishes at the endpoints; I just don't know why comparing two disconnected paths would work a priori.
The second approach, is to consider the atmosphere to be divided into homogeneous, thin layers. In this model, light suffers total reflection upon arriving at the boundary for the next layer, and travels around the planet in a polygonal path - which tends to a circle as the thickness of the layers tend to $0$.

From the geometric construction above, we equate the sine of the angle of incidence with the sine of the limiting angle - that is: $$\frac{R}{R+h}=\frac{n(R+h)}{n_0}$$
This gives our previous relation. However, the condition for total reflection to occur is that the angle of incidence must be greater or equal than the limiting angle, i.e. $$\frac{R}{R+h}\geq\frac{n(R+h)}{n_0}$$
In other words, the upper layer has to have a sufficiently small refractive index, but there's no intrinsic lower boundary for it's value. As long as the refractive index falls off sufficiently fast with height, this model should work - but again, we do know that equality is required from the previous method.
What am I missing in these two cases?
As an aside, although both approaches are pretty different, I chose not to split this question in 2 as both pertain to the same problem.
 A: I concur with your assessment; this problem is not an instance of Fermat's least time.
The way I understand the description: the gradient of index of refraction is such that at every altitude the time to complete a circumnavigation is the same.
This time-to-complete-a-circumnavigation setup reminds me of the following mechanics problem: circumnavigating motion when the force towards the center of circumnavigation is Hooke's law.
In the case of Hooke's law the resulting motion has the property that the period of circumnavigation is the same for all amplitudes of the motion.
More generally, the motion resulting from Hooke's law can be represented as a superposition of two harmonic oscillations, at right angles to each other. Each component oscillation has the same period, independent of amplitude.
If you launch an object, precisely tangent to the circle, at precisely the right velocity, then it will proceed along a perfect circle.
When an object is launched a tad too slow (but still precisely tangent to the circle), then it will proceed along an ellipse. (With intersection of major and minor axis coinciding with the center of circumnavigation) That is, now the object proceeds such that it is at an "apogee" twice every circumnavigation, and at a "perigee" twice every circumnavigation.

Propagation of light
Returning to the propagation of light, through a medium with a gradient in index of refraction:
When we consider the case in terms of Huygens principle then the constant circumnavigation time implies that a propagating wavefront that starts out parallel to the radial vector will remain parallel to the radial vector. Hence the propagating wavefront will propagate along a circular path.
To assess the same case in terms of Fermat's least time:
As you point out: in terms of Fermat's least time you must establish two fixed points to serve as starting point and end point, and then allow for variation of the path between those two points.

More generally:
In my opinion: being aware of the relation between Fermat's least time and Huygens principle is key.
Huygens principle assesses propagation of light by assuming that the entity that is propagating has spatial extent. For visualization it is helpful to think in terms of a propagating wavefront. That wavefront isn't necessarily an objective reality; the wavefront visualization expresses the property of having spatial extent.
As the propagating wavefront encounters a medium where the speed of propagation is different the wavefront undergoes a reorientation. Snell's law gives the relation between the sines of angle of incidence, and the propagation speeds in the different mediums.
As we know, Fermat's least time is also stated in terms of the speed of propagation in the medium.
Huygens principle and Fermat's least time are an example of something that is a well known phenomenon: two concepts that are inter-derivable. Stackexchange contributor knzhou has written about that pointing out that:

[...] in physics, you can often run derivations in both directions: you can use X to derive Y, and also Y to derive X. That isn't circular reasoning, because the real support for X (or Y) isn't that it can be derived from Y (or X), but that it is supported by some experimental data D.

A: I found a justification for the use of Fermat's principle as per the solution, I'll present it as an answer. I'm still unsure about the second approach.
The idea is the following: If we have two closed loops, close to each other, we can construct a third one, close to both, and that intersect each in points $A$ and $B$ respectively. The period around this intermediary loop must be the same whether it starts on $A$ or $B$. Hence, the period of each loop must be equal to that of the intermediate loop, and therefore to each other.
Consider 2 close orbits as curves $\Gamma(t), \Gamma'(t) : [0,1] \to \mathbb{R}^3$, such that $\delta(t)=\Gamma(t)-\Gamma'(t)$ is small. We can construct a third curve $\Gamma_m(t)$ that intersects the first two and is also "close" to them - for instance, if $A= \Gamma (0)$ and $B=\Gamma'(1/2)$,  then the curve $\Gamma_m(t)=\Gamma(t)+4t(1-t)\delta(t)$ passes through $A$ and $B$, and is close to both: $|\Gamma_m(t)-\Gamma(t)|\leq\delta(t)$ on $[0,1]$. Furthermore, this new curve passes through $A$ at $0$ and $B$ at $1/2$. It's also easy to re-parametrize both $\Gamma'(t)$ and $\Gamma'_m(t)$ so that both intersect at B at $t=0$, and evidently they will have the same period. We have $$T-T' = (T-T_m)+(T_m-T') $$
By Fermat's principle both terms on the right are of second order or greater, and therefore so is the LHS $_\square$
