refactor(test): replace deprecated tempfile.mktemp() with tempfile.mkstemp() #736

Closed
CoreRasurae wants to merge 1 commits from refactor/m3-replace-mktemp into master

1 Commits

Author SHA1 Message Date
CoreRasurae 532f128a49 refactor(test): replace deprecated tempfile.mktemp() with tempfile.mkstemp()
CI / benchmark-publish (pull_request) Has been skipped
CI / lint (pull_request) Successful in 14s
CI / quality (pull_request) Successful in 17s
CI / build (pull_request) Successful in 25s
CI / typecheck (pull_request) Successful in 38s
CI / security (pull_request) Successful in 43s
CI / unit_tests (pull_request) Successful in 3m7s
CI / docker (pull_request) Successful in 41s
CI / integration_tests (pull_request) Successful in 5m3s
CI / coverage (pull_request) Successful in 5m26s
CI / benchmark-regression (pull_request) Successful in 38m33s
Replaced all 28 uses of the deprecated tempfile.mktemp() function with the
atomic tempfile.mkstemp() + os.close(fd) pattern across 16 test infrastructure
and benchmark files.  Added import os where it was not already present.

tempfile.mktemp() has been deprecated since Python 2.3 due to a TOCTOU race
condition: between name generation and file creation, another process could
create a file at the predicted path.  Under 16-worker parallel test execution,
there was also a non-zero risk of path collisions.

Files modified:
- features/environment.py (3 call sites)
- robot/helper_resource_registry_migration.py (3 call sites)
- robot/helper_plan_phase_migration.py (1 call site)
- robot/helper_plan_persistence_e2e.py (1 call site)
- robot/helper_persistence_lifecycle.py (1 call site)
- robot/helper_db_lifecycle_models.py (1 call site)
- robot/helper_automation_profiles.py (1 call site)
- features/steps/skill_discovery_steps.py (2 call sites)
- features/steps/resource_registry_tables_steps.py (2 call sites)
- features/steps/plan_persistence_steps.py (1 call site)
- features/steps/persistence_robot_alignment_steps.py (1 call site)
- features/steps/garbage_collection_cli_steps.py (3 call sites)
- features/steps/decision_recording_steps.py (1 call site)
- features/steps/coverage_boost_steps.py (1 call site)
- features/steps/cli_streaming_steps.py (1 call site)
- features/steps/automation_profiles_guards_steps.py (1 call site)
- benchmarks/persistence_robot_bench.py (4 call sites)

All 10,640 BDD scenarios pass.  No performance regression observed (within
normal run-to-run variance).  Zero remaining uses of tempfile.mktemp() in
the codebase.

ISSUES CLOSED: #730
2026-03-12 14:29:01 +00:00