Mishkat al-Masabih
Ali reported God’s Messenger as saying, “There are three whose actions are not recorded: a sleeper till he awakes, a boy till he reaches puberty, and an idiot till he is restored to reason.” Tirmidhi and Abu Dawud transmitted it. Darimi transmitted it on the authority of 'A’isha, and Ibn Majah on the authority of both (i.e. ‘Ali and ‘A’isha’)
وَعَنْ عَلِيٍّ رَضِيَ اللَّهُ عَنْهُ قَالَ: قَالَ رَسُولُ اللَّهِ صَلَّى اللَّهُ عَلَيْهِ وَسَلَّمَ: " رُفِعَ الْقَلَمُ عَنْ ثَلَاثَةٍ: عَنِ النَّائِمِ حَتَّى يَسْتَيْقِظَ وَعَنِ الصَّبِيِّ حَتَّى يَبْلُغَ وَعَنِ الْمَعْتُوهِ حَتَّى يعقل ". رَوَاهُ التِّرْمِذِيّ وَأَبُو دَاوُد وَرَوَاهُ الدَّارِمِيُّ عَنْ عَائِشَةَ وَابْنُ مَاجَهْ عَنْهُمَا
Reference