In human cultivation systems, farmers increasingly use technology to gather data for evaluating tradeoffs between diverse—and sometimes conflicting—crop requirements to maximize yield. Some social insects have also evolved agricultural practices, but it is unknown how they evaluate local conditions to balance conflicting crop requirements. In the obligate farming symbiosis between ants and plants in Fijian rainforests, we show how ant farmers also face key tradeoffs in crop cultivation. While ants cannot simultaneously maximize all services to their crops, our work demonstrates that they cultivate crops in high-light conditions to maximize floral food rewards, despite the nitrogen costs of this strategy. Evaluation of crop tradeoffs plays a key role in the evolution of farming strategies.

Diverse forms of cultivation have evolved across the tree of life. Efficient farming requires that the farmer deciphers and actively promotes conditions that increase crop yield. For plant cultivation, this can include evaluating tradeoffs among light, nutrients, and protection against herbivores. It is not understood if, or how, nonhuman farmers evaluate local conditions to increase payoffs. Here, we address this question using an obligate farming mutualism between the ant Philidris nagasau and epiphytic plants in the genus Squamellaria that are cultivated for their nesting sites and floral rewards. We focused on the ants’ active fertilization of their crops and their protection against herbivory. We found that ants benefited from cultivating plants in full sun, receiving 7.5-fold more floral food rewards compared to shade-cultivated plants. The higher reward levels correlated with higher levels of crop protection provided by the ants. However, while high-light planting yielded the greatest immediate food rewards, sun-grown crops contained less nitrogen compared to shade-grown crops. This was due to lower nitrogen input from ants feeding on floral rewards instead of insect protein gained from predation. Despite this tradeoff, farming ants optimize crop yield by selectively planting their crops in full sun. Ancestral state reconstructions across this ant–plant clade show that a full-sun farming strategy has existed for millions of years, suggesting that nonhuman farmers have evolved the means to evaluate and balance conflicting crop needs to their own benefit.

Across the tree of life, organisms have evolved the ability to cultivate or “farm” individuals of other species (1⇓⇓⇓⇓–6). This can involve habitual planting, husbandry, and harvesting of “crops,” such as seen in social amoebae rearing bacteria (1), marine snails propagating fungi (2), and damselfish cultivating seaweed (3). True agriculture, as defined by four key steps—namely habitual planting, cultivation, harvest, and dependence of the farmer on the crop (7)—is restricted to social insects (ants, termites, beetles) cultivating fungi (7⇓⇓–10) and ants cultivating plants (11).

True agriculture is also practiced by humans and generally involves the farmer deciphering and actively promoting the conditions that increase yield. For plant crops, this can involve evaluating tradeoffs among requirements for light, nutrients, and protection against herbivores. The ability to evaluate tradeoffs is important because farmers, both human and nonhuman, are unlikely to find conditions in which all crop needs are optimally and consistently met. For example, increasing nutrient conditions may inadvertently increase herbivore pressure (12), whereas increasing crop densities may negatively affect light conditions for individual plants (13).

While in human farming, technology and modeling are increasingly employed to evaluate complex tradeoffs (14, 15), it is not understood if, or how, nonhuman farmers evaluate local conditions to increase payoffs. There are cases of early insect agriculture in which tradeoffs are largely unresolved, and conflict can emerge between farmers selecting for edible hyphae and fungal crops allocating resources to reproductive structures, such as mushrooms (16). Such conflicts, as seen between phylogenetically basal attine ants and their basidiomycete fungal crops, can result in low-productivity farming (16). In contrast, there are cases of agriculture involving a suite of adaptations and coevolved traits, such as practiced by leafcutter or plant-farming ants, in which ant farmers appear to actively manipulate conditions to increase yield per unit input. Leafcutter ants, for example, mediate their local environment in ways that increase productivity, such as by sustaining large populations of Actinomycete bacteria in specific crypts that suppress parasites in fungal gardens (17). However, as farmers cannot simultaneously optimize all conditions (e.g., herbivore and pathogen defense, fertilization, modulating environmental variables), it is an open question as to whether, and how, insect farmers mediate crop tradeoffs.

To answer this question, we studied an obligate farming mutualism between the ant Philidris nagasau (Dolichoderinae) and epiphytic plants in the genus Squamellaria (Hydnophytinae, Rubiaceae), occurring in Fijian rainforests on Taveuni and Vanua Levu islands (11). P. nagasau workers cultivate multiplant colonies of Squamellaria epiphytes that can contain 50 or more individuals whose plant-formed cavities in modified stems (domatia) house one queen and ∼250,000 workers (11, 18). In this mutualism, the ants control dispersal, fertilization, and defense of the epiphytes. They do this by actively collecting Squamellaria seeds, planting them under the branch bark of their host tree, and subsequently protecting both seedlings and adults from herbivory (11, 18). The ants also fertilize these nutrient-limited (soilless) epiphytes by defecating on specialized and highly absorptive warts within a plant’s tuberous domatium, which is also the ants’ obligatory nest site (11, 18). In return, the ants feed on sugar- and amino acid-rich food rewards produced by the flowers’ nectaries. The food rewards and the domatia, which contain a complex network of interconnected cavities (11, 18⇓⇓–21), are key to the ants’ survival. Similar to the other “true” agricultures in attine ants, termites, and ambrosia beetles (7), there is an obligate dependence of the farmer on the crop (11, 18). Squamellaria crops are likewise obligately dependent on the farmer (11, 18).

