With increased oxides, ROS, and reduced products from regular metabolic process MOST plants increased secondary metabolites to prevent excess cell damage and death. This is all plants in general...
I can also be wrong on my ideas but a few things are true across all plants. As for fluctuations in profile yes these alkaloids are moved and also used. I suspect that mescaline may be a growth regulator and hope I can set up some experiment in the future. I am not a researcher nor a botanist so I may be misunderstanding things.
As for dark periods in the short term some plant do increase alkaloids. In papers on other plants this tend to peak after a week. However the process in biosynthesis of mescaline in cacti such as Tyrosine hydroxylase and DOPA decarboxylase activity can be inhibited by dark treatment and cold temps reduce DD. Where as the drought period that is constant during the 'dark stress' increases both these activity and in nearly all plants increases alkaloids other secondary metabolites. Unless cacti have different up and down regulation of these enzymes
As far as I'm aware, Light is required in NADPH+ which is the process which would accelerate alkaloids accumulation as well as up-regulated the same enzymes as drought. Heat also up-regulated the same enzymes.
Mescaline and other alkaloids have many functions but I doubt it would be a direct relation and more the natural selection is what lead to us having them. Microbal attack and insects eating a plant would result in the plant increasing production or tannins and alkaloids in response. The plants that produced alkaloids 'x' survived and the plants that produced alkaloids 'y' didn't. Natural selection would have made the offspring that had the favorable profile increase in population since less of the unfavorable profile plant survived producing less seeds. Add in a couple hundred years with or without human intervention and the plants have those profiles. Cacti that function in similar manners would all produce the same profile under the same conditions if it were specific function and not an added benefit.
The increased levels of the nocturnal acid might play a role however I believe it is just the natural cam cycle. I'm sure there area likely multiple pathways for these alkaloids and maybe a different one is available with zero light. But malic acid being in high amounts wouldn't mean more alkaloids but rather more salts and as acid is used the alkaloids become 'free' near the end of the day.
All theories that I have; maybe you have a better botanical background then I do and please correct me if I am wrong. Also from my understanding plants increase alkaloids in response to not in prevention of. A plant grown in greenhouse under optimal conditions with zero stressors will have the same products however in much lower concentrations unless specifically selected seeds. Acacias don't have excess tannin naturally but only after excess grazing as with tobacco from insects attacking and other plants. The plants don't have the alkaloid for the function of insecticide but rather the alkaloids helped the plant survive so those that produce it continue on.
I understand not wanting to discuss this in open forum I posted a thread on a few forums titled 'Increasing Mescaline Biosynthesis to Genetic Potential' but no discussion ever arose.