State of charge VS capacity
At any moment, the car (or any appliances that uses battery) can only tell the voltage on a battery and use that voltage to extrapolate the state of charge. There's no way for the car to know "how many miles are left on the battery" just by charging a battery to full. The way to calculate capacity is to take a set amount of votage out of the battery, and calculate the energy produced. You got a long range model 3? Drainig the battery from full to empty should get you 75kw/h of energy. You getting only 65kw/h of energy? You got degradation. We can also calculate capacity based on the energy put into the battery instead, which is what the Tesla does.**
Degradation example
So for a new long range 75kw battery, one should be able to charge each battery cell from 3.3V (0%) to 4.2V (100%) after putting 75kw/h of energy in to the battery. The Tesla's software base it's mileage reading off this calculation (there are many factors which I'll ignore in this example). If 10 years later, charging from 0% to 1000% requires only 60kw/h of energy, the system can assume that 80% of battery had been degraded, and at 4.2V (100% state of charge), the battery mileage reading would be 256 miles (320miles x 80%).
How your charging habit can influence capacity reading
The car's system can accurately gauge the battery's capacity when you fully drain then charge the battery from empty to full. But of course doing so is not good for the battery's life, and we don't want to do that all the time. In reality we often drive for 30 miles, draining the battery by about 10%, and put the car back to 90 percent charge at night. This is great for battery life, but the car now only has a limiting set of statistics to calculate its capacity.
If each battery cell went from 4.0V (73%) to 4.1V (90%) with, let's say, 12.75kw/h charged (17% of 75kw/h), then the system could assume you still have 320 miles of range. But note how small a change in voltage is between 73% and 90%. With a delta of 0.1Volt, the voltage reading can only be so accurate. Then there's fluctuation in temperature and other factors that will fluctuate this reading day by day. But if you're charging from 0% to 100%, the difference in voltage would be much more signifiant, and the bigger numbers produce more accurate results.
That is why the Tesla reps recommend to discharge and charge the battery by a large margin (10% to 100%) in order to better calculate capacity, and repeat this 3 times in a row. The car calculates capacity based on the history of multiple charges, not just one.
Time will tell
Even with properly charging from empty to full, our charging at home can only be accurate up to a certain point, and when the first year of use would only result in about 5% of degradation, your personal finding will inevitably have a high margin of inaccuracy. The only way to have a truly accurate reading is to plot a set of data from 2 or 3 years of usage. My guess is that it's too early to tell.
The only unit to calculate a battery's capacity and degradation is kilo watt per hour. Not any units in miles or kilometers. What we are seeing is just an algorithm making a best guess.
I must claim that this is all based on my personal finding and is prone to mistakes. There are also a lot more stuff like how the maximum voltage also degrades over time which I'm omitting to keep this short. Please correct me if anything here is incorrect.
** In a lab environment, calculating drain is more accurate than calculating charge because you can simulate the speed of discharge with the application. But when you're driving an EV, it's impossible to have this perfect discharge environment to calculate drain as current varies like crazy and regen braking happens every few minutes.