How do we know what the kinetic energies are in the principle of least action I've been trying to wrap my head around the principle of least action, and have come across a conceptual snag.
The classic example that is often given is of a mass's vertical position as a function of time, in a gravitational field. The parabola is the correct path, but other imaginary paths are shown on the same graph as a means of illustration.
The next idea is that action, S, is defined as the definite time integral, between two time points, of the kinetic energy, KE, minus the potential energy, PE, and that the path that is actually taken is the path that minimizes S.
Next, calculus of variations is used to find the path that minimizes S.
I am going to study calculus of variations so I can better follow the relevant ideas, but suppose you wanted to approximate a solution to this problem the hard way, and generate millions of arbitrary paths, and solve for S in each one.
My question is this: 
How would you know what KE and PE of the system are, at each point in time?
Is the answer as simple as taking the time derivative of the path to calculate velocity (which will allow a calculation of KE), and obtaining PE using mgh?
But that doesn't seem reasonable, since conservation of energy can easily be violated here (for example, if one imaginary path had a bunch of minima at different heights, then the total energy would be different at each minima, since KE is 0 at these points, but PE is different.
More generally, given that these imaginary paths could not occur under the actual laws of physics, how do we know which laws apply when calculating the action at each point?
 A: 
Is the answer as simple as taking the time derivative of the path to calculate velocity (which will allow a calculation of KE), and obtaining PE using mgh?

Yes, it is. 

But that doesn't seem reasonable, since conservation of energy can easily be violated here.

It is true that a path drawn down at random easily violates energy conservation, but this is not a problem. The correct path is the one that minimizes S among all the imaginable paths, even those paths in which energy is not conserved. But it happens that these "non-conservative" paths never minimize S. 
To be more precise, a very important theorem makes the following statement. If the potential energy is not explicitly function of time (that is, PE as a function depends only on the coordinates of the system and not on time; it still evolves over time, but only because the coordinates evolve), then the path that minimizes S respects energy conservation.

More generally, given that these imaginary paths could not occur under the actual laws of physics, how do we know which laws apply when calculating the action at each point?

The amazing thing about the principle of least action is that we do not need to assume anything about the laws that apply! As you will learn if you continue to study this topic, once that the PE has been properly defined (for example, in our case it is mgh) the correct laws follow from the principle of least action, just like energy conservation does. That is, you can throw in literally any imaginable path (as long as it is continuous and differentiable) because you can be sure that the ones that minimize S respect the correct laws. The laws themselves follow from the fact that the action has to be minimal.
The principle of least action is a foundation of the whole corpus of Mechanics (and not only Mechanics), alternative but equivalent to Newton's Laws. But we cannot show you this at length here. You will see it by yourself if you continue to study the topic. 
A: Yes it is that simple. For any particular trajectory $\vec{r}(t)$ you can compute the velocity $\vec{v}(t)$ and thus the kinetic and potential energies. More generally, the Lagrangian can be an arbitrary function $L=L(\vec{r},\vec{v},t)$ but these are still all things you know if you know the time-parametrised trajectory. The only 'rule' when calculating the action is that you have an actual path $\vec{r}(t)$, you use this to compute $L$ and then to find $A[\vec{r}(t)]=\int dt L$.

Aside about on-shell/off-shell things:
In particular, the thing that concerned you about this approach is that several of the imaginary trajectories under consideration do not conserve energy! What is going on? What is going on is that these are not the solutions to the equations of motion. In fact, they're not the solutions to any physically sensible equations of motion (sensible meaning ones that conserve energy of course, for brevity). When you consider all possible paths, we say you are considering "off-shell" paths. That means paths without any consideration for if they are physical or not. The set of all possible paths is a very big set $\mathcal{P}$ and only a very small subset $\mathcal{S}\subset \mathcal{P}$ (called the solution set) are realised as physical paths that are the solution to the equations of motion for some set of initial conditions.
Solutions to the equations of motion (i.e. ones that minimise the action) are called on-shell. Several results only apply on-shell, because their proofs involve the fact that the equations of motion are satisfied (ie that the path minimises action). Such results include Nother's theorem and ultimately the conservation of energy. As an even further aside, it's usually the case that every possible trajectory $\vec{r}(t) \in \mathcal{S}$ is in one-to-one correspondance with its initial condition. In this case, $\mathcal{S}$ is equivalent to the set of all initial conditions i.e. phase space.
