Fix topological sorting of top-level targets

Top level targets do not execute in an Environment, but they're targets
that may be depended upon. This case was not handled in the topo sort,
as it was attempting to use the environment's digest as part of the key.