builtin/apply: move check_apply_state() to apply.c