By controlling dispersal, fertilization, and defense of the crop, the farmer could potentially maximize crop productivity by modulating growing conditions, but this remains poorly understood. Specifically, it is unknown if farming strategies are tailored to particular environmental conditions. Because of the challenges in empirically manipulating most farming mutualisms, it is difficult to test how demands for light, nutrients, and protection are evaluated by insect farmers. Here, we address this challenge by studying the P. nagasau–Squamellaria farming mutualism under different natural light conditions. Our aim is to test if ants optimize farming and defense of their crop to match local environments. Using productivity metrics, behavioral assays, and stable isotope analyses, we asked 1) whether crop productivity (i.e., food rewards) is influenced by light conditions; 2) how defense levels provided by farmers to their crop differed along light gradients; and 3) whether there are tradeoffs between farming traits, such as active fertilization, and other crop services across light levels. We also traced the evolutionary history of farming strategies in the Philidris/Squamellaria mutualism, using a densely sampled plant phylogeny, to ask if light niche is correlated over evolutionary time to defense and fertilization of the crop by the ants.

We next compared the transition rates under the best-fitting correlated evolution model to ask two questions. First, are food rewards more readily gained in variable light (q12) or in high-light environments (q43)? Second, does domatium wall differentiation evolve more readily in variable-light environments (q12) or in high-light environments (q43)? We found that both food rewards and domatium wall differentiation evolved more readily in canopy species, associated with high-light conditions (food rewards [mean ± SE]: q12 = 0.01± 0.0003; q34 = 3.05 ± 0.09; Kolmogorov–Smirnov test: D = 0.979, P < 0.001; wall differentiation: q12 = 0.01 ± 0.0003; q34 = 13.95 ± 0.0769; Kolmogorov–Smirnov test: D = 1, P < 0.001; SI Appendix, Figs. S11 and S12 ). This shows that farming traits evolved in a high-light niche and suggests that despite a reduction of nitrogen to their crops, selection has favored the planting of crops in high-light conditions.

Given the evidence that the farmer controls the light environment in a way that maximizes crop productivity, we next asked how plant traits related to farming have changed across the Hydnophytinae, the ant–plant clade to which the genus Squamellaria belongs. We traced the evolution of three farming-related traits on the Hydnophytinae phylogeny ( 28 ), which contains obligately farmed species, facultatively farmed species, generalist ant-associated (but nonfarmed) plants, and non–ant-associated plants. Specifically, we focused on the 1) presence of food rewards; 2) domatium wall differentiation, as a measure of the emergence of specialized wart structures to capture ant-derived fertilizer ( 18 ); and 3) location in the canopy as a measure of the species’ light niche ( Materials and Methods ).

To test which strategy is more likely, we mapped the light niche of 657 S. wilsonii individuals from n = 100 P. nagasau colonies in Taveuni ( Materials and Methods ). We found that light level, while controlling for tree size, was a predictor of crop number per colony size, with shaded colonies being significantly smaller than sun-exposed colonies ( Fig. 4A ; ANOVA: F 4,95 = 5.82, P < 0.001). Specifically, of the 657 S. wilsonii, 406 were growing in full sun, 208 were growing in midexposed conditions, and 43 grew in a fully shaded environment ( Fig. 4A ). We found 69% of the colonies occurred at a single light level, with 22 colonies farming full-sun and midexposed crops and only 9 colonies farming midexposed and fully shaded crops ( Fig. 4A ). In the cases where colonies spanned two light niches, this was generally associated with host tree growth, namely Squamellaria crops becoming shaded by the growth of large branches of the host tree. However, we did observe rare cases of fully shaded Squamellaria (including seedlings in a few instances), growing low in the canopy, which reflects that farming ants have retained the ability to plant Squamellaria outside full sun. More generally, these data reveal the absence of the balanced-cultivation strategy and are more in line with ants maximizing high-light productivity as posited by the immediate rewards-first hypothesis. These data also suggest there are few costs associated with a mostly plant-based diet for ants vs. an insect protein-rich diet in shade conditions, consistent with the documented herbivorous diets of arboreal ants ( 26 , 27 ). More research is needed in the role of gut microorganisms in the nutrition of the ants in shade vs. sun conditions.

Given the evidence that farmed Squamellaria is associated with sun-exposed sites, why is there any diversity in the height at which ants cultivate their crops? Two hypothetical strategies could be employed: 1) a “balanced cultivation” in which Squamellaria are planted at various light levels, ensuring a balance of high crop productivity in sun-exposed plants and high nitrogen inputs in shade-exposed crops (this would be effective since ant workers move among domatia [supplementary figure S2a in ref. 11 ]); and 2) an “immediate rewards-first cultivation” strategy, in which Squamellaria are consistently planted in sun-exposed sites only. If this hypothesis is true, Squamellaria farmed within the same ant colony will be predominantly found in a single light level.

