Let's call these functions "packers" for now - they're reversible mappings between some group of identifiers and a single integer that represents all of them.
We have packers for tract+patch, visit+detector, exposure+detector, and probably more. Some of these are implemented in astro_metadata_translator; some are implemented in CameraMapper (Gen2) and daf_butler DataIdPacker classes (Gen3). There is also completely distinct code in afw.table.IdFactory that mangles any integer representing an image (often generated by one of the above) with an autoincrement integer coming from the detection code into a Source or Object ID.
I don't really see much of this as a middleware concern - while there is code in both Butlers to define some of them, the packers are really obs-package or skymap-defined mappings, and the middleware's role is just to deliver them from obs-package or skymap to science code, which is then responsible for mangling them into Source or Object IDs. It also uses the outputs of the packers in astro_metadata_translator at ingest time, but doesn't care that it does - it just cares that it is given unique integers.
Maybe this is semantics, because I think Tim Jenness probably owns a good chunk of the problem regardless of the hat he's wearing, but I think it's most helpful to just think of middleware's role in this as that of a middleman between obs-package, skymap, and the science pipelines.