Private/Test-RuntimeVolumePopulated.ps1

function Test-RuntimeVolumePopulated {
    <#
    .SYNOPSIS
        Tests whether a runtime volume has been populated with the Node.js runtime.
    .DESCRIPTION
        Mounts the volume read-only-ish into a stock image and checks for the node
        binary. Used to decide whether a volume is usable (selection) or still needs
        provisioning. Windows uses servercore (not nanoserver) for the same reason
        provisioning does: nanoserver's restrictive ACLs on first mount break later writes.
    #>

    [CmdletBinding()]
    [OutputType([bool])]
    param(
        [Parameter(Mandatory)]
        [ValidateSet('windows', 'linux')]
        [string]$ContainerOS,

        [Parameter(Mandatory)]
        [string]$VolumeName
    )

    # The volume is "populated" when Node.js is present. The Go entrypoint binary is NOT stored
    # in the volume — it ships in the module and is mounted into the container at launch.
    if ($ContainerOS -eq 'linux') {
        docker run --rm -v "${VolumeName}:/check" $script:DClaudeImages.ProvisionLinux test -f /check/node/bin/node 2>$null
    }
    else {
        $check = 'if exist C:\check\node\node.exe (exit 0) else (exit 1)'
        docker run --rm -v "${VolumeName}:C:\check" $script:DClaudeImages.ProvisionWindows cmd /c $check 2>$null
    }

    return $LASTEXITCODE -eq 0
}