How does Disk Utility repair corruption? How does Disk Utility repair corruption?

When you run First Aid, it logs things like "checking fsroot tree", checking the EFI jumpstart record", etc. How does it know if something is broken, like does it have a correct version to compare things to? What if the correct reference gets corrupted as well?
I have often asked myself, if a disk or volume is corrupt. And, if so, would I be better off backing up files before or after running repair software. In other words, could the repair destroy a file that otherwise could have be copied. Therefore, I would like to separate the detection for corruption from the possible repair of corruption. Depending on the version of OS X/macOS, the Disk Utility may or may not offer this option.

The Disk Utility basically runs the command diskutil repairdisk device, where the device is usually disk followed by an positive integer. If you right click on a drive shown in the Disk Utility and select "Get Info", the device is the "BSD device node" shown in the popup.

Older versions of OS X/macOS allowed you to select a disk verification. This option was eliminated from the Disk Utility in the latest versions of macOS. However, you can still run disk verification by entering the command diskutil verifydisk device in a Terminal application window. Again, you will need to replace device with the appropriate "BSD device node".

You can also apply the same to just a volume. You will need to replace repairdisk and verifydisk with repairvolume and verifyvolume. Also the device will usually be disk, an positive integer, the letter s and finally another postive integer. For example, disk0s2.