apply: move lockfile into `apply_state`