Skip to content

Windows installer refresh routine also guards SOUL.md cleanup with Test-Path -PathType Container on a file (ods.ps1:589) #3343

Description

@patil2001

File: ods/installers/windows/ods.ps1, Repair-HermesSoulMd (line 589).

This is the same defect class as the install phase (phases/06-directories.ps1:547), but in a different file and a different code path: ods.ps1's copy of Repair-HermesSoulMd runs during the Windows installer's own update/sync flow, not just the directory phase.

Defective code:

if (-not $rendered) {
    if (Test-Path -LiteralPath $output -PathType Container) {
        Remove-Item -LiteralPath $output -Recurse -Force
    }
    if (-not (Test-Path -LiteralPath $output -PathType Leaf)) {
        $content = Get-Content -LiteralPath $template -Raw
        $content = $content -replace "(?m)^\s*<!-- INSTALLATION_CONTEXT -->\s*\r?\n?", ""
        [System.IO.File]::WriteAllText($output, $content, (New-Object System.Text.UTF8Encoding($false)))
        Write-AIWarn "Generated fallback Hermes SOUL.md without dynamic installation context"
    }
}

($output is the data\persona\SOUL.md file path.)

Behavior:
The cleanup guard uses -PathType Container (directory). Because $output is a file, that test is always $false, so the Remove-Item that should discard a stale SOUL.md never executes. The subsequent write is gated on -not (Test-Path ... -PathType Leaf), so when a stale SOUL.md already exists the fallback regeneration is skipped entirely.

Impact:
On Windows updates/syncs, a stale Hermes SOUL.md is never refreshed to drop the <!-- INSTALLATION_CONTEXT --> block / pick up new installation context, so the agent keeps serving outdated persona content. The Linux/macOS paths do not share this PowerShell bug, making the behavior platform-inconsistent.

Fix:
Test for the item's existence directly, e.g. if (Test-Path -LiteralPath $output) { Remove-Item -LiteralPath $output -Recurse -Force }, and only regenerate when the file is absent (or unconditionally regenerate the fallback once the stale file is removed).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions