The hadith you quoted was referenced — with slighty different words — in both Sahih Al-Bukhari 86/52, and Sahih Muslim 50/53.
Yes, the Prophet (ﷺ) was informed on multiple occasions of a person being forgiven through a divine revelation. For example, the three that stayed behind to avoid joining the battle of Tabuk (see Qur'an 9:118), or the story of Abi Lubaba ibn Abd al-Mundhir and his story of repentance after the Banu Quraidha meeting.
From Fat'h Al-Bari
Ibn Hajar Al-Asqalani, in his book Fat'h Al-Bari (Arabic: فتح الباري شرح صحيح البخاري), his interpretation of this hadith said:
ظاهر ترجمة البخاري حمله على من أقر بحد ولم يفسره فإنه لا يجب على الإمام أن يقيمه عليه إذا تاب
— NOTE: My own translation, so treat with care:
It appears from Al-Bukhari's version that it is interpreted to be related to one who admits having committed a sin that requires a hadd, but did not specify the sin or the hadd, then the Imam is not obliged to carry the hadd if the person repents.
Ibn Hajar continues with the view of Abu Sulaiman Al-Khattabi (Arabic: أبو سليمان الخطابي), one of the major scholars of the Sahfe'i school, that this hadith was most likely based on a revelation that Allah had forgiven the person:
حمله الخطابي على أنه يجوز أن يكون النبي - صلى الله عليه وسلم - اطلع بالوحي على أن الله قد غفر له لكونها واقعة عين
Al-Khattabi said that it is possible that the Prophet (ﷺ) was informed through a revelation that Allah forgave him as the person in this incident was known by name.
Ibn Hajar also adds the possibility that a major sin cannot be determined by possibility alone, and that it was most likely a minor sin:
إنه لا يكشف عن الحدود بل يدفع مهما أمكن وهذا الرجل لم يفصح بأمر يلزمه به إقامة الحد عليه فلعله أصاب صغيرة ظنها كبيرة توجب الحد فلم يكشفه النبي - صلى الله عليه وسلم - عن ذلك لأن موجب الحد لا يثبت بالاحتمال
He [the Prophet (ﷺ)] did not pursue with the person in question about what the hadd intended was; rather, he avoided asking a question that would obligate a hadd, and it is possible that it was a minor sin that the person in question mistakenly thought was a major sin that mandates a hadd, but the Prophet (ﷺ) did not investigate further. Accordingly, a hadd is not mandated by possibility alone.
Finally, Ibn Hajar puts forward the view of Al-Nawawi, and others, that the sin was a minor one that can be expiated through prayers:
جزم النووي وجماعة أن الذنب الذي فعله كان من الصغائر بدليل أن في بقية الخبر أنه كفرته الصلاة بناء على أن الذي تكفره الصلاة من الذنوب الصغائر لا الكبائر
Al-Nawawi, among others, said that the sin committed was a minor one, accordingly — as per the narration — it could be expiated through prayers, and only minor sins are expiated through prayers, not the major sins.
From Al Minhaj bi Sharh Sahih Muslim
Al-Nawawi, in his book Al Minhaj bi Sharh Sahih Muslim (Arabic: شرح صحيح مسلم للنووي), his interpretation of this hadith said:
هذا الحد معناه معصية من المعاصي الموجبة للتعزير وهي هنا من الصغائر لأنها كفرتها الصلاة ولو كانت كبيرة موجبة لحد أو غير موجبة له لم تسقط بالصلاة
This hadd means the sin in question was a disobedience that required ta'zir, so it is a minor sin that can be expiated through prayers. Had it been a major sin — whether mandating a hadd or not — it cannot be expiated by prayers.
The reason behing the Prophet (ﷺ) not asking about further details is to conceal this man's sin, and to teach us that when a sin that requires hadd is committed, which typically requires witnesses or a confession, one may elect to retract their confession:
ولم يستفسره النبي صلى الله عليه وسلم عنه إيثارا للستر، بل استحب تلقين الرجوع عن الإقرار بموجب الحد صريحا
The Prophet (ﷺ) did not ask the person to give further as a preference to conceal the person's sin. Furthermore, it is mustahabb (preferred) to retract one's confession associated with a sin that requires explicits [witnesses or confession].
Conclusion
There is a similar incident that took place with
عَنِ ابْنِ مَسْعُودٍ ـ رضى الله عنه ـ أَنَّ رَجُلاً أَصَابَ مِنَ امْرَأَةٍ قُبْلَةً، فَأَتَى رَسُولَ اللَّهِ صلى الله عليه وسلم فَذَكَرَ ذَلِكَ لَهُ فَأُنْزِلَتْ عَلَيْهِ «وَأَقِمِ الصَّلاَةَ طَرَفَىِ النَّهَارِ وَزُلَفًا مِنَ اللَّيْلِ إِنَّ الْحَسَنَاتِ يُذْهِبْنَ السَّيِّئَاتِ ذَلِكَ ذِكْرَى لِلذَّاكِرِينَ». قَالَ الرَّجُلُ أَلِيَ هَذِهِ قَالَ «لِمَنْ عَمِلَ بِهَا مِنْ أُمَّتِي» "
Narrated Ibn Masud: A man kissed a woman and then came to Allah's Messenger (ﷺ) and told him of that, so this Divine Inspiration was revealed to the Prophet (ﷺ) 'And offer Prayers perfectly at the two ends of the day, and in some hours of the night; (i.e. (five) compulsory prayers). Verily, the good deeds remove the evil deeds (small sins) That is a reminder for the mindful.' (Qur'an 11:114) The man said, Is this instruction for me only?' The Prophet (ﷺ) said, "It is for all those of my followers who encounter a similar situation."
— Sahih Al-Bukhari 65/4687
Based on this hadith and the one you quoted, the scholarly conclusion is:
- The Prophet (ﷺ) did not carry the hadd (punishment) as the sin mentioned was not one that had a defined hadd associated with it.
- The sin committed was not a major sin, as major sins — whether punishbable by a defined hadd or not — cannot be expiated through prayers.
- The Prophet (ﷺ) did not declare a sin forgiven except through revelation. Since he declared this man's sin forgiven, it must have been through a revelation from Allah.
- The preference goes to satr (concealment of sin) over carrying a hadd from the Imam's perspective.