Farming ants control plant light niche over ecological and evolutionary time. (A) Light niches of 657 S. wilsonii plants occupied by 100 P. nagasau colonies in Taveuni. (B) Current (ecological) light niche of farmed vs. nonfarmed Fijian Squamellaria. (C) Ancestral state reconstruction of light niche over a phylogeny of the Hydnophytinae ( 31 ), estimated from a maximum likelihood approach ( 36 ) with 1,000 simulations of character states, and a reverse-jump MCMC approach using 1,000 trees from the dating analysis ( 37 ), taking into account phylogenetic uncertainty (shown as probabilities above branches).

The identification of a light-mediated tradeoff between defense and nutrition prompted us to investigate the extent to which farming ants can manipulate their crop’s light environment over space and time. Squamellaria species are either dispersed by birds (nonfarmed) or by P. nagasau ants (farmed) ( 11 ). We therefore asked if there was a difference in the height at which farmed vs. a nonfarmed Squamellaria species were found when they co-occurred in the same forest. We found that farmed species were significantly higher in the canopy compared to nonfarmed species, dispersed by birds (n = 30 [ SI Appendix, Fig. S9 ]; t test: t = 7.57, df = 45.44, P < 0.0001). We then determined the mean light niche for the nine Fijian Squamellaria species and found that farmed species are significantly more sun-exposed than nonfarmed species ( Fig. 4B ; Fisher exact test [farmed vs. nonfarmed]: χ 2 = 67.79, df = 2, P < 0.001). In farmed Squamellaria, seedlings were found preferentially on tree trunks that received direct sunlight, suggesting that light is a potential cue for where ants plant Squamellaria seeds.

Together, these experiments show that tradeoffs exist between two key services offered by the ant to the plant, namely defense, which is highest under full sun, and ant-mediated nutrition, which is highest in the shade. By populating a probabilistic model with our empirical data, we find a clear tradeoff between defense and nutrition ( Fig. 3 and Materials and Methods ). Similar to tradeoffs faced by human farmers, ants cannot simultaneously maximize all services to their crops ( Figs. 1 – 3 ). Given that food rewards are likely to yield the highest immediate individual benefit to the ants, it is expected that ants will plant crops in full sun ( Fig. 1 ), even if this results in lower fertilizer input to their crop.

We tested a final alternative explanation for the lower N content of sun-exposed S. wilsonii, namely that these epiphytes might be facultative (inducible) Crassulacean acid metabolism (CAM) plants. CAM plants have a substantially lower rubisco content and hence contain less nitrogen per gram of tissue. Under this scenario, S. wilsonii would switch on CAM metabolism under full sun, leading to lower nitrogen levels. Three of the six Fijian Squamellaria farmed by P. nagasau indeed have CAM capabilities ( 20 ), but when we tested S. wilsonii for CAM activity by measuring the δ 13 C ratio in warty tissue, roots, and leaf samples across the light gradient, all samples showed values near −30‰ ( SI Appendix, Fig. S8 ), ruling out substantial CAM activity in this species. This is also supported by leaf morphology: while the three CAM Squamellaria all have succulent leaves, S. wilsonii has thin leaves ( 20 ).

A second test of the hypothesis that light influences fertilization input by ants via food rewards is to compare N levels of Squamellaria without food rewards in the sun and shade conditions. To do so, we took advantage of Squamellaria grayi, a species that has lost the ability to produce food bodies over evolutionary time ( 20 , 21 ). We compared nitrogen levels of both ant workers and warty tissue grown in shade vs. sun in S. grayi. In contrast to S. wilsonii, which does produce food bodies, we found there was no significant difference in N levels in shade vs. sun conditions in S. grayi, which does not produce food rewards ( SI Appendix, Fig. S7 ), further supporting our idea that plant food rewards influence ant N input across a light gradient.

We then quantified hunting behavior. If higher N levels in low-light environments comes from more insect hunting, we should observe different P. nagasau worker behavior in shade vs. light colonies. By monitoring workers outside their crops in full-sun vs. shaded colonies, we found significantly higher insect hunting activities in the shade, compared to sun colonies ( SI Appendix, Fig. S6 A–C ). To further test the ant’s hunting behavior in sun vs. shade environments, we offered a cockroach placed 1 m from a Squamellaria crop ( Materials and Methods ). We found that both the time of discovery and the time of arrival of the second recruit were significantly shorter in the shade ( SI Appendix, Fig. S6 D–F ). This suggests that shade-grown plants receive more external N from ant feces because ants are forced to forage for insects to supplement their food. In contrast, plants cultivated in the sun, are forced to more tightly recycle nitrogen because of a lack of external N inputs.

To test this explanation, we traced back the nitrogen in plant tissues to either plant-derived resources or insect predation using N stable-isotope ratios (δ 15 N), following previous studies ( 22 , 23 ). We collected P. nagasau from N = 8 colonies across the light gradient and sampled the warty-walled tissue of their domatia where ant defecation takes place. We found a tight positive correlation (Pearson correlation coefficient = 0.86; P = 0.005; SI Appendix, Fig. S5 ) between ant δ 15 N and warty-walled tissue N content. This correlation implies that light-dependent food availability (from flowers or insects) drives the higher nitrogen input in shade conditions.

A second scenario is that nitrogen input is mediated by ant diet and differs across light levels. Under this scenario, an ants’ feces will reflect its diet, which will differ under shade vs. sun conditions. This is because plants cultivated by ants in the shade produce fewer flowers and hence provide less food compared to sun-grown plants ( Fig. 1A ). As a result, P. nagasau workers may be forced to forage for supplementary sugar and protein elsewhere in the canopy, including foraging as predators for insect prey. If a greater proportion of the shade farmer’s diet consists of insects, rather than crop-produced rewards, this will lead to a greater external N input into the shade system.

