Atomic delete: interrupted idstack-learnings-delete can destroy the whole log
Surfaced by PR #35 (closed — its perf premise was synthetic and os.replace widened file mode 600→644, verified). The underlying point is real and worth doing properly.
bin/idstack-learnings-delete:42-43 truncates in place. An interrupt mid-write leaves the learnings log truncated or empty — the file is the user's accumulated project memory, so this is data loss, not an inconvenience.
Do it the way bin/idstack-manifest-merge:126-141 already does: tempfile.mkstemp in the learnings dir, shutil.copymode the original mode onto the temp before the replace (this is what #35 got wrong), os.replace, unlink on exception.
Ships with a test asserting mode is preserved.
Fixed in e5c60c1: delete now writes a tempfile in the same directory, copies the original file mode onto it, and swaps it in with os.replace. 0606b11 later moved this into the delete branch of bin/idstack-learnings. test/integration-test.sh checks that a mode-600 log keeps its mode, and #127 adds a mutation for it. The commit cited this issue without a closing keyword, so it stayed open.