can you give more details about your system, what kernel you are using what distro? also, have you tried testing a live boot usb to do testing, and also (I am presuming that you changed motherboard, and kept rest same) can you replace 1 part at a time and check.
Usually random breakages mean memory or power errors, and even different modules breaking can be caused by corrupt storage (maybe the readheads of hdd are broken, or if ssd, something something something, maybe broken/damged contacts). But you say going back to older cpu fixed this. Can you check what speed does your menory work at, sometimes, stable ram speeds depend on cpu, maybe you had it lower/higher for older cpu (usually lower than stable is not issue, higher is the issue), or maybe, your newer cpu is drawing more power, or you have some kind of faulty contact and some stray currents are developing on your motherboard. A fey more details would be really helpful
reinventing shell scripting. Though I am guilty of this, I do something like this (more complex) but essentially a shell script in rust just because for some application, reading files is slower that way