Introduction

The rapid development of large-scale and intensive livestock and poultry farming has met the increasing demand for protein from meat, eggs, and milk but has also resulted in the generation of a substantial amount of livestock and poultry manure. Statistics indicate that approximately 3.05 billion tons of this manure are produced annually in China1and its value as an organic resource is now widely recognized and increasingly harnessed. Manure is rich in essential nutrients such as nitrogen (N), phosphorus (P), potassium (K), and organic matter2yet it also contains various emerging pollutants, including heavy metals and antibiotics3. In 2021, the total nitrogen and total phosphorus discharges from agricultural sources in China reached approximately 1.685 million tons and 265,000 tons, respectively, with livestock farming as a major contributor. Furthermore, the direct incorporation of untreated manure into the soil poses significant risks to crop growth, environmental quality, and public health.

Aerobic composting is a crucial technology for reducing and recycling livestock and poultry manure. This process involves humification, which promotes the breakdown of organic materials and the formation of humic substances (HSs)4,5. HSs, especially humic acid (HA), play a pivotal role in detoxifying pollutants and stabilizing nutrients because of their high adsorption capacity and chelation ability6. Notably, the strong binding capacity of HA for heavy metals is positively correlated with the passivation rates of metals such as Cu, Zn, Cd, Cr, and Pb7. Additionally, the increase in pH during composting facilitates the transformation of heavy metals into inert forms8. In terms of antibiotic degradation, aerobic composting employs several mechanisms, including microbial metabolic breakdown, thermal degradation at elevated temperatures, and physical adsorption9. Microorganisms degrade certain antibiotics through metabolic activities under oxygen-rich conditions10. High temperatures can disrupt the molecular structure of antibiotics, leading to their degradation or inactivation11. Although light exposure is limited during composting, antibiotics may also degrade under specific conditions when light is present12. These mechanisms are crucial for effectively reducing antibiotic concentrations and mitigating their environmental impact. Consequently, aerobic composting significantly decreases heavy metal activity and antibiotic levels in livestock and poultry manure, facilitating its safe and resourceful use.

Traditional aerobic composting often relies on bulking agents and amendments—such as sawdust, straw, rice husk, biochar, zeolite, and microbial inoculants—to improve porosity, adjust the C/N ratio, and enhance microbial activity. However, this approach has several limitations, including high additive consumption, long composting cycles, and nonuniform product quality. The implementation of a two-step composting process in which the larvae of flies, such as Calliphora vomitoria, Lucilia sericata, and houseflies, are utilized to bioconvert raw materials can address these issues. Housefly larvae rapidly dehydrate high-moisture organic waste, increase material porosity, and facilitate composting without the use of additives13,14. This transformation by housefly larvae enhances the degradation of proteins and fats in waste, leading to the accumulation of aromatic substances and HAs15. Moreover, larvae convert nutrients in waste into insect proteins, supporting sustainable farming practices. For example, studies have shown that tilapia-fed dehydrated housefly larvae exhibit optimal growth and nutrition16and broiler chickens fed fly larvae demonstrate greater amino acid digestibility17.

This study aimed to evaluate the environmental detoxification potential of chicken manure via housefly larva bioconversion during aerobic composting, using two controls: direct composting without additives (CK1) and conventional sawdust‑amended aerobic composting (CK2). CK2 serves as a benchmark for standard bulking‑agent practice, allowing us to assess the added value of the maggot bioconversion step. Over 45 days, we monitored compost maturity (seed germination index, humification rate), heavy metal stabilization (speciation analysis), antibiotic degradation (LC-MS/MS), and key physicochemical parameters to assess each treatment’s effectiveness.

Materials and methods

Composting materials

The experiment was conducted at the Xiaoshan Huiren Compound Organic Fertilizer Company in Hangzhou, Zhejiang, China. The company provided chicken manure and sawdust. The housefly larvae used for inoculation (newly hatched ≤ 24 h) were bred and supplied by our research team.

Experimental design and sampling

Three different composting processes were tested: housefly larva bioconversion plus aerobic composting (MC), and two control groups-direct composting (CK1), and sawdust‑amended composting (CK2). The MC group had three replicates, each with 270 kg of fresh chicken manure spread on a concrete surface to a thickness of approximately 7 cm. Housefly larvae (hatched within ≤ 24 h) were introduced at a ratio of 1.0% (w/w), resulting in approximately 4.76 million larvae. An additional 200 kg of fresh chicken manure was added on the second day of maggot breeding. On the fourth day under ambient conditions, over 90% of larvae had matured into pale yellow maggots (near pupation) and separated from manure by gradually removing the surface manure manually with a broom, because maggots liked staying in dark. The three remaining manure was combined and covered for two days, and then the material underwent 41 days of aerobic composting. Meanwhile, a direct composting was constructed as a control(CK1)in the same way, which was combined another three replicates manure without maggot inoculum and covered for two days, then followed by 41 days of aerobic composting. A sawdust‑amended composting was performed as other control (CK2), which was 800 kg of fresh chicken manure added with wood chips at a 17% (w/w) ratio and thoroughly mixed, and then the mixture was formed into windrows approximately 2.0 × 1.5 × 0.8 m in size for aerobic composting.

