Caterpillars create cocoons from spun silk and body hairs. Adult males are seen at our lights after they eclose. Wingless females emerge from the cocoon and release pheromones to attract a male. After fertilization (or even without fertilization in capture situations) the female releases her eggs in a froth on the cocoon. The shrivelled female, essentially an empty egg sack, then dies. Upon hatching the new caterpillars disperse, beginning a new life cycle.
An ichneumon wasp laid an egg in this caterpillar which ultimately died providing sustenance to the internal parasitoid. The caterpillar's corpse is here seen attached, with the cocoon of the wasp, to the leaf where the wasp larva emerged to pupate. It will spend the winter attached to the withered leaf and an adult will emerge next summer. The cocoon is 5.5mm long and 3mm in diameter. The brown spots are believed to be fecal material incorporated into the cocoon. I am grateful to Anthony Thomas for identifying the cocoon and explaining the process to me. Tony thinks the wasp is probably in the subfamily Campopleginae of the Ichneumonidae.