Resolves a node/fragment id to its top-level index (O(1) when cached), or -1.
typedef TopLevelIndexResolver = int Function(String id);