Get material/object ID the ray is currently hitting?

without rendering more than once and using the compositor, is it possible to have one object in the scene reflect/be lit by something other than the hdri environment?

I though perhaps I could use something like the below. I want all objects with a material ID greater than 4 to be lit by and reflect a solid green environment, and all other objects to be lit/reflect the environment texture:

if it’s not possible, perhaps it would be a good idea to give the light path node two additional outputs. A material ID output, and a object ID output. This would output the ID which the ray is currently hitting.

The user could then use a math node to check if the ray is hitting a specific ID, and then hook that up to the factor of a mix shader or a mix rgb node, so that that one object is lit by, reflects, or refracts something other than the hdri…a solid colour for example.

I made a proposal on right click select if anyone would also like this feature: