If I may add some amplification to Bob's comments -
(a) as part of the certification flight test process, the TPs make assessments based on the Standards (eg FAR 23) and associated support documents (eg AC 23-8C). If the design folk get things reasonably right, the TP confirms that all is well, otherwise there are changes made to improve the aircraft. In concert, these provide for acceptable handling and performance.
The envelope limits generally are not cliff edge situations, rather there is a progressive degradation from good to bad to disastrous and the TP is the link in the chain which puts the final line in the sand for certification acceptability.
(b) in operational practice, the operator (pilot) has to make allowance for reasonable misloading. So, for instance, if there is a problem with a freight compartment's not being loaded at the declared centroid (ie the nominal loading arm), then there needs to be an allowance made in how the loading system is applied to ensure that the final weight/CG is unlikely to get itself outside the approved envelope.
Unfortunately, CASA doesn't require either the WCO or the aspiring pilot to know anything much about the techniques used to achieve this (although this is likely to change in due course - refer
www.casa.gov.au/rules-and-regulations/st...l-officer-and-weight).. In US practice, it is referred to as a "curtailment process".
For the practising pilot, the aim is
(a) loading should be run as accurately as is feasible
(b) if there has to be an error, then do your best to make it conservative (eg, if you are ballasting to get back into the envelope, go a bit further than the sums require to gain a little fat at the limit).
(c) make sure you don't get yourself outside the envelope at
any stage of flight for there be dragons there.