  We introduce the anytime-valid (AV) logrank test, a version of the logrank
test that provides type-I error guarantees under optional stopping and optional
continuation. The test is sequential without the need to specify a maximum
sample size or stopping rule, and allows for cumulative meta-analysis with
type-I error control. The method can be extended to define anytime-valid
confidence intervals. The logrank test is an instance of the martingale tests
based on E-variables that have been recently developed. We demonstrate type-I
error guarantees for the test in a semiparametric setting of proportional
hazards and show how to extend it to ties, Cox' regression and confidence
sequences. Using a Gaussian approximation on the logrank statistic, we show
that the AV logrank test (which itself is always exact) has a similar rejection
region to O'Brien-Fleming alpha-spending but with the potential to achieve 100%
power by optional continuation. Although our approach to study design requires
a larger sample size, the *expected* sample size is competitive by optional
stopping.