Ventilation was controlled by manually turning the piles. Samples were collected on days 0, 2, and 4 to monitor the maggot bioconversion stage. After larval removal, additional samples were taken on days 10 and 17 to capture early composting dynamics, followed by weekly sampling on days 24, 31, and 38, with a final sample on day 45. Temperature measurements were taken at each sampling. Samples were taken before the piles were turned, with random points sampled from each pile. The collected samples were mixed thoroughly and bagged, with each sample amounting to approximately 2 kg. The retrieved samples were divided into four parts: fresh samples for moisture, pH, and EC measurements; air-dried samples were ground for analysis of HSs, infrared spectroscopy, heavy metal content, and speciation; and the remaining samples were stored in a freezer at -40 °C.

Measurement methodology

Temperature: The temperatures of the heaps were measured via a 50 cm long alcohol thermometer that was randomly inserted into three different parts of the heap at a depth of approximately 25 cm. The surface temperature was determined with an alcoholic thermometer suspended in air. Moisture content: Fresh samples were dried in an oven at 105 °C to a constant weight to determine the moisture content. The pH was determined by taking fresh samples with a 1/10 (w/v) ratio, which were then agitated at 180 rpm for one hour. After the samples were left undisturbed for half an hour, the sample pH was determined via an electrode (pHS-3 C pH meter). OM, TN, and Seed Germination Index: These indices were determined according to the “NY/T525-2021 Organic Fertilizer”18 standard.

Heavy Metal Extraction: A total of 0.5000 g of dry sample was finely ground via an agate mortar and then sifted through a 60-mesh plastic sieve. The extraction of heavy metals was conducted via the modified Community Bureau of Reference (BCR) sequential extraction method19as modified previously20. Via this method, heavy metals are categorized into four species fractions: exchangeable (EXC), reducible (RED), oxidizable (OXI), and residual (RES). These fractions are extracted following the optimized BCR protocol and analyzed via an inductively coupled plasma mass spectrometer (Aurora M90, Jena, Germany).

Humic substances (HSs)—including fulvic acids (FA, the low-molecular-weight, water-soluble fraction), and humic acids (HA, the higher-molecular-weight and less soluble fraction)—were quantified by measuring their total carbon contents with an organic carbon analyzer (Multi N/C2100, Aurora, Germany) after the samples were pretreated according to “NY/T 1867–2010 Determination of humus content in soil”21. Fourier transform infrared (FT-IR) spectroscopy: FT-IR spectra were obtained via an FT-IR spectrometer (ThermoNexus8700) with a wavenumber range of 400–4000 cm− 1. Background subtraction was performed using high-purity KBr pressed as a standard reagent.

Antibiotic selection, extraction, and quantification: (1) Class screening: Five antibiotic classes were surveyed by broad-scan LC-MS; only tetracyclines and quinolones consistently exceeded quantification limits. (2) Sample extraction: Lyophilized compost (1.00 g) was extracted×3 with 5 mL EDTA–McIlvaine buffer (pH 4.0)/0.1% formic acid in acetonitrile (vortex 30 s, shake 20 min, ultrasonicate 8 min at 20 °C, centrifuge 4 500 rpm × 8 min). Supernatants were combined, evaporated under N2 at 40 °C, reconstituted to ≤ 2.5% organic content, and purified on Oasis HLB cartridges (6 cc/200 mg, 30 μm; conditioned with MeOH/H₂O; washed with 25% MeOH; eluted with 80% MeOH). Eluates were concentrated to ~ 1 mL under N₂, filtered (0.22 μm), and transferred to vials. (3) LC-MS/MS analysis: Instrument: AB Sciex Qtrap 5500 plus. Column: Agilent ZORBAX Eclipse Plus C18 (3.0 × 100 mm, 3.5 μm) at 25 °C. Mobile phases: A, 0.2% formic acid in water; B, acetonitrile; flow rate 0.30 mL/min; injection 10 µL. ESI-positive mode: spray voltage 4 000 V; curtain gas 241 kPa; auxiliary gas 5 L/min; ion-transfer capillary 350 °C; nebulizer 275 °C; collision gas (Ar) 0.2 Pa. Scheduled MRM transitions and collision energies are in Table S1. (4) Validation: Matrix-matched calibration (six levels) yielded R² > 0.99; LOQs 2–25 ng/mL; recoveries > 70%; RSD < 15%.

Data processing and analysis

