In general I think there isn’t a strict rule about what is a valid order or not. Instead it’s more along the lines that if the phrase is understandable then it is fine. If both the subject and the object can take the accusative then the order is pretty flexible because there is no ambiguity. Otherwise the usual thing to do is to rely on the default subject-verb-object order to get the meaning across.
With that in mind, I would say your example of ŝatas lerni mi is fine because it is understandable without ambiguity, although I wouldn’t recommend it unless there is some particular reason to do it for emphasis or to make a rhyme.
With legi asistas skribi, there are no accusative markers so if the order is changed it is very likely to be misunderstood and thus it wouldn’t be recommended.
Some minor corrections to your question:
- It’s ekzameni not egzameni.
- In ekzameni asisti la detektivon I assume you meant ekzameni asistas la detektivon, otherwise there is no main verb in the phrase.
- Although asisti is a word, I think in this context it would be better to use helpi which is much more common.
You can avoid all of these ambiguities if you express the verb as a noun instead. I would even argue this would be the more normal way to express it. For example:
- Ekzamenado helpas la detektivon aŭ Helpas la detektivon ekzamenado.
- Legado helpas skribadon aŭ Helpas skribadon legado.