The low N content of full sun-cultivated plants could arise from two scenarios. First, if Squamellaria plants grow faster in full sunlight, this could lead to lower N level by diluting nitrogen inputs. However, past work argues against this possibility. Specifically, a tight linear correlation has been found between the size of the worker ant colony and the size of Squamellaria domatium (i.e., a measure of plant growth) ( 18 ). This means faster plant growth is mirrored by proportional increase in ant workers, and hence nitrogen inputs, thus preventing a dilution effect. We verified that this relationship between worker population and domatium size holds across light levels ( SI Appendix, Fig. S4 ). This suggests that faster growth in full sun is matched by a proportional increase in fertilizing ants, preventing N dilution.

Given the well-established positive relationship between leaf nitrogen and photosynthetic capacity ( 24 , 25 ), we had expected to find higher N levels in plants cultivated under sun conditions. However, we found the opposite: across all tissues tested, plants growing under full sun contained the least amount of N per gram of tissue ( Fig. 2 and SI Appendix, Fig. S3B ; GLMM: t = −2.58, P = 0.03), with N content increasing under midexposed and fully shaded conditions. We found that the difference in N content between sun and shade was particularly pronounced in the warty cavity wall ( Fig. 2 ), the location in the domatia where ants defecate to fertilize their crop. Here, we found that warty tissue of sun-grown plants had the lowest N per gram of tissue.

To evaluate levels of nitrogen fertilization by P. nagasau under different light conditions, we collected tissue from four S. wilsonii individuals from each of the three light environments. We sampled six tissues (leaves, stem, roots, smooth cavity tissue, warty cavity tissue, and tuber tissue; see SI Appendix, Fig. S3A for description) and quantified nitrogen content in different tissues along the light gradient. For each tissue, we sampled triplicates, leading to a total of n = 18 samples per plant and a total of n = 216 samples.

In the variables quantified thus far—1) food rewards to ant farmers and 2) defense by ants against herbivores—the interests of the farmer and its crop are aligned in full-sun conditions: ants are offered more rewards and plants benefit from better protection. However, ants perform another crucial farming function, namely fertilizer input. This function is especially important for nutrient-limited epiphytes that grow in soilless conditions. Targeted fertilization is a key trait in this farming mutualism and involves P. nagasau workers defecating exclusively on highly absorptive warts on the inner walls of domatia ( 18 ). This active fertilization continues from the seedling to the adult stage of Squamellaria plants ( 11 , 18 ). However, it is unknown whether there are tradeoffs between active fertilization and other ant-mediated crop demands across light levels.

We further tested the alternative explanation that there are fewer herbivores in full sun by running two additional experiments to determine herbivory levels across our three light environments. While studies of herbivory in forest canopies generally find higher densities of herbivores under sun compared to shade conditions, this can vary locally ( 22 , 23 ). Therefore, we quantified herbivory in three representative plant species (Macaranga harveyana, Miconia calvescens, Psychotria sp.) with branches placed in experimental blocks across different light levels (experiment 1). After 8 d, we imaged all leaves and calculated herbivory levels ( Materials and Methods ). Our generalized linear mixed model (GLMM) analysis revealed no consistent association between herbivory and light level, except in Macaranga, where we found a strong positive effect of light environment (F = 5.6, P = 0.01), with a trend toward more herbivory in full sun (t = 1.96, P = 0.056) ( SI Appendix, Fig. S1 and Table S1 ). We then repeated this experiment with S. wilsonii (experiment 2) and again found no significant association between herbivory and light level ( SI Appendix, Fig. S2 and Table S2 ). Taken together, these data suggest that the correlation between higher food rewards and lower herbivory in full sun-grown Squamellaria is a result of increased patrolling by ants, not lower herbivore abundance.

Lower herbivory levels in full sun could either be the result of higher ant defense or fewer herbivores. We therefore measured ant patrolling behavior across light conditions, systematically recording the distribution of P. nagasau workers on plant surfaces ( Materials and Methods ). We found significantly more patrolling ants on full-sun plants compared to fully shaded plants ( Fig. 1C ; t test: t = −16.17, degree of freedom [df] = 14.08, P < 0.001), with a significant negative correlation between the levels of rewards and herbivory along the light gradient ( Fig. 1D ; F 1,151 = 105.2, P < 0.001; Pearson correlation coefficient = −0.64). This suggests that ants are more likely to patrol and defend Squamellaria under full-sun conditions when plants bear more flowers and more food rewards are available. This can also help generate partner-fidelity feedbacks ( 18 ), such that there is alignment of colony size with plant size.

We then analyzed the links between crop yield and ant defense, asking how defense levels provided by farmers to their crop differed along light gradients. Specifically, we tested whether higher rewards were correlated with increased crop protection, as this has the potential to generate positive feedback for cultivation in sun conditions. We quantified herbivory under different light levels and found that <25% of the leaves of plants cultivated in full sun showed herbivore damage. In contrast, herbivory increased to nearly 90% in plants cultivated in full shade ( Fig. 1B ; ANOVA: F 2,150 = 70.05, P < 0.001) (Tukey’s HSD post hoc test: full sun vs. full shade, P = 0.0; midexposed vs. full shade, P = 0.0; midexposed vs. full sun, P < 0.001). The antiherbivore defense role of P. nagasau ants has also been shown in previous ant-exclusion experiments ( 18 ).

