The previous write_registry wiped existing .md files first, then wrote
new ones. When multiple xdist workers ran the script concurrently, they
would clobber each other mid-write, causing intermittent test failures
(test_generate_type_registry.py would see missing or stale files).
Fix: generate to a sibling staging directory (PID+timestamp suffix)
first, then use os.replace() to atomically swap into place. No observer
can see the registry in a partial state.
The staging dir is built manually (not via tempfile) because
scripts/audit_no_temp_writes.py forbids tempfile imports in scripts/.
Verified: 6/6 tests in test_generate_type_registry.py PASS in isolation
and in tier-1-unit-core batch (was: 2 failed due to race); audit CLEAN.