Bug? white halo around object using raw and shadow catcher

I render in raw colorspace and convert to AgX colorspace with compositor.
But if I do so, a white halo appears around my object.

Note also that I use shadow catcher (this is important).

halo1
halo1.blend (327.8 KB)

What, if I use premultiply?
You will see a dark halo:

halo1-premulti

What, if I tune premultiply and set value to 0.9?
You will see a less visible halo (hard to see, but it still exists):

halo1-premulti-0.9

What, if I try to render with transparent background and later combine this image with a background in GIMP?
Again this halo:

halo1-alpha2

What, if I do not use raw, and instead I use AgX and then do alpha over?
Everything is fine:

halo1-agx

What, if I render again transparent image (in AgX colorspace) and later combine this image with a background in GIMP?
Everything is fine:

halo1-agx-alpha2

Sooo… in my eyes, here is something broken in RAW colorspace, when I work with shadow catcher.

Using AgX, filmic, Standard do not produce this halo.

In general, layer combination operations, blur, defocus, etc. must be done in linear space. Read this, in the light wins part, it will explain it better. About your problem you can do this:

-Place the colorspace node at the end of your composition, this will cause your background texture to also be affected by the view transform, so you can do a reverse transformation. After the background texture node but before the alpha over, place another colorspace node that transforms that texture from the view transform to linear space (AgX → Linear rec.709). Since the final node of the composition is Linear rec.709—>AgX that would become a no-op (it works in several cases, although not in all, it is a hack). With this you should no longer have those lines.

Regarding the shadow catcher part, it is the first time I use it but when modifying the scene I noticed that if the lights affect the plane with shadow catcher (unchecking shadow catcher in the lights) edges appear on the cube. In the end, testing compositions I verified that the shadow catcher pass must be composed before doing alpha over. In your case it is only necessary to do the inverted transformation, but I still mention this in case something similar happens to you and you don’t know what to do.

your file modified:
halo_01.blend (331.5 KB)