Crop productivity varies across a light gradient and correlates with anti-herbivore defense efficiency. (A) Normalized number of food bodies per shoot along a light gradient. Inset shows food rewards (postanthetic nectaries), with a P. nagasau worker foraging on one such food reward. (B) Herbivore damage on crops along a light gradient. (C) Ant patrolling activity on the domatium vs. shoot across the light gradient. Patrolling activity was measured as the percentage of ants present on the shoot (leaves, stem, food rewards [where most ants are found; cf. ref. 16 ]) vs. the domatium surface. *** refers to the significance of t test comparing ants patrolling on shoots vs. on the domatium surface (full shade: t = 16.33, df = 14, P < 0.001; full sun: t = −16.61, df = 38, P < 0.001). n.s., nonsignificant. (D) Linear relationship between food bodies and herbivory (y = −0.012x + 1.182; R 2 = 0. 40, P < 0.001).

We found that food rewards were 7.5-fold higher in plants cultivated in full sun than in plants cultivated in full shade ( Fig. 1A ): higher light levels consistently led to more flowers and hence food availability ( Fig. 1A ; analysis of variation [ANOVA]: F 2,150 = 20.19, P < 0.001) (Tukey’s honest significance test [HSD] post hoc test: full sun vs. full shade, P = 0.0; midexposed vs. full shade, P = 0.003; midexposed vs. full sun, P = 0.0004). These data confirm that crop yield varies as a function of light regime and is maximized when the crop is grown under high light conditions.

First, we asked how crop productivity, as measured by food rewards to ants, varied along a natural light gradient. Mature Squamellaria flowers provide P. nagasau workers with a sugary sap rich in sucrose and amino acids that is only accessible to this ant species ( 21 ). We quantified food reward (number of postanthetic nectaries; ref. 21 ) on n = 133 shoots belonging to 50 Squamellaria wilsonii plants spanning a light gradient in Taveuni rainforest canopies categorized as full shade, midlight-exposed, and full sun, controlling for shoot size ( Materials and Methods ).

More generally, our work highlights the role of tradeoffs in the evolution of insect agriculture. While human agriculture has seen an increase in the use of technology to gather data for evaluating tradeoffs ( 30 ), the ant–plant farming mutualism has been subject to millions of years of natural selection. While ants cannot simultaneously maximize all services to their epiphyte crops, our work supports the idea that they buffer environmental variation by selecting the environment where their crop is most productive.

Human farmers balance diverse crop requirements across different environments to optimize yield. Our data revealed that P. nagasau farmers likewise optimize crop yield by controlling their crop’s light environment. This farming strategy has evolved despite lower nitrogen inputs associated with sun conditions because it most directly benefits farmers. Further, nitrogen input from farmers cultivating crops in full sun is still roughly three times higher than any byproduct fertilization found in nonfarmed Squamellaria species ( 18 ), suggesting that the loss of nitrogen in full sun may be trivial in the short term.

Materials and Methods

Study Sites. In September 2014, March 2015, August 2016, August 2017, July 2018, and June 2019, G.C. conducted fieldwork on Viti Levu, Vanua Levu, and Taveuni, Fiji. In July to August 2017, G.C. and E.T.K. jointly conducted fieldwork in Taveuni. The study sites in Viti Levu were Colo-i-Suva forest reserve in the south of the island (18°1′46.808″S, 178°24′0.4175″E) and forest around Navai in the center of the island (17°37′49.5979″S, 177°58′34.9315″E). In Vanua Levu, the study sites were in the Waisali forest reserve (16°38′19.8″S, 179°13′19.7″E) and along the Cross Island road before the bifurcation to Nabouwalu and Labasa. In Taveuni, the study sites were along the trail to DesVoeux peak and Mt. Manuca on the western side of the island (16°48′25.8133″S, 179°56′36.6843″E) and at the end of Lavena coastal walk, Bouma heritage park, on the eastern side of the island (16°51′45.4433″S, 179°54′6.5149″E).

Defining the Light Gradient of Farming and Nonfarming Ant/Plant Symbioses in Fiji. Our study system consisted of a recently described farming mutualism involving the ant species P. nagasau (Dolichoderinae), which obligately and exclusively cultivates Squamellaria ant plants (11). Squamellaria taxonomy follows Chomicki and Renner (20). S. wilsonii is the most abundant species on Taveuni (11). Initially, we aimed to provide a continuous measurement of the light level associated with each plant. However, this metric proved to be unreliable due to 1) frequent cloud shading, 2) wind patterns moving branches above the Squamellaria, and 3) daytime, which all drastically affected light level readings. We thus opted for a discrete categorization of a light environment based on canopy shading. We classified the light environment as 1) fully shaded, when 90 to 100% of canopy cover overshaded the ant plants—an environment typical of the rainforest under story; 2) midexposed, when 40 to 75% of the canopy above a Squamellaria plant was shaded; 3) fully exposed, when a maximum of 20% canopy cover shaded the Squamellaria plants, an environment in which they were exposed to direct sunlight for the majority of the day. We used this same categorization for all Fijian Squamellaria species and counted the number of individuals in fully shade, midexposed, and fully exposed environments.

