The sphere of infinite space is without form. If he is perceiving form, then he is not in that attainment. It follows that his mind slipped back to perceiving form, which knocked him out of that attainment. The same for the other attainments and jhānas discussed. The sutta isn't stating that these things happen whilst in jhāna. They are stating what went wrong, what removed one from jhāna. Ergo, he is not in x jhāna or attainment but is reviewing after the fact.
I assume this is Ven. Ṭhānissaro's translation here? What he has translated as "discernment" is "paññā". If we look at the sanskrit Prajñā we can see that it is comprised of pra (प्र) and jñā (ज्ञा)Obviously he was able to discern it as stressful, which implies that discernment doesn't happen at the vitakka-vicara level but at the consciousness level.
"'Consciousness, consciousness': Thus is it said. To what extent, friend, is it said to be 'consciousness'?"
"'It cognizes, it cognizes': Thus, friend, it is said to be 'consciousness.' And what does it cognize? It cognizes 'pleasant.' It cognizes 'painful.' It cognizes 'neither painful nor pleasant.' 'It cognizes, it cognizes': Thus it is said to be 'consciousness.'"
"Discernment & consciousness, friend: Are these qualities conjoined or disjoined? Is it possible, having separated them one from the other, to delineate the difference between them?"
"Discernment & consciousness are conjoined, friend, not disjoined. It's not possible, having separated them one from the other, to delineate the difference between them. For what one discerns, that one cognizes. What one cognizes, that one discerns. Therefore these qualities are conjoined, not disjoined, and it is not possible, having separated them one from another, to delineate the difference between them."
"Discernment & consciousness, friend: What is the difference between these qualities that are conjoined, not disjoined?"
"Discernment & consciousness, friend: Of these qualities that are conjoined, not disjoined, discernment is to be developed, consciousness is to be fully comprehended."
jñā: knowledge, understanding
Prajñā/paññā: Great understanding/knowledge.
This is the meaning we find in the suttas. Discernment is more the function of dhamma vicaya. It is this which leads to paññā. Using typical jhāna lite definitions an argument can be put forward that insight occurs within the 1st jhāna, since there is vitakka-vicāra (defined as something along the lines of thinking and pondering) and so the possibility of dhamma vicaya, but when we move past the 1st jhāna the whole argument unravels. Since vitakka-vicāra is absent from the 2nd jhāna onwards there is no possibility of dhamma vicaya and so no possibility of being able to review or gain any kind of paññā whilst in any of those attainments. The whole jhāna lite enterprise thus collapses itself, due to its own definitions. The alternative view, which is much more in line with what we see in the pali, is that vitakka-vicāra in the jhāna pericope doesn't mean normal "thinking and pondering/contemplating" but more "applied and sustained thought" and so even from the 1st jhāna there is no possibility of any reviewing or insight whilst in the attainment. This is much more consistent than the jhāna lite argument, where you have insight in 1 attainment but not for the rest. It is then only upon leaving x jhāna or attainment that normal functions of the mind return and so dhamma vicaya can do it's work, thus resulting in wisdom.
As a supplement to my argument (which I mentioned earlier) the sutta also repeats “saññāmanasikārā”, as if attention to multiple perceptions are part of what is going wrong. If saññāmanasikārā is part of the problem then it follows that part of doing jhāna well is to have 1 attention of perception (saññā) rather than many. In other words, absorption.