In this article
A temporary pathname is not a reserved file; creation and use must preserve the object returned by the atomic operation.
The operational scenario
A model downloader chooses an apparently unused temporary filename and later opens it for writing. Another process can occupy that name in the gap, so an earlier absence check does not reserve the intended destination. Random-looking names reduce guessing opportunities but do not combine checking and creation. The control concerns atomic object creation, rather than the separate question of how long a service runtime directory should survive.
The trust-boundary mechanism
Python’s tempfile guide explicitly contrasts the insecure name-returning mktemp pattern with immediate creation through mkstemp and related helpers. Linux documents the atomic existence-and-creation behavior of O_CREAT with O_EXCL under its applicable semantics. The returned open descriptor matters: discarding it and reopening the name can reintroduce another path-selection boundary. Cleanup and later publication remain additional lifecycle operations.
Define the control contract
Define the trusted staging parent, process identity, required access mode and object lifetime. Choose a supported creation helper and preserve its actual cleanup and reopening semantics on the selected platform. Keep durable accepted model artifacts separate from temporary partial downloads. An existing old staging entry after restart should require explicit ownership and lifecycle handling rather than being adopted solely because its name matches the expected pattern.
A step-by-step verification
First create a harmless staging file through the selected atomic interface and continue writing through the returned object. Verify permissions and owner from that object. Use a disposable control with a preoccupied candidate name to confirm the established collision behavior. Exercise interrupted download, normal completion and restart cleanup separately. Validate complete bytes before publishing under the accepted release identity; a successfully created empty file is not a qualified model.
Evidence required for acceptance
Evidence should retain creation interface, parent identity, access properties, collision outcomes and the link between validated temporary bytes and final publication. A control that returns an unused name without creating it must not receive the same acceptance label. Verify cleanup removes only owned staging material and leaves accepted artifacts intact. Reopening by pathname requires its own reviewed boundary, not trust inherited from the original descriptor.
Failure cases and limits
Atomic creation does not prevent later mutation by an authorized writer, bound disk consumption or guarantee durability after power loss. Network-filesystem behavior and platform-specific temporary-file reopening need their actual documentation. This protocol creates no files here. It prevents a name-generation convenience from being mistaken for ownership, while preserving compatibility, content validation and cleanup as distinct evidence requirements.
Primary references and related reading
A temporary pathname is not a reserved file; creation and use must preserve the object returned by the atomic operation. Python atomic temporary creation; Linux open file creation and descriptor semantics.
The proposed investigation of atomic tempfile creation name race is a proposed control review; no live security test was executed. Related reading: Create serving runtime directories with an explicit lifetime; Validate safetensors weight artifacts separately from repository code.
Earn rental income from GPUs
Have idle GPUs or looking to fund AI infrastructure? Retrivium finds a rental platform, sets up the server and helps you assess income and costs with a pilot.