Reference implementation. A skeleton showing what this looks like as code — the lookup chain, the checklists, and what the record ends up holding:
It is written as a specification rather than a library, so it refuses to run without the hooks you supply. The repo also carries implementation notes covering the parts this post leaves out.