Assuming I'm on an NTFS partition, is it just as safe to edit files during defragmentation as when not? Is there any added risk, even if very small? If not, how does the operating system ensure the integrity/consistency of the data?
There is no risk associated with editing files during defragmentation. If a file is open for editing (you can aquire a read-only or a read-write lock when opening a file) it is considered "locked". When the defrag process gets to that file it skips over it, leaving it in it's current place.