when the build breaks 'bear' record only those files which were compiled up until the break. but developers usually fix the break, and just build further (and not start a clean build) to see it goes well or not. this case the new files would overwrite the previous files.
before write a new compilation database, would read the old one and merge with the new set of files.
this would solve the use case describe above
this would deal with edit-compile-run cycles on normal development.
newly added files would be handled normally
deleted files could be detected by file existence check before write
this would not detect compiler flag changes, and would cause double entries in the output.
when the build breaks 'bear' record only those files which were compiled up until the break. but developers usually fix the break, and just build further (and not start a clean build) to see it goes well or not. this case the new files would overwrite the previous files.
before write a new compilation database, would read the old one and merge with the new set of files.