All the physicochemical data were visualized via GraphPad Prism 8 and R software, while the statistical analyses were performed via Microsoft Excel 2016, SPSS Statistics 22.0, and R software. FT-IR spectra were analyzed and plotted via Origin 2021 software. Multivariate relationships among heavy-metal bioavailability factors (BFs), tetracycline antibiotic concentrations, and environmental parameters were explored in R using two complementary approaches:

  1. 1.

    Redundancy analysis (RDA) via the vegan package to quantify how much variance in BFs and antibiotic residues is explained by eleven predictors (Days, Temperature, Moisture, pH, OM, TN, TP, TK, C/N, HA, HS).

  2. 2.

    Classification and Regression Tree (CART) modelling via the rpart package to identify the primary environmental split-points driving each response (BF–Cu, BF–Zn, BF–Cd, BF–Cr, BF–Pb, BF–As, OTC, CTC, DOX) and to rank variable importance.

The composting humification rate is the ratio of humus (including HA and FA) to the total organic matter22,23indicating compost maturity and quality:

$$\:Humification\:rate\:\left(\%\right)\:=\:\frac{HA+FA\:}{Total\:organic\:matter}\times\:\:100.$$
(1)

Heavy metals are operationally partitioned into four fractions by the BCR sequential extraction: exchangeable (EXC), reducible (RED), oxidizable (OXI) and residual (RES). Their availability decreases in the order EXC > RED > OXI > RES. Define the heavy-metal bioavailability factor (BF) as the sum of the exchangeable and reducible fractions24:

$$\:BF=EXC+RED.$$
(2)

Each fraction’s distribution rate is calculated as:

$$\:{\:Distribution\:rate}_{i}\left(\%\right)=\:\frac{Mass\:of\:metal\:in\:fraction\:i}{Total\:metal\:mass\:}\times\:\:100.$$
(3)

And the passivation (immobilization) rate on day n is:

$$\:{Passivation\:rate}_{n}\:=\frac{\:({BF}_{initial}\:-\:{BF}_{n}\:)\:}{{BF}_{initial}}\:\times\:\:100.$$
(4)

Antibiotic degradation was modeled as first-order decay:

$$\:{C}_{t}={C}_{0}{e}^{-kt}.$$
(5)

with half‑life:

$$\:{T}_{1/2}=\:\frac{ln\left(2\right)}{k}.$$
(6)

Results and analysis

Material conversion and loss

In the MC treatment, 470 kg of fresh chicken manure was subjected to housefly larval bioconversion. After three days, 28.58 kg of maggots (6.08% w/w) were collected via phototactic behavior, and 222.95 kg of granular manure residue remained—corresponding to an overall weight reduction of 52.56%. Compared with those of pig manure25both the conversion rate and average larval mass (15.75 mg) were lower, likely due to compositional differences. Chicken manure generally contains relatively high levels of uric acid and fibrous materials, which may limit larval digestibility and metabolism26. The residue exhibited a granular structure, presumably resulting from the selective degradation of soluble organic matter by the larvae, leaving behind fibrous and mineral-rich components that aggregated during processing. This observation is consistent with previous research on pig manure residue granulation20. This granular structure is expected to improve subsequent aerobic composting by reducing compaction, facilitating oxygen diffusion, and optimizing microbial activity.

Table 1 Conversion of nutrients during the three composting processes (dry weight).

Table 1 shows the nutrient loss rates of carbon (C), nitrogen (N), phosphorus (P), and potassium (K) for the MC, CK1, and CK2 treatments. The comparison between MC and CK1 was designed to isolate the effect of larval addition, since both treatments shared an identical substrate composition and differed only in the presence of larvae. MC exhibited C and N loss rates of 55.26% and 36.48%, respectively, which were both significantly higher than CK1’s losses of 51.62% and 34.50% (P < 0.05), likely resulting from accelerated organic-matter degradation mediated by maggot feeding activity. In contrast, MC achieved a significant reduction in K loss (–7.08%; P < 0.05), likely resulting from enhanced moisture removal and improved substrate structure mediated by larval activity, which collectively limit nutrient leaching. So MC gains in insect protein outweigh the slight C, N, and P losses compared to CK1. CK2, employing sawdust as a bulking agent, served as a control for conventional industrial composting and provided a benchmark for nutrient retention in the housefly larva bioconversion process (MC) versus traditional methods. Compared with CK2, MC reduced losses by 8.59% for C, 19.71% for N, 17.74% for P and 26.45% for K (P < 0.05), underscoring the superior nutrient conservation achieved by combining larval bioconversion with aerobic composting. The higher C, N, P, and K losses in CK2 compared to MC and CK1 partly resulted from elevated pile temperatures, stronger degradation, and greater moisture leakage. These findings are consistent with those of Zhu Fengxiang et al.13and they suggest that larval bioconversion not only converts organic matter into insect protein but also improves nutrient retention—particularly for potassium—which likely benefits from reduced water-driven leaching and increased retention in the compost matrix.

Changes in physicochemical properties

Fig. 1
figure 1

Changes in major physicochemical properties during the three composting processes: (a) temperature; (b) moisture content; (c) pH value; (d) organic matter content; (e) total nitrogen content; (f) seed germination index.

