builtin/apply: move 'check' global into 'struct apply_state'