Quantifying Herbivory along a Light Gradient. Our aim was to compare defense and fertilization services provided by P. nagasau to S. wilsonii plants and the rewards provided by S. wilsonii to P. nagasau across a light gradient. Except in cases where Squamellaria plants were accessible near the ground, we accessed the plants by tree climbing, using a rope secured by a partner on the ground. This technique allowed long stays in the canopy with minimal disturbance of ant colonies. To measure the effectiveness of the defense function of P. nagasau mutualists, we quantified leaf herbivory in 50 S. wilsonii plant individuals spanning the light gradient (10 fully shaded, 22 midexposed, and 18 fully exposed). For each individual, we used three shoots (more when possible, and only two in one instance), leading to a total sample size of N = 30 for fully shaded, N = 71 for midexposed, and N = 53 for fully exposed plants. Leaf herbivory was measured as the percentage of leaves eaten at more than 10%. We also confirmed in the field that using a different threshold (i.e., 50%) did not change our results: H e r b i v o r y = N u m b e r o f l e a v e s e a t e n a t > 10 % T o t a l n u m b e r o f l e a v e s p e r s h o o t ∗ 100 . [1]

Quantifying Plant-Produced Food Rewards along the Light Gradient. Using the same 50 S. wilsonii individuals (N = 153 shoots spanning the light gradient), we quantified the food reward provided by the crop. These rewards are only accessible to the P. nagasau mutualists (21). We counted the number of postanthetic nectaries and divided this number by the number of internodes of the shoot. The number of internode per shoot has previously been shown to directly reflect the age of the Squamellaria shoot and thus allows to compare the food rewards per shoots regardless of shoot age (11, 21).

Quantifying Ant Patrolling Activity on Crops along the Light Gradient. To test whether lower herbivory levels in full sun were the result of higher ant defense rather than fewer herbivores, we measured ant patrolling across light conditions by recording the distribution of P. nagasau workers on the plant surface. The expectation was that if the lower herbivory level of full-sun Squamellaria reflected more ant defense, we should observe a difference in patrolling activity in sun vs. shade Squamellaria. Patrolling activity was measured as the percentage of ants present on shoot (leaves, stem, food rewards [where most ants are found; cf. ref. 21]) vs. the domatium surface. We selected n = 8 S. wilsonii from distinct P. nagasau colonies growing in full shade, n = 13 growing in midexposition, and n = 20 growing in full sun. We recorded the number of ants on the shoots vs. the domatium surface for 5 consecutive minutes on each plant. Observations were made on sunny days at 11:00 AM to 12:00 PM and 1:00 PM to 2:00 PM, and late morning and early afternoon observations were averaged.

Testing the Effect of the Light Level on Herbivory. To experimentally test the effect of light level on leaf herbivory, we designed an experiment (experiment 1) wherein we placed shoots from three species in 15 blocks of cut plastic bottles filled with water (SI Appendix, Fig. S1A). This experiment was performed in the rainforest of Taveuni island, along the road leading to DesVoeux peak. We selected plants from three families: M. harveyana (Euphorbiaceae), the Neotropical invasive M. calvescens (Melastomataceae), and Psychotria sp. (Rubiaceae) that likely differed in leaf chemistry. Macaranga and Miconia were growing in full shade, while Psychotria plants were sun-exposed. In all cases, twigs used in the experiments came from the same plant individual to control for intraspecific variation in leaf chemistry. We ensured that each twig had leaves of comparable physiological age by using twigs with similar number of leaves counting from the apex. We created n = 5 blocks per light environment (full shade, midexposed, and fully exposed), each with three twigs per each of the three species (hence nine twigs per bottle). We selected twigs free of herbivory or where leaf herbivory was <10% on any leaf (removing some damaged leaves while selecting the twigs, prior to the experiment). The experiment lasted 7 d. On the eighth day, all twigs were collected, and leaves were removed one by one (total, n = 685 leaves), and photographed. We scored all leaves eaten at >10%, and calculated herbivory as above (Eq. 1). In June 2019, we replicated this experiment but, this time, only using sun-grown S. wilsonii twigs (experiment 2; same field site). We collected 15 twigs from a single sun-exposed S. wilsonii and placed each twig in a cut bottle, using n = 5 blocks in our three light levels as above. This allowed to directly test the alternative hypothesis that light-dependent background herbivory rates could explain our results. For the statistics, we used a GLMM using the function “lmer” implemented in the R package “lme4” (31). We set herbivory as a dependent variable, and light, species (for experiment 1), and leaf number as fixed-effect predictors, with leaf number nested within species (to represent the structure of each experimental block). We used “block” as our random effect predictor, and again we modeled the leaf number per species nested within the block. Model estimates are shown in SI Appendix, Tables S1 and S2.

Quantifying Nitrogen Fertilization along the Light Gradient. Fertilization by defecation is a key function in this farming mutualisms and involves P. nagasau workers defecating exclusively on highly absorptive warts on the inner domatium walls (11, 18). To evaluate the nitrogen fertilization by P. nagasau in the different light conditions, we collected four S. wilsonii individuals for each light environment. We next sampled six plant parts (leaves, stem, roots, smooth cavity tissue, warty cavity tissue, and tuber tissue; see SI Appendix, Fig. S3A for description). For each tissue, we sampled triplicates, leading to a total of N = 18 samples per plant and a total of N = 216 samples. Samples consisted of tissue aliquots that were silica-dried in the field and analyzed via isotope-ratio mass spectrometry.

