Extracted from build-graph codebase.