Temperature is a critical indicator of composting progress. The three treatments presented similar temperature patterns, with phases of heating, high temperature, cooling, and stabilization (Fig. 1a). Significant differences in temperature were observed across composting times (p < 0.001). The temperature ranged from 24.6 °C to 46 °C, with an average of 35.5 °C. In the MC group, windrows formed from maggot-treated manure by day 4. After two days of passive fermentation, the high-temperature phase commenced on day 7; during this phase, the temperature peaked at 54 °C, with an average of 59.6 °C and a maximum of 69.5 °C over a 14-day period. Stabilization was achieved by day 38 at approximately 38.0 °C. In contrast, the CK1 group presented temperatures fluctuating between 43.4 °C and 59.1 °C, maintaining temperatures above 50 °C for only 4 days, with stabilization beginning after day 31. The CK2 group, however, reached 50.6 °C by day 3 and sustained its high-temperature phase for 21 days, with an average of 60.7 °C and a maximum of 69.2 °C, stabilizing after day 45. In accordance with the “GB 7959 − 2012 hygienic requirements for harmless disposal of night soil”27compost must maintain temperatures above 50°C for at least 10 days or above 60°C for 5 days. Both MC and CK2 met these standards, whereas CK1 did not. Notably, the MC group reached a maximum temperature similar to that of CK2 but stabilized earlier, suggesting that maggot bioconversion accelerated composting. CK2 presented greater carbon loss than MC and CK1 did, likely due to its prolonged thermophilic phase and greater degradation of organic matter.

Figure 1b and c illustrate the changes in moisture content and pH. Significant differences in moisture content were detected between the MC group and both CK1 and CK2 (p < 0.001), whereas no significant difference was detected between CK1 and CK2 (p = 0.735). Initially, the moisture content ranged from 70 to 80%, and it eventually decreased to 12–18% by the end of composting. From days 4 to 14, the MC treatment resulted in an additional 5–8% decrease in moisture, indicating enhanced dehydration; in contrast, CK2 retained higher moisture levels in later stages, likely due to the water-absorbing properties of sawdust28. Moreover, the pH increased consistently across all the treatments (p < 0.001), ranging from 8.11 to 9.35 for MC, 8.11–8.96 for CK1, and 8.11–9.21 for CK2.

As composting progressed, the organic matter content decreased in all the treatments (Fig. 1d), with significant differences among them (F32, 66 = 1581.343, p < 0.001). In both MC and CK1, organic matter decreased sharply within the first 4 days—from 60.5 to 45.2% in MC and to 50.6% in CK1—before the rate of decline slowed. Overall, organic matter was reduced to 36.5% in MC and 38.5% in CK1 (p < 0.01). In CK2, organic matter decreased more gradually, from 67.4 to 52.7%, remaining significantly greater than that in both MC (mean difference = 13.97%, p < 0.01) and CK1 (mean difference = 8.89%, p < 0.01). Accordingly, the organic matter degradation rates were 39.65% for MC, 36.33% for CK1, and only 21.78% for CK2, indicating that the MC process promoted more efficient decomposition.

The total nitrogen content displayed a dynamic trend, initially decreasing, then increasing, and finally declining again (Fig. 1e). In the MC group, the nitrogen content decreased to 1.8% by day 4—likely due to consumption by housefly larvae—peaked at 2.5% on day 31 and subsequently declined to 2.1% by the end. In the CK2 treatment, nitrogen steadily decreased until day 17 and then increased to 2.4%, before decreasing again to 1.9%. The CK1 group gradually decreased to 2.2% by day 21, followed by an increase to 2.49% on day 24 and stabilization thereafter. Compared with CK2, CK1 presented a significantly greater nitrogen content (mean difference = 0.3431, p < 0.01) and CK2 (mean difference = 0.3899, p < 0.01), whereas MC maintained significantly more nitrogen than did CK2 (mean difference = 0.0468, p < 0.01). This suggests that in the MC treatment, a portion of the nitrogen was converted into maggot protein (Table 2).

The seed germination index (GI), a key indicator of compost maturity (values above 70% indicate nontoxicity to crops), increased rapidly in all the treatments before they entered the stabilization phase (Fig. 1f). ANOVA revealed significant effects of composting method and duration (F26, 54 = 342.666, p < 0.001). In the MC group, the GI reached 113% by day 17 and stabilized above 100%. In contrast, the GIs of CK1 and CK2 increased more gradually, reaching 60% and 90%, respectively, by day 17; those of CK1 peaked at 132%, and those of CK2 peaked at 134% by day 24, after which fluctuations were observed. Significant differences were noted between CK1 and both MC and CK2 (p < 0.001), whereas no significant difference was detected between MC and CK2 (p = 0.447). Overall, although MC and CK2 achieved comparable maturities on the basis of GI, the MC treatment stabilized more rapidly, further demonstrating the advantage of maggot bioconversion in accelerating composting. In contrast, CK1—lacking additives or maggot bioconversion—did not fully meet the harmless treatment standards, as reflected by its lower temperature and GI values.