Quantifying Nitrogen Content in Ants and Squamellaria When Food Rewards for the Ants Are Absent. To confirm that light influences fertilization input by ants, we compared the nitrogen content of Squamellaria that do not offer food rewards to ant farmers in the sun vs. shade. We took advantage of S. grayi, a farmed species that has lost the ability to produce food bodies over evolutionary time (20, 21). The expectation was that if the light-dependent nitrogen input derives from the abundance of food rewards, absence of food rewards should lead to similar nitrogen levels in both ant workers and plant tissues. We thus sampled P. nagasau workers and S. grayi plant tissues from n = 5 colonies from full-sun vs. n = 5 colonies in full-shade environments. Ant workers and plant tissues (leaves, stem, roots, smooth cavity tissue, warty cavity tissue, and tuber tissue) were sampled and dried as above and submitted to isotope-ratio mass spectrometry.

Isotope-Ratio Mass Spectrometry. For measurements of nitrogen content, δ15N ‰ and δ13C ‰ measurements, plant tissues were harvested and dried with silica gel. Samples were ground to fine powder with a mixer mill MM301 (Retsch). Stable N and C isotope values relative to air N 2 and to the Pee Dee belemnite standard, respectively, were determined from ∼10 mg (± 0.5 mg) of sample in case of N isotopes and from 200 µg of sample in the case of C isotopes with the stable isotope-ratio mass spectrometer MAT253 (Thermo Scientific), the organic elemental analyzer Flash 2000 Elemental Analyzer (Thermo Scientific), and a Conflo IV (Thermo Scientific) at the Institut für Geowissenschaften (Institute for Geological Sciences) at the University of Mainz, Germany.

Monitoring Ant Hunting Behavior in Full Sun vs. in the Shade. Our hypothesis that farming ants provide more nitrogen in the shade implies more hunting activity in the shade as opposed to the sun. To quantify this, we monitored hunting behavior in n = 5 P. nagasau colonies living in S. wilsonii growing in full sun and n = 5 plants growing in the shade, both along the DesVoeux peak track, Taveuni. We monitored hunting behavior in a radius of 2 m from each Squamellaria individual, and in each case, we selected Squamellaria of similar sizes in shade vs. sun. To ensure replicability in our measure of hunting behavior across colonies, we recorded hunting behavior for 10 min between 12:00 PM to 1:00 PM on sunny days (SI Appendix, Fig. S6A). Next, we performed an experiment to determine the times to discovery and to arrival of the first recruit (second ant) to an immobilized cockroach placed in the full shade or full sun at 1 m of a S. wilsonii. The experiment was replicated 5 times in each light environment (SI Appendix, Fig. S6 D–F).

Determining the Light Niches of Farmed vs. Nonfarmed Squamellaria. We quantified distribution patterns of n = 30 Squamellaria imberbis (farmed) and the same number of Squamellaria wilkinsonii (bird-dispersed) in a region where both coexist in a rainforest on the island of Vanua Levu around the Waisali forest reserve (S 16 38′19.8″, E 179 13′19.7″). We determined the height at which Squamellaria were growing using the standard tangent method (32). Knowing the distance angles between the horizon and the Squamellaria at two adjacent distances next to the tree, one obtains: H = D · tan ( α ) · tan ( β ) tan ( α ) − tan ( β ) , [2] where H is the height of the Squamellaria in the tree; D, the distance on the ground from which the two angles were measured; α, the angle between the horizon and the Squamellaria from the point closer to the tree; and β, the angle from the more distant point on the ground. For each of the two species, we measured n = 15 specimens along the same transect. Next, we determined the light niche of all nine Squamellaria species, which grow in forests with a different height. We quantified the proportion of plants per species growing in full sun, midexposed, or full shade along transects across Viti Levu, Vanua Levu, and Taveuni islands in Fiji (Study Sites). Sample sizes were as follow: Squamellaria thekii (N = 20), S. grayi (n = 40), Squamellaria huxleyana (n = 20), Squamellaria major (n = 20), S. imberbis (n = 100), S. wilsonii (n = 100), Squamellaria tenuiflora (n = 60), S. wilkinsonii (n = 60), and Squamellaria jebbiana (n = 20).

Quantifying the Light Niche of S. wilsonii. To quantify the light niche of S. wilsonii and to address whether P. nagasau ants plant across light levels, ensuring a balance of high crop productivity in sun-exposed plants and high nitrogen inputs in shade-exposed crops (balanced cultivation), or whether a single colony would consistently plant Squamellaria in sun-exposed sites (immediate rewards-first cultivation strategy), we mapped the light niche of 657 S. wilsonii individuals from n = 100 P. nagasau colonies in Taveuni, along the DesVoeux peak track as well as near the hydroelectric Somosomo dam. For each of the 100 P. nagasau colonies, the Squamellaria individuals occupied by the respective ant colonies (excluding seedlings that could not be accurately quantified) were counted, and the light level (full shade, midexposed, full sun) of each was determined, following our classification scheme described above. We then plotted the percentage of plants in each of the light levels for the 100 colonies.

