From a microbial perspective, insect metamorphosis is a treacherous business. The transformation from little earthbound crawler to lapis-blue flier is a flashy eye-catcher, but the change is more than skin-deep. Deep within the larva, the contents of the gut are emptied, intestinal cells wither away by autophagy and apoptosis, and the cavity is reupholstered with dividing stem cells that generate a new gut. For a hatchling insect to pupate and emerge in its winged adult form, it must orchestrate a complete remodeling of its own anatomy – demolishing the existing gut and stitching together a new one de novo. This is a fine opportunity for pathogens to slink in. The larva must navigate the line between retaining its gut symbionts and avoiding pathogens lurking in the sidelines. (The gut microbes in Kafka's The Metamorphosis must have had the shock of their lives during that overnight transformation.)
How to survive a whole-body reconstruction project as a microbe? Becoming homebodies plus making biofilms are possible solutions. First, hiding out inside of the host cells while the gut contents are purged gets the bacteria past one hurdle. In later stages, living an extracellular life within a biofilm can offer protection against hostile elements and shield the host from pathogens.
Endosymbionts that switch between intra- and extracellular settings include the olive fly endosymbiont, Erwinia dacicola, which lives intracellularly in cells of the larval midgut and extracellularly in biofilms in the adult foregut. Wigglesworthia of the tsetse fly dwells both intracellularly in bacteriocytes in the midgut and extracellularly in milk gland secretions (milk glands, an odd term in the insect world). The secondary tsetse symbiont Sodalis is found in midgut cells both intra- and extracellularly. It requires the gene of the outer membrane protein A (ompA) to form biofilms and properly colonize the host gut.
This microbial propagation by sticky finesse is a common theme among insect endosymbionts. In the nearby world of extracellular-only gut symbionts of insects, inoculation of the eggshell can also involve biofilms. Hatching larvae must use their mouthparts to bite through the eggshell, and any microbe hanging around on that shell goes down the gullet. Female Paederus rove beetles, for example, coat their eggs with biofilms of their Pseudomonas-like bacterial symbiont (~95% sequence similarity), which they house extracellularly both in specialized organs near the egg depositor and in the abdominal cavity outside of the gut. On the eggs, the biofilm might help prevent the microbes from being washed away by rainwater, ensuring that they are present when the hatchlings emerge.
A different beetle presents an interesting spinoff of the extracellular symbiont biofilm, this time with a matrix provided by the host. As covered by Christoph here and here, the Stammera symbionts of the tortoise leaf beetle C. viridis are buoyed to beetle offspring via a sticky "caplet" at one end of each batch of eggs – a microbial multivitamin pill that is one of the hatchlings' first meals. Here, the host provides the biofilm, as Christoph points out: Stammera, which lack peptidoglycan, are encased in the host's sticky secretions. They are otherwise unlikely to survive in isolation – not quite terra firma. This a very important "pseudo-biofilm," as sterilizing the caplet slashes the survival rate of the hatchlings. These peptidoglycan-lacking bacteria would probably not hold up well to the mechanical force of being smeared across eggs, hence the clever caplet workaround.
One lingering question: do endosymbionts form biofilms during their intracellular stage? There clearly exist such symbionts capable of forming biofilms of some sort, as demonstrated in the extracellular phases of their lives, but whether they make use of these talents indoors is another question.
This question first calls for a look at pathogens, for some of which the intracellular situation is stickier. Studies at the start of the century discovered that some human bacterial pathogens long considered to be solely extracellular are also able to slip inside of host cells. Escherichia coli, for example, forms biofilm-like "pods" inside of cells in the urinary bladder that bulge out into the bladder lumen. These pods carry all the red flags of bona fide biofilms. They feature polysaccharide matrix scaffolding, uroplakin shells, antibiotic resistance, and differential expression of biofilm-associated genes between bacterial subpopulations. Similarly, Pseudomonas aeruginosa enters lung epithelial cells during infection and forms similar "pod-like clusters". The pathogen pods serve as home base for the bacteria that may produce persistent infections, offering protection from antibiotics and host immune defenses. In these safe zones, the pathogens are free to replicate and then dispatch individuals into the lumen to launch an attack elsewhere.
A similar scenario hails from the gray area between intracellular friend and foe. Here, the crop plant pathogen "Ca. Liberibacter spp." offers a second window into the secret lives of biofilms. Liberibacter is transmitted by the Asian citrus psyllid (Diaphorina citri), in whom it dwells both intra- and extracellularly in a variety of tissues. Liberibacter does business in its insect vector's gut with a similar stratagem as E. coli and P. aeruginosa, first adhering to the outer midgut surface, invading the cells, and forming a bulging biofilm that shields against the host immune system and reactive oxygen species. There is, however, conflicting evidence on whether Liberibacter primarily harms or benefits its host psyllid (reviewed here), some authors reporting that the presence of Liberibacter increases midgut cell death while others that it increases host reproductive fitness. In either case, the formation of the pods likely serves the same purpose as the human pathogen pods above: ensuring persistence within the host. Perhaps it also allows Liberibacter to persist throughout metamorphosis. At the very least, here is a case of intracellular biofilm formation by what appears to be a conditional endosymbiont.
What other intracellular biofilms are there? To the extent that biofilms are ubiquitous, from the human gut to ocean-floor hydrothermal vents to deep subsurface rock, it would not be too surprising to uncover others inside mutualistic host cells, insect or otherwise. They've proven a bit evasive – maybe another good reason why a cloud of gnats is called a "ghost."
(For a related recent Talmudic Question, see here.)