Changes in the humic acid content and FT-IR data during composting

Fig. 2
figure 2

Changes in humic substances and the FT-IR spectra during the three composting processes: (a) Total humic substance (HS) content (g·kg⁻¹); (b) Fulvic acid (FA) content (g·kg⁻¹); (c) Humic acid (HA) content (g·kg⁻¹); (d) FT‑IR spectra of MC at key composting stages; (e) FT‑IR spectra of CK1 at key composting stages; (f) FT‑IR spectra of CK2 at key composting stages.

HSs, including HA and FA, are key macromolecular compounds essential for compost humification. FA, as a low-molecular-weight fraction, is more readily degraded by microorganisms, whereas HA is more stable and plays a significant role in heavy metal adsorption29. Figure 2a shows that the initial total HS content was 87.57 g·kg⁻¹ for both the MC and CK1 treatments and 74.23 g·kg⁻¹ for CK2. In the MC and CK1 groups, the HS content decreased rapidly during the mesophilic phase, slightly rebounded during the thermophilic stage, and ultimately stabilized at 65.80 g·kg⁻¹ and 72.57 g·kg⁻¹, respectively. In contrast, the HS content in CK2 continuously decreased, reaching 54.62 g·kg⁻¹—likely due to the breakdown of unstable HS components30. The modest recovery in MC and CK1 may reflect a balance between organic matter degradation and HS synthesis. As shown in Fig. 2b, the FA content decreased in all the treatments, with reductions of 11.55 g·kg⁻¹ (MC), 3.99 g·kg⁻¹ (CK1), and 17.93 g·kg⁻¹ (CK2). In the MC group, the FA content continued to decrease through the high-temperature phase before rebounding to 31.48 g·kg⁻¹ by the end of composting. In CK1, the FA content decreased to 36.10 g·kg⁻¹ during the mesophilic stage and increased thereafter, whereas in CK2, the FA content decreased continuously to 23.4 g·kg⁻¹. Figure 2c shows that the HA content increased consistently in the MC and CK1 treatments—increasing from 10.38 g·kg⁻¹ to 17.29 g·kg⁻¹ and 15.08 g·kg⁻¹, respectively. In contrast, the HA content in CK2 initially decreased, peaked during the high-temperature phase, and then decreased to 12.51 g·kg⁻¹ by the end. These trends suggest that the microbial conversion of FA to HA was more pronounced in the MC and CK1 treatments than in the other treatment. The humification rate, defined as the proportion of HA within the total HS (Eq. 1), increased from initial values of 19.44% in MC and CK1 and 22.99% in CK2 to final values of 35.45% (MC), 27.87% (CK1), and 34.79% (CK2). Notably, CK2 had a peak humification rate of 37.85% by day 24, suggesting that further prolongation of composting may not be necessary. These findings suggest that MC effectively promotes HA production and enhances compost humification.

FT-IR is widely used to analyze the functional groups in compost humus. Figure 2d and f show the FT-IR spectra of the three composting treatments. In the final compost products, all the treatments resulted in enhanced absorption bands related to O–H and C–O stretching vibrations, which indicate increased humification31. Notably, MC treatment markedly intensified the bands associated with stable aromatic structures and carboxyl groups, suggesting that housefly larval bioconversion promotes the formation of more stable humic compounds and facilitates heavy metal stabilization32. In contrast, the disappearance of the aliphatic C–H stretching bands implies the oxidation of easily degradable organic components. Overall, these spectral changes confirmed that the MC process accelerated compost maturation and contributed to the development of a stable humic matrix.

Effects of different composting processes on heavy metals

Table 2 Variations in the total contents of cu, zn, as, cd, cr, and Pb before and after composting (mg·kg− 1 dry weight).

In this study, three composting treatments were evaluated—MC, CK1, and CK2—to assess both the changes in total heavy metal contents (Cu, Zn, As, Cd, Cr, and Pb) and their immobilization during composting. As shown in Table 2, the concentrations of Cu, Zn, and As were greater in the MC and CK1 treatments than in the CK2 treatment, whereas the levels of Cd, Cr, and Pb were slightly greater in the CK2 treatment. As composting progressed, the decomposition of organic matter and the volatilization of compounds (e.g., CO₂ and ammonia) produced a “relative concentration effect” that increased heavy metal concentrations in all the treatments33. For example, in the MC treatment, Cu, Zn, and As increased by approximately 65.2%, 65.6%, and 64.0%, respectively—values considerably greater than those observed in CK1 and CK2. In contrast, the increases in Cd, Cr, and Pb were lower in MC, possibly due to partial transformation or uptake by housefly larvae, whereas the incorporation of sawdust in CK2 may have diluted these metals. Ultimately, the final concentrations of As, Pb, Cd, and Cr in all the treatments met the agricultural industry standard (NY/T525-2021) in China.