Statistical Analysis. We compared 1) plant defense by ants in the different light environments, 2) ant-mediated nitrogen fertilization in the different light environments, 3) food reward abundance in function of the light level, and 4) the correlation between food reward abundance and herbivory. For 1, 2, and 3, we first used one-way ANOVA, followed by post hoc tests when the data were normally distributed (as verified by a Shapiro–Wilk test) and when there was no random effect to take into account. When data were nonnormal and/or random effects were present, we used a GLMM. Specifically, we used a GLMM to test the effect of light environment on nitrogen level. We used a GLMM approach modeled under penalized quasilikelihood (PQL), using a Gaussian probability with the function “glmmPQL” implemented in the R package MASS (33). In this model, light level and tissues are the fixed effects while specimens (from which several samples are drawn) are the random effect. We further used multinominal logistic regressions to obtain a probabilistic framework of plant defense by ants, ant-mediated nitrogen fertilization, and food reward abundance in function of the light environment categories (Fig. 3). For all logistic regressions, we first used the actual overall sample size (N = 153 for food rewards and plant defense and N = 205 nitrogen fertilization), and we subsequently used a simulated sample size of 1,000. In all cases, results between real and simulated sample sizes were comparable. For the multinomial logistic regressions, we used the R package “MASS” (33), and dependencies, relying on the function “polr.” To test the correlation between food reward abundance and herbivory, we used Pearson correlation coefficients implemented in function “corr” of the “stats” package in the R base. We used the stats package in the R base and “anova” from the car package to generate P values and the package “ggplot2” (34) for plotting graphs, all in R version 3.4.3.

Testing the Evolutionary Correlation of Defense, Nutrition, and Niche Evolution. We inferred the evolutionary history of defense and nutrition traits on the Hydnophytinae phylogeny (28) and then tested for their correlated evolution. We coded all 76 ingroup species for the absence (coded “0”) or presence (coded “1”) of concealed postanthetic flower rewards (21, 28) as defense trait (this study). The majority of Hydnophytinae form nutritional symbioses with ants, either involving specialized Dolichoderinae species (from the genera Philidris and Anonychomyrma) or involving generalist species (11, 18⇓⇓–21, 28). A key nutrition trait is the structure of the inner domatium walls. Specialized species have domatia with differentiated warty tissue where ants defecate and nonabsorptive smooth tissue where they raise their brood. By contrast, species forming generalist symbioses have poorly differentiated domatium walls with “wart-like” and “smooth-like” areas that are variable over space and time. Species that have lost symbioses with ants have lost the absorptive warts (18). In order to perform a test of correlated evolution, we coded domatium internal wall type as a binary variable with either poorly differentiated walls or wart absence as “0” and differentiated walls as “1.” We next studied the evolutionary history of light niche in the Hydnophytinae. Hydnophytinae that form facultative symbiosis with many generalist ant species are predominantly found in the lowlands, nonmutualists occur typically at high altitude, and specialized species are found across different altitudes (28). We coded the light niche as a binary trait (light-variable coded “0” or high-light coded “1”) based on the literature (28, 35⇓⇓–38). Light-variable environments correspond to species that can be found at widely varying height in the canopy and which typically are species dispersed by birds and forming generalist symbioses with various ant species (11). We included in this category the few Myrmecodia species inhabited by lowland rainforest Anomychomyrma ants, which grow in shaded-light environments. We categorized species of high-light environments by their reported ability to live high up in the rainforest canopy, in open, semidry forests, or even as terrestrial, soil-rooted plants in open highlands in New Guinea. In all three traits, 0 → 1 transitions correspond to the evolution of defense, nutrition traits, or high-light niche. To infer the evolutionary history of defense and nutrition traits, we used two approaches. First, a stochastic mapping method, relying on the function “make.simmap” in the phytools package (version 04-60) (39), which implements the stochastic character mapping approach developed by Bollback (40). We estimated ancestral states under the best-fitting model as determined by Akaike information criterion and then simulated 1,000 character histories on the maximum clade credibility (MCC) tree. We summarized the 1,000 simulated character histories with probability density plotted on the phylogeny using the function “densityMap.” Second, we used the Bayesian reversible jump Markov chain Monte Carlo (MCMC) approach implemented in BayesTraits version 2 (41), using a sample of 1,000 trees from the BEAST analysis (42) to account for phylogenetic uncertainty, a chain of 50 million generations with rate coefficients and ancestral states sampled every 1,000th generation. We ensured that the acceptance rate was between 20 and 40%, as recommended in the manual, and reconstructed the nodes of interest using the command “addnode.” We reconstructed all key nodes and reported the probabilities above nodes in Fig. 4. To test for possible evolutionary contingencies or correlations between defense and nutrition traits and the niche type, we used a method for discrete traits (29, 41) as implemented in BayesTraits version 2 (41). We again used the MCC tree from BEAST but pruned the outgroups and first ran a model of independent trait evolution and estimated the four-transition rate parameters α1, α2, β1, β2, wherein double transitions from state 0,0 to 1,1 or from 0,1 to 1,0 are set to zero. We then ran a model of dependent trait evolution with eight parameters (q12, q13, q21, q24, q31, q34, q42, q43). To compare these nonnested models, we calculated their Bayes factor scores.