  This document presents the physics case and ancillary studies for the
proposed CODEX-b long-lived particle (LLP) detector, as well as for a smaller
proof-of-concept demonstrator detector, CODEX-$\beta$, to be operated during
Run 3 of the LHC. Our development of the CODEX-b physics case synthesizes
`top-down' and `bottom-up' theoretical approaches, providing a detailed survey
of both minimal and complete models featuring LLPs. Several of these models
have not been studied previously, and for some others we amend studies from
previous literature: In particular, for gluon and fermion-coupled axion-like
particles. We moreover present updated simulations of expected backgrounds in
CODEX-b's actively shielded environment, including the effects of shielding
propagation uncertainties, high-energy tails and variation in the shielding
design. Initial results are also included from a background measurement and
calibration campaign. A design overview is presented for the CODEX-$\beta$
demonstrator detector, which will enable background calibration and detector
design studies. Finally, we lay out brief studies of various design drivers of
the CODEX-b experiment and potential extensions of the baseline design,
including the physics case for a calorimeter element, precision timing, event
tagging within LHCb, and precision low-momentum tracking.