Fig. 3
figure 3

Effects of three composting treatments on the immobilization of heavy metals over time: (a) Cu, (b) Zn, (c) Cd, (d) Cr, (e) As, and (f) Pb.

Heavy metal immobilization (or passivation) was monitored as an indicator of stabilization within the compost matrix. All bioavailability factors (BFs) and passivation rates were calculated using Eq. 2 ~ 4. As shown in Fig. 3a, Cu passivation increased over time. During the initial phase (days 0–10), CK1 and MC presented Cu passivation rates ranging from 54 to 77%, which were significantly higher than those of CK2 (P < 0.05). In the later stages, CK1 and MC maintained relatively stable Cu immobilization (62–72%), whereas that of CK2 gradually increased to 87.92% by the end. Although the final degree of Cu passivation in CK2 was significantly greater than that in CK1 (64.80%) and MC (62.71%) (P < 0.05), the overall differences were not statistically significant (F2, 44 = 0.1630, P > 0.05). Figure 3b shows that all treatments exhibited a time-dependent increase in Cr immobilization, with MC demonstrating in significantly greater Cr passivation during the first 17 days (P < 0.05). The final Cr passivation reached approximately 83% in both CK1 and CK2, with the MC remaining between 71% and 77% (F2, 43 = 0.7260, P > 0.05). Regarding Zn (Fig. 3c), the MC treatment consistently outperformed CK1 and CK2, achieving final immobilization rates of 45.09%, 31.32% and 25.88%, respectively (P < 0.05). Similarly, Fig. 3d shows that Cd immobilization was significantly greater in both CK1 and MC than in CK2 (F2, 38 = 10.327, P < 0.05), with MC increasing steadily to 45.59% at the end, compared with 40.13% in CK1 and 22.16% in CK2 (P < 0.05). Although overall As immobilization was low (Fig. 3e), CK1 consistently exhibited significantly greater stabilization than both CK2 and MC did (F2, 36 = 7.72, P < 0.05), reaching a final passivation rate of 26.04% versus only 4.50% in CK2. For Pb (Fig. 3f), significant differences were observed (F2, 40 = 22.87, P < 0.05): CK1 initially increased but then slightly declined, CK2 exhibited a steady upward trend, and MC increased in the early stage before stabilizing—resulting in final Pb immobilization rates of 86.20% for CK1, 68.55% for CK2, and 69.69% for MC.

In summary, all three composting methods effectively immobilized Cu, Cr, and Pb, whereas Zn and Cd were moderately immobilized and As exhibited the lowest immobilization efficiency. Notably, the MC treatment not only yielded a protein-rich product but also alleviated delays in heavy metal immobilization typically associated with conventional compost additives—significantly increasing Zn immobilization. However, the increased As bioavailability observed in the MC treatment contrasts with previous findings in pig manure composting20warranting further investigation.

Effects of different composting processes on antibiotics

Fig. 4
figure 4

Effects of three different composting methods on the changes in the antibiotic content of tetracycline during composting: (a) oxytetracycline (OTC), (b) chlortetracycline (CTC), and (c) doxycycline (DOX).

