For controlled discrete-time stochastic processes we introduce a new class of dynamic risk measures, which we call process-based. Their main features are that they measure risk of processes that are functions of the history of the base process. We introduce a new concept of conditional stochastic time consistency and we derive the structure of process-based risk measures enjoying this property. We show that they can be equivalently represented by a collection of static law-invariant risk measures on the space of functions of the state of the base process. We apply this result to controlled Markov processes and we derive dynamic programming equations. Next, we consider partially observable processes and we derive the structure of stochastically conditionally time-consistent risk measures in this case. We prove that they can be represented by a sequence of law invariant risk measures on the space of function of the observable part of the state. We also prove corresponding dynamic programming equations.