Private/Write-FileAtomic.ps1

# Internal helper -- write a file atomically via .tmp + Move-Item.
# Preserved verbatim from scripts/start-channels.ps1 lines 206-211.

function Write-FileAtomic {
    param(
        [Parameter(Mandatory)][string]$Path,
        [Parameter(Mandatory)][string]$Content
    )
    $tmp = "$Path.tmp"
    [IO.File]::WriteAllText($tmp, $Content)
    [IO.File]::Move($tmp, $Path, $true)
}