  We explore the production and escape of ionizing photons in young galaxies by
investigating the ultraviolet and optical emission-line properties of models of
ionization-bounded and density-bounded HII regions, active-galactic-nucleus
(AGN) narrow-line regions and radiative shocks computed all using the same
physically-consistent description of element abundances and depletion on to
dust grains down to very low metallicities. We compare these models with a
reference sample of metal-poor star-forming galaxies and Lyman-continuum (LyC)
leakers at various redshifts, which allows the simultaneous exploration of more
spectral diagnostics than typically available at once for individual
subsamples. We confirm that current single- and binary-star population
synthesis models do not produce hard-enough radiation to account for the
high-ionization emission of the most metal-poor galaxies. Introducing either an
AGN or radiative-shock component brings models into agreement with
observations. A published model including X-ray binaries is an attractive
alternative to reproduce the observed rise in HeII4686/Hbeta ratio with
decreasing oxygen abundance in metal-poor star-forming galaxies, but not the
high observed HeII4686/Hbeta ratios of galaxies with large EW(Hbeta). A source
of harder ionizing radiation appears to be required in these extreme objects,
such as an AGN or radiative-shock component, perhaps linked to an
initial-mass-function bias toward massive stars at low metallicity. This would
also account for the surprisingly high [OI]/[OIII] ratios of confirmed LyC
leakers relative to ionization-bounded models. We find no simple by-eye
diagnostic of the nature of ionizing sources and the escape of LyC photon,
which require proper simultaneous fits of several lines to be discriminated
against.
