Today I discovered that (at least) one of the ceiling lights in my house isn't mounted on a junction box.
As an added bonus, most of the wiring is fabric insulated copper. You can see the single wire coming from the light switch has cracked insulation.
I was going to move all of this into a typical round old work box, but then I realized it's directly below a joist. There are also wire clamps on the bracket that attaches to the joist, so this must've been acceptable at some point.
Looking for advice on what to do. I think the safest option is to move all the old wiring to a separate box in the attic and just bring the wires for this specific light (neutral and switched live) into a pancake box somehow mounted in the same spot.
The ceiling is about 1.375" thick with the rock lath, plaster, and foam ceiling tiles. I imagine I can fit a pancake box under the joist here, right?