Doghouse is right.
Lighting is usually a radial circuit where either the ceiling rose or the light switch or a junction box feeds the next fitting.
Sockets if reasonably new will be a ring circuit and can be be identified, but not definitely, by having two cables connected to it.
Beware a socket on a radial circuit with a spur taken off as they might look the same.
A socket on a ring will have both cables live when disconnected from the socket.
Do turn the power off first.
You are quite right, it is not as simple as a terminal block etc.
My advice would be look up maintenance free junction boxes.
Wago do a good range of terminals and boxes designed for just.
They are marked with the British Standard whatever, followed by MF for maintenance free.
There are designed to fit through a small hole.
I must admit I've never seen a socket in a ceiling in a domestic building.. Do you mean the lamp batten holder?
Could you clarify or post a photo of everything you want to remove?
Regardless of exactly what you have, the principle is the same, if you are going to conceal it, you must make it safe and these days that means maintenance free if you can't get to it to inspect it.