Forward Invariance in Trajectory Spaces for Safety-critical Control