  We develop a model for stochastic pre-enrichment and self-enrichment in
globular clusters (GCs) during their formation process. GCs beginning their
formation have an initial metallicity determined by the pre-enrichment of their
surrounding protocloud, but can also undergo internal self-enrichment during
formation. Stochastic variations in metallicity arise because of the finite
numbers of supernova. We construct an analytic formulation of the combined
effects of pre-enrichment and self-enrichment and use Monte Carlo models to
verify that the model accurately encapsulates the mean metallicity and
metallicity spread among real GCs. The predicted metallicity spread due to
self-enrichment alone, a robust prediction of the model, is much smaller than
the observed spread among real GCs. This result rules out self-enrichment as a
significant contributor to the metal content in most GCs, leaving
pre-enrichment as the viable alternative. Self-enrichment can, however, be
important for clusters with masses well above 10^6 Msun, which are massive
enough to hold in a significant fraction of their SN ejecta even without any
external pressure confinement. This transition point corresponds well to the
mass at which a mass-metallicity relationship ("blue tilt") appears in the
metal-poor cluster sequence in many large galaxies. We therefore suggest that
self-enrichment is the primary driver for the mass-metallicity relation. Other
predictions from our model are that the cluster-to-cluster metallicity spread
decreases amongst the highest mass clusters; and that the red GC sequence
should also display a more modest mass-metallicity trend if it can be traced to
similarly high mass.