Table 3 First-order kinetic parameters for Tetracycline antibiotic degradation under three composting treatments. C₀: initial concentration (µg·kg⁻¹); k: decay rate constant (d[- [1); R2: coefficient of determination; RMSE: root mean square error; AIC: Akaike information criterion.

This study evaluated the degradation kinetics of two classes of antibiotics—tetracyclines and quinolones—under three composting treatments (MC, CK1, and CK2). Non-linear regression confirmed that a first-order exponential decay model (Eq. 5) accurately described tetracycline removal in all treatments (Table 3), as evidenced by high determination coefficients (R² > 0.90) and low RMSE values. Degradation kinetics were modeled via an exponential decay function to derive half-life values (Eq. 6), and overall degradation rates were determined after composting. For the tetracycline antibiotics oxytetracycline (OTC), chlortetracycline (CTC), and doxycycline (DOX), all the treatments achieved effective degradation, although with distinct kinetics (Fig. 4a and c). The OTC concentrations decreased rapidly during the early phase and then stabilized. The CK1 treatment resulted in the shortest OTC half-life (3.01 days), followed by MC (4.07 days) and CK2 (5.78 days), with final degradation rates of approximately 97.62%, 97.17%, and 96.20%, respectively. CTC followed a similar trend; notably, the MC treatment resulted in the shortest half-life (2.57 days) compared with those of CK1 and CK2 (with CK2 having a half-life of 9.90 days), and its final degradation rate (91.02%) was greater than those of CK1 (88.88%) and CK2 (86.61%). In contrast, the degradation of DOX varied among the treatments. CK2 started with the highest initial DOX concentration (30.30 µg·kg⁻¹), whereas MC and CK1 both began at 16.69 µg·kg⁻¹. In CK1, DOX exhibited a prolonged half-life of 15.75 days, resulting in an 89.03% degradation rate. CK2 showed a rapid initial decrease (half-life of 9.90 days) and reached a degradation rate of 77.31%, whereas for MC, the DOX concentration reached a minimum (2.55 µg·kg⁻¹ by day 24) before slightly rebounding to 5.72 µg·kg⁻¹, corresponding to an 84.72% degradation rate. This non-monotonic rebound yielded a lower R² and higher RMSE and AIC for DOX–MC, indicating that simple first-order kinetics cannot fully capture its transient behavior. Overall, the degradation efficacy followed the order of OTC > CTC > DOX, which was consistent with Danni Wu34. The MC provided a moderate rate for OTC, the fastest degradation for CTC, and a DOX degradation rate comparable to that of CK2.

The quinolone antibiotics ciprofloxacin (CIP), enrofloxacin (ENR), and norfloxacin (NOR) have been shown to be much more recalcitrant under aerobic composting (Fig. 5a and c). In the MC treatment, the CIP concentration initially increased, peaking at 82.4 µg·kg⁻¹ on day 31 after early fluctuations, and then decreased to 34.1 µg·kg⁻¹. Similar fluctuating trends were observed in CK1 and CK2, with CIP peaking at approximately 79.7 µg·kg⁻¹ (CK1) and 75.97 µg·kg⁻¹ (CK2) before a gradual decline. ENR levels generally decreased over time; in MC, ENR peaked at 96.95 µg·kg⁻¹ on day 17 and then declined to 47.25 µg·kg⁻¹, whereas in CK1 and CK2, ENR initially decreased by ~ 15 µg·kg⁻¹ within the first two days, increased to approximately 85 µg·kg⁻¹ by day 14, and finally reached 55.47 µg·kg⁻¹ and 34.55 µg·kg⁻¹, respectively. NOR concentrations generally increased in MC and CK1 during the early phase—reaching 40.0 µg·kg⁻¹ and 35.5 µg·kg⁻¹, respectively—followed by a slight decrease and subsequent increase, with final values of 32.47 µg·kg⁻¹ (MC) and 40.45 µg·kg⁻¹ (CK1). In CK2, NOR initially decreased to 16.13 µg·kg⁻¹, peaked at 47.03 µg·kg⁻¹ on day 21, and then declined to 28.65 µg·kg⁻¹. These results indicate that quinolone antibiotics are highly stable during aerobic composting, which is consistent with previous reports35.

Fig. 5
figure 5

Effects of three different composting methods on the changes in the quinolone antibiotic content during composting: (a) ciprofloxacin (CIP), (b) enrofloxacin (ENR), and (c) norfloxacin (NOR).

In summary, aerobic composting effectively degrades tetracycline antibiotics—following the order of OTC > CTC > DOX—with the MC process notably accelerating CTC degradation and achieving DOX degradation comparable to that of CK2, whereas CK1 was most efficient for OTC. Conversely, quinolone antibiotics are markedly recalcitrant, with slow and variable degradation trends observed across treatments. These findings underscore the importance of optimizing process parameters and microbial activity to increase the removal of recalcitrant antibiotic compounds during composting.

Correlations between environmental factors, heavy metal bioavailability, and changes in the antibiotic content of Tetracycline

Fig. 6
figure 6

Correlation analysis of environmental factors with heavy metal bioavailability and changes in the antibiotic content of tetracycline in three composting processes: (a) RDA biplot for the MC treatment showing heavy-metal bioavailability factors (red arrows) and environmental variables (blue arrows). Axes labels give the percentage of explained constrained variance (RDA1 82.07%, RDA2 7.29%); (b) RDA biplot for the CK1 treatment (RDA1 77.09%, RDA2 8.24%); (c) RDA biplot for the CK2 treatment (RDA1 82.57%, RDA2 6.38%).

Redundancy analysis (RDA) demonstrated that the eleven environmental variables (Days, Temperature, Moisture, pH, Organic Matter [OM], TN, TP, TK, C/N, HA, and HS) collectively explained 89.4% of the variance in MC, 85.3% in CK1, and 88.9% in CK2 along the first two ordination axes (Fig. 6). These values confirm that this suite of factors robustly predicts shifts in heavy-metal bioavailability (BFs) and tetracycline-class antibiotic concentrations (OTC, CTC, DOX) during composting. In the MC (Fig. 6a), Axis 1 was primarily influenced by moisture, composting duration, OM, and pH, while Axis 2 was driven by temperature, TN, C/N ratio, and HA. This pattern suggests that larvae-induced dehydration accelerated pile heating and OM decomposition, facilitating the transformation of metals into oxidized (OXI) and residual (RES) fractions. Concurrent alkalinization (rise in pH) enhanced metal hydroxide precipitation and complexation, reducing bioavailability36. Meanwhile, increased humic substances (HA and HS) provided abundant carboxyl and phenolic binding sites that chelated metals and adsorbed antibiotics, synchronously boosting stabilization and degradation22. In CK1 (Fig. 6b), composting duration, moisture, pH, and temperature dominated Axis 1 and negatively correlated with BF–Cu and BF–Cd. With prolonged composting, reduced moisture, and elevated temperature and pH, Cu and Cd shifted into non-exchangeable pools. These same conditions correlated with a decrease in OTC concentration, indicating that dehydration and thermophilic phases are critical for OTC degradation37. Moreover, Organic Matter and TN also loaded strongly on Axis 1, implying that nitrogen-supported microbial activity coupled with OM decomposition drove both metal immobilization and antibiotic degradation38,39. For the CK2 (Fig. 6c), were the principal drivers of Axis 1 and correlated positively with BF–Zn and BF–Cd, indicating that organic-matter breakdown, humification and K⁺ release govern Zn/Cd partitioning into OXI/RES fractions. These factors also correlated negatively with OTC and CTC concentrations, demonstrating that advanced humification paired with active K⁺ mobilization promotes thorough antibiotic degradation40. Axis 2, influenced by composting duration and moisture, further modulated BF–Cu, BF–Pb and DOX degradation dynamics. Overall, bioconversion by housefly larvae—through rapid moisture removal and enhanced humification—significantly improved heavy-metal stabilization and tetracycline antibiotic degradation during chicken manure composting.

To further elucidate how environmental variables drive metal immobilization and antibiotic degradation in the MC group, a Classification and Regression Tree (CART) model41 (Figure S1) was constructed for each response variable. Moisture emerged as the primary determinant for Cu, Zn, and Pb stabilization: when moisture dropped below 63.4–74.5%, bioavailable Cu, Zn, and Pb decreased sharply, indicating that dehydration enhances metal–humic chelation. Specifically, BF–Cu declined to its minimum (~ 9.7) under further dehydration (Moisture < 63.4%) combined with low TK (< 9.4), demonstrating the synergistic effect of water and Kฎ⁺ removal on Cu–humic binding. Under the same moisture threshold, TN 2.07% reduced BF–Zn from ~ 64 to ~ 54. For Pb, TN ≥ 2.14% and HS < 50 in low-moisture conditions lowered BF–Pb from ~ 5.73 to ~ 5.38, highlighting the collaborative influence of nitrogen and humic substances on Pb stabilization. Cd stabilization was governed primarily by composting duration and HA content: prolonged treatment and elevated HA enhanced Cd immobilization42, as increased carboxyl and phenolic groups strengthened metal binding. Conversely, arsenic mobilization intensified at higher TK levels43, whereas elevated organic matter attenuated As release44. All three tetracyclines (OTC, CTC, DOX) showed clear responses to composting time, moisture, and temperature (Figure S2). OTC underwent rapid breakdown during the initial 7-day thermophilic phase45, with subsequent OM decomposition driving further removal46. CTC degradation was co-regulated by moisture and TN, with the lowest residuals observed under combined low-moisture and optimal nitrogen conditions. DOX removal depended critically on early thermophilic temperature and moisture evaporation47, with moderate K⁺ concentrations in later stages further enhancing its degradation.

Conclusions

In this study, the MC process yielded 6.08% (w/w) maggot protein and significantly reduced nutrient losses of carbon, nitrogen, phosphorus, and potassium by 13.45%, 35.08%, 62.15%, and 70.89%, respectively, compared with those in CK2. Although all three aerobic composting methods effectively promoted heavy metal passivation, the MC process uniquely enhanced the formation of aromatic structures and HAs. This improvement in humification not only accelerated organic matter decomposition but also increased the immobilization of heavy metals, particularly Zn and Cd. Moreover, MC mitigates the adverse effects of auxiliary additives, which are often linked to delayed heavy metal stabilization. Tetracycline antibiotics were effectively degraded during composting, with degradation efficacy ranked as OTC > CTC > DOX. Notably, the MC process achieved a moderate degradation rate for OTC, the fastest degradation for CTC, and a DOX degradation rate comparable to that of CK2, whereas quinolone antibiotics exhibited limited degradation. Environmental factors such as temperature, moisture content, pH, organic matter content, the C/N, and composting duration significantly influenced both heavy metal bioavailability and antibiotic degradation. Redundancy analysis demonstrated that these variables collectively explained over 85% of the observed variation in heavy metal stabilization and antibiotic residue degradation. CART analysis identified key thresholds for optimal heavy metal immobilization and antibiotic degradation: maintaining moisture content below 63–74% and potassium concentrations below 9.4 mg kg⁻¹ maximized metal–humic acid chelation. Elevated HA and HS content further enhanced the immobilization of Cd. Additionally, the removal of tetracycline antibiotics predominantly occurred through thermophilic degradation, supplemented by adsorption and chelation processes mediated by humic acids and K⁺ ions. These findings highlight the enhanced potential for value-added compost products and broaden their practical applications in environmental management through the integration of housefly larval bioconversion, significantly reducing environmental risks associated with heavy metals and